Copyright (C) 2005 FhG Fokus
Definition in file sip.c.
#include "sip.h"
#include "../../mem/mem.h"
#include "../../data_lump.h"
#include "../../data_lump_rpl.h"
#include "../../parser/parse_to.h"
#include "../../parser/parse_from.h"
#include "../../parser/parse_expires.h"
#include "../../parser/parse_via.h"
#include "../../parser/parse_content.h"
#include "../../parser/parse_nameaddr.h"
#include "../../parser/contact/contact.h"
#include "../../parser/contact/parse_contact.h"
#include "../tm/tm_load.h"
#include "mod.h"
#include "auth_api.h"
Go to the source code of this file.
Defines | |
| #define | strtotime(src, dest) |
| #define | get_qparam(src, name, dst) |
| #define | get_param(src, name, dst) |
Functions | |
| int | cscf_add_header_first (struct sip_msg *msg, str *hdr, int type) |
| Adds a header to the message as the first one in the message. | |
| int | cscf_add_header (struct sip_msg *msg, str *hdr, int type) |
| Adds a header to the message. | |
| int | cscf_add_header_rpl (struct sip_msg *msg, str *hdr) |
| Adds a header to the reply message. | |
| str | cscf_get_private_identity (struct sip_msg *msg, str realm) |
| Returns the Private Identity extracted from the Authorization header. | |
| str | cscf_get_public_identity (struct sip_msg *msg) |
| Returns the Public Identity extracted from the To header. | |
| int | cscf_get_expires_hdr (struct sip_msg *msg) |
| Returns the expires value from the Expires header in the message. | |
| int | cscf_get_max_expires (struct sip_msg *msg) |
| Returns the expires value from the message. | |
| str | cscf_get_public_identity_from_requri (struct sip_msg *msg) |
| Get the Public Identity from the Request URI of the message. | |
| sip_msg * | cscf_get_request (unsigned int hash, unsigned int label) |
| Retrieves the SIP request that generated a diameter transaction. | |
| int | cscf_get_integrity_protected (struct sip_msg *msg, str realm) |
| Returns if the SIP message is integrity protected. | |
| int | cscf_get_transaction (struct sip_msg *msg, unsigned int *hash, unsigned int *label) |
| Returns the tm transaction identifiers. | |
| int | cscf_reply_transactional (struct sip_msg *msg, int code, char *text) |
| Transactional SIP response - tries to create a transaction if none found. | |
| str | cscf_get_auts (struct sip_msg *msg, str realm) |
| Looks for the auts parameter in the Authorization header and returns its value. | |
| str | cscf_get_nonce (struct sip_msg *msg, str realm) |
| Looks for the nonce parameter in the Authorization header and returns its value. | |
| str | cscf_get_algorithm (struct sip_msg *msg, str realm) |
| Looks for the algorithm parameter in the Authorization header and returns its value. | |
| str | cscf_get_digest_uri (struct sip_msg *msg, str realm) |
| Looks for the uri parameter in the Authorization header and returns its value. | |
| int | cscf_get_nonce_response (struct sip_msg *msg, str realm, str *nonce, str *response, enum qop_type *qop, str *qop_str, str *nc, str *cnonce, str *uri) |
| Looks for the nonce and response parameters in the Authorization header and returns them. | |
| str | cscf_get_user_agent (struct sip_msg *msg) |
| Looks for the User-Agent header and extracts its content. | |
| contact_body_t * | cscf_parse_contacts (struct sip_msg *msg) |
| Parses all the contact headers. | |
| str | cscf_get_path (struct sip_msg *msg) |
| Retrieve a list of concatenated contents of Path headers found in the message. | |
| str | cscf_get_event (struct sip_msg *msg) |
| Looks for the Event header and extracts its content. | |
| str | cscf_get_asserted_identity (struct sip_msg *msg) |
| Looks for the P-Asserted-Identity header and extracts its content. | |
| str | cscf_get_asserted_identity_domain (struct sip_msg *msg) |
| Looks for the P-Asserted-Identity header and extracts the domain inside the uri. | |
| str | cscf_get_contact (struct sip_msg *msg) |
| Looks for the Contact header and extracts its content. | |
| str | cscf_get_first_route (struct sip_msg *msg, struct hdr_field **hr) |
| Looks for the First Route header. | |
| int | cscf_remove_first_route (struct sip_msg *msg, str value) |
| Looks if the first entry in the first Route points is equal to the given value and deletes the old header. | |
| int | cscf_is_myself (str uri) |
| Returns if the uri is of myself. | |
| int | cscf_remove_own_route (struct sip_msg *msg, struct hdr_field **h) |
| Looks if the first entry in the first Route points to myself and if positive, it removes it deletes the old header. | |
| str | cscf_get_record_routes (struct sip_msg *msg) |
| Returns all the record routes, concatenated. | |
| hdr_field * | cscf_get_next_record_route (struct sip_msg *msg, struct hdr_field *start) |
| Returns the next record route header. | |
| hdr_field * | cscf_get_next_via_hdr (struct sip_msg *msg, struct hdr_field *start) |
| Returns the next via header. | |
| static int | str_trim (str *s) |
| trims the str | |
| str | cscf_get_next_via_str (struct sip_msg *msg, struct hdr_field *h, int pos, struct hdr_field **h_out, int *pos_out) |
| Returns the next via str. | |
| int | cscf_via_matching (struct via_body *req_via, struct via_body *rpl_via) |
| cscf_via_matching | |
| static void | free_via_param_list (struct via_param *vp) |
| int | cscf_str_via_matching (str *sreq_via, str *srpl_via) |
| Checks if 2 via strings are equal. | |
| str | cscf_get_realm_from_ruri (struct sip_msg *msg) |
| Delivers the Realm from request URI. | |
| str | cscf_get_identity_from_ruri (struct sip_msg *msg) |
| Gets identity from the request URI. | |
| str | cscf_get_call_id (struct sip_msg *msg, struct hdr_field **hr) |
| Looks for the Call-ID header. | |
| int | cscf_get_cseq (struct sip_msg *msg, struct hdr_field **hr) |
| Looks for the Call-ID header. | |
| str | cscf_get_cseq_method (struct sip_msg *msg, struct hdr_field **hr) |
| Looks for the Call-ID header. | |
| sip_msg * | cscf_get_request_from_reply (struct sip_msg *reply) |
| Returns the corresponding request for a reply, using tm transactions. | |
| str | cscf_get_called_party_id (struct sip_msg *msg, struct hdr_field **hr) |
| Looks for the P-Preferred-Identity header and extracts its content. | |
| int | cscf_get_subscription_state (struct sip_msg *msg) |
| Looks for the Subscription-State header and extracts its content. | |
| int | cscf_replace_string (struct sip_msg *msg, str orig, str repl) |
| Replace a string in a message with another one. | |
| str | cscf_get_headers_content (struct sip_msg *msg, str header_name) |
| Get the content of a certain header. | |
| hdr_field * | cscf_get_header (struct sip_msg *msg, str header_name) |
| Returns the first header structure for a given header name. | |
| hdr_field * | cscf_get_next_header (struct sip_msg *msg, str header_name, struct hdr_field *last_header) |
| Returns the next header structure for a given header name. | |
| hdr_field * | cscf_get_next_header_type (struct sip_msg *msg, hdr_types_t type, struct hdr_field *last_header) |
| Returns the next header structure for a given hdr_types_t type. | |
| str | cscf_get_body (struct sip_msg *msg) |
| Returns the first header structure for a given header name. | |
| str | cscf_get_access_network_info (struct sip_msg *msg, struct hdr_field **h) |
| Return the P-Access-Network-Info header. | |
| str | cscf_get_visited_network_id (struct sip_msg *msg, struct hdr_field **h) |
| Return the P-Visited-Network-ID header. | |
| str | cscf_get_authorization (struct sip_msg *msg, struct hdr_field **h) |
| Looks for the Authorization header and returns its body. | |
| str | cscf_get_authenticate (struct sip_msg *msg, struct hdr_field **h) |
| Looks for the WWW-Authenticate header and returns its body. | |
| str | cscf_get_session_expires_body (struct sip_msg *msg, struct hdr_field **h) |
| Looks for the Session-Expires header and returns its body. | |
| time_t | cscf_get_session_expires (str expHdr, str *refresher) |
| get Session Expires Value . | |
| str | cscf_get_min_se (struct sip_msg *msg, struct hdr_field **h) |
| Looks for the Min-SE header and returns its body. | |
| int | cscf_del_header (struct sip_msg *msg, struct hdr_field *h) |
| Deletes the given header. | |
| int | cscf_del_all_headers (struct sip_msg *msg, int hdr_type) |
| Deletes all the headers of a given type. | |
| via_body * | cscf_get_first_via (struct sip_msg *msg, struct hdr_field **h) |
| Looks for the First Via header and returns its body. | |
| via_body * | cscf_get_last_via (struct sip_msg *msg) |
| Looks for the Last Via header and returns it. | |
| via_body * | cscf_get_ue_via (struct sip_msg *msg) |
| Looks for the UE Via in First Via header if its a request or in the last if its a response and returns its body. | |
| str | cscf_get_realm (struct sip_msg *msg) |
| Looks for the realm parameter in the Authorization header and returns its value. | |
| str | cscf_get_realm_from_uri (str uri) |
| Extracts the realm from a SIP/TEL URI. | |
| int | cscf_get_p_associated_uri (struct sip_msg *msg, str **public_id, int *public_id_cnt) |
| Returns the content of the P-Associated-URI header Public_id is pkg_alloced and should be later freed. | |
| int | cscf_get_first_p_associated_uri (struct sip_msg *msg, str *public_id) |
| Returns the first entry of the P-Associated-URI header. | |
| name_addr_t | cscf_get_preferred_identity (struct sip_msg *msg, struct hdr_field **hr) |
| Looks for the P-Preferred-Identity header and extracts its content. | |
| hdr_field * | cscf_get_next_route (struct sip_msg *msg, struct hdr_field *start) |
| Returns the next route. | |
| str | cscf_get_content_type (struct sip_msg *msg) |
| Looks for the Content-Type header and extracts its content. | |
| int | cscf_get_content_len (struct sip_msg *msg) |
| Looks for the Content-length header and extracts its content. | |
| str * | cscf_get_service_route (struct sip_msg *msg, int *size) |
| Returns the content of the Service-Route header. | |
| int | cscf_get_originating_contact (struct sip_msg *msg, str *host, int *port, int *transport) |
| Returns the originating contact. | |
| int | cscf_get_terminating_contact (struct sip_msg *msg, str *host, int *port, int *transport) |
| Returns the terminating contact. | |
| int | cscf_get_terminating_identity (struct sip_msg *msg, str *uri) |
| Returns the terminating contact. | |
| int | cscf_add_p_charging_vector (struct sip_msg *msg) |
| Inserts the P-Charging-Vector header P-Charging-Vector:. | |
| str | cscf_get_last_via_sent_by (struct sip_msg *msg) |
| Get the sent-by parameter of the last Via header in the message. | |
| str | cscf_get_last_via_received (struct sip_msg *msg) |
| Get the received parameter of the last Via header in the message. | |
| int | cscf_get_from_tag (struct sip_msg *msg, str *tag) |
| Get the from tag. | |
| int | cscf_get_to_tag (struct sip_msg *msg, str *tag) |
| Get the to tag. | |
| int | cscf_get_from_uri (struct sip_msg *msg, str *local_uri) |
| Get the local uri from the From header. | |
| int | cscf_get_to_uri (struct sip_msg *msg, str *local_uri) |
| Get the local uri from the To header. | |
Variables | |
| tm_binds | tmb |
| Structure with pointers to tm funcs. | |
| static str | s_ip = {"integrity-protected",19} |
| str | ua_dummy = {"Unknown UA",10} |
| str | ua_nomsg = {"No Message",10} |
| str | s_asserted_identity = {"P-Asserted-Identity",19} |
| static str | route_hdr_s = {"Route: ",7} |
| static str | route_hdr_e = {"\r\n",2} |
| static str | s_record_route = {"Record-route",12} |
| static str | via_hdr_term = {"\r\n.",3} |
| static str | s_called_party_id = {"P-Called-Party-ID",17} |
| static str | s_subscription_state = {"Subscription-State",18} |
| static str | s_active = {"active",6} |
| static str | s_pending = {"pending",7} |
| static str | s_terminated = {"terminated",10} |
| static str | s_expires = {"expires=",8} |
| str | cscf_p_access_network_info = {"P-Access-Network-Info",21} |
| str | cscf_p_visited_network_id = {"P-Visited-Network-ID",20} |
| static str | s_refresher = {"refresher=", 10} |
| static str | realm_p = {"realm=\"",7} |
| static str | phone_context_s = {";phone-context=",15} |
| static str | s_preferred_id = {"P-Preferred-Identity",20} |
| char * | cscf_icid_value_prefix = "abcd" |
| hexadecimal prefix for the icid-value - must be unique on each node | |
| unsigned int * | cscf_icid_value_count = 0 |
| to keep the number of generated icid-values | |
| gen_lock_t * | cscf_icid_value_count_lock = 0 |
| to lock acces on the above counter | |
| char * | cscf_icid_gen_addr = "127.0.0.1" |
| address of the generator of the icid-value | |
| char * | cscf_orig_ioi = "open-ims.test" |
| name of the Originating network | |
| char * | cscf_term_ioi = "open-ims.test" |
| name of the Terminating network | |
| str | cscf_icid_value_prefix_str |
| fixed hexadecimal prefix for the icid-value - must be unique on each node | |
| str | cscf_icid_gen_addr_str |
| fixed address of the generator of the icid-value | |
| str | cscf_orig_ioi_str |
| fixed name of the Originating network | |
| str | cscf_term_ioi_str |
| fixed name of the Terminating network | |
| static str | p_charging_vector_s = {"P-Charging-Vector: icid-value=\"",31} |
| static str | p_charging_vector_1 = {"\";icid-generated-at=",20} |
| static str | p_charging_vector_2 = {";orig-ioi=\"",11} |
| static str | p_charging_vector_e = {"\"\r\n",3} |
| static char | hex_chars [17] = "0123456789abcdef" |
| #define strtotime | ( | src, | |||
| dest | ) |
| #define get_qparam | ( | src, | |||
| name, | |||||
| dst | ) |
| #define get_param | ( | src, | |||
| name, | |||||
| dst | ) |
Value:
{\
int i,j;\
(dst).s=0;(dst).len=0;\
for(i=0;i<(src).len-(name).len;i++)\
if (strncasecmp((src).s+i,(name).s,(name).len)==0 &&\
((src).s[i-1]==' ' ||(src).s[i-1]==';'||(src).s[i-1]=='\t')){\
j=i+(name).len;\
(dst).s = (src).s+j;\
(dst).len = 0;\
while(j<(src).len && (src).s[j]!=','&& (src).s[j]!=' '&& (src).s[j]!='\t'&& (src).s[j]!=';') \
j++; \
(dst).len = j-i-(name).len;\
break;\
} \
}
| int cscf_add_header_first | ( | struct sip_msg * | msg, | |
| str * | hdr, | |||
| int | type | |||
| ) |
Adds a header to the message as the first one in the message.
| msg | - the message to add a header to | |
| content | - the str containing the new header |
Definition at line 128 of file sip.c.
00129 { 00130 struct hdr_field *first; 00131 struct lump* anchor,*l; 00132 00133 first = msg->headers; 00134 anchor = anchor_lump(msg, first->name.s - msg->buf, 0 , 0 ); 00135 00136 if (anchor == NULL) { 00137 LOG(L_ERR, "ERR:"M_NAME":cscf_add_header_first: anchor_lump failed\n"); 00138 return 0; 00139 } 00140 00141 if (!(l=insert_new_lump_before(anchor, hdr->s,hdr->len,type))){ 00142 LOG(L_ERR, "ERR:"M_NAME":cscf_add_header_first: error creating lump for header\n" ); 00143 return 0; 00144 } 00145 return 1; 00146 }
| int cscf_add_header | ( | struct sip_msg * | msg, | |
| str * | hdr, | |||
| int | type | |||
| ) |
Adds a header to the message.
| msg | - the message to add a header to | |
| content | - the str containing the new header |
Definition at line 154 of file sip.c.
00155 { 00156 struct hdr_field *last; 00157 struct lump* anchor; 00158 last = msg->headers; 00159 while(last->next) 00160 last = last->next; 00161 anchor = anchor_lump(msg, last->name.s + last->len - msg->buf, 0 , 0); 00162 if (anchor == NULL) { 00163 LOG(L_ERR, "ERR:"M_NAME":cscf_add_header_first: anchor_lump failed\n"); 00164 return 0; 00165 } 00166 00167 if (!insert_new_lump_after(anchor, hdr->s,hdr->len,type)){ 00168 LOG(L_ERR, "ERR:"M_NAME":cscf_add_header_first: error creting lump for header\n" ); 00169 return 0; 00170 } 00171 return 1; 00172 }
| int cscf_add_header_rpl | ( | struct sip_msg * | msg, | |
| str * | hdr | |||
| ) |
Adds a header to the reply message.
| msg | - the request to add a header to its reply | |
| content | - the str containing the new header |
Definition at line 180 of file sip.c.
References M_NAME.
00181 { 00182 if (add_lump_rpl( msg, hdr->s, hdr->len, LUMP_RPL_HDR)==0) { 00183 LOG(L_ERR, "ERR:"M_NAME":cscf_add_header_rpl: Can't add header <%.*s>\n", 00184 hdr->len,hdr->s); 00185 return 0; 00186 } 00187 return 1; 00188 }
| str cscf_get_private_identity | ( | struct sip_msg * | msg, | |
| str | realm | |||
| ) |
Returns the Private Identity extracted from the Authorization header.
If none found there takes the SIP URI in To without the "sip:" prefix
| msg | - the SIP message | |
| realm | - the realm to match in an Authorization header |
Definition at line 200 of file sip.c.
References cscf_get_public_identity(), find_credentials(), and M_NAME.
00201 { 00202 str pi={0,0}; 00203 struct hdr_field* h=0; 00204 int ret,i; 00205 00206 if (parse_headers(msg,HDR_AUTHORIZATION_F,0)!=0) { 00207 LOG(L_ERR,"ERR:"M_NAME":cscf_get_private_identity: Error parsing until header Authorization: \n"); 00208 return pi; 00209 } 00210 00211 if (!msg->authorization){ 00212 LOG(L_ERR, "ERR:"M_NAME":cscf_get_private_identity: Message does not contain Authorization header.\n"); 00213 goto fallback; 00214 } 00215 00216 ret = find_credentials(msg, &realm, HDR_AUTHORIZATION_F, &h); 00217 if (ret < 0) { 00218 LOG(L_ERR, "ERR:"M_NAME":cscf_get_private_identity: Error while looking for credentials.\n"); 00219 goto fallback; 00220 } else 00221 if (ret > 0) { 00222 LOG(L_ERR, "ERR:"M_NAME":cscf_get_private_identity: No credentials for this realm found.\n"); 00223 goto fallback; 00224 } 00225 00226 if (h) pi=((auth_body_t*)h->parsed)->digest.username.whole; 00227 00228 goto done; 00229 00230 fallback: 00231 LOG(L_INFO,"INF:"M_NAME":cscf_get_private_identity: Falling back to private_id=stripped(public_id)\n" 00232 "-> Message did not contain a valid Authorization Header!!! This fallback is deprecated outside Early-IMS or NASS-Bundled!\n"); 00233 pi = cscf_get_public_identity(msg); 00234 if (pi.len>4&&strncasecmp(pi.s,"sip:",4)==0) {pi.s+=4;pi.len-=4;} 00235 for(i=0;i<pi.len;i++) 00236 if (pi.s[i]==';') { 00237 pi.len=i; 00238 break; 00239 } 00240 done: 00241 LOG(L_DBG,"DBG:"M_NAME":cscf_get_private_identity: <%.*s> \n", 00242 pi.len,pi.s); 00243 return pi; 00244 }
| str cscf_get_public_identity | ( | struct sip_msg * | msg | ) |
Returns the Public Identity extracted from the To header.
| msg | - the SIP message |
Definition at line 251 of file sip.c.
00252 { 00253 str pu={0,0}; 00254 struct to_body *to; 00255 int i; 00256 00257 if (parse_headers(msg,HDR_TO_F,0)!=0) { 00258 LOG(L_ERR,"ERR:"M_NAME":cscf_get_public_identity: Error parsing until header To: \n"); 00259 return pu; 00260 } 00261 00262 if ( get_to(msg) == NULL ) { 00263 to = (struct to_body*) pkg_malloc(sizeof(struct to_body)); 00264 parse_to( msg->to->body.s, msg->to->body.s + msg->to->body.len, to ); 00265 msg->to->parsed = to; 00266 } 00267 else to=(struct to_body *) msg->to->parsed; 00268 00269 pu = to->uri; 00270 00271 /* truncate to sip:username@host or tel:number */ 00272 for(i=4;i<pu.len;i++) 00273 if (pu.s[i]==';' || pu.s[i]=='?' ||pu.s[i]==':'){ 00274 pu.len = i; 00275 } 00276 00277 LOG(L_DBG,"DBG:"M_NAME":cscf_get_public_identity: <%.*s> \n", 00278 pu.len,pu.s); 00279 return pu; 00280 }
| int cscf_get_expires_hdr | ( | struct sip_msg * | msg | ) |
Returns the expires value from the Expires header in the message.
It searches into the Expires header and if not found returns -1
| msg | - the SIP message, if available |
Definition at line 290 of file sip.c.
00291 { 00292 exp_body_t *exp; 00293 int expires; 00294 if (!msg) return -1; 00295 /*first search in Expires header */ 00296 if (parse_headers(msg,HDR_EXPIRES_F,0)!=0) { 00297 LOG(L_ERR,"ERR:"M_NAME":cscf_get_expires_hdr: Error parsing until header EXPIRES: \n"); 00298 return -1; 00299 } 00300 if (msg->expires){ 00301 if (!msg->expires->parsed) { 00302 parse_expires(msg->expires); 00303 } 00304 if (msg->expires->parsed) { 00305 exp = (exp_body_t*) msg->expires->parsed; 00306 if (exp->valid) { 00307 expires = exp->val; 00308 LOG(L_DBG,"DBG:"M_NAME":cscf_get_expires_hdr: <%d> \n",expires); 00309 return expires; 00310 } 00311 } 00312 } 00313 00314 return -1; 00315 }
| int cscf_get_max_expires | ( | struct sip_msg * | msg | ) |
Returns the expires value from the message.
First it searches into the Expires header and if not found it also looks into the expires parameter in the contact header
| msg | - the SIP message |
Definition at line 324 of file sip.c.
References cscf_get_expires_hdr(), cscf_parse_contacts(), and M_NAME.
00325 { 00326 unsigned int exp; 00327 int max_expires = -1; 00328 struct hdr_field *h; 00329 contact_t *c; 00330 /*first search in Expires header */ 00331 max_expires = cscf_get_expires_hdr(msg); 00332 00333 cscf_parse_contacts(msg); 00334 for(h=msg->contact;h;h=h->next){ 00335 if (h->type==HDR_CONTACT_T && h->parsed) { 00336 for(c=((contact_body_t *) h->parsed)->contacts;c;c=c->next){ 00337 if(c->expires){ 00338 if (!str2int(&(c->expires->body), (unsigned int*)&exp) && (int)exp>max_expires) max_expires = exp; 00339 } 00340 } 00341 } 00342 } 00343 LOG(L_DBG,"DBG:"M_NAME":cscf_get_max_expires: <%d> \n",max_expires); 00344 return max_expires; 00345 }
| str cscf_get_public_identity_from_requri | ( | struct sip_msg * | msg | ) |
Get the Public Identity from the Request URI of the message.
| msg | - the SIP message |
Definition at line 352 of file sip.c.
References M_NAME.
00353 { 00354 str pu={0,0}; 00355 00356 if (msg->first_line.type!=SIP_REQUEST) { 00357 LOG(L_ERR,"INF:"M_NAME":cscf_get_public_identity_from_requri: This ain't a request \n"); 00358 return pu; 00359 } 00360 if (parse_sip_msg_uri(msg)<0){ 00361 LOG(L_ERR,"INF:"M_NAME":cscf_get_public_identity_from_requri: Error parsing requesturi \n"); 00362 return pu; 00363 } 00364 00365 if(msg->parsed_uri.type==TEL_URI_T){ 00366 pu.len = 4 + msg->parsed_uri.user.len ; 00367 pu.s = shm_malloc(pu.len+1); 00368 sprintf(pu.s,"tel:%.*s", 00369 msg->parsed_uri.user.len, 00370 msg->parsed_uri.user.s); 00371 }else{ 00372 pu.len = 4 + msg->parsed_uri.user.len + 1 + msg->parsed_uri.host.len; 00373 pu.s = shm_malloc(pu.len+1); 00374 sprintf(pu.s,"sip:%.*s@%.*s", 00375 msg->parsed_uri.user.len, 00376 msg->parsed_uri.user.s, 00377 msg->parsed_uri.host.len, 00378 msg->parsed_uri.host.s); 00379 } 00380 00381 LOG(L_DBG,"DBG:"M_NAME":cscf_get_public_identity_from_requri: <%.*s> \n", 00382 pu.len,pu.s); 00383 return pu; 00384 }
| struct sip_msg* cscf_get_request | ( | unsigned int | hash, | |
| unsigned int | label | |||
| ) | [read] |
Retrieves the SIP request that generated a diameter transaction.
| hash | - the tm hash value for this request | |
| label | - the tm label value for this request |
Definition at line 392 of file sip.c.
00393 { 00394 struct cell *c; 00395 if (tmb.t_lookup_ident(&c,hash,label)<0){ 00396 LOG(L_INFO,"INF:"M_NAME":Cx_UAA_timeout: No transaction found for %u %u\n", 00397 hash,label); 00398 return 0; 00399 } 00400 return c->uas.request; 00401 }
| int cscf_get_integrity_protected | ( | struct sip_msg * | msg, | |
| str | realm | |||
| ) |
Returns if the SIP message is integrity protected.
Looks for the integrity-protected field in the in the Authorization header.
| msg | - the SIP message | |
| realm | - the realm to match in the authorization |
Definition at line 414 of file sip.c.
References find_credentials(), if, M_NAME, and s_ip.
00415 { 00416 struct hdr_field* h=0; 00417 int ret,i,j; 00418 00419 if (parse_headers(msg,HDR_AUTHORIZATION_F,0)!=0) { 00420 LOG(L_ERR,"ERR:"M_NAME":cscf_get_integrity_protected: Error parsing until header Authorization: \n"); 00421 return 0; 00422 } 00423 00424 if (!msg->authorization){ 00425 LOG(L_ERR, "ERR:"M_NAME":cscf_get_integrity_protected: Message does not contain Authorization header.\n"); 00426 return 0; 00427 } 00428 00429 ret = find_credentials(msg, &realm, HDR_AUTHORIZATION_F, &h); 00430 if (ret < 0) { 00431 LOG(L_ERR, "ERR:"M_NAME":cscf_get_integrity_protected: Error while looking for credentials.\n"); 00432 return 0; 00433 } else 00434 if (ret > 0) { 00435 LOG(L_ERR, "ERR:"M_NAME":cscf_get_integrity_protected: No credentials for this realm found.\n"); 00436 return 0; 00437 } 00438 00439 if (h) { 00440 for(i=0;i<h->body.len-s_ip.len;i++) 00441 if (strncasecmp(h->body.s+i,s_ip.s,s_ip.len)==0) 00442 for(j=i+s_ip.len;j<h->body.len;j++){ 00443 if (h->body.s[j]=='y' || h->body.s[j]=='Y') return 1; 00444 if (h->body.s[j]==' ') return 0; 00445 } 00446 } 00447 00448 return 0; 00449 }
| int cscf_get_transaction | ( | struct sip_msg * | msg, | |
| unsigned int * | hash, | |||
| unsigned int * | label | |||
| ) |
Returns the tm transaction identifiers.
If no transaction, then creates one
| msg | - the SIP message | |
| hash | - where to write the hash | |
| label | - where to write the label |
Definition at line 461 of file sip.c.
00462 { 00463 00464 if (tmb.t_get_trans_ident(msg,hash,label)<0){ 00465 LOG(L_DBG,"DBG:"M_NAME":cscf_get_transaction: SIP message without transaction. OK - first request\n"); 00466 if (tmb.t_newtran(msg)<0) 00467 LOG(L_INFO,"INF:"M_NAME":cscf_get_transaction: Failed creating SIP transaction\n"); 00468 if (tmb.t_get_trans_ident(msg,hash,label)<0){ 00469 LOG(L_INFO,"INF:"M_NAME":cscf_get_transaction: SIP message still without transaction\n"); 00470 return -1; 00471 }else { 00472 LOG(L_DBG,"DBG:"M_NAME":cscf_get_transaction: New SIP message transaction %u %u\n", 00473 *hash,*label); 00474 return 1; 00475 } 00476 }else { 00477 LOG(L_INFO,"INF:"M_NAME":cscf_get_transaction: Transaction %u %u exists." 00478 "Retransmission?\n",*hash,*label); 00479 return 0; 00480 } 00481 }
| int cscf_reply_transactional | ( | struct sip_msg * | msg, | |
| int | code, | |||
| char * | text | |||
| ) |
Transactional SIP response - tries to create a transaction if none found.
| msg | - message to reply to | |
| code | - the Status-code for the response | |
| text | - the Reason-Phrase for the response |
Definition at line 490 of file sip.c.
00491 { 00492 unsigned int hash,label; 00493 if (tmb.t_get_trans_ident(msg,&hash,&label)<0){ 00494 00495 if (tmb.t_newtran(msg)<0) 00496 LOG(L_INFO,"INF:"M_NAME":cscf_get_transaction: Failed creating SIP transaction\n"); 00497 } 00498 return tmb.t_reply(msg,code,text); 00499 }
| str cscf_get_auts | ( | struct sip_msg * | msg, | |
| str | realm | |||
| ) |
Looks for the auts parameter in the Authorization header and returns its value.
| msg | - the SIP message | |
| realm | - realm to match the right Authorization header |
Definition at line 507 of file sip.c.
References find_credentials(), M_NAME, and name.
00508 { 00509 str name={"auts=\"",6}; 00510 struct hdr_field* h=0; 00511 int i,ret; 00512 str auts={0,0}; 00513 00514 if (parse_headers(msg,HDR_AUTHORIZATION_F,0)!=0) { 00515 LOG(L_ERR,"ERR:"M_NAME":cscf_get_auts: Error parsing until header Authorization: \n"); 00516 return auts; 00517 } 00518 00519 if (!msg->authorization){ 00520 LOG(L_ERR, "ERR:"M_NAME":cscf_get_auts: Message does not contain Authorization header.\n"); 00521 return auts; 00522 } 00523 00524 ret = find_credentials(msg, &realm, HDR_AUTHORIZATION_F, &h); 00525 if (ret < 0) { 00526 LOG(L_ERR, "ERR:"M_NAME":cscf_get_auts: Error while looking for credentials.\n"); 00527 return auts; 00528 } else 00529 if (ret > 0) { 00530 LOG(L_ERR, "ERR:"M_NAME":cscf_get_auts: No credentials for this realm found.\n"); 00531 return auts; 00532 } 00533 00534 if (h) { 00535 for(i=0;i<h->body.len-name.len;i++) 00536 if (strncasecmp(h->body.s+i,name.s,name.len)==0){ 00537 auts.s = h->body.s+i+name.len; 00538 while(i+auts.len<h->body.len && auts.s[auts.len]!='\"') 00539 auts.len++; 00540 } 00541 } 00542 00543 return auts; 00544 }
| str cscf_get_nonce | ( | struct sip_msg * | msg, | |
| str | realm | |||
| ) |
Looks for the nonce parameter in the Authorization header and returns its value.
| msg | - the SIP message | |
| realm | - realm to match the right Authorization header |
Definition at line 552 of file sip.c.
References find_credentials(), and M_NAME.
00553 { 00554 struct hdr_field* h=0; 00555 int ret; 00556 str nonce={0,0}; 00557 00558 if (parse_headers(msg,HDR_AUTHORIZATION_F,0)!=0) { 00559 LOG(L_ERR,"ERR:"M_NAME":cscf_get_nonce: Error parsing until header Authorization: \n"); 00560 return nonce; 00561 } 00562 00563 if (!msg->authorization){ 00564 LOG(L_ERR, "ERR:"M_NAME":cscf_get_nonce: Message does not contain Authorization header.\n"); 00565 return nonce; 00566 } 00567 00568 ret = find_credentials(msg, &realm, HDR_AUTHORIZATION_F, &h); 00569 if (ret < 0) { 00570 LOG(L_ERR, "ERR:"M_NAME":cscf_get_nonce: Error while looking for credentials.\n"); 00571 return nonce; 00572 } else 00573 if (ret > 0) { 00574 LOG(L_ERR, "ERR:"M_NAME":cscf_get_nonce: No credentials for this realm found.\n"); 00575 return nonce; 00576 } 00577 00578 if (h&&h->parsed) { 00579 nonce = ((auth_body_t*)h->parsed)->digest.nonce; 00580 } 00581 00582 return nonce; 00583 }
| str cscf_get_algorithm | ( | struct sip_msg * | msg, | |
| str | realm | |||
| ) |
Looks for the algorithm parameter in the Authorization header and returns its value.
| msg | - the SIP message | |
| realm | - realm to match the right Authorization header |
Definition at line 591 of file sip.c.
References find_credentials(), and M_NAME.
00592 { 00593 struct hdr_field* h=0; 00594 int ret; 00595 str alg={0,0}; 00596 00597 if (parse_headers(msg,HDR_AUTHORIZATION_F,0)!=0) { 00598 LOG(L_ERR,"ERR:"M_NAME":cscf_get_algorithm: Error parsing until header Authorization: \n"); 00599 return alg; 00600 } 00601 00602 if (!msg->authorization){ 00603 LOG(L_ERR, "ERR:"M_NAME":cscf_get_algorithm: Message does not contain Authorization header.\n"); 00604 return alg; 00605 } 00606 00607 ret = find_credentials(msg, &realm, HDR_AUTHORIZATION_F, &h); 00608 if (ret < 0) { 00609 LOG(L_ERR, "ERR:"M_NAME":cscf_get_algorithm: Error while looking for credentials.\n"); 00610 return alg; 00611 } else 00612 if (ret > 0) { 00613 LOG(L_ERR, "ERR:"M_NAME":cscf_get_algorithm: No credentials for this realm found.\n"); 00614 return alg; 00615 } 00616 00617 if (h&&h->parsed) { 00618 alg = ((auth_body_t*)h->parsed)->digest.alg.alg_str; 00619 } 00620 return alg; 00621 }
| str cscf_get_digest_uri | ( | struct sip_msg * | msg, | |
| str | realm | |||
| ) |
Looks for the uri parameter in the Authorization header and returns its value.
| msg | - the SIP message | |
| realm | - realm to match the right Authorization header |
Definition at line 629 of file sip.c.
References find_credentials(), and M_NAME.
00630 { 00631 struct hdr_field* h=0; 00632 int ret; 00633 str uri={0,0}; 00634 00635 if (parse_headers(msg,HDR_AUTHORIZATION_F,0)!=0) { 00636 LOG(L_ERR,"ERR:"M_NAME":cscf_get_digest_uri: Error parsing until header Authorization: \n"); 00637 return uri; 00638 } 00639 00640 if (!msg->authorization){ 00641 LOG(L_ERR, "ERR:"M_NAME":cscf_get_digest_uri: Message does not contain Authorization header.\n"); 00642 return uri; 00643 } 00644 00645 ret = find_credentials(msg, &realm, HDR_AUTHORIZATION_F, &h); 00646 if (ret < 0) { 00647 LOG(L_ERR, "ERR:"M_NAME":cscf_get_digest_uri: Error while looking for credentials.\n"); 00648 return uri; 00649 } else 00650 if (ret > 0) { 00651 LOG(L_ERR, "ERR:"M_NAME":cscf_get_digest_uri: No credentials for this realm found.\n"); 00652 return uri; 00653 } 00654 00655 if (h&&h->parsed) { 00656 uri = ((auth_body_t*)h->parsed)->digest.uri; 00657 } 00658 return uri; 00659 }
| int cscf_get_nonce_response | ( | struct sip_msg * | msg, | |
| str | realm, | |||
| str * | nonce, | |||
| str * | response, | |||
| enum qop_type * | qop, | |||
| str * | qop_str, | |||
| str * | nc, | |||
| str * | cnonce, | |||
| str * | uri | |||
| ) |
Looks for the nonce and response parameters in the Authorization header and returns them.
| msg | - the SIP message | |
| realm | - realm to match the right Authorization header | |
| nonce | - param to fill with the nonce found | |
| response | - param to fill with the response |
Definition at line 669 of file sip.c.
References find_credentials(), and M_NAME.
00671 { 00672 struct hdr_field* h=0; 00673 int ret; 00674 00675 if (parse_headers(msg,HDR_AUTHORIZATION_F,0)!=0) { 00676 LOG(L_ERR,"ERR:"M_NAME":cscf_get_nonce: Error parsing until header Authorization: \n"); 00677 return 0; 00678 } 00679 00680 if (!msg->authorization){ 00681 LOG(L_ERR, "ERR:"M_NAME":cscf_get_nonce: Message does not contain Authorization header.\n"); 00682 return 0; 00683 } 00684 00685 ret = find_credentials(msg, &realm, HDR_AUTHORIZATION_F, &h); 00686 if (ret < 0) { 00687 LOG(L_ERR, "ERR:"M_NAME":cscf_get_nonce: Error while looking for credentials.\n"); 00688 return 0; 00689 } else 00690 if (ret > 0) { 00691 LOG(L_ERR, "ERR:"M_NAME":cscf_get_nonce: No credentials for this realm found.\n"); 00692