Content Length is wrong

I am running Asterisk 1.6 on Ubuntu server 10.04 There is an Audiocodes Mediant 1000 MSBG which acts as an SBC to support remote users on my Asterisk box.

When I make call from internal through the SBC to the remote user, the call works just fine. However when remote users make calls through the SBC to internal users, the internal phones ring, the user answers, and they hear dead air while the remote user continues to hear ringback.

I have isolated this issue to the final SIP 200 OK, in the call setup, sent from the Asterisk box to the SBC. The SBC is basically rejecting the 200 OK because of an inconsistency in the Content-length recorded in the message and the computation performed on the SBC. You can the error in my syslogs, on the SBC, below.

10:08:33.593 : : WARNING : ( sip_stack)(27394 ) !! [ERROR] AcSIPParser: Parse Error. Content length header 296 is inconsistent with the actual body's length 328 10:08:33.593 : : WARNING : ( sip_stack)(27395 ) !! [ERROR] Message type: 200 OK 10:08:33.609 : : WARNING : ( sip_stack)(27396 ) !! [ERROR] Source header: 10:08:33.609 : : WARNING : ( sip_stack)(27397 ) !! [ERROR] Line: 14. Column: 1 10:08:33.609 : : WARNING : SIP/2.0 200 OK

I have found a recorded asterisk issue which seems to be related but I am unsure of how to apply the fix to my system. See link below… … issue-tabs

Any help that you could provide would be greatly appreciated.

Thanks in advance.

1.6 is three different versions, with many revision levels. I would hope that this is already fixed in 1.6.2.. You should check the revision log, which hopefully the packages has included.

I believe Ubuntu build with non-standard settings, so you need to investigate the Ubuntu build process if you need to apply the patch yourself, but basically you can get the patch from the link in the bug tracker entries for the SVN commit for the right branch and apply it to the source with the patch tool that comes with all Unix type systems, then recompile.

Ok I just tried to apply the patch using the “patch” command and I get the following output.

admin-svr01:~$ sudo patch -p0 < ./sip-automatic-content-length162-8.diff patching file channels/chan_sip.c Hunk #1 FAILED at 1195. Hunk #2 FAILED at 1217. Hunk #3 FAILED at 2570. Hunk #4 FAILED at 2584. Hunk #5 FAILED at 3079. Hunk #6 FAILED at 4204. Hunk #7 FAILED at 4218. Hunk #8 FAILED at 4229. Hunk #9 FAILED at 4248. Hunk #10 FAILED at 4259. Hunk #11 FAILED at 5591. Hunk #12 FAILED at 9100. Hunk #13 FAILED at 9336. Hunk #14 FAILED at 9350. Hunk #15 FAILED at 9632. Hunk #16 FAILED at 9727. Hunk #17 FAILED at 9742. Hunk #18 FAILED at 9774. Hunk #19 FAILED at 9784. Hunk #20 FAILED at 9804. Hunk #21 FAILED at 9827. Hunk #22 FAILED at 9852. Hunk #23 FAILED at 9879. Hunk #24 FAILED at 10081. Hunk #25 FAILED at 10372. Hunk #26 FAILED at 10455. Hunk #27 FAILED at 11000. Hunk #28 FAILED at 11317. Hunk #29 FAILED at 11371. Hunk #30 FAILED at 11394. Hunk #31 FAILED at 11415. Hunk #32 FAILED at 11845. Hunk #33 FAILED at 11990. Hunk #34 FAILED at 12037. Hunk #35 FAILED at 18805. Hunk #36 FAILED at 18817. Hunk #37 FAILED at 18853. Hunk #38 FAILED at 18948. Hunk #39 FAILED at 22008. 39 out of 39 hunks FAILED -- saving rejects to file channels/chan_sip.c.rej patching file include/asterisk/strings.h Hunk #1 FAILED at 573. 1 out of 1 hunk FAILED -- saving rejects to file include/asterisk/strings.h.rej

What am I doing wrong here?

With that many rejects, probably trying to patch with a file containing Microsoft style end of line sequences.

Alternatively, you are using a patch that is for a version that is too far removed from the version you have.

What you should do when a patch fails is to look at the rejected patches and try and find the before version of the first one in the code, and then work out why it doesn’t match what is there (well enough).

I am running version

What has me confused is what file it is trying to patch. In the index, it lists “channels/chan_sip.c”

I don’t even see a channels directory anywhere in my server.

It obviously found it as an immediate sub-directory of the current directory, or it would have been asking you to supply the name of the file to patch.

Where would this “channels” directory normally be? I don’t see it in /etc/asterisk.

Wherever you installed the Asterisk source code. Conventionally it would be in /usr/src/asterisk, but that’s not where I have it on any of my systems.

If you have a binary packages, you will not have a copy. However, the output from your patch run suggests that you ran patch in the top level source code directory.

No I ran it from my home directory and it created the channels directory. My mistake, this is the first time that I have used the Patch command.

I installed Asterisk from the Ubuntu repositories so I did not compile it from the source. So any idea which file I need to patch?

To use the patch file, you need to build it from source.

As I believe that Ubuntu do things like running it non-root, they may not use the standard build options, and may even use modified source code, so I can’t tell you how to make a version that is compatible with the Ubuntu packaged one.

If you were doing a standard build (I’ve only ever tried on CentOS and Slackware), you would download the latest source code tar.gz file and extract it into a working directory. Alternatively you could fetch it using svn. You would almost certainly not need to apply the patch, as it would almost certainly be in that version, unless there were some problems with it that prevented its going into a release version.

You’d then make sure you had a complete set of standard development tools and go into the top level source directory and run:


You may have to give it options if Ubuntu don’t use the installation and configuration directories assumed by the standard build. Assuming that finishes OK, you would run:

make menuconfig

and adjust any parameters. Disabling compiler optimisation is a good idea, if you ever expect it to crash, unless you are really critical on CPU power.

Next you would run


and finally

make install

There are some extra steps for a install on a clean system, which install the system start up scripts and a sample set of configuration files.

Incidentally, I don’t believe that patch should have treated your case as an attempted file creation. I would still have expected it to ask for the location of the file.