Przeglądaj źródła

Revert "ims_usrloc_pcscf: Improvement: Let the consumer decide, if we want to retrieve REGISTERED only or all contacts (especially, if we have more than one contact per IP/Port)"
- this is already done in changes coming in...
- rely on the consumer to check the status of the contact if one is found

This reverts commit fe8a06a2e1b18219e52b3a85abd3f3961cc9773a.

Jason Penton 11 lat temu
rodzic
commit
7deddf5646

+ 1 - 1
modules/ims_qos/cdpeventprocessor.c

@@ -237,7 +237,7 @@ void cdp_cb_event_process() {
                         return;
                     }
                     ul.lock_udomain(domain, &p_session_data->registration_aor);
-                    if (ul.get_pcontact(domain, &p_session_data->registration_aor, 0,
+                    if (ul.get_pcontact(domain, &p_session_data->registration_aor,
                             &pcontact) != 0) {
                         LM_DBG("no contact found for terminated Rx reg session..... ignoring\n");
                     } else {

+ 1 - 1
modules/ims_qos/mod.c

@@ -742,7 +742,7 @@ static int w_rx_aar_register(struct sip_msg *msg, char* route, char* str1, char*
         if (h->type == HDR_CONTACT_T && h->parsed) {
             for (c = ((contact_body_t*) h->parsed)->contacts; c; c = c->next) {
                 ul.lock_udomain(domain_t, &c->uri);
-                if (ul.get_pcontact(domain_t, &c->uri, 0, &pcontact) != 0) {
+                if (ul.get_pcontact(domain_t, &c->uri, &pcontact) != 0) {
                     LM_DBG("This contact does not exist in PCSCF usrloc - error in cfg file\n");
                     ul.unlock_udomain(domain_t, &c->uri);
                     lock_release(saved_t_data->lock);

+ 1 - 1
modules/ims_qos/rx_aar.c

@@ -246,7 +246,7 @@ void async_aar_reg_callback(int is_timeout, void *param, AAAMessage *aaa, long e
         LM_DBG("Registering for Usrloc callbacks on DELETE\n");
 
         ul.lock_udomain(domain_t, &local_data->contact);
-        if (ul.get_pcontact(domain_t, &local_data->contact, 0, &pcontact) != 0) {
+        if (ul.get_pcontact(domain_t, &local_data->contact, &pcontact) != 0) {
             LM_ERR("Shouldn't get here, can find contact....\n");
             ul.unlock_udomain(domain_t, &local_data->contact);
             goto error;

+ 1 - 1
modules/ims_registrar_pcscf/notify.c

@@ -103,7 +103,7 @@ int process_contact(udomain_t * _d, int expires, str contact_uri, int contact_st
 	
 	ul.lock_udomain(_d, &contact_uri);
 	
-	if (ul.get_pcontact(_d, &contact_uri, 0, &pcontact) != 0) { //contact does not exist
+	if (ul.get_pcontact(_d, &contact_uri, &pcontact) != 0) { //contact does not exist
 	    if (contact_state == STATE_TERMINATED) {
 		LM_DBG("This contact: <%.*s> is in state terminated and is not in usrloc, ignore\n", contact_uri.len, contact_uri.s);
 		ret = RESULT_CONTACTS_FOUND;

+ 2 - 2
modules/ims_registrar_pcscf/save.c

@@ -157,7 +157,7 @@ static inline int update_contacts(struct sip_msg *req,struct sip_msg *rpl, udoma
 				ci.received_proto = 0;
 
 				ul.lock_udomain(_d, &c->uri);
-				if (ul.get_pcontact(_d, &c->uri, 0, &pcontact) != 0) { //need to insert new contact
+				if (ul.get_pcontact(_d, &c->uri, &pcontact) != 0) { //need to insert new contact
 					if ((expires-local_time_now)<=0) { //remove contact - de-register
 						LM_DBG("This is a de-registration for contact <%.*s> but contact is not in usrloc - ignore\n", c->uri.len, c->uri.s);
 						goto next_contact;
@@ -305,7 +305,7 @@ int save_pending(struct sip_msg* _m, udomain_t* _d) {
 		ci.received_port = 5060;
 
 	ul.lock_udomain(_d, &c->uri);
-	if (ul.get_pcontact(_d, &c->uri, 0, &pcontact) != 0) { //need to insert new contact
+	if (ul.get_pcontact(_d, &c->uri, &pcontact) != 0) { //need to insert new contact
 		LM_DBG("Adding pending pcontact: <%.*s>\n", c->uri.len, c->uri.s);
 		if (ul.insert_pcontact(_d, &c->uri, &ci, &pcontact) != 0) {
 			LM_ERR("Failed inserting new pcontact\n");

+ 3 - 3
modules/ims_registrar_pcscf/service_routes.c

@@ -127,7 +127,7 @@ pcontact_t * getContactP(struct sip_msg* _m, udomain_t* _d) {
 
 		if (b && b->contacts) {
 			for (ct = b->contacts; ct; ct = ct->next) {
-				if (ul.get_pcontact(_d, &ct->uri, 1, &c) == 0) {
+				if (ul.get_pcontact(_d, &ct->uri, &c) == 0) {
 					if (c->security) {
 						switch (c->security->type) {
 						case SECURITY_IPSEC:
@@ -176,7 +176,7 @@ pcontact_t * getContactP(struct sip_msg* _m, udomain_t* _d) {
 			LM_WARN("Contact not found based on Contact-header, trying IP/Port/Proto\n");
 			received_host.len = ip_addr2sbuf(&_m->rcv.src_ip, srcip, sizeof(srcip));
 			received_host.s = srcip;
-			if (ul.get_pcontact_by_src(_d, &received_host, _m->rcv.src_port, _m->rcv.proto, 1, &c) == 1)
+			if (ul.get_pcontact_by_src(_d, &received_host, _m->rcv.src_port, _m->rcv.proto, &c) == 1)
 				LM_DBG("No entry in usrloc for %.*s:%i (Proto %i) found!\n", received_host.len, received_host.s, _m->rcv.src_port, _m->rcv.proto);
 		}
 	}
@@ -210,7 +210,7 @@ pcontact_t * getContactP_from_via(struct sip_msg* _m, udomain_t* _d) {
 		current_msg_id = _m->id;
 		c = NULL;
 		LM_DBG("Looking for <%d://%.*s:%d>\n", vb->proto, vb->host.len, vb->host.s, vb->port);
-		if (ul.get_pcontact_by_src(_d, &vb->host, vb->port, vb->proto, 1, &c) == 1)
+		if (ul.get_pcontact_by_src(_d, &vb->host, vb->port, vb->proto, &c) == 1)
 			LM_WARN("No entry in usrloc for %.*s:%i (Proto %i) found!\n", vb->host.len, vb->host.s, vb->port, vb->proto);
 	}
 

+ 37 - 42
modules/ims_usrloc_pcscf/udomain.c

@@ -441,7 +441,7 @@ error:
     return -1;
 }
 
-int get_pcontact(udomain_t* _d, str* _contact, int is_registered, struct pcontact** _c) {
+int get_pcontact(udomain_t* _d, str* _contact, struct pcontact** _c) {
 	unsigned int sl, i, aorhash, len, len2;
 	struct pcontact* c;
 	char *ptr, *ptr2;
@@ -490,16 +490,14 @@ int get_pcontact(udomain_t* _d, str* _contact, int is_registered, struct pcontac
 			if ((len2 <= c->aor.len) && (memcmp(ptr2, ptr, len2)==0)) {
 				impu = c->head;
 				while (impu) {
-					if ((is_registered == 0) || (c->reg_state == PCONTACT_REGISTERED)) {
-						LM_DBG("comparing first %d chars of impu [%.*s] for contact [%.*s]\n",
-								len,
-								impu->public_identity.len, impu->public_identity.s,
-								_contact->len, _contact->s);
-						if (memcmp(impu->public_identity.s, _contact->s, len) == 0) {
-							//match
-							*_c = c;
-							return 0;
-						}
+					LM_DBG("comparing first %d chars of impu [%.*s] for contact [%.*s]\n",
+							len,
+							impu->public_identity.len, impu->public_identity.s,
+							_contact->len, _contact->s);
+					if (memcmp(impu->public_identity.s, _contact->s, len) == 0) {
+						//match
+						*_c = c;
+						return 0;
 					}
 					impu = impu->next;
 				}
@@ -511,7 +509,7 @@ int get_pcontact(udomain_t* _d, str* _contact, int is_registered, struct pcontac
 }
 
 /* can't assume we are locked here */
-int get_pcontact_by_src(udomain_t* _d, str * _host, unsigned short _port, unsigned short _proto, int is_registered, struct pcontact** _c) {
+int get_pcontact_by_src(udomain_t* _d, str * _host, unsigned short _port, unsigned short _proto, struct pcontact** _c) {
 	int i;
 	struct pcontact* c;
 	unsigned int aorhash, sl;
@@ -538,21 +536,20 @@ int get_pcontact_by_src(udomain_t* _d, str * _host, unsigned short _port, unsign
 			LM_DBG("Searching for contact in P-CSCF usrloc [%.*s]\n",
 					s_contact.len,
 					s_contact.s);
-			if ((is_registered == 0) || (c->reg_state == PCONTACT_REGISTERED)) {
-				// First check, if Proto and Port matches:
-				if ((c->received_port == _port) && (c->received_proto == _proto)) {
-					LM_DBG("Received host len %d (search %d)\n", c->received_host.len, _host->len);
-					// Then check the length:
-					if (c->received_host.len == _host->len) {
-						LM_DBG("Received host %.*s (search %.*s)\n",
-								c->received_host.len, c->received_host.s,
-								_host->len, _host->s);
 
-						// Finally really compare the "received_host"
-						if (!memcmp(c->received_host.s, _host->s, _host->len)) {
-							*_c = c;
-							return 0;
-						}
+			// First check, if Proto and Port matches:
+			if ((c->received_port == _port) && (c->received_proto == _proto)) {
+				LM_DBG("Received host len %d (search %d)\n", c->received_host.len, _host->len);
+				// Then check the length:
+				if (c->received_host.len == _host->len) {
+					LM_DBG("Received host %.*s (search %.*s)\n",
+							c->received_host.len, c->received_host.s,
+							_host->len, _host->s);
+
+					// Finally really compare the "received_host"
+					if (!memcmp(c->received_host.s, _host->s, _host->len)) {
+						*_c = c;
+						return 0;
 					}
 				}
 			}
@@ -568,21 +565,19 @@ int get_pcontact_by_src(udomain_t* _d, str * _host, unsigned short _port, unsign
 					c->received_port, _port, c->received_proto, _proto,
 					reg_state_to_string(c->reg_state), reg_state_to_string(PCONTACT_REGISTERED)
 					);
-				if ((is_registered == 0) || (c->reg_state == PCONTACT_REGISTERED)) {
-					// First check, if Proto and Port matches:
-					if ((c->received_port == _port) && (c->received_proto == _proto)) {
-						LM_DBG("Received host len %d (search %d)\n", c->received_host.len, _host->len);
-						// Then check the length:
-						if (c->received_host.len == _host->len) {
-							LM_DBG("Received host %.*s (search %.*s)\n",
-								c->received_host.len, c->received_host.s,
-								_host->len, _host->s);
-
-							// Finally really compare the "received_host"
-							if (!memcmp(c->received_host.s, _host->s, _host->len)) {
-								*_c = c;
-								return 0;
-							}
+				// First check, if Proto and Port matches:
+				if ((c->received_port == _port) && (c->received_proto == _proto)) {
+					LM_DBG("Received host len %d (search %d)\n", c->received_host.len, _host->len);
+					// Then check the length:
+					if (c->received_host.len == _host->len) {
+						LM_DBG("Received host %.*s (search %.*s)\n",
+							c->received_host.len, c->received_host.s,
+							_host->len, _host->s);
+
+						// Finally really compare the "received_host"
+						if (!memcmp(c->received_host.s, _host->s, _host->len)) {
+							*_c = c;
+							return 0;
 						}
 					}
 				}
@@ -642,7 +637,7 @@ int assert_identity(udomain_t* _d, str * _host, unsigned short _port, unsigned s
 int delete_pcontact(udomain_t* _d, str* _aor, struct pcontact* _c)
 {
 	if (_c==0) {
-		if (get_pcontact(_d, _aor, 0, &_c) > 0) {
+		if (get_pcontact(_d, _aor, &_c) > 0) {
 			return 0;
 		}
 	}

+ 2 - 2
modules/ims_usrloc_pcscf/udomain.h

@@ -76,8 +76,8 @@ void unlock_ulslot(udomain_t* _d, int i);
 int update_rx_regsession(struct udomain* _d, str* session_id, struct pcontact* _c);
 int update_pcontact(struct udomain* _d, struct pcontact_info* _ci, struct pcontact* _c);
 int insert_pcontact(struct udomain* _d, str* _contact, struct pcontact_info* _ci, struct pcontact** _r);
-int get_pcontact(udomain_t* _d, str* _aor, int is_registered, struct pcontact** _r);
-int get_pcontact_by_src(udomain_t* _d, str * _host, unsigned short _port, unsigned short _proto, int is_registered, struct pcontact** _c);
+int get_pcontact(udomain_t* _d, str* _aor, struct pcontact** _r);
+int get_pcontact_by_src(udomain_t* _d, str * _host, unsigned short _port, unsigned short _proto, struct pcontact** _c);
 int assert_identity(udomain_t* _d, str * _host, unsigned short _port, unsigned short _proto, str * _identity);
 int delete_pcontact(udomain_t* _d, str* _aor, struct pcontact* _r);
 

+ 2 - 2
modules/ims_usrloc_pcscf/usrloc.h

@@ -206,9 +206,9 @@ typedef struct pcontact {
 	struct pcontact* next; 					/*!< Previous item in the hash entry */
 } pcontact_t;
 
-typedef int (*get_pcontact_t)(struct udomain* _d, str* _contact, int is_registered, struct pcontact** _c);
+typedef int (*get_pcontact_t)(struct udomain* _d, str* _contact, struct pcontact** _c);
 
-typedef int (*get_pcontact_by_src_t)(struct udomain* _d, str * _host, unsigned short _port, unsigned short _proto, int is_registered, struct pcontact** _c);
+typedef int (*get_pcontact_by_src_t)(struct udomain* _d, str * _host, unsigned short _port, unsigned short _proto, struct pcontact** _c);
 
 typedef int (*assert_identity_t)(struct udomain* _d, str * _host, unsigned short _port, unsigned short _proto, str * _identity);