Module: kamailio
Branch: master
Commit: bf9dec59480cb8bed1deaa7670454b57045b8b90
URL: 
https://github.com/kamailio/kamailio/commit/bf9dec59480cb8bed1deaa7670454b57045b8b90

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2024-08-27T12:38:25+02:00

tm: implement headers_mode option for build_local()

---

Modified: src/modules/tm/t_msgbuilder.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/bf9dec59480cb8bed1deaa7670454b57045b8b90.diff
Patch: 
https://github.com/kamailio/kamailio/commit/bf9dec59480cb8bed1deaa7670454b57045b8b90.patch

---

diff --git a/src/modules/tm/t_msgbuilder.c b/src/modules/tm/t_msgbuilder.c
index c195193d6e6..49c801d2e8f 100644
--- a/src/modules/tm/t_msgbuilder.c
+++ b/src/modules/tm/t_msgbuilder.c
@@ -187,6 +187,28 @@ char *build_local(struct cell *Trans, unsigned int branch, 
unsigned int *len,
                        LM_BUG("unhandled reason cause %d\n", reason->cause);
        }
        *len += reason_len;
+       if(imsg != NULL && (tm_headers_mode & TM_CANCEL_HEADERS_COPY)) {
+               for(hdr = imsg->headers; hdr; hdr = hdr->next) {
+                       switch(hdr->type) {
+                               case HDR_CALLID_T:
+                               case HDR_CSEQ_T:
+                               case HDR_VIA_T:
+                               case HDR_TO_T:
+                               case HDR_FROM_T:
+                               case HDR_ROUTE_T:
+                               case HDR_MAXFORWARDS_T:
+                               case HDR_REQUIRE_T:
+                               case HDR_PROXYREQUIRE_T:
+                               case HDR_CONTENTLENGTH_T:
+                               case HDR_REASON_T:
+                               case HDR_EOH_T:
+                                       /* skip these headers - they were added 
already */
+                                       break;
+                               default:
+                                       *len += hdr->len;
+                       }
+               }
+       }
        *len += CRLF_LEN; /* end of msg. */
 
        cancel_buf = shm_malloc(*len + 1);
@@ -258,6 +280,29 @@ char *build_local(struct cell *Trans, unsigned int branch, 
unsigned int *len,
                        }
                }
        }
+       if(imsg != NULL && (tm_headers_mode & TM_CANCEL_HEADERS_COPY)) {
+               for(hdr = imsg->headers; hdr; hdr = hdr->next) {
+                       switch(hdr->type) {
+                               case HDR_CALLID_T:
+                               case HDR_CSEQ_T:
+                               case HDR_VIA_T:
+                               case HDR_TO_T:
+                               case HDR_FROM_T:
+                               case HDR_ROUTE_T:
+                               case HDR_MAXFORWARDS_T:
+                               case HDR_REQUIRE_T:
+                               case HDR_PROXYREQUIRE_T:
+                               case HDR_CONTENTLENGTH_T:
+                               case HDR_REASON_T:
+                               case HDR_EOH_T:
+                                       /* skip these headers - they were added 
already */
+                                       break;
+                               default:
+                                       append_str(p, hdr->name.s, hdr->len);
+                       }
+               }
+       }
+
        append_str(p, CRLF, CRLF_LEN); /* msg. end */
        *p = 0;
 

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to [email protected]

Reply via email to