/*! \brief * This function will process request that * contained some contact header fields */ static inline int add_contacts(struct sip_msg* _m, contact_t* _c, udomain_t* _d, struct save_ctx *_sctx) { int res; urecord_t* r; ul.lock_udomain(_d, &_sctx->aor); res = ul.get_urecord(_d, &_sctx->aor, &r); if (res < 0) { rerrno = R_UL_GET_R; LM_ERR("failed to retrieve record from usrloc\n"); ul.unlock_udomain(_d, &_sctx->aor); return -2; } if (res == 0) { /* Contacts found */ if (update_contacts(_m, r, _c, _sctx) < 0) { build_contact(r->contacts); ul.release_urecord(r); ul.unlock_udomain(_d, &_sctx->aor); return -3; } build_contact(r->contacts); ul.release_urecord(r); } else { if (insert_contacts(_m, _c, _d, &_sctx->aor, _sctx) < 0) { ul.unlock_udomain(_d, &_sctx->aor); return -4; } } ul.unlock_udomain(_d, &_sctx->aor); return 0; }
/*! \brief * This function will process request that * contained some contact header fields */ static inline int add_contacts(struct sip_msg* _m, udomain_t* _d, str* _a, int _mode, int _use_regid) { int res; int ret; urecord_t* r; sip_uri_t *u; u = parse_to_uri(_m); if(u==NULL) return -2; ret = 0; ul.lock_udomain(_d, _a); res = ul.get_urecord(_d, _a, &r); if (res < 0) { rerrno = R_UL_GET_R; LM_ERR("failed to retrieve record from usrloc\n"); ul.unlock_udomain(_d, _a); return -2; } if (res == 0) { /* Contacts found */ if ((ret=update_contacts(_m, r, _mode, _use_regid)) < 0) { build_contact(_m, r->contacts, &u->host); ul.release_urecord(r); ul.unlock_udomain(_d, _a); return -3; } build_contact(_m, r->contacts, &u->host); ul.release_urecord(r); } else { if (insert_contacts(_m, _d, _a, _use_regid) < 0) { ul.unlock_udomain(_d, _a); return -4; } ret = 1; } ul.unlock_udomain(_d, _a); return ret; }