Definition in file registrar.h.
#include "../../sr_module.h"
#include "registrar_storage.h"
Go to the source code of this file.
Functions | |
| void | registrar_timer (unsigned int ticks, void *param) |
| The Registrar timer looks for expires contacts and removes them. | |
| int | P_save_location (struct sip_msg *rpl, char *str1, char *str2) |
| Save the contacts and their associated public ids. | |
| int | r_is_integrity_protected (str host, int port, int r_port, int transport, unsigned long session_hash) |
| Finds if the message is integrity protected. | |
| int | r_is_registered (str host, int port, int transport) |
| Finds if the user is registered. | |
| name_addr_t | r_assert_identity (str host, int port, int transport, name_addr_t preferred) |
| Asserts the identity of the user and returns the value. | |
| void registrar_timer | ( | unsigned int | ticks, | |
| void * | param | |||
| ) |
The Registrar timer looks for expires contacts and removes them.
| ticks | - the current time | |
| param | - pointer to the domain_list |
Definition at line 91 of file registrar.c.
00092 { 00093 r_contact *c,*cn; 00094 int i; 00095 #ifdef WITH_IMS_PM 00096 int impu_cnt=0,contact_cnt=0,ipsec_cnt=0,tls_cnt=0,nat_cnt=0; 00097 r_public *rp; 00098 #endif 00099 00100 LOG(L_DBG,"DBG:"M_NAME":registrar_timer: Called at %d\n",ticks); 00101 if (!registrar) registrar = (r_hash_slot*)param; 00102 00103 r_act_time(); 00104 00105 for(i=0;i<r_hash_size;i++){ 00106 r_lock(i); 00107 c = registrar[i].head; 00108 while(c){ 00109 cn = c->next; 00110 switch (c->reg_state){ 00111 case NOT_REGISTERED: 00112 LOG(L_DBG,"DBG:"M_NAME":registrar_timer: Contact <%.*s> Not Registered and removed.\n", 00113 c->uri.len,c->uri.s); 00114 del_r_contact(c); 00115 break; 00116 case REGISTERED: 00117 if (c->expires<=time_now) { 00118 LOG(L_DBG,"DBG:"M_NAME":registrar_timer: Contact <%.*s> expired and Deregistered.\n", 00119 c->uri.len,c->uri.s); 00120 if (c->security){ 00121 /* If we have IPSec SAs, we keep them 60 seconds more to relay further messages */ 00122 c->reg_state = DEREGISTERED; 00123 c->expires = time_now + 60; 00124 }else{ 00125 LOG(L_DBG,"DBG:"M_NAME":registrar_timer: Contact <%.*s> expired and removed.\n", 00126 c->uri.len,c->uri.s); 00127 del_r_contact(c); 00128 } 00129 } 00130 #ifdef WITH_IMS_PM 00131 else { 00132 contact_cnt++; 00133 for(rp=c->head;rp;rp=rp->next) 00134 impu_cnt++; 00135 if (c->security && c->security->type==SEC_IPSEC) ipsec_cnt++; 00136 if (c->security && c->security->type==SEC_TLS) tls_cnt++; 00137 if (c->pinhole) nat_cnt++; 00138 } 00139 #endif 00140 break; 00141 case DEREGISTERED: 00142 if (c->expires<=time_now) { 00143 LOG(L_DBG,"DBG:"M_NAME":registrar_timer: Contact <%.*s> expired and removed.\n", 00144 c->uri.len,c->uri.s); 00145 P_security_drop(c,c->security); 00146 P_security_drop(c,c->security_temp); 00147 del_r_contact(c); 00148 } 00149 break; 00150 case REG_PENDING: 00151 if (c->expires<=time_now) { 00152 LOG(L_DBG,"DBG:"M_NAME":registrar_timer: Contact <%.*s> Registration pending expired and removed.\n", 00153 c->uri.len,c->uri.s); 00154 P_security_drop(c,c->security); 00155 P_security_drop(c,c->security_temp); 00156 del_r_contact(c); 00157 } 00158 break; 00159 } 00160 if (pcscf_nat_enable && pcscf_nat_ping) nat_send_ping(c); 00161 c = cn; 00162 } 00163 r_unlock(i); 00164 } 00165 print_r(L_INFO); 00166 #ifdef WITH_IMS_PM 00167 IMS_PM_LOG01(RD_NbrContact,contact_cnt); 00168 IMS_PM_LOG01(RD_NbrIMPU,impu_cnt); 00169 IMS_PM_LOG01(RD_NbrIPSecSA,ipsec_cnt); 00170 IMS_PM_LOG01(RD_NbrTLSSA,tls_cnt); 00171 IMS_PM_LOG01(RD_NbrNATPinHoles,nat_cnt); 00172 #endif 00173 }
| int P_save_location | ( | struct sip_msg * | rpl, | |
| char * | str1, | |||
| char * | str2 | |||
| ) |
Save the contacts and their associated public ids.
| rpl | - the SIP Register 200 OK response that contains the Expire and Contact headers | |
| str1 | - not used | |
| str2 | - not used |
Removed because this would parse the hdr, but then it will fail to free the hdr->parsed
Definition at line 294 of file registrar.c.
References cscf_get_expires_hdr(), cscf_get_p_associated_uri(), cscf_get_realm(), cscf_get_request_from_reply(), cscf_get_service_route(), cscf_parse_contacts(), CSCF_RETURN_ERROR, CSCF_RETURN_TRUE, M_NAME, requires_nat(), and update_contacts().
00295 { 00296 struct sip_msg *req; 00297 contact_body_t* b=0; 00298 str realm; 00299 int expires_hdr=0; 00300 str *public_id=0; 00301 int public_id_cnt=0; 00302 int expires; 00303 str *service_route=0; 00304 int service_route_cnt; 00305 00306 req = cscf_get_request_from_reply(rpl); 00307 if (!req){ 00308 LOG(L_ERR,"ERR:"M_NAME":P_save_location: No transactional request found.\n"); 00309 goto error; 00310 } 00311 00312 expires_hdr = cscf_get_expires_hdr(rpl); 00314 // if (expires_hdr<0) 00315 // expires_hdr = cscf_get_expires_hdr(req); 00316 00317 if (parse_headers(rpl, HDR_EOH_F, 0) <0) { 00318 LOG(L_ERR,"ERR:"M_NAME":r_save_location: error parsing headers\n"); 00319 return CSCF_RETURN_ERROR; 00320 } 00321 00322 b = cscf_parse_contacts(rpl); 00323 00324 if (!b||(!b->contacts && !b->star)) { 00325 LOG(L_DBG,"DBG:"M_NAME":r_save_location: No contacts found\n"); 00326 return 0; 00327 } 00328 00329 realm = cscf_get_realm(req); 00330 00331 cscf_get_p_associated_uri(rpl,&public_id,&public_id_cnt); 00332 00333 service_route = cscf_get_service_route(rpl,&service_route_cnt); 00334 00335 if ((expires=update_contacts(req,rpl,b->star,expires_hdr,public_id,public_id_cnt,service_route,service_route_cnt,requires_nat(req)))<0) 00336 goto error; 00337 00338 //print_r(L_ERR); 00339 00340 00341 if (service_route) pkg_free(service_route); 00342 if (public_id) pkg_free(public_id); 00343 return CSCF_RETURN_TRUE; 00344 error: 00345 if (service_route) pkg_free(service_route); 00346 if (public_id) pkg_free(public_id); 00347 return CSCF_RETURN_ERROR; 00348 }
| int r_is_integrity_protected | ( | str | host, | |
| int | port, | |||
| int | r_port, | |||
| int | transport, | |||
| unsigned long | session_hash | |||
| ) |
Finds if the message is integrity protected.
| host | - host of the UE | |
| port | - port of the UE | |
| r_port | - received port (added by PCSCF) | |
| transport | - transport of the UE | |
| session_hash | - TLS session hash |
Definition at line 360 of file registrar.c.
References _r_security::data, get_r_contact(), _r_contact::hash, _r_security::ipsec, _r_tls::port_tls, _r_ipsec::port_uc, _r_ipsec::port_us, r_unlock(), SEC_IPSEC, SEC_NONE, SEC_TLS, _r_contact::security, _r_contact::security_temp, _r_tls::session_hash, _r_security::tls, and _r_security::type.
Referenced by P_is_integrity_protected().
00361 { 00362 int ret=0; 00363 r_contact *c; 00364 00365 if (port==0) port=5060; 00366 // LOG(L_ERR,"DBG:"M_NAME":r_is_registered: Looking if registered <%d://%.*s:%d>\n", 00367 // transport,host.len,host.s,port); 00368 00369 // print_r(L_INFO); 00370 c = get_r_contact(host,port,transport); 00371 00372 if (!c) return 0; 00373 00374 if (c->security){ 00375 switch (c->security->type){ 00376 case SEC_NONE: 00377 break; 00378 case SEC_TLS: 00379 if (c->security->data.tls&& 00380 (c->security->data.tls->port_tls==r_port) && 00381 (session_hash!= 0 && c->security->data.tls->session_hash == session_hash) // test same session 00382 ){ 00383 ret = 1; 00384 } 00385 break; 00386 case SEC_IPSEC: 00387 if (c->security->data.ipsec&& 00388 (c->security->data.ipsec->port_uc==port || c->security->data.ipsec->port_us==port)){ 00389 ret = 1; 00390 } 00391 break; 00392 } 00393 } 00394 if (!ret && c->security_temp){ 00395 switch (c->security_temp->type){ 00396 case SEC_NONE: 00397 break; 00398 case SEC_TLS: 00399 //nothing to do here becaues TLS security in temp does not mean that the user knows the password! 00400 break; 00401 case SEC_IPSEC: 00402 if (c->security_temp->data.ipsec&& 00403 (c->security_temp->data.ipsec->port_uc==port || c->security_temp->data.ipsec->port_us==port)){ 00404 ret = 1; 00405 } 00406 break; 00407 } 00408 } 00409 r_unlock(c->hash); 00410 return ret; 00411 }
| int r_is_registered | ( | str | host, | |
| int | port, | |||
| int | transport | |||
| ) |
Finds if the user is registered.
| host | - host of the UE | |
| port | - port of the UE | |
| transport | - transport of the UE |
Definition at line 420 of file registrar.c.
References get_r_contact(), _r_contact::hash, r_act_time(), r_reg_contact(), and r_unlock().
Referenced by P_is_registered().
00421 { 00422 int ret=0; 00423 r_contact *c; 00424 00425 if (port==0) port=5060; 00426 // LOG(L_ERR,"DBG:"M_NAME":r_is_registered: Looking if registered <%d://%.*s:%d>\n", 00427 // transport,host.len,host.s,port); 00428 00429 // print_r(L_INFO); 00430 c = get_r_contact(host,port,transport); 00431 00432 if (!c){ 00433 return 0; 00434 } 00435 r_act_time(); 00436 if (r_reg_contact(c)){ 00437 ret = 1; 00438 } 00439 r_unlock(c->hash); 00440 00441 return ret; 00442 }
| name_addr_t r_assert_identity | ( | str | host, | |
| int | port, | |||
| int | transport, | |||
| name_addr_t | preferred | |||
| ) |
Asserts the identity of the user and returns the value.
| host | - host of the UE | |
| port | - port of the UE | |
| transport | - transport of the UE | |
| preferred | - the P-Preferred-Identity header value |
Definition at line 453 of file registrar.c.
References _r_public::aor, get_r_contact(), _r_contact::hash, _r_contact::head, id, _r_public::is_default, M_NAME, _r_public::next, r_act_time(), r_reg_contact(), and r_unlock().
Referenced by P_assert_identity().
00454 { 00455 r_contact *c; 00456 r_public *p; 00457 name_addr_t id; 00458 if (port==0) port=5060; 00459 00460 memset(&id,0,sizeof(name_addr_t)); 00461 00462 LOG(L_DBG,"DBG:"M_NAME":r_assert_identity: Asserting preferred id <%.*s>\n", 00463 preferred.uri.len,preferred.uri.s); 00464 // print_r(L_INFO); 00465 c = get_r_contact(host,port,transport); 00466 00467 if (!c){ 00468 LOG(L_DBG,"DBG:"M_NAME":r_assert_identity: Contact not found\n"); 00469 return id; 00470 } 00471 r_act_time(); 00472 if (!r_reg_contact(c)){ 00473 LOG(L_DBG,"DBG:"M_NAME":r_assert_identity: Contact expired\n"); 00474 r_unlock(c->hash); 00475 return id; 00476 } 00477 00478 if (!c->head){ 00479 LOG(L_DBG,"DBG:"M_NAME":r_assert_identity: No public ids for this user\n"); 00480 r_unlock(c->hash); 00481 return id; 00482 } 00483 id.name = preferred.name; 00484 if (!preferred.uri.len){ 00485 p = c->head; 00486 while(p&&!p->is_default) 00487 p = p->next; 00488 if (p) { 00489 LOG(L_DBG,"DBG:"M_NAME":r_assert_identity: to <%.*s>\n",p->aor.len,p->aor.s); 00490 id.uri=p->aor; 00491 r_unlock(c->hash); 00492 return id; 00493 } else { 00494 LOG(L_DBG,"DBG:"M_NAME":r_assert_identity: to <%.*s>\n",c->head->aor.len,c->head->aor.s); 00495 id.uri=c->head->aor; 00496 r_unlock(c->hash); 00497 return id; 00498 } 00499 }else{ 00500 p = c->head; 00501 while(p){ 00502 if (p->aor.len==preferred.uri.len && 00503 strncasecmp(p->aor.s,preferred.uri.s,preferred.uri.len)==0) 00504 { 00505 LOG(L_DBG,"DBG:"M_NAME":r_assert_identity: to <%.*s>\n",p->aor.len,p->aor.s); 00506 id.uri = preferred.uri; 00507 r_unlock(c->hash); 00508 return id; 00509 } 00510 p = p->next; 00511 } 00512 } 00513 r_unlock(c->hash); 00514 return id; 00515 }
1.5.2