[asterisk-dev] [Code Review]: Patch to detect/parse ANI-II / ANI2 / OLI from SIP INVITE messages

Rob Gagnon reviewboard at asterisk.org
Thu May 24 15:19:24 CDT 2012



> On May 24, 2012, 2:52 p.m., Mark Michelson wrote:
> > /trunk/channels/chan_sip.c, line 1494
> > <https://reviewboard.asterisk.org/r/1947/diff/1/?file=28256#file28256line1494>
> >
> >     Since the return value of this function is not actually checked, you may as well have it return void.

Done.  it is now void.  I was thinking we might need a future return value should SIP eventually need to pass OLI through to the B-side, but I can't see a need at this time.


> On May 24, 2012, 2:52 p.m., Mark Michelson wrote:
> > /trunk/channels/chan_sip.c, lines 24031-24038
> > <https://reviewboard.asterisk.org/r/1947/diff/1/?file=28256#file28256line24031>
> >
> >     You can combine this to all be if (ast_strlen_zero) since it checks both for NULL and zero-length strings.

Removed the "if (!s)" piece of code.  This was left over from a test driver I wrote to handle many kinds of "From:" headers to ensure all use-cases I could come up with didn't crash the routine.


> On May 24, 2012, 2:52 p.m., Mark Michelson wrote:
> > /trunk/channels/chan_sip.c, lines 24040-24056
> > <https://reviewboard.asterisk.org/r/1947/diff/1/?file=28256#file28256line24040>
> >
> >     This all certainly works, and I'm not going to say this *can't* go in like this, but there are some functions that can help you out here to make things a bit simpler.
> >     
> >     s = ast_strip_quoted(s, "\"");
> >     if (sscanf(s, "%2d", &ani2) == 1) {
> >         ast_channel_caller(chan)->ani2 = ani2;
> >     }
> >     
> >     The only caveat to this approach is that ast_strip_quoted() modifies the string that you grabbed from the SIP request, so you'd need to change the top line of this function to
> >     
> >     char *from = ast_strdupa(sip_get_header(req, "From");

I thought of sscanf() and strip quoted as well, but since this was a simple 2-digit search only, I went for processing speed with the manual character manipulation.


- Rob


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1947/#review6317
-----------------------------------------------------------


On May 24, 2012, 3:18 p.m., Rob Gagnon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1947/
> -----------------------------------------------------------
> 
> (Updated May 24, 2012, 3:18 p.m.)
> 
> 
> Review request for Asterisk Developers and Rob Gagnon.
> 
> 
> Summary
> -------
> 
> Add ANI2 / OLI parsing for SIP.  The patch checks the "From" header during the handle_request_invite() function for the presence of "isup-oli", "ss7-oli", or "oli" tags.  If present, the up-to-2-digits following the equal sign in the tag are set on the channel's caller structure in the "ani2" int element.
> 
> This allows SIP functions that reference ANI2 to work properly for SIP.  Specifically tested was the messaging that occurs when AGI transmits its data to an AGI script.
> 
> 
> This addresses bug 19912.
>     https://issues.asterisk.org/jira/browse/19912
> 
> 
> Diffs
> -----
> 
>   /trunk/channels/chan_sip.c 367677 
> 
> Diff: https://reviewboard.asterisk.org/r/1947/diff
> 
> 
> Testing
> -------
> 
> Call processing via AGI call in dial plan which logs all AGI incoming values was executed from cell phone, land line, and payphone.  During the payphone call, the value of "agi_callingani2" was properly transmitted as "7" while the others were "0"
> 
> 
> Thanks,
> 
> Rob
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20120524/05c6ce57/attachment-0001.htm>


More information about the asterisk-dev mailing list