[asterisk-dev] shan_sip: Should we zero the Content-Length here?

Dimitar Penev dpn at switchvoice.com
Tue Feb 22 12:22:37 CST 2011


Hi Guys,

It is my first post in this list.  If this is not the best place to ask please point me to the proper one.

I am using Asterisk with uClinux running on Blackfin DSP. 
I have  Asterisk 1.4.32 working stable on my platform.
Recently I've decided to upgrade to the latest Asterisk 1.4.39.2 and find out that Asterisk 1.4.39.2 is not stable.
The SIP registration is OK but I get Asterisk crash on the first SIP call.
  
After some experiments I came to the patch below. 
I am not into the SIP channel driver and SIP protocol so I am not sure if there is rational in this patch but it is fact 
that it makes latest Asterisk stable on my Blackfin target. 
Probably someone can clarify to me? 

--- channels/chan_sip.c 2010-12-10 00:00:30.000000000 +0200
+++ channels/chan_sip.c 2011-02-22 19:46:52.000000000 +0200
@@ -1604,6 +1604,7 @@
 static void build_callid_registry(struct sip_registry *reg, struct in_addr ourip, const char *fromdomain);
 static void make_our_tag(char *tagbuf, size_t len);
 static int add_header(struct sip_request *req, const char *var, const char *value);
+static int add_header_contentLength(struct sip_request *req, int len);
 static int add_content(struct sip_request *req, const char *line);
 static int finalize_content(struct sip_request *req);
 static int add_text(struct sip_request *req, const char *text);
@@ -6229,6 +6230,15 @@
 }

 /*! \brief Add 'Content-Length' header to SIP message */
+static int add_header_contentLength(struct sip_request *req, int len)
+{
+       char clen[10];
+
+       snprintf(clen, sizeof(clen), "%d", len);
+       return add_header(req, "Content-Length", clen);
+}
+
+/*! \brief Add 'Content-Length' header to SIP message */
 static int finalize_content(struct sip_request *req)
 {
        char clen[10];
@@ -6840,6 +6850,7 @@
        struct sip_request resp;
        respprep(&resp, p, msg, req);
        add_header(&resp, "Accept", "application/sdp");
+       add_header_contentLength(&resp, 0);  //Penev: Zero the Content-Length !
        return send_response(p, &resp, reliable, 0);
 }
 

Thank you.
Dimitar Penev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20110222/f58f3cdf/attachment.htm>


More information about the asterisk-dev mailing list