MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / new_ucontact

Function new_ucontact

modules/usrloc/ucontact.c:100–216  ·  view source on GitHub ↗

! \brief * Create a new contact structure */

Source from the content-addressed store, hash-verified

98 * Create a new contact structure
99 */
100ucontact_t*
101new_ucontact(str* _dom, str* _aor, str* _contact, ucontact_info_t* _ci)
102{
103 struct sip_uri ct_uri;
104 ucontact_t *c;
105 int_str_t shtag, *shtagp;
106
107 c = (ucontact_t*)shm_malloc(sizeof(ucontact_t));
108 if (!c) {
109 LM_ERR("no more shm memory\n");
110 return NULL;
111 }
112 memset(c, 0, sizeof(ucontact_t));
113
114 if (have_mem_storage()) {
115 if (!ZSTRP(_ci->packed_kv_storage))
116 c->kv_storage = store_deserialize(_ci->packed_kv_storage);
117 else
118 c->kv_storage = map_create(AVLMAP_SHARED);
119
120 if (!c->kv_storage)
121 goto mem_error;
122 }
123
124 if (parse_uri(_contact->s, _contact->len, &ct_uri) < 0) {
125 LM_ERR("contact [%.*s] is not valid! Will not store it!\n",
126 _contact->len, _contact->s);
127 goto out_free;
128 }
129
130 if (shm_str_dup( &c->c, _contact) < 0) goto mem_error;
131 if (shm_str_dup( &c->callid, _ci->callid) < 0) goto mem_error;
132
133 /* an additional null byte may be needed by "regexec" later on */
134 if (shm_nt_str_dup( &c->user_agent, _ci->user_agent) < 0) goto mem_error;
135
136 if (_ci->received.s && _ci->received.len) {
137 if (shm_str_dup( &c->received, &_ci->received) < 0) goto mem_error;
138 }
139
140 if (_ci->instance.s && _ci->instance.len) {
141 if (shm_str_dup( &c->instance, &_ci->instance) < 0) goto mem_error;
142 }
143
144 if (_ci->path && _ci->path->len) {
145 if (shm_str_dup( &c->path, _ci->path) < 0) goto mem_error;
146 }
147
148 if (_ci->attr && _ci->attr->len) {
149 if (shm_str_dup( &c->attr, _ci->attr) < 0) goto mem_error;
150 }
151
152 if (_ci->cdb_key.s && _ci->cdb_key.len) {
153 if (shm_str_dup( &c->cdb_key, &_ci->cdb_key) < 0) goto mem_error;
154 }
155
156 if (_ci->shtag.s) {
157 if (shm_str_dup(&c->shtag, &_ci->shtag) < 0)

Callers 1

mem_insert_ucontactFunction · 0.85

Calls 14

shm_mallocFunction · 0.85
have_mem_storageFunction · 0.85
store_deserializeFunction · 0.85
map_createFunction · 0.85
parse_uriFunction · 0.85
shm_nt_str_dupFunction · 0.85
kv_putFunction · 0.85
kv_getFunction · 0.85
compute_next_hopFunction · 0.85
INIT_LIST_HEADFunction · 0.85
start_refresh_timerFunction · 0.85
shm_freeFunction · 0.85

Tested by

no test coverage detected