Summary:ASTERISK-00753: [patch] New sip channel - chan_sip2.c
Reporter:Olle Johansson (oej)Labels:
Date Opened:2004-01-07 12:06:15.000-0600Date Closed:2011-06-07 14:05:10
Versions:Frequency of
Environment:Attachments:( 0) chan_sip2A5.c
( 1) chan_sip2A6.c
( 2) chan_sip2A6-mysql.v1.2.c.diff
( 3) chan_sip2B.c
( 4) chan_sip2C.c
( 5) chan_sip2E.c
Description:This is a new version of the SIP channel. No major rewrite, but a lot of small changes in one package. Also, I've incorporated a number of patches from bugs.digium.com.

* THIS IS NOT A FORK * I disclaim the rights to Digium as usual.

I just wanted to test a lot of things at the same time, so I added some stuff I needed into a different version, so I could roll back to the standard chan_sip if things did not work.

Please test this and report any problems here. I'll hang on and maintain this for a while until we agree it is production ready.
* Add chan_sip2 to the channels/Makefile
* Rename the file downloaded to chan_sip2.c
* make / make install
* Change your modules.conf
 Add "noload=chan_sip.so" if you want to run chan_sip2
* Restart asterisk


Test and report here - positive and negative reports.


Read the source file for additional information. Things I'm working on are
* Template support for easier configuration of peers/users
* Outbound proxy support
* Additional CLI commands
* Statistics (in the long run stuff for SNMP maybe)
* More RFC compliant functionality
Comments:By: geertn (geertn) 2004-01-30 03:47:14.000-0600

It works.

I do have MWI packets getting send to This is solved by patch 1.283->1.284 in chan_sip.c (Don't send VMWI when we're not registered) (tested).

I will keep this on to check if I have any problems and maybe test autocreatepeer today with acl.

(edit: remove bogus debug info)

edited on: 01-30-04 04:43

By: Olle Johansson (oej) 2004-02-01 08:17:07.000-0600

The build_peer messages is just warnings for your type=friend peers, don't worry. I need to be better at checking what applies to a user and what applies to a peer. For now, please ignore them.

The sip_xmit is a bug both in chan_sip and chan_sip2.c - I have a patch for that in another bug - see 0000956 . I'll upload a new chan_sip2.c soon, but you should be able to run your channel, ignoring these warnings. The channels send OPTIONS and NOTIFY (MWI) messages to not reachable clients, it's no big deal but not very nice. This happens until registration.

By: flavour (flavour) 2004-02-02 10:16:04.000-0600

Confirmed that channel runs just fine, despite the warning messages :)

By: Olle Johansson (oej) 2004-02-08 03:49:06.000-0600

Uploaded a new version that is up to date with CVS patches.

* Added support for WWW-auth for registrations (according to SIP RFC).
* Number of small fixes
* Added support for subscribecontext for SUBSCRIBE on extensions. (Not
 heavily tested). To test with Windows Messenger, make sure you set
 realm= to be the same as your server's hostname.


edited on: 02-08-04 04:03

edited on: 02-08-04 04:04

By: flavour (flavour) 2004-02-08 13:22:59.000-0600

Yup, those 2 bugs have now gone away since upgrading to chan_sip2h
All the +x, none of the pain :)

By: Olle Johansson (oej) 2004-02-09 15:17:00.000-0600

* Adds templates for users. Now you *have* to define type= within the template.
* Numerous fixes in template system
* New CLI command: sip show peer <peername> (inspired by another patch somewhere here in bugs)

By: Olle Johansson (oej) 2004-02-15 16:40:33.000-0600

* Added 'sip show stats' - a beginning.
* Up to date with CVS

By: z_smurf (z_smurf) 2004-02-16 22:06:24.000-0600

I think your comments on top of each function is excellent. Also the prefix of "global_" of all global variables, I would really like to see that in all our code :)

I see you have done some work to move peers from sip.conf to mysql-database, which is exactly what I am looking for, but not every detail is there yet. I cannot get the MYSQL_FRIEND in chan_sip.c to work (or I dont understand how it is supposed to work), so I wonder how your implementation work? Is it possible to not include every single peer in sip.conf anymore, but store them in database?
How is the new table-structure(s)?

By: Olle Johansson (oej) 2004-02-17 01:38:00.000-0600

z_smurf: Thank you.

For the MYSQL_FRIENDs part, I haven't done anything. I have another function, called MYSQL_AUTH where I check the secret from a database, the rest goes in sip.conf, either in per device configs or with templates. The template stuff is really powerful. Think about the combination of template, autocreatepeer and mysql_auth.

The MYSQL_FRIEND stuff is documented a bit more on the Wiki. I think it's very limited in the number of options you can set. There's another patch out there, res_config, that is more powerful if you want to move the .conf file to the database.

By: Olle Johansson (oej) 2004-02-20 18:14:01.000-0600

* Update according to CVS
* Tried to solve the SIP INFO problem (in another BUG #)
* Added "sip show subscriptions" command
* Added data and fixed the "sip show channel <chan-id>" command
* Numerous small fixes and more comments in the source code

By: zoa (zoa) 2004-02-21 04:28:21.000-0600

SIP info problem = http://bugs.digium.com/bug_view_page.php?bug_id=0001053

By: flavour (flavour) 2004-02-22 13:33:55.000-0600

1 issue with chan_sip2: changes to templates are not seen with a simple 'reload' a full stop/start is required.
This would require saving the template from which a user/peer has been created - I think this would be useful for display within 'sip show xpeers' anyway :)

By: z_smurf (z_smurf) 2004-02-23 17:48:00.000-0600

I confirm that your SIP_INFO bugfix works. I copied these lines into chan_sip.c and there is no more hangups on info-packets. And there is no need to remove any 183-session in progress anymore.

if (strncasecmp(pkt->data, "INFO",4)) {
ast_log(LOG_NOTICE, "Maximum retries exceeded on INFO message %s for seqno %d \n", pkt->owner->callid, pkt->seqno);
} else {

By: geertn (geertn) 2004-03-03 12:34:48.000-0600

Works fine here in "produktion" for a few days now. I do get the following error sometimes which I don't get with chan_sip.c:
WARNING[16401]: chan_sip2m.c:6049 handle_response: Error: Packet: SIP/2.0

I think it is caused by a packet sent by SER proxy:
--- Sip read from
SIP/2.0 200 OK
Via: SIP/2.0/UDP;branch=z9hG4bK52aacdd6
From: <sip:1200*662@inoc-dba.pch.net>;tag=as5eca0176
To: <sip:1200*662@inoc-dba.pch.net>;tag=b27e1a1d33761e85846fc98f5f3a7e58.9c9d
Call-ID: 3201c4d87b7e96b72759df0d3c0d26b6@
Contact: <sip:1200662@>;q=0.00;expires=120
Server: Sip EXpress router (0.8.11rc7 (sparc64/solaris))
Content-Length: 0
Warning: 392 "Noisy feedback tells:  pid=268 req_src_ip= req_src_port=5060 in_uri=sip:inoc-dba.pch.net out_uri=sip:inoc-dba.pch.net via_cnt==1"

  - 10 headers, 0 lines
Mar  3 18:13:58 WARNING[16401]: chan_sip2m.c:6049 handle_response: Error: Packet: SIP/2.0

Also previously, calls stopped after 5 times with the following packet.

Mar  3 18:19:57 WARNING[16401]: chan_sip2m.c:873 retrans_pkt: Maximum retries exceeded on INFO message 2BD72775-A9B9-4E09-9B03-1DD1A951DA75@ for seqno 1

Now it does keep the call, only no BYE is sent anymore so the call always keeps open. Is this normal behaviour?

By: Olle Johansson (oej) 2004-03-03 15:10:20.000-0600

I've added several warning/error messages, so the output from chan_sip2 is more verbose than chan_sip. Mostly to help me understand the channel, but also to help the user. This particular error messages is not very helpful, I know. Trying to fix it.

The second matter is helpful. I've fixed the INFO problem, but your asterisk doesn't issue a BYE. I'll see what I can do, if there's a better way to handle
the INFO matter.
Thank you for your input.

By: geertn (geertn) 2004-03-04 03:45:17.000-0600

I'm afraid I wasn't clear in what happens. Asterisk does send a bye to the SER proxy, but if I hangup at the ser-inoc/dba side, no BYE is sent to asterisk (checked with tcpdump).

So when I setup a conference call and dial in a few times, the channels keep up and asterisk thinks there are xxx user in the conference. So maybe this is a SER issue.

If you are interested, I have some packet dumps. I think it is a ser issue, or Asterisk does not send a good formatted 200 OK message. You see the retransmit happening.

Call from ser-user to asterisk (with no BYE)

Call from asterisk to ser-user (with BYE):

Added some compile fixes for errors and warnings I get with gcc 3.3.3.

edited on: 03-05-04 03:26

By: Olle Johansson (oej) 2004-03-06 03:57:54.000-0600

* Merged geertn's fixes
* Added new functionality for localnet= from Paul Winkeler
* Continued work on 'sip show stats', still long way to go :-)
** More log messages on these events
* New more solid fix for INFO message problem

Thanks to flavour, geertn and Paul for your testing and support.
Read the text in the source code for more information, configuration and roadmap for this SIP channel.

And yes, I'm using this in production. Living on the edge :-) It's still not a recommendation if you're not technical and can evaluate what happens.

Looking forward to your feedback.

By: Olle Johansson (oej) 2004-03-06 03:57:56.000-0600

* Merged geertn's fixes
* Added new functionality for localnet= from Paul Winkeler
* Continued work on 'sip show stats', still long way to go :-)
** More log messages on these events
* New more solid fix for INFO message problem

Thanks to flavour, geertn and Paul for your testing and support.
Read the text in the source code for more information, configuration and roadmap for this SIP channel.

And yes, I'm using this in production. Living on the edge :-) It's still not a recommendation if you're not technical and can evaluate what happens.

Looking forward to your feedback.

By: Olle Johansson (oej) 2004-03-06 10:39:51.000-0600

Added new patches for acl.c and acl.h (from Paul) that you need for chan_sip2n.c

By: zoa (zoa) 2004-03-06 11:32:50.000-0600

oej, doin' great !!!!

By: geertn (geertn) 2004-03-07 07:33:34.000-0600

sip_fixup() is updated according to the development asterisk cvs, but in the stable cvs the definition is:
int (*fixup)(struct ast_channel *oldchan, struct ast_channel *newchan);
and not:
int (*fixup)(struct ast_channel *oldchan, struct ast_channel *newchan, int lock);

Offcourse I can just change it back (because I'm using asterisk stable), but the question rises:
Is chan_sip2 supposed to be developed against devel cvs or stable?

By: Olle Johansson (oej) 2004-03-07 08:07:33.000-0600

As of now, chan_sip2 is a development platform, so I'm using devel. Is there a way to ifdef so we can get it to work regardless?

By: flavour (flavour) 2004-03-08 05:59:50.000-0600

I'm running with Asterisk-0.7.2 & latest release of chan_sip2: n

I have a problem with my 7960 (ulaw) being unable to hear any sound from Voicemail or Conference apps (although DTMF digits get sent fine). X-Lite (iLBC) is fine with these apps, though, despite occasional garbling with this error:
NOTICE[-1362404432]: rtp.c:418 ast_rtp_read: Unknown RTP codec 72 received

Calls are fine either way.

This doesn't seem to be related to the sip_fixup() issue, as I made that change manually (although things worked as 'fine' before that as well).

I also get this new error, which appears harmless?:
NOTICE[-1320350800]: chan_sip2.c:2499 process_sdp: Content is '', not 'application/sdp'

I have confirmed that these problems don't exist with the previous version chan_sip2: m

Also I think this note in the header is out of date?
*  + Up to date with chan_sip cvs as of feb 5, 2004

edited on: 03-08-04 04:50

By: Olle Johansson (oej) 2004-03-08 06:14:53.000-0600

The Content is '' shows that my SDP-filter works. Before that, everything was processed as SDP regardless of Content-Type: definition.

The codec problem is more mysterious to me. The rtp.c message seems unrelated to chan_sip2. Or maybe not, since it works with chan_sip2m. I'll go look.

Flavour, please do a SIP debug, maybe the SDP filter removes the sound. Is someone sending messages with SDP without indicating it? Mail the debug output to me.

The header will be patched in a coming version :-)

By: geertn (geertn) 2004-03-08 06:35:11.000-0600

Mar  8 11:59:52 NOTICE[16401]: chan_sip2n.c:2497 process_sdp: Content is '', not 'application/sdp'.

I have the same.

I think there is a problem in the debug filter:
geert/geert  D  5060     OK (42ms)
audix*CLI> sip debug geert
Peer geert at
SIP Debugging Enabled. Filter on IP

So it filters at the wrong IP. Also when I do 'sip debug', the same happens:
audix*CLI> sip debug
SIP Debugging Enabled. Filter on IP
--- Sip read from
  - 10 headers, 0 lines

Only a sip debug all catches all packets. I think a 'sip debug' should also catch all packets, or give an error 'No such command 'sip no' (type 'help' for help)' (better would be: ambigous command).

By: Olle Johansson (oej) 2004-03-08 07:03:41.000-0600

Found it. New version coming right up :-)

There was a bug in sdp-filters.

In SIP debug <peer> I matched the first hit, so 'sip debug olle' matched not only olle but everything 'olle*' and grabbed the first hit.

Error message added if you ever 'sip debug peer' for a non-registred peer.

By: geertn (geertn) 2004-03-08 07:55:51.000-0600

Works like a charm:)

I see support for subscribe. Also, my SNOM does subscribe successfully. But what does it do?

By: Olle Johansson (oej) 2004-03-08 08:07:27.000-0600

Thank you for the feedback.

The SUBSCRIBE support has been there for a long time. I've tried to go through it. You can monitor any *EXTENSION*, not peer, for availability. Is the line busy or not?

I've added 'sip show subscriptions'.

By: flavour (flavour) 2004-03-08 08:22:39.000-0600

All issues reported are now solved with chan_sip2o - thanks for speedy response :)

By: geertn (geertn) 2004-03-18 07:51:30.000-0600

I have an issue:
Grandstream phones latest 2 firmwares at least shoot back a garbled ACK as a reply on a 200 OK message. When traveling through SER, SER drops the ACK and Asterisk will go retransmitting the 200 OK. After a few times Asterisk drops the call.

I have attached a small patch that does not terminate the call when having an rtp session and 200 OK retransmit. I'm not sure if this is safe to do. What do you think?

Update :
From SIP rfc:
"If the server retransmits the 2xx response for 64*T1 seconds without
  receiving an ACK, the dialog is confirmed, but the session SHOULD be
  terminated.  This is accomplished with a BYE, as described in Section

So the call tear down is correct, and the patch is only a small hack until grandstream fixes the bug.

edited on: 03-18-04 08:01

By: Olle Johansson (oej) 2004-03-19 15:32:58.000-0600

Geertn: That's a fix, not a general patch as I see it. What version of Grandstream, so I can avoid it?

By: geertn (geertn) 2004-03-20 09:36:53.000-0600

At least it is in:

With all later firmware It does not even initiate a call anymore, so I do not know if it is solved there.

By: Olle Johansson (oej) 2004-03-21 03:45:06.000-0600

Added new version that is up to date with CVS. (DNID patch and preferred codec patch from Mark)

By: togg (togg) 2004-03-23 05:03:09.000-0600

Hmm I double checked the problem. I reinstalled the old sip channel driver again and this is choppy also :-/ Seems to be a asterisk-cvs problem.

Sorry to rouse you :)

By: Olle Johansson (oej) 2004-03-23 05:13:16.000-0600

Togg: No problem, better more reports than fewer :-)

By: Olle Johansson (oej) 2004-03-23 05:25:33.000-0600

* Started work on domain support
* Up to date with CVS
* Took away some of the chattyness if you don't run verbose
* Small fixes here and there

A bit more dangerous, but works in my network.

By: brif8 (brif8) 2004-03-25 14:37:33.000-0600

oej: does this mean that sip2 is now a part of CVS?
Exactly what are the improvements esp. regarding NAT and double NAT
on SIP2?

By: Olle Johansson (oej) 2004-03-25 15:01:15.000-0600

No, chan_sip2 is not part of CVS, it is very much a work in progress now.

I do not think that there's any big difference in how chan_sip handles NAT compared with chan_sip2. The big difference is the support for outbound proxies that we are implementing in chan_sip2. An outbound proxy is an application level gateway you place on your NAT server to take care of inbound and outbound calls, in most cases together with a RTP proxy.

Is it something special you're looking for in regards to NAT?

By: Olle Johansson (oej) 2004-04-10 16:11:03

This has to do with me being occupied with too much other stuff...

There's been quite a lot of changes to HEAD chan_sip lately, as well as other stuff, so I need to do a major update soon. It's coming.

By: Olle Johansson (oej) 2004-04-12 06:43:10

New version, trying to stay up to date with CVS head as of today. Not tested much yet...

CVS additions adds
* More resilient to heavy loads on LAN
* QoP support for digest auth (bad patch, but should work)
* Many more small changes, bug fixes, additions
Mark's been busy with chan_sip problems lately.

Can't compile CVS head on my FreeBSD due to recursive threads, so I'm lost on my test system.

By: Olle Johansson (oej) 2004-04-12 14:58:29

Rutger (chan_sip2r.c) is now a bit sanitized, works in my server. Please test.

edited on: 04-12-04 13:57

By: Olle Johansson (oej) 2004-04-17 03:29:02

Did a code check to see if I successfully merged all patches to chan_sip into chan_sip2 and found a few small differences.

For breakfast: chan_sip2.c - codename Sixten.
Please update chan_sip2r.

No other changes or additions this time.

By: Olle Johansson (oej) 2004-04-17 03:29:10

Did a code check to see if I successfully merged all patches to chan_sip into chan_sip2 and found a few small differences.

For breakfast: chan_sip2.c - codename Sixten.
Please update chan_sip2r.

No other changes or additions this time.

By: Olle Johansson (oej) 2004-04-17 03:37:43

Did a code check to see if I successfully merged all patches to chan_sip into chan_sip2 and found a few small differences.

For breakfast: chan_sip2.c - codename Sixten.
Please update chan_sip2r.

No other changes or additions this time.

By: Brian West (bkw918) 2004-04-18 02:07:35

Can we have chan_sip2 use port 5061 and register channeltype SIP2/  and use sip2.conf as the conf file so they can both run at the same time.

Just an idea?

By: Brian West (bkw918) 2004-04-18 02:08:22

Or can we have chan_sip_proxy.c

just throwing out ideas.. its late.


By: Olle Johansson (oej) 2004-04-18 02:51:05

I don't think there's any need to have them both at the same time, since they're doing the same functions, it's either or. That's why I changed the name so you could choose by using load/noload in modules.conf - it's easy to switch between them for testing.

By: Olle Johansson (oej) 2004-04-25 09:20:49


* Very basic support for symmetricrtp in global/peer/user config
* Up to date with cvs, including ast_gethostbyname

By: iwhite (iwhite) 2004-04-27 19:19:31

Minor cosmetic bugs.

In sip_show_stats, the line:
ast_cli(fd,"* Active subscriptions:   %3d\n", num);
should be
ast_cli(fd,"* Active subscriptions:   %3d\n", sub);

Also, I haven't looked at the code yet for this, but the auto completion in the CLI when typing "sip show channels" tries to do the autocomplete from "sip show channel". There shouldn't be an autocomplete on the "sip show channels" as it doesn't take any further parameters.

By: Olle Johansson (oej) 2004-05-07 17:44:43

* Up to date with cvs (excluding new sip debug scheme -lack of time)
* A lot of small fixes

Please also note that some features from chan_sip2 are now integrated into chan_sip in cvs HEAD.

Please test this version before putting it into production. There's a lot of changes in the code.

By: Olle Johansson (oej) 2004-05-16 05:50:48

* Update according to cvs bug fixes
* Removed comments about features now existing in CVS head

By: Olle Johansson (oej) 2004-05-20 16:46:50

* Added manager events for Peer registration, outbound registration and monitored peers status changes (qualify)
* Started work on RDNIS header for outbound calls

By: Olle Johansson (oej) 2004-05-21 10:04:24

* Small patch to fix crash on registration from unknown peers.

By: Olle Johansson (oej) 2004-05-27 16:19:25

Removing the acl.c/acl.h patch since they are going to be committed to cvs. Time to begin moving template functionality into chan_sip.

By: mh (mh) 2004-06-06 07:02:27

I have installed chan_sip2xb.c on my server. It works fine with my SIP provider.

Also I have changed the code to set the variable SIPTOURI additionally to SIPFROMURI.
I need this because my SIP account has several phone numbers and extensions assigned to it and I want to send each call to another account on my server. Is it possible to add this little snipped to the source so that I don?t have to patch it every time in the future?

By: Olle Johansson (oej) 2004-06-06 15:31:05

mh: Isn't the To: URI the extension in your dial plan?
Please send me the patch by e-mail and I'll look at it.

By: Olle Johansson (oej) 2004-06-12 04:41:19

* Back to experimental phase, a lot of changes in authentication
* Added ability to add and read any SIP headers
 No need to add any more channel variabels, you can get anything now
* Requires patch in bug ASTERISK-922 to be able to add SIP headers
* Up to date with cvs as of today

Please test and report any problems you have. Yngve is a bit scary in authentication, so don't use this in production without testing. And don't forget feedback. I need feedback on the changes, please. Read the start of the file for more information on what I've messed up this time :-)

By: Olle Johansson (oej) 2004-06-12 16:01:47

New chan_sip2y:
* Added sipaddheader() application
 Still requires patch in bug ASTERISK-922
* You also now have sipgetheader()

By: Olle Johansson (oej) 2004-07-06 15:24:01

Updated version that compiles with cvs head. No new features added, not in sync with cvs chan_sip otherwise.

By: ivoice (ivoice) 2004-07-10 21:34:49

Hi all!
I'm using chan_sip2 and I have one question and one request :-)

-- The question: I'm trying with Windows Messenger 5.0, it's possible with SUBSCRIBE/NOTIFY known on-line contacts? Now on SUBSCRIBE sip message I got:

Jul 11 04:15:06 NOTICE[81925]: chan_sip2.c:7834 handle_request: Failed to find extension for SUBSCRIBE <sip:2005@domain.com> From "2005@domain.com" <sip:2005@domain.com>;tag=76ceefeffbe349ec93df51e0a1ab19c6;epid=a116ff958f

and on NOTIFY:

Got SIP response 481 "Call Leg/Transaction Does Not Exist" back from

-- The request: some user on my * cannot use port 5060 because NATs of an internet public network corrupts packets. I don't want to change port 5060 to another port because all existing users and new users want to use default SIP port. I tryed netfilter rediret but if an UA is behind a nat some problems occurred. It's possible to have in sip.conf indead port=5060 the ability to set
port=5060,5090,5061 and so on?


By: ivoice (ivoice) 2004-07-10 22:15:49

When I try to call from x-lite an user on Windows Messenger 5.0 I got segfault.

In http://home.armiento.com/chan_sip_segfault_2004_07_11.txt you can find sip messages, asterisk log and backtrace.

P.S. If I call using chan_sip.so (not sip2) it works...


edited on: 07-11-04 07:43

By: Olle Johansson (oej) 2004-07-16 15:29:06


* Up to date with CVS (phew, never more holidays)
* Fix bug that crashed in some cases
* REALM authentication

Feedback welcome.

By: dweber (dweber) 2004-07-17 12:50:44

For a second chan_sip implementation, shouldn't this be using a SIP library such as osip2 or resiprocate both which have compatible licenses.

By: Olle Johansson (oej) 2004-07-19 04:50:00

Update to recent cvs (parking.h renamed features.h)

By: mh (mh) 2004-07-19 06:11:24

Sorry for my late response, but because of the holiday season I had no time up to now.
I have installed the new code on my server and it seems to work fine - Thanks!


By: cshaw59 (cshaw59) 2004-07-28 15:48:49

Hey olle, I thought I'd refresh this post by saying that it's working great for me, when do you think it'll be included in CVS?

By: Olle Johansson (oej) 2004-07-28 16:25:17


Implemented the outboundproxy support finally. Please test it! Thanks to dan2 for discussions and pushing on :-)

Chan_sip2 will not be included in cvs, but I copy functions from this version to chan_sip now and then. That requires feedback on new functions in chan_sip2 :-)

By: Olle Johansson (oej) 2004-07-29 03:54:44

Chan_sip2Ab.c: Fixes to outbound proxy support

By: ivoice (ivoice) 2004-07-29 09:25:02

Hi oej!
How about to add multiples listen ports?
for example:

Bye, Aldo.

By: Olle Johansson (oej) 2004-07-30 12:41:45

The latest version broke NAT support. It is now fixed in A3.

By: Olle Johansson (oej) 2004-07-30 16:20:56

A4: Small fixes in debug and contact header handling. Better SNOM support :-)

By: madugur (madugur) 2004-08-14 09:51:52


Actually forgot to ask something.  The outbound proxy seems to be a global parameter?  Is that correct?  I couldn't get it to behave in any other way, putting outboundproxy under a peer for instance.

Is it a single global parameter?  Wouldn't it make sense for it to allow multiple outbound proxy depending on the peer?



By: Olle Johansson (oej) 2004-08-14 10:05:03

Of course that's the way to go, but let's first get this version working. After that, we'll add peer-based config of outbound proxies.

By: Olle Johansson (oej) 2004-08-14 10:18:44

* Fix for ast_pthread_create (FreeBSD compatibility patch)
* Fixed localnet sensitivity that indeed was turned around.

Thank you very much for the feedback. Please confirm if the
outbound proxy function works as expected now.

By: Olle Johansson (oej) 2004-08-14 11:57:56

*Really* added latest version now :-)

Also, deleted some old bugnotes.

Anyone besides me that likes symmetricrtp= setting?

By: eltorio (eltorio) 2004-08-15 03:27:32

No sorry it doexn't work I add localnet= and it doesn't send properly to the outbound proxy.
if I don't add the localnet it sends to the outbound proxy even for local net

By: Olle Johansson (oej) 2004-08-15 03:46:25

Obviously a bad coding day, yesterday :-)

Madugur - could you please capture your debug output with full SIP debug and "asterisk -vvvvdr". Add it as a file to the bug report, not in the bug note. Thank you!

By: Olle Johansson (oej) 2004-08-15 04:33:32

Of course it sends everything to the outbound proxy if you don't configure localnet. I can't see where you are having an error? Do I misunderstand you somehow?

The logic is this:
 - If the address is included in the localnet, we do not use the outbound proxy
 - *everything* else is sent to the outbound proxy

By: eltorio (eltorio) 2004-08-15 07:10:10

my config

i try to register to fwd.pulver.com
i got
    -- Outbound proxy overrun by localnet setting. Not using outbound proxy.
    -- >>>  Sending SIP message to
sure that is not in

By: Olle Johansson (oej) 2004-08-15 08:22:23

Eltorio: Test chan_sip2A6.c - I think I've found the problem.

By: madugur (madugur) 2004-08-15 10:43:13

OEJ, added the trace.  Same thing occurs as previously described. Thanks for the quick turn around times, I'm impressed!

By: Olle Johansson (oej) 2004-08-15 12:32:29

Madagur: The log file clearly states that the INVITE is sent to the outbound proxy.

   -- sip_xmit of 0x8146714 (len 850) to sent via outbound proxy

You are getting a "trying" response from Broadvoice!

By: madugur (madugur) 2004-08-16 00:20:57

hmmm... Don't know if it is some kind of SIP message incompatibility or what, but this is definitely not working with Broadvoice.  I initially thought it was the outbound proxy stuff, and glad we found a couple of things there, but it is still not working with them.  I compare SIP sequences and messages w/ X-Lite (which works) and they all seem the same. However, Broadvoice does not allow outbound dialling w/ Asterisk.  The "trying" and "ringing" messages you see is them connecting to a message that says "We're sorry, your call cannot be completed at this time." rather than the call being completed.  I even went so far as to use Ethereal to capture the raw data and compare the differences between Asterisk and X-Lite with Broadvoice :-(  Ah well, might have to give up soon.  Got VoicePulse to work great (both IAX and SIP).  Maybe I'll ask them for suggestions.

By: iwhite (iwhite) 2004-08-16 00:59:17

If everything else seems the same, try changing the global_useragent and make it look like x-lite or some other SIP client that is known to work. Perhaps they're intentionally disabling support for use with Asterisk.

By: eltorio (eltorio) 2004-08-16 03:12:57

Hello oej,
Grat, Now it seems to works, i'll do some extended tests

By: fwittekind (fwittekind) 2004-08-16 15:25:24

madugur: The name Broadvoice implies they might be using Broadworks software.  

The patch in http://bugs.digium.com/bug_view_page.php?bug_id=0002244 might address your issue.

By: madugur (madugur) 2004-08-16 18:01:13


fwittekind you might have something here, I do believe it is broadworks software.  That patch looks like it is for the original chan_sip.  OEJ, any chance of integrating it into chan_sip2?

Thanks!  I'll be happy to test and let you folks know if chan_sip2 gets patched, if not i'll try the original chan_sip in a few days.

By: tbclark (tbclark) 2004-08-17 06:53:18

It's working perfectly for me using Broadvoice, with

Using localnet=, it is possible to register and receive calls from a second sip provider at the same time, so it looks like localnet is doing what it's supposed to.

When will outboundproxy= work as a peer parameter?

This is fantastic! Thanks, Olle.

By: Olle Johansson (oej) 2004-08-17 13:02:48

Seems like we have a working solution for outbound proxy in Asterisk. Great. Thank you for testing this, all of you!

Next step is to add support for setting outboundproxy in a [peer] section. This is an interesting task, as it will change a lot of logic that depends on the IP of the peer in Asterisk. When I can start doing this depends as usual on funding and available time...

By: twisted (twisted) 2004-08-25 18:35:38

oej, i've seen some excellent work come out of this!  Are you going to continue working here (in this bug) as usual?

By: Olle Johansson (oej) 2004-08-26 01:03:38

twisted: Yes, I think chan_sip2 stays here. After 1.0, I will rip out templates, realm auth and outbound proxy to be applied to chan_sip. After that, I'll open a new bug for chan_sip3 :-)

By: eltorio (eltorio) 2004-08-26 14:54:29

I use the oej's fantastic work and aslo the mysql peers so I modified his version A6 for having it working with mysql functions on today's CVS.
I added also the auth= directive in [general] section for storing the auth field in the database

You need to compile with -DMYSQL_AUTH (see the channels/Makefile.diff)

By: eltorio (eltorio) 2004-08-26 16:34:59

chan_sip2A6-mysql.c.diff (8,794 bytes) 08-26-04 16:33

1/ John told me that it didn't work with template ant autocreatepeer, corrected,
2/ The patches are reversed !!!!!!!!!!!!!!!!!

By: pasha (pasha) 2004-10-02 23:18:57

I can't get it working with cisco 7960 sip code 7.2
I can make calls, but it fails to ring...
phone telling me that "FROM" is missing from the INVITE.

By: Olle Johansson (oej) 2004-10-04 08:15:17

Update: I will soon start coding again, and possibly rip out the outbound proxy to chan_sip. I've spent a month managing Astricon :-) Don't worry, chan_sip2 will be updated.

By: Peter Whisker (whiskerp) 2004-10-13 07:59:40

chan_sip2.c won't compile any more since changes to structures in channels.h I think. For example, restrictcid has changed to cid_pres and callerid to cid_num.


By: Mark Spencer (markster) 2004-10-14 01:17:05

Even though I was against the idea at first, I'd like to go ahead and get outbound proxy support into chan_sip whenever it's convenient.

By: Olle Johansson (oej) 2004-10-15 03:48:13

Markster: Will contact you over IRC
...working on getting chan_sip2 into the match again, updating to CVS head level.

By: Olle Johansson (oej) 2004-10-20 15:03:26


A chan_sip2 updated to cvs head. PLEASE test and report bugs, there has been quite a lot of changes.

* Integrated the new realtime architecture
* Disabled mysql authentication while trying to find out how to do a realtime setup for auth
* Added a small function to check for interfaces on a system in order to prepare for future changes

By: Olle Johansson (oej) 2004-10-20 15:12:09

Please note that this new version is not tested at all, it compiles with a few warnings (nothing serious) and works on my FreeBSD system...

By: smerf (smerf) 2004-10-22 06:07:27

I find missing line: static int check_user_full [....]


  /* Get just the username part */
       if ((c = strchr(of, '@')))
               *c = '\0';
       if ((c = strchr(of, ':')))
               *c = '\0';
>>>>   strncpy(p->cid_num, of, sizeof(p->cid_num) - 1);
       if (*calleridname)
               strncpy(p->cid_name, calleridname, sizeof(p->cid_name) - 1);
       if (ast_strlen_zero(of))


edited on: 10-22-04 06:11

edited on: 10-22-04 06:28

By: Olle Johansson (oej) 2004-10-23 03:32:09

smerf, try finding me on IRC to sort this out. Thank you.

By: Peter Whisker (whiskerp) 2004-10-28 10:41:43

More deviation by the CVS-HEAD I'm afraid. There are a lot of cases of this and similar variations around "p1->owner", "p->owner" and "c"

<               if (p2->owner->bridge)
>               if (ast_bridged_channel(p2->owner))

which cause the compile to fail. It seems to work if they are edited. Any sign of the goodies in chan_sip2.c getting moved across into chan_sip.c?
Thanks, Peter

By: Olle Johansson (oej) 2004-11-03 02:25:28.000-0600

chan_sip2C: Cecilia
* Fixed the auth bug. Using chan_sip2 in my network again
* Up to date with CVS head
* Added re-registration re-use of auth challenge. We will try to re-use the
 auth nonce from previous registration when re-registering to an outside
 SIP proxy.
 This part of development was sponsored by BroadVoice and will be ported to
* Numerous small code fixes, less chattiness etc

PLEASE TEST and report any problems to me. Thank you!

By: Olle Johansson (oej) 2004-11-03 13:34:09.000-0600

tbclark: I need a gdb backtrace (see the wiki) that tells me more about your crash. Mail me or find me on the IRC (oej)

By: tbclark (tbclark) 2004-11-03 14:03:43.000-0600

(gdb) bt
#0  reload_config () at chan_sip2.c:10188
#1  0x41fb318c in reqprep (req=0x41e1fff4, p=0xbffff480,
   msg=0x21 <Address 0x21 out of bounds>, seqno=30, newbranch=80)
   at chan_sip2.c:3402
#2  0x08056f79 in ast_load_resource (resource_name=0x80ffd7f "chan_sip2.so")
   at loader.c:384
#3  0x0805778e in load_modules () at loader.c:479
#4  0x0809daa5 in main (argc=-1073744160, argv=0xbffff5d0) at asterisk.c:1848
ASTERISK-1  0x42015704 in __libc_start_main () from /lib/tls/libc.so.6

By: carlo (carlo) 2004-11-09 16:39:58.000-0600


I found this (tdbclark) is related to "register" option in sip.conf. I got same error when adding register => ... to sip.conf.

By: Peter Whisker (whiskerp) 2004-11-12 07:27:31.000-0600

Found the bug
chan_sip2C.c line 4641
               if (!r->callid_valid) {
                       build_callid(r->callid, sizeof(r->callid), __ourip, p->fromdomain);
                       r->callid_valid = 1;

"p" is not initialised at this point so p->fromdomain may crash the program.

By: Peter Whisker (whiskerp) 2004-11-12 07:52:35.000-0600

I have replaced p->fromdomain with global_fromdomain (which is probably not right!) but it now doesn't crash and it registers successfully with all my providers.


By: Olle Johansson (oej) 2004-11-12 07:56:06.000-0600

Thank you, I'll upgrade the channel to current cvs and fix this issue during the weekend. Also, integrated Broadvoice patch :-)

By: linuxa (linuxa) 2004-11-12 08:04:26.000-0600

Having watched the, somewhat heated, discusion on the BV patch, does this patch help other providers?

By: Olle Johansson (oej) 2004-11-12 10:12:26.000-0600

The bv patched simplifies re-registration for a lot of providers, but added logging. chan_sip2 is by default _very_ chatty to help debugging.

By: Olle Johansson (oej) 2004-11-21 15:04:04.000-0600

A small update. Adds patch for user=phone and some additional variable resets at SIP reload.

By: fcs_1 (fcs_1) 2004-11-23 12:15:23.000-0600

I am not a C hacker so any errors are a mistery to me.

Download patch chan_sip2E.c followed instructions on web site http://www.voip-info.org/tiki-index.php?page=Asterisk%20SIP%20chan_sip2

Using: CVS-HEAD-11/22/04-12:53:02

[root@fcspbx channels]# make
cc -Wno-missing-prototypes -Wno-missing-declarations   -DZAPATA_PRI   -DIAX_TRUNKING   -DCRYPTO -fPIC    -c -o chan_sip2.o chan_sip2.c
In file included from chan_sip2.c:354:
/usr/include/asterisk/lock.h: In function `ast_mutex_init':
/usr/include/asterisk/lock.h:311: error: `PTHREAD_MUTEX_RECURSIVE' undeclared (first use in this function)
/usr/include/asterisk/lock.h:311: error: (Each undeclared identifier is reported only once
/usr/include/asterisk/lock.h:311: error: for each function it appears in.)
chan_sip2.c: At top level:
chan_sip2.c:495: error: syntax error before "ASTERISK_VERSION"
make: *** [chan_sip2.o] Error 1
[root@fcspbx channels]#

By: wai2 (wai2) 2004-11-29 04:52:00.000-0600

unfortunately I have the same problem which fcs_1 is having right now.

any suggestion how to resolve ?


By: Peter Whisker (whiskerp) 2004-11-29 09:04:38.000-0600


(Feature request!)
Would it be possible to allow the rest of the [global] parameters to be over-rideable in the SIP peer sections in much the same way as the allow= codec parameters?

Specifically I need to be able to have a different "externip=" for different peers (as I have multiple NICs). The way it is now, I can register with either one of two of my peers but not both at the same time.


By: Olle Johansson (oej) 2004-11-29 13:41:02.000-0600

Feature requests and support issues is best handled via e-mail or on the IRC - find me!

Peter: I need to find out what you really want do do, please find me on e-mail or IRC. THank you!

By: Clod Patry (junky) 2004-12-16 22:14:42.000-0600

Any development in here , oej, since 2 weeks?


By: Olle Johansson (oej) 2004-12-17 00:46:08.000-0600

Junky, this is not a bug report, it's experimental features, new development. I've been busy fixing real bugs in CVS for a while, but I'll be back updating chan_sip2 soon.

By: Olle Johansson (oej) 2005-01-08 04:08:33.000-0600

Closing this due to lack of time. Will re-open when I've updated chan_sip2 to current cvs, which will not happen soon.