Lines Matching refs:_d

196 static inline int str_duplicate(str *_d, str *_s)  in str_duplicate()  argument
198 _d->s = shm_malloc(_s->len); in str_duplicate()
199 if(!_d->s) { in str_duplicate()
204 memcpy(_d->s, _s->s, _s->len); in str_duplicate()
205 _d->len = _s->len; in str_duplicate()
218 static inline int calculate_hooks(dlg_t *_d) in calculate_hooks() argument
226 memset(&_d->hooks, 0, sizeof(_d->hooks)); in calculate_hooks()
227 if(_d->route_set) { in calculate_hooks()
228 uri = &_d->route_set->nameaddr.uri; in calculate_hooks()
235 if(_d->rem_target.s) in calculate_hooks()
236 _d->hooks.request_uri = &_d->rem_target; in calculate_hooks()
238 _d->hooks.request_uri = &_d->rem_uri; in calculate_hooks()
239 _d->hooks.next_hop = &_d->route_set->nameaddr.uri; in calculate_hooks()
240 _d->hooks.first_route = _d->route_set; in calculate_hooks()
243 _d->hooks.request_uri = &_d->route_set->nameaddr.uri; in calculate_hooks()
244 _d->hooks.next_hop = _d->hooks.request_uri; in calculate_hooks()
245 _d->hooks.first_route = _d->route_set->next; in calculate_hooks()
246 if(_d->rem_target.len > 0) in calculate_hooks()
247 _d->hooks.last_route = &_d->rem_target; in calculate_hooks()
249 _d->hooks.last_route = NULL; /* ? */ in calculate_hooks()
253 if(_d->rem_target.s) in calculate_hooks()
254 _d->hooks.request_uri = &_d->rem_target; in calculate_hooks()
256 _d->hooks.request_uri = &_d->rem_uri; in calculate_hooks()
258 if(_d->dst_uri.s) in calculate_hooks()
259 _d->hooks.next_hop = &_d->dst_uri; in calculate_hooks()
261 _d->hooks.next_hop = _d->hooks.request_uri; in calculate_hooks()
269 _d->hooks.first_route = 0; in calculate_hooks()
270 _d->hooks.last_route = 0; in calculate_hooks()
273 if((_d->hooks.request_uri) && (_d->hooks.request_uri->s) in calculate_hooks()
274 && (_d->hooks.request_uri->len)) { in calculate_hooks()
275 _d->hooks.ru.s = _d->hooks.request_uri->s; in calculate_hooks()
276 _d->hooks.ru.len = _d->hooks.request_uri->len; in calculate_hooks()
277 _d->hooks.request_uri = &_d->hooks.ru; in calculate_hooks()
278 get_raw_uri(_d->hooks.request_uri); in calculate_hooks()
280 if((_d->hooks.next_hop) && (_d->hooks.next_hop->s) in calculate_hooks()
281 && (_d->hooks.next_hop->len)) { in calculate_hooks()
282 _d->hooks.nh.s = _d->hooks.next_hop->s; in calculate_hooks()
283 _d->hooks.nh.len = _d->hooks.next_hop->len; in calculate_hooks()
284 _d->hooks.next_hop = &_d->hooks.nh; in calculate_hooks()
285 get_raw_uri(_d->hooks.next_hop); in calculate_hooks()
295 int w_calculate_hooks(dlg_t *_d) in w_calculate_hooks() argument
297 return calculate_hooks(_d); in w_calculate_hooks()
304 str *_ruri, dlg_t **_d) in new_dlg_uac() argument
321 if(!_cid || !_ltag || !_luri || !_ruri || !_d) { in new_dlg_uac()
352 *_d = res; in new_dlg_uac()
354 if(calculate_hooks(*_d) < 0) { in new_dlg_uac()
375 int dlg_add_extra(dlg_t *_d, str *_ldname, str *_rdname) in dlg_add_extra() argument
377 if(!_d || !_ldname || !_rdname) { in dlg_add_extra()
383 if(shm_str_dup(&_d->loc_dname, _ldname) < 0) in dlg_add_extra()
386 if(shm_str_dup(&_d->rem_dname, _rdname) < 0) in dlg_add_extra()
602 static inline int response2dlg(struct sip_msg *_m, dlg_t *_d) in response2dlg() argument
614 if(_d->rem_target.s) { in response2dlg()
615 shm_free(_d->rem_target.s); in response2dlg()
616 _d->rem_target.s = 0; in response2dlg()
617 _d->rem_target.len = 0; in response2dlg()
619 if(_d->dst_uri.s) { in response2dlg()
620 shm_free(_d->dst_uri.s); in response2dlg()
621 _d->dst_uri.s = 0; in response2dlg()
622 _d->dst_uri.len = 0; in response2dlg()
624 if(contact.len && str_duplicate(&_d->rem_target, &contact) < 0) in response2dlg()
629 if(rtag.len && str_duplicate(&_d->id.rem_tag, &rtag) < 0) in response2dlg()
632 if(get_route_set(_m, &_d->route_set, REVERSE_ORDER) < 0) in response2dlg()
637 if(_d->id.rem_tag.s) in response2dlg()
638 shm_free(_d->id.rem_tag.s); in response2dlg()
639 _d->id.rem_tag.s = 0; in response2dlg()
640 _d->id.rem_tag.len = 0; in response2dlg()
643 if(_d->rem_target.s) in response2dlg()
644 shm_free(_d->rem_target.s); in response2dlg()
645 _d->rem_target.s = 0; in response2dlg()
646 _d->rem_target.len = 0; in response2dlg()
655 static inline int dlg_new_resp_uac(dlg_t *_d, struct sip_msg *_m) in dlg_new_resp_uac() argument
681 if(response2dlg(_m, _d) < 0) in dlg_new_resp_uac()
683 _d->state = DLG_CONFIRMED; in dlg_new_resp_uac()
685 if(calculate_hooks(_d) < 0) { in dlg_new_resp_uac()
695 _d->state = DLG_DESTROYED; in dlg_new_resp_uac()
708 static inline int dlg_early_resp_uac(dlg_t *_d, struct sip_msg *_m) in dlg_early_resp_uac() argument
724 if(response2dlg(_m, _d) < 0) in dlg_early_resp_uac()
726 _d->state = DLG_CONFIRMED; in dlg_early_resp_uac()
728 if(calculate_hooks(_d) < 0) { in dlg_early_resp_uac()
734 _d->state = DLG_DESTROYED; in dlg_early_resp_uac()
748 dlg_t *_d, struct sip_msg *_m, target_refresh_t is_target_refresh) in dlg_confirmed_resp_uac() argument
767 _d->state = DLG_DESTROYED; in dlg_confirmed_resp_uac()
788 if(_d->rem_target.s) in dlg_confirmed_resp_uac()
789 shm_free(_d->rem_target.s); in dlg_confirmed_resp_uac()
790 if(_d->dst_uri.s) { in dlg_confirmed_resp_uac()
791 shm_free(_d->dst_uri.s); in dlg_confirmed_resp_uac()
792 _d->dst_uri.s = 0; in dlg_confirmed_resp_uac()
793 _d->dst_uri.len = 0; in dlg_confirmed_resp_uac()
797 if(str_duplicate(&_d->rem_target, &contact) < 0) in dlg_confirmed_resp_uac()
801 if(calculate_hooks(_d) < 0) in dlg_confirmed_resp_uac()
813 dlg_t *_d, struct sip_msg *_m, target_refresh_t is_target_refresh) in dlg_response_uac() argument
815 if(!_d || !_m) { in dlg_response_uac()
821 switch(_d->state) { in dlg_response_uac()
823 return dlg_new_resp_uac(_d, _m); in dlg_response_uac()
826 return dlg_early_resp_uac(_d, _m); in dlg_response_uac()
829 return dlg_confirmed_resp_uac(_d, _m, is_target_refresh); in dlg_response_uac()
935 static inline int request2dlg(struct sip_msg *_m, dlg_t *_d) in request2dlg() argument
947 if(_d->rem_target.s) in request2dlg()
948 shm_free(_d->rem_target.s); in request2dlg()
949 if(_d->dst_uri.s) { in request2dlg()
950 shm_free(_d->dst_uri.s); in request2dlg()
951 _d->dst_uri.s = 0; in request2dlg()
952 _d->dst_uri.len = 0; in request2dlg()
954 if(str_duplicate(&_d->rem_target, &contact) < 0) in request2dlg()
960 if(rtag.len && str_duplicate(&_d->id.rem_tag, &rtag) < 0) in request2dlg()
965 if(callid.len && str_duplicate(&_d->id.call_id, &callid) < 0) in request2dlg()
968 if(get_cseq_value(_m, &_d->rem_seq.value) < 0) in request2dlg()
970 _d->rem_seq.is_set = 1; in request2dlg()
972 if(get_dlg_uri(_m->from, &_d->rem_uri) < 0) in request2dlg()
974 if(get_dlg_uri(_m->to, &_d->loc_uri) < 0) in request2dlg()
977 if(get_route_set(_m, &_d->route_set, NORMAL_ORDER) < 0) in request2dlg()
982 if(_d->loc_uri.s) in request2dlg()
983 shm_free(_d->loc_uri.s); in request2dlg()
984 _d->loc_uri.s = 0; in request2dlg()
985 _d->loc_uri.len = 0; in request2dlg()
987 if(_d->rem_uri.s) in request2dlg()
988 shm_free(_d->rem_uri.s); in request2dlg()
989 _d->rem_uri.s = 0; in request2dlg()
990 _d->rem_uri.len = 0; in request2dlg()
992 if(_d->id.call_id.s) in request2dlg()
993 shm_free(_d->id.call_id.s); in request2dlg()
994 _d->id.call_id.s = 0; in request2dlg()
995 _d->id.call_id.len = 0; in request2dlg()
997 if(_d->id.rem_tag.s) in request2dlg()
998 shm_free(_d->id.rem_tag.s); in request2dlg()
999 _d->id.rem_tag.s = 0; in request2dlg()
1000 _d->id.rem_tag.len = 0; in request2dlg()
1002 if(_d->rem_target.s) in request2dlg()
1003 shm_free(_d->rem_target.s); in request2dlg()
1004 _d->rem_target.s = 0; in request2dlg()
1005 _d->rem_target.len = 0; in request2dlg()
1013 int new_dlg_uas(struct sip_msg *_req, int _code, /*str* _tag,*/ dlg_t **_d) in new_dlg_uas() argument
1018 if(!_req || /*!_tag ||*/ !_d) { in new_dlg_uas()
1051 *_d = res; in new_dlg_uas()
1054 (*_d)->state = DLG_NEW; in new_dlg_uas()
1056 (*_d)->state = DLG_EARLY; in new_dlg_uas()
1058 (*_d)->state = DLG_CONFIRMED; in new_dlg_uas()
1060 if(calculate_hooks(*_d) < 0) { in new_dlg_uas()
1075 int update_dlg_uas(dlg_t *_d, int _code, str *_tag) in update_dlg_uas() argument
1077 if(_d->state == DLG_CONFIRMED) { in update_dlg_uas()
1080 } else if(_d->state == DLG_DESTROYED) { in update_dlg_uas()
1086 if(_d->id.loc_tag.s) { in update_dlg_uas()
1087 if((_tag->len == _d->id.loc_tag.len) in update_dlg_uas()
1088 && (!memcmp(_tag->s, _d->id.loc_tag.s, _tag->len))) { in update_dlg_uas()
1095 if(str_duplicate(&_d->id.loc_tag, _tag) < 0) { in update_dlg_uas()
1103 _d->state = DLG_EARLY; in update_dlg_uas()
1105 _d->state = DLG_CONFIRMED; in update_dlg_uas()
1107 _d->state = DLG_DESTROYED; in update_dlg_uas()
1116 dlg_t *_d, struct sip_msg *_m, target_refresh_t is_target_refresh) in dlg_request_uas() argument
1121 if(!_d || !_m) { in dlg_request_uas()
1135 if(_d->rem_seq.is_set && (cseq <= _d->rem_seq.value)) in dlg_request_uas()
1139 _d->rem_seq.value = cseq; in dlg_request_uas()
1140 _d->rem_seq.is_set = 1; in dlg_request_uas()
1154 if(_d->rem_target.s) in dlg_request_uas()
1155 shm_free(_d->rem_target.s); in dlg_request_uas()
1156 if(_d->dst_uri.s) { in dlg_request_uas()
1157 shm_free(_d->dst_uri.s); in dlg_request_uas()
1158 _d->dst_uri.s = 0; in dlg_request_uas()
1159 _d->dst_uri.len = 0; in dlg_request_uas()
1161 if(str_duplicate(&_d->rem_target, &contact) < 0) in dlg_request_uas()
1165 if(calculate_hooks(_d) < 0) in dlg_request_uas()
1176 int calculate_routeset_length(dlg_t *_d) in calculate_routeset_length() argument
1181 if(!_d->route_set) in calculate_routeset_length()
1186 for(ptr = _d->hooks.first_route; ptr; ptr = ptr->next) { in calculate_routeset_length()
1190 if(_d->hooks.last_route) { in calculate_routeset_length()
1191 if(_d->hooks.first_route) in calculate_routeset_length()
1193 len += _d->hooks.last_route->len + 2; /* < > */ in calculate_routeset_length()
1207 char *print_routeset(char *buf, dlg_t *_d) in print_routeset() argument
1211 ptr = _d->hooks.first_route; in print_routeset()
1213 if(ptr || _d->hooks.last_route) { in print_routeset()
1229 if(_d->hooks.last_route) { in print_routeset()
1230 if(_d->hooks.first_route) { in print_routeset()
1236 memcpy(buf, _d->hooks.last_route->s, _d->hooks.last_route->len); in print_routeset()
1237 buf += _d->hooks.last_route->len; in print_routeset()
1242 if(_d->hooks.first_route || _d->hooks.last_route) { in print_routeset()
1254 void free_dlg(dlg_t *_d) in free_dlg() argument
1256 if(!_d) in free_dlg()
1259 destroy_trans_dlg_callbacks(_d); in free_dlg()
1261 if(_d->id.call_id.s) in free_dlg()
1262 shm_free(_d->id.call_id.s); in free_dlg()
1263 if(_d->id.rem_tag.s) in free_dlg()
1264 shm_free(_d->id.rem_tag.s); in free_dlg()
1265 if(_d->id.loc_tag.s) in free_dlg()
1266 shm_free(_d->id.loc_tag.s); in free_dlg()
1268 if(_d->loc_uri.s) in free_dlg()
1269 shm_free(_d->loc_uri.s); in free_dlg()
1270 if(_d->rem_uri.s) in free_dlg()
1271 shm_free(_d->rem_uri.s); in free_dlg()
1272 if(_d->rem_target.s) in free_dlg()
1273 shm_free(_d->rem_target.s); in free_dlg()
1274 if(_d->dst_uri.s) in free_dlg()
1275 shm_free(_d->dst_uri.s); in free_dlg()
1277 if(_d->loc_dname.s) in free_dlg()
1278 shm_free(_d->loc_dname.s); in free_dlg()
1279 if(_d->rem_dname.s) in free_dlg()
1280 shm_free(_d->rem_dname.s); in free_dlg()
1283 shm_free_rr(&_d->route_set); in free_dlg()
1284 shm_free(_d); in free_dlg()
1291 void print_dlg(FILE *out, dlg_t *_d) in print_dlg() argument
1294 fprintf(out, "id.call_id : '%.*s'\n", _d->id.call_id.len, in print_dlg()
1295 _d->id.call_id.s); in print_dlg()
1296 fprintf(out, "id.rem_tag : '%.*s'\n", _d->id.rem_tag.len, in print_dlg()
1297 _d->id.rem_tag.s); in print_dlg()
1298 fprintf(out, "id.loc_tag : '%.*s'\n", _d->id.loc_tag.len, in print_dlg()
1299 _d->id.loc_tag.s); in print_dlg()
1300 fprintf(out, "loc_seq.value : %d\n", _d->loc_seq.value); in print_dlg()
1301 fprintf(out, "loc_seq.is_set: %s\n", _d->loc_seq.is_set ? "YES" : "NO"); in print_dlg()
1302 fprintf(out, "rem_seq.value : %d\n", _d->rem_seq.value); in print_dlg()
1303 fprintf(out, "rem_seq.is_set: %s\n", _d->rem_seq.is_set ? "YES" : "NO"); in print_dlg()
1304 fprintf(out, "loc_uri : '%.*s'\n", _d->loc_uri.len, _d->loc_uri.s); in print_dlg()
1305 fprintf(out, "rem_uri : '%.*s'\n", _d->rem_uri.len, _d->rem_uri.s); in print_dlg()
1306 fprintf(out, "rem_target : '%.*s'\n", _d->rem_target.len, in print_dlg()
1307 _d->rem_target.s); in print_dlg()
1308 fprintf(out, "dst_uri : '%.*s'\n", _d->dst_uri.len, _d->dst_uri.s); in print_dlg()
1309 fprintf(out, "secure: : %d\n", _d->secure); in print_dlg()
1311 switch(_d->state) { in print_dlg()
1325 print_rr(out, _d->route_set); in print_dlg()
1326 if(_d->hooks.request_uri) in print_dlg()
1327 fprintf(out, "hooks.request_uri: '%.*s'\n", _d->hooks.request_uri->len, in print_dlg()
1328 _d->hooks.request_uri->s); in print_dlg()
1329 if(_d->hooks.next_hop) in print_dlg()
1330 fprintf(out, "hooks.next_hop : '%.*s'\n", _d->hooks.next_hop->len, in print_dlg()
1331 _d->hooks.next_hop->s); in print_dlg()
1332 if(_d->hooks.first_route) in print_dlg()
1333 fprintf(out, "hooks.first_route: '%.*s'\n", _d->hooks.first_route->len, in print_dlg()
1334 _d->hooks.first_route->nameaddr.name.s); in print_dlg()
1335 if(_d->hooks.last_route) in print_dlg()
1336 fprintf(out, "hooks.last_route : '%.*s'\n", _d->hooks.last_route->len, in print_dlg()
1337 _d->hooks.last_route->s); in print_dlg()
1345 int set_dlg_target(dlg_t *_d, str *_ruri, str *_duri) in set_dlg_target() argument
1348 if(!_d || !_ruri) { in set_dlg_target()
1353 if(_d->rem_target.s) in set_dlg_target()
1354 shm_free(_d->rem_target.s); in set_dlg_target()
1355 if(_d->dst_uri.s) { in set_dlg_target()
1356 shm_free(_d->dst_uri.s); in set_dlg_target()
1357 _d->dst_uri.s = 0; in set_dlg_target()
1358 _d->dst_uri.len = 0; in set_dlg_target()
1361 if(str_duplicate(&_d->rem_target, _ruri)) in set_dlg_target()
1364 if(str_duplicate(&_d->dst_uri, _duri)) in set_dlg_target()
1368 if(calculate_hooks(_d) < 0) { in set_dlg_target()