Module: sip-router Branch: master Commit: 8a246b06838b99e63d86fe186b23a23f57347548 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8a246b06...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Nov 4 10:04:35 2013 +0100
pua_reginfo: reflect use domain from usrloc
- avoid duplicate contacts if domain is not considered - patch by Wonbin Cho, FS#350
---
modules/pua_reginfo/notify.c | 24 ++++++++++++++++-------- modules/pua_reginfo/pua_reginfo.c | 7 +++++++ modules/pua_reginfo/pua_reginfo.h | 2 ++ 3 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/modules/pua_reginfo/notify.c b/modules/pua_reginfo/notify.c index 1187e34..c1ea699 100644 --- a/modules/pua_reginfo/notify.c +++ b/modules/pua_reginfo/notify.c @@ -208,6 +208,8 @@ int reginfo_parse_event(char * s) { int process_body(str notify_body, udomain_t * domain) { xmlDocPtr doc= NULL; xmlNodePtr doc_root = NULL, registrations = NULL, contacts = NULL, uris = NULL; + char uri[MAX_URI_SIZE]; + str aor_key = {0, 0}; str aor = {0, 0}; str callid = {0, 0}; str contact_uri = {0, 0}; @@ -260,14 +262,20 @@ int process_body(str notify_body, udomain_t * domain) { goto next_registration; }
+ if (reginfo_use_domain) { + aor_key.s = uri; + } else { + aor_key.s = parsed_aor.user.s; + } + aor_key.len = strlen(aor_key.s); /* Now let's lock that domain for this AOR: */ - ul.lock_udomain(domain, &aor); + ul.lock_udomain(domain, &aor_key); /* and retrieve the user-record for this user: */ - result = ul.get_urecord(domain, &aor, &ul_record); + result = ul.get_urecord(domain, &aor_key, &ul_record); if (result < 0) { - ul.unlock_udomain(domain, &aor); + ul.unlock_udomain(domain, &aor_key); LM_ERR("failed to query usrloc (AOR %.*s)\n", - aor.len, aor.s); + aor_key.len, aor_key.s); goto next_registration; } /* If no contacts found, then set the ul_record to NULL */ @@ -285,7 +293,7 @@ int process_body(str notify_body, udomain_t * domain) { } ul_contact = ul_contact->next; } - if (ul.delete_urecord(domain, &aor, ul_record) < 0) { + if (ul.delete_urecord(domain, &aor_key, ul_record) < 0) { LM_ERR("failed to remove record from usrloc\n"); } /* If already a registration with contacts was found, then keep that result. @@ -371,7 +379,7 @@ int process_body(str notify_body, udomain_t * domain) { contact_uri.len, contact_uri.s);
/* Add to Usrloc: */ - result = process_contact(domain, &ul_record, parsed_aor.user, callid, cseq, expires, event, contact_uri); + result = process_contact(domain, &ul_record, aor_key, callid, cseq, expires, event, contact_uri); /* Process the result */ if (final_result != RESULT_CONTACTS_FOUND) final_result = result; @@ -385,8 +393,8 @@ next_contact: next_registration: // if (ul_record) ul.release_urecord(ul_record); /* Unlock the domain for this AOR: */ - if (aor.len > 0) - ul.unlock_udomain(domain, &aor); + if (aor_key.len > 0) + ul.unlock_udomain(domain, &aor_key);
registrations = registrations->next; } diff --git a/modules/pua_reginfo/pua_reginfo.c b/modules/pua_reginfo/pua_reginfo.c index 73d7113..b3ddb26 100644 --- a/modules/pua_reginfo/pua_reginfo.c +++ b/modules/pua_reginfo/pua_reginfo.c @@ -46,6 +46,8 @@ int publish_reginfo = 1;
sruid_t _reginfo_sruid;
+int reginfo_use_domain = 0; + /** Fixup functions */ static int domain_fixup(void** param, int param_no);
@@ -167,6 +169,11 @@ static int mod_init(void) if(sruid_init(&_reginfo_sruid, (char)'-', "regi", SRUID_INC)<0) return -1;
+ /* + * Import use_domain parameter from usrloc + */ + reginfo_use_domain = ul.use_domain; + return 0; }
diff --git a/modules/pua_reginfo/pua_reginfo.h b/modules/pua_reginfo/pua_reginfo.h index 2ff8e54..972ae0b 100644 --- a/modules/pua_reginfo/pua_reginfo.h +++ b/modules/pua_reginfo/pua_reginfo.h @@ -34,4 +34,6 @@ str server_address; extern usrloc_api_t ul; /*!< Structure containing pointers to usrloc functions*/ extern pua_api_t pua; /*!< Structure containing pointers to PUA functions*/
+extern int reginfo_use_domain; + #endif