Module: kamailio Branch: master Commit: 547d0acb8c93448a3796aef33f6736824e23e123 URL: https://github.com/kamailio/kamailio/commit/547d0acb8c93448a3796aef33f6736824e23e123
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2025-12-11T13:24:51+01:00 core: parameter to add extra value to via branch --- Modified: src/core/config.h Modified: src/core/forward.c Modified: src/core/msg_translator.c Modified: src/core/msg_translator.h --- Diff: https://github.com/kamailio/kamailio/commit/547d0acb8c93448a3796aef33f6736824e23e123.diff Patch: https://github.com/kamailio/kamailio/commit/547d0acb8c93448a3796aef33f6736824e23e123.patch --- diff --git a/src/core/config.h b/src/core/config.h index 7d0d4df5fe3..900c2bf8451 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -198,10 +198,15 @@ #define MCOOKIE \ "z9hG4bK" /*!< magic cookie for transaction matching as defined in RFC3261 */ #define MCOOKIE_LEN (sizeof(MCOOKIE) - 1) + +/*! \brief Maximum length of extra value in Via-branch parameter */ +#define MAX_BRANCH_XVAL_LEN 8 + /*! \brief Maximum length of values appended to Via-branch parameter */ #define MAX_BRANCH_PARAM_LEN \ (MCOOKIE_LEN \ + 8 /*int2hex*/ + 1 /*sep*/ + MD5_LEN /* max(int2hex, MD5_LEN) */ \ + + 1 /*sep*/ + MAX_BRANCH_XVAL_LEN /*extra value*/ \ + 1 /*sep*/ + 8 /*int2hex*/ \ + 1 /*extra space, needed by t_calc_branch*/) diff --git a/src/core/forward.c b/src/core/forward.c index 8b9a98e18d4..b54e364b765 100644 --- a/src/core/forward.c +++ b/src/core/forward.c @@ -598,7 +598,7 @@ int forward_request_mode(struct sip_msg *msg, str *dst, unsigned short port, goto error; } msg->hash_index = hash(msg->callid->body, get_cseq(msg)->number); - if(!branch_builder(msg->hash_index, 0, md5, 0 /* 0-th branch */, + if(!branch_builder(msg->hash_index, 0, md5, NULL, 0 /* 0-th branch */, msg->add_to_branch_s, &msg->add_to_branch_len)) { LM_ERR("branch_builder failed\n"); ret = E_UNSPEC; diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c index 069eb70b4a6..d5f7d410372 100644 --- a/src/core/msg_translator.c +++ b/src/core/msg_translator.c @@ -2779,7 +2779,7 @@ char *build_res_buf_from_sip_req(unsigned int code, str *text, str *new_tag, /* do nothing, we are interested only in the above headers */ ; } /* end switch */ - } /* end for */ + } /* end for */ /* lumps */ for(lump = msg->reply_lump; lump; lump = lump->next) if(lump->flags & LUMP_RPL_HDR) { @@ -2848,8 +2848,8 @@ char *build_res_buf_from_sip_req(unsigned int code, str *text, str *new_tag, */ int branch_builder(unsigned int hash_index, /* only either parameter useful */ - unsigned int label, char *char_v, int branch, char *branch_str, - int *len) + unsigned int label, char *char_v, str *xval, int branch, + char *branch_str, int *len) { char *begin; @@ -2886,6 +2886,20 @@ int branch_builder(unsigned int hash_index, return 0; } + /* extra value */ + if(xval != NULL && xval->s != NULL && xval->len > 0 + && xval->len <= MAX_BRANCH_XVAL_LEN) { + *begin = BRANCH_SEPARATOR; + begin++; + size--; + if(memcpy(begin, xval->s, xval->len)) { + begin += xval->len; + size -= xval->len; + } else { + return 0; + } + } + if(size) { *begin = BRANCH_SEPARATOR; begin++; diff --git a/src/core/msg_translator.h b/src/core/msg_translator.h index a512ff68385..7e83d85c9cb 100644 --- a/src/core/msg_translator.h +++ b/src/core/msg_translator.h @@ -120,7 +120,7 @@ char *create_via_hf(unsigned int *len, struct sip_msg *msg, int branch_builder(unsigned int hash_index, /* only either parameter useful */ - unsigned int label, char *char_v, int branch, + unsigned int label, char *char_v, str *xval, int branch, /* output value: string and actual length */ char *branch_str, int *len); _______________________________________________ Kamailio - Development Mailing List -- [email protected] To unsubscribe send an email to [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender!
