Module: kamailio Branch: master Commit: 233dda7b9a1ca6954c35f2f0b271cb9bc4c813d9 URL: https://github.com/kamailio/kamailio/commit/233dda7b9a1ca6954c35f2f0b271cb9b...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2024-08-27T12:38:25+02:00
core: helper function to forward uac style with dst attributes
---
Modified: src/core/forward.c Modified: src/core/forward.h
---
Diff: https://github.com/kamailio/kamailio/commit/233dda7b9a1ca6954c35f2f0b271cb9b... Patch: https://github.com/kamailio/kamailio/commit/233dda7b9a1ca6954c35f2f0b271cb9b...
---
diff --git a/src/core/forward.c b/src/core/forward.c index 3d2e743cdbd..97953ee7b85 100644 --- a/src/core/forward.c +++ b/src/core/forward.c @@ -695,6 +695,41 @@ int forward_request(struct sip_msg *msg, str *dst, unsigned short port, }
+int forward_request_uac(struct sip_msg *msg, str *dst, unsigned short port, + struct dest_info *send_info) +{ + int ret; + sr_lump_t *anchor; + hdr_field_t *hf; + msg_flags_t msg_flags_bk; + + if(parse_headers(msg, HDR_EOH_F, 0) == -1) { + LM_ERR("error while parsing message\n"); + return -1; + } + /* remove incoming Via headers */ + for(hf = msg->headers; hf; hf = hf->next) { + if(hf->type != HDR_VIA_T) { + continue; + } + anchor = del_lump(msg, hf->name.s - msg->buf, hf->len, 0); + if(anchor == 0) { + LM_ERR("cannot remove Via header\n"); + return -1; + } + } + + msg_flags_bk = msg->msg_flags; + msg->msg_flags |= FL_VIA_NORECEIVED; + ret = forward_request_mode(msg, dst, port, send_info, BUILD_NO_VIA1_UPDATE); + msg->msg_flags = msg_flags_bk; + if(ret >= 0) { + return 1; + } + + return -1; +} + /** * forward request like initial uac sender, with only one via */ diff --git a/src/core/forward.h b/src/core/forward.h index 5b414a7a64b..31086c6512b 100644 --- a/src/core/forward.h +++ b/src/core/forward.h @@ -82,6 +82,8 @@ int forward_request(struct sip_msg *msg, str *dst, unsigned short port, struct dest_info *send_info); int forward_request_mode(struct sip_msg *msg, str *dst, unsigned short port, struct dest_info *send_info, unsigned int mbmode); +int forward_request_uac(struct sip_msg *msg, str *dst, unsigned short port, + struct dest_info *send_info); int forward_uac_uri(sip_msg_t *msg, str *vuri); int update_sock_struct_from_via( union sockaddr_union *to, struct sip_msg *msg, struct via_body *via);