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

Function append_fixed_vars

modules/exec/exec_hf.c:426–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424}
425
426static int append_fixed_vars(struct sip_msg *msg, struct hf_wrapper **list)
427{
428 static char tid[MD5_LEN];
429 str *uri;
430 struct sip_uri parsed_uri, oparsed_uri;
431 char *val;
432 int val_len;
433
434 /* source ip */
435 if (!append_var(EV_SRCIP, ip_addr2a(&msg->rcv.src_ip), 0, list)) {
436 LM_ERR("append_var SRCIP failed \n");
437 return 0;
438 }
439 /* request URI */
440 uri=msg->new_uri.s && msg->new_uri.len ?
441 &msg->new_uri : &msg->first_line.u.request.uri;
442 if (!append_var(EV_RURI, uri->s, uri->len, list )) {
443 LM_ERR("append_var URI failed\n");
444 return 0;
445 }
446 /* userpart of request URI */
447 if (parse_uri(uri->s, uri->len, &parsed_uri)<0) {
448 LM_WARN("uri not parsed\n");
449 } else {
450 if (!append_var(EV_USER, parsed_uri.user.s,
451 parsed_uri.user.len, list)) {
452 LM_ERR("append_var USER failed\n");
453 goto error;
454 }
455 }
456 /* original URI */
457 if (!append_var(EV_ORURI, msg->first_line.u.request.uri.s,
458 msg->first_line.u.request.uri.len, list)) {
459 LM_ERR("append_var O-URI failed\n");
460 goto error;
461 }
462 /* userpart of request URI */
463 if (parse_uri(msg->first_line.u.request.uri.s,
464 msg->first_line.u.request.uri.len,
465 &oparsed_uri)<0) {
466 LM_WARN("orig URI not parsed\n");
467 } else {
468 if (!append_var(EV_OUSER, oparsed_uri.user.s,
469 oparsed_uri.user.len, list)) {
470 LM_ERR("ppend_var OUSER failed\n");
471 goto error;
472 }
473 }
474 /* tid, transaction id == via/branch */
475 if (!char_msg_val(msg, tid)) {
476 LM_WARN("no tid can be determined\n");
477 val=0; val_len=0;
478 } else {
479 val=tid;val_len=MD5_LEN;
480 }
481 if (!append_var(EV_TID, val,val_len, list)) {
482 LM_ERR("append_var TID failed\n");
483 goto error;

Callers 1

set_envFunction · 0.85

Calls 4

append_varFunction · 0.85
ip_addr2aFunction · 0.85
parse_uriFunction · 0.85
char_msg_valFunction · 0.85

Tested by

no test coverage detected