Module: kamailio
Branch: master
Commit: 526ec68fa56cb8066db9da3a4b82f9e20aebf8c3
URL:
https://github.com/kamailio/kamailio/commit/526ec68fa56cb8066db9da3a4b82f9e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-01-10T14:27:06+01:00
tm: if transaction had an uac auth, propagate cseq headers for local ACK and CANCEL
- related to GH #870, #918, #919
---
Modified: src/modules/tm/t_msgbuilder.c
---
Diff:
https://github.com/kamailio/kamailio/commit/526ec68fa56cb8066db9da3a4b82f9e…
Patch:
https://github.com/kamailio/kamailio/commit/526ec68fa56cb8066db9da3a4b82f9e…
---
diff --git a/src/modules/tm/t_msgbuilder.c b/src/modules/tm/t_msgbuilder.c
index 09b0f4f..dadba50 100644
--- a/src/modules/tm/t_msgbuilder.c
+++ b/src/modules/tm/t_msgbuilder.c
@@ -35,6 +35,7 @@
#include "../../core/parser/parser_f.h"
#include "../../core/parser/parse_to.h"
#include "../../core/ut.h"
+#include "../../core/srapi.h"
#include "../../core/parser/msg_parser.h"
#include "../../core/parser/contact/parse_contact.h"
#include "lw_parser.h"
@@ -276,6 +277,8 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
int reason_len, code_len;
struct hdr_field *reas1, *reas_last, *hdr;
#endif /* CANCEL_REASON_SUPPORT */
+ int hadded = 0;
+ sr_cfgenv_t *cenv = NULL;
invite_buf = Trans->uac[branch].request.buffer;
invite_len = Trans->uac[branch].request.buffer_len;
@@ -353,6 +356,8 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
s = eat_line(s, invite_buf_end - s);
append_str(d, s1, s - s1);
+ cenv = sr_cfgenv_get();
+
/* check every header field name,
we must exclude and modify some of the headers */
first_via = 1;
@@ -470,15 +475,35 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
default:
s = lw_next_line(s, invite_buf_end);
+ hadded = 0;
+
+ /* uac auth headers */
+ if(Trans->uas.request &&
+ (Trans->uas.request->msg_flags & FL_UAC_AUTH)) {
+ if(s1 + cenv->uac_cseq_auth.len + 2 < invite_buf_end) {
+ if(s1[cenv->uac_cseq_auth.len]==':'
+ && strncmp(s1, cenv->uac_cseq_auth.s,
+ cenv->uac_cseq_auth.len)==0) {
+ hadded = 1;
+ append_str(d, s1, s - s1);
+ } else if(s1[cenv->uac_cseq_refresh.len]==':'
+ && strncmp(s1, cenv->uac_cseq_refresh.s,
+ cenv->uac_cseq_refresh.len)==0) {
+ hadded = 1;
+ append_str(d, s1, s - s1);
+ }
+ }
+ }
- if (cfg_get(tm, tm_cfg, ac_extra_hdrs).len
- && (s1 + cfg_get(tm, tm_cfg, ac_extra_hdrs).len < invite_buf_end)
- && (strncasecmp(s1,
- cfg_get(tm, tm_cfg, ac_extra_hdrs).s,
- cfg_get(tm, tm_cfg, ac_extra_hdrs).len) == 0)
- ) {
- append_str(d, s1, s - s1);
- } /* else skip this line */
+ if(likely(hadded==0)) {
+ if (cfg_get(tm, tm_cfg, ac_extra_hdrs).len
+ && (s1 + cfg_get(tm, tm_cfg, ac_extra_hdrs).len < invite_buf_end)
+ && (strncasecmp(s1,
+ cfg_get(tm, tm_cfg, ac_extra_hdrs).s,
+ cfg_get(tm, tm_cfg, ac_extra_hdrs).len) == 0)) {
+ append_str(d, s1, s - s1);
+ }
+ }
break;
}
}