Summary:ASTERISK-02435: [patch] initial Remote-Party-ID support & app to set RestrictCID
Reporter:ajlow (ajlow)Labels:
Date Opened:2004-09-20 09:38:34Date Closed:2008-01-15 15:49:24.000-0600
Versions:Frequency of
Environment:Attachments:( 0) chan_sip.rev7.strdup.diff
Description:My first patch so don't expect too much (c;

Adds a basic Remote-Party-ID in app_dial sourced SIP INVITE's based on From field and RestrictCID and a app to set RestrictCID in dialplan.


Refs: 0002012 0001120

It seems I like others use Cisco AS5300's and would like to be able to control how the 5300 handles the forwarding of SIP CID's onto the ISDN networks. This allows me to use SetCallerID and RestrictCID to give a simple solution to denying CLI's on outbound calls.

I intend to implement more support for this field once I grasp the full architecture... understanding the state of the drafts on this but I am sure those Cisco users will be grateful once it matures.
Comments:By: Mark Spencer (markster) 2004-09-20 17:14:14

Can you please attach your patch as a tar.gz or tar.bz2

By: Mark Spencer (markster) 2004-09-20 17:14:26

Also, do you have a disclaimer on file?  Thanks.

By: ajlow (ajlow) 2004-09-21 04:38:09

Apologies Mark, updating archive now and will fax disclaimer a little later.

By: Mark Spencer (markster) 2004-09-21 07:49:12

Great, patch looks good, so as soon as you get your disclaimer in we can add the patch, thanks!

By: Andreas Anderson (aanderson) 2004-09-21 16:05:06

The idea is great, but why a new application, 'SetCallerPres' is already there and supports all possible combinations that cisco does:

;privacy=off;screen=no  Presentation allowed of user-provided number, number not screened (0x00)
;privacy=off;screen=yes  Presentation allowed of user-provided number, number passed network screening (0x01)
;privacy=[full|uri|name];screen=no Presentation prohibited of user-provided number, number not screened (0x20)
;privacy=[full|uri|name];screen=yes  Presentation prohibited of user-provided number, number passed network screening (0x21)
;screen=no  Presentation allowed of user-provided number, number not screened (0x00)
;screen=yes  Presentation allowed of user-provided number, number passed network screening (0x01)
;privacy=off  Presentation allowed of user-provided number, number not screened (0x00)
;privacy=[full|uri|name]  Presentation prohibited of user-provided number, number not screened (0x20)
(no screen or privacy tags)  Presentation allowed of user-provided number, number not screened (0x00)

It would also be very nice if it would be possible to set ${CALLINGPRES} to the correct value...

A complete overview of the Cisco Remote-Party-ID is here:


edited on: 09-21-04 16:10

By: Mark Spencer (markster) 2004-09-22 01:08:13

SetCallerPres is the right application, can we update your patch to support RPID with callerpres?

By: ajlow (ajlow) 2004-09-22 03:14:55

I've already been working on it guys, this was the 'initial' release just to support restrictcid at first. I did have some issues with SetCallerPres and chan_sip but I will work full support in this coming weekend. thanks for the comments ...

By: ajlow (ajlow) 2004-09-24 19:38:36

Ok so here's my latest attempt to provide support for the Remote-Party-ID header that was originally defined in the IETF specification,
draft-ietf-privacy-.02.txt (SIP Extensions for Caller Identity and Privacy) and more practical, implemented by Cisco in their gateways.

1. It now uses the CallingPres field to set the values that it will use.
2. It will also replace the caller name and ID in the From field as applicable.
3. It can be disabled/enabled using the 'global_enablerpid' static.

Feedback, comments and flames most welcome (c;

By: ajlow (ajlow) 2004-09-24 19:45:07

Please ignore the 'rpid-patch.*' files, chan_sip.c.diff is the latest release.

You can use the SetCallerPress app to control its behaviour. I've done extensive testing with a Cisco AS5300 and the AS5300 translates the Remote-Party-ID SIP options onto the ISDN circuits as desired.

By: Andreas Anderson (aanderson) 2004-09-25 09:21:16

The new patch works fine on a C3620 with BRI for outgoing calls, but all incoming calls now show as Unknown on a Cisco 7960.

By: ajlow (ajlow) 2004-09-25 12:47:33

aanderson, I've confirmed your finding on my C7940's, fixing now ...

By: Brian West (bkw918) 2004-09-27 17:23:56

also guys diff -u

By: twisted (twisted) 2004-10-27 15:58:20

Where do we stand on this?  Markster seemed as if he's all about adding this, but does it apply cleanly after a month of downtime?  If not, can we get it updated, confirm that a disclaimer is filed, and move forward?



By: twisted (twisted) 2004-11-14 21:14:10.000-0600

Another close due to lack of interst/no real progress since 10/27/04.  Please feel free to re-open if this is still an issue/progress/updates/etc...

By: ajlow (ajlow) 2004-12-01 11:29:40.000-0600

It works fine so why can't it just be added in !?

By: twisted (twisted) 2004-12-15 20:45:34.000-0600

1) confirm you have a disclaimer on file
2) get people to test this patch
3) get kram's approval

Then it can go in.  This bug needs activity, and you need to answer the question regarding your disclaimer.  please confirm/respond to keep this open.


By: Olle Johansson (oej) 2004-12-16 10:46:00.000-0600

Please add a "cvs diff -u channels/chan_sip.c" to get the proper patch format.

By: twisted (twisted) 2005-01-04 01:03:34.000-0600

AJLow, i'm trying to be leniant, but as stated, you need to answer the questions, get this tested, and markster's approval.

It's been a month since this has had any activity, over two weeks since the last marshal request.  Please respond.

By: Mark Spencer (markster) 2005-01-16 01:35:53.000-0600

Suspended until we get feedback from the patch submitter.

By: ajlow (ajlow) 2005-03-10 06:49:46.000-0600

Ok original poster back, sorry for the long absence but this was due to me changing browser (and losing login credentials) and not having any means to get my password recovered for the site, anyone fancy developing this ? :)

My disclaimer is on file at Digium !

Is this patch still even applicable, I understand there has been some additional Remote-Party-ID support added, or is their any interest in me continuing with this ?

By: Kevin P. Fleming (kpfleming) 2005-03-10 11:50:25.000-0600

I have also been working on this, independently of your patch (sorry, never noticed it in Mantis), so contact me off-line and we can discuss how to proceed from here.


By: Mark Spencer (markster) 2005-03-11 00:41:04.000-0600

RestrictCID app should definitely not be needed now that we have SetCallerPres...  I don't know if the rest of the stuff in Remote-Party-ID is working or not...

By: Brian West (bkw918) 2005-03-17 21:18:58.000-0600

house keeping.... Is this up to date?  Whats da skinny on this patch/bug?


By: Andreas Anderson (aanderson) 2005-04-05 06:19:38

this does not work with CVS from today:

chan_sip.c: In function `create_addr':
chan_sip.c:1536: error: `ast' undeclared (first use in this function)
chan_sip.c:1536: error: (Each undeclared identifier is reported only once
chan_sip.c:1536: error: for each function it appears in.)
chan_sip.c: In function `add_sdp':
chan_sip.c:3679: error: syntax error before "static"
chan_sip.c: In function `build_rpid':
chan_sip.c:3688: error: structure has no member named `callerid'
chan_sip.c:3689: error: structure has no member named `callerid'
chan_sip.c:3724: error: structure has no member named `restrictcid'
chan_sip.c:3736: error: structure has no member named `rpid'
chan_sip.c:3736: error: structure has no member named `rpid'
chan_sip.c:3738: error: structure has no member named `rpid'
chan_sip.c:3738: error: structure has no member named `rpid'
chan_sip.c:3740: error: structure has no member named `rpid_from'
chan_sip.c:3740: error: structure has no member named `rpid_from'
chan_sip.c: In function `initreqprep':
chan_sip.c:4123: warning: implicit declaration of function `build_rpid'
chan_sip.c:4124: error: structure has no member named `rpid_from'
chan_sip.c:4125: error: structure has no member named `rpid'
make[1]: *** [chan_sip.o] Error 1
make[1]: Leaving directory `/usr/src/asterisk-head/asterisk/channels'
make: *** [subdirs] Error 1

someone has an updated version?

edited on: 04-05-05 07:10

By: Kevin P. Fleming (kpfleming) 2005-04-05 17:12:30

No, it has not been updated. I have a new version (with more features) in the works, but I won't be able to continue working on it until this weekend.

By: silik0n (silik0n) 2005-05-10 17:48:09

KP Any updates on this patch?

By: Olle Johansson (oej) 2005-06-05 17:34:06

---no activity. Re-open when we have an update.


By: twisted (twisted) 2005-08-26 00:01:03

I have updated the patch to work on current head.

The INVITE is sent properly, however, when we were testing this with asterlink, we noticed another bug in CVS head relating to chan_sip that I will post as another bug:  When asterisk replys to an invite telling the remote host 407 Proxy Authentication Required, asterisk simply copys the request, and sends it back untouched to the INVITING machine.  At this point asterisk acts accordingly and rewrites the request when sending auth, but now all the fields are reversed.

otherwise, this patch works :)
file: chan_sip-rpid.2471.patch

By: Andreas Anderson (aanderson) 2005-08-26 09:27:21

Outgoing CID restriction works without problems on a Cisco 3640 with BRI, thanks!

By: Serge Vecher (serge-v) 2005-08-26 10:31:01

What's the reason for this change?

-#ifndef MAX
+#ifndef mAX

By: twisted (twisted) 2005-08-26 15:17:16

can't say that I saw that in the patch - if it's in there it's due to a bad keymapping on my mac at home. I will update the patch tonight.

By: twisted (twisted) 2005-08-27 01:14:39

updated to fix the MAX issue.  chan_sip-rpid-2471.diff

By: twisted (twisted) 2005-08-30 23:50:37

attached is also the patch for sip.conf.

By: Brian West (bkw918) 2005-08-31 01:13:06

Ok this is a fully working rpid patch for chan_sip.  We transmit and build the RPID like we should now.  Before the RPID was rebuilt on the second invite which it shouldn't have been.  This caused the callerid to have the number we were calling in the rpid which wasn't the right thing to do.


By: twisted (twisted) 2005-08-31 01:14:33

chan_sip.rev5.diff is fully functional, and yes, even between two asterisk boxes. :)

but 5034 was deleted because initially bkw and I were under the impression that chan_sip was doing the wrong thing (tm), but because the code is so cluttered, it took us until now to realize that it wasn't - we change the private structure we look at when we respond to the 407 to the structure of the new request.


By: twisted (twisted) 2005-08-31 01:14:59

kpfleming, this is ready to go in now

By: Joshua C. Colp (jcolp) 2005-08-31 16:47:40

This is a beautiful patch that finally makes SIP between Asterisk boxes with username authentication work just the way that one would think, with working callerid. I'm all for getting it into CVS. This makes me crave a muffin.

By: Olle Johansson (oej) 2005-08-31 19:23:40

I don't like allocating another 512 bytes for every SIP_PVT. Please make them pointers and allocate only when needed.

Shouldn't this be a peer and general option?

By: Brian West (bkw918) 2005-08-31 21:03:07

ok thats coming right up.

By: Brian West (bkw918) 2005-08-31 21:15:20

Updated to be a char * on the PVT and only strdup in build_rpid and free the rpid/rpid_from in sip_destroy before the peer->call is destroyed so we don't leak memory.


By: Joshua C. Colp (jcolp) 2005-09-01 16:22:18

Don't forget people to enable RPID generation by setting generaterpid to yes - like yeah people just might not look at the example config to see that.

By: Jason Parker (jparker) 2005-09-01 22:41:27

Small typo fixed in sip.conf.sample - SetCallingPres() > SetCallerPres()

Not trying to be an ass, it just bothered me.

By: Brian West (bkw918) 2005-09-02 15:53:17

Now if this would get added to cvs.. thanks for the fix north! ;)


By: twisted (twisted) 2005-09-06 15:12:13

pushing for this again.  stilll works good with the strdup/free stuff, although I thought sip_destroy() free'd the entire struct.  *shrug*  better to be safe than sorry I guess :)

By: darkskiez (darkskiez) 2005-09-06 16:42:25

If the RPID has ;party=called as an option Cisco 79x0 phones with 7.5 firmware will update their display with the callerid name and the number with the sip username in the remote party id field.

I tested by adding a header line into the transmit_response_with_sdp function
snprintf(cbuf,sizeof(cbuf), "\"%s\" <sip:%s@astersk>;party=called",p->cid_name,p->cid_num);
add_header(&resp, "Remote-Party-ID", cbuf);

This updates the screen, but of course with the wrong details (that of the caller not the called), I do not know asterisk's code well enough to develop a proper patch. It would be very cool if it worked and could make things like call parking a lot quicker and easier if the display updated to reflect the parking position etc (that may be more work of course).

Just thought I'd note this here incase anyone wanted to develop something more concrete or adapt this patch apropriately.

By: Michael Jerris (mikej) 2005-09-06 17:39:26

let's leave the additional feature requests on this to another bug please so this can continue on in to 1.2.

By: Brian West (bkw918) 2005-09-06 17:40:51

You have to free the strdup'ed objects otherwise they get thrown into outerspace and you have a memory leak because they are pointers on the pvt pointing to memory that we malloced via strdup.


By: Brian West (bkw918) 2005-09-06 17:41:45

darkskiez find me on IRC and let me in and we can make this do what you want then maybe update this for post 1.2?


By: Brian West (bkw918) 2005-09-07 16:06:55

What is holding this up?

By: Brian West (bkw918) 2005-09-07 16:38:41

Updated for CVS-HEAD

By: Brian West (bkw918) 2005-09-07 18:55:21

Ok for clarification this is the final patch I will ever disclaim to the project.  From this date forward I'll post my patches up for people to use or not use.


By: Michael Jerris (mikej) 2005-09-18 04:52:36

For clarification, is the attached patch the one that worked prior to the commital of "factor out INVITE response handling in its own function (issue ASTERISK-4992)" ?

By: silik0n (silik0n) 2005-09-20 10:20:16

Any status update on this? many of us are eargerly awaiting its inclusion and would love to see it commited sooner then later so we can start testing it for pending deployments

By: Michael Jerris (mikej) 2005-09-24 15:20:28

Is anybody able to update this patch for cvs head?

By: twisted (twisted) 2005-09-24 19:16:33

This is NOT a formatting/comments patch MikeJ... please only reassign where appropriate.

By: Michael Jerris (mikej) 2005-09-24 19:31:03

Not sure how I did that... Change was unintentional.. Sorry.

By: Kevin P. Fleming (kpfleming) 2005-09-26 21:58:14

Committed to CVS HEAD with significant re-work... this patch was not at all ready for merging as it was posted in this bug. If you are interested in what all needed to be changed, ask :-)

By: Digium Subversion (svnbot) 2008-01-15 15:49:24.000-0600

Repository: asterisk
Revision: 6671

U   trunk/channels/chan_sip.c
U   trunk/configs/sip.conf.sample

r6671 | kpfleming | 2008-01-15 15:49:23 -0600 (Tue, 15 Jan 2008) | 2 lines

support optional sending of Remote-Party-ID headers (issue ASTERISK-2435, heavily modified to actually work properly)