/*! * \brief Match a contact record to a contact string but only compare the ip port portion * \param ptr contact record * \param _c contact string * \return ptr on successfull match, 0 when they not match */ static inline struct ucontact* contact_port_ip_match(ucontact_t* ptr, str* _c) { str string_ip_port, contact_ip_port; aor_to_contact(_c, &string_ip_port);//strip userpart from test contact while (ptr) { aor_to_contact(&ptr->c, &contact_ip_port);//strip userpart from contact if ((string_ip_port.len == contact_ip_port.len) && !memcmp(string_ip_port.s, contact_ip_port.s, string_ip_port.len)) { return ptr; } ptr = ptr->next; } return 0; }
/*! * \brief Match a contact record to a contact string but only compare the ip port portion * \param ptr contact record * \param _c contact string * \return ptr on successfull match, 0 when they not match */ static inline struct ucontact* contact_port_ip_match(unsigned int slot, str* _c) { ucontact_t* ptr = contact_list->slot[slot].first; str string_ip_port, contact_ip_port; aor_to_contact(_c, &string_ip_port); //strip userpart from test contact while (ptr) { aor_to_contact(&ptr->c, &contact_ip_port); //strip userpart from contact if ((ptr->state != CONTACT_DELAYED_DELETE) && (string_ip_port.len == contact_ip_port.len) && !memcmp(string_ip_port.s, contact_ip_port.s, string_ip_port.len)) { return ptr; } ptr = ptr->next; } return 0; }
unsigned int get_aor_hash(udomain_t* _d, str* _aor) { str contact; unsigned int aorhash; if ((hashing_type == 0) || (aor_to_contact(_aor, &contact) != 0)) { if (hashing_type !=0) { LM_DBG("Unable to get contact host:port from contact header... falling back to full AOR\n"); } aorhash = core_hash(_aor, 0, 0); } else { aorhash = core_hash(&contact, 0, 0); } return aorhash; }
/* return the slot id for inserting contacts in the hash */ unsigned int get_hash_slot(udomain_t* _d, str* _aor){ str contact; unsigned int sl; if ((hashing_type == 0) /*use full AOR for hash*/ || (aor_to_contact(_aor, &contact) != 0)) { if (hashing_type!=0) { LM_DBG("Unable to get contact host:port from contact header... falling back to full AOR\n"); } sl = core_hash(_aor, 0, _d->size); } else { sl = core_hash(&contact, 0, _d->size); } return sl; }