[asterisk-dev] How to get SIP packet source ip address in asterisk application
Olle E. Johansson
oej at edvina.net
Tue Nov 17 02:51:26 CST 2009
17 nov 2009 kl. 09.33 skrev santoshchintalwar at gmail.com:
>
> There is one way to access it.
> Create a new header file in include/asterisk directory.
> Remove the structure from chan_sip.c and add it to the new header, and
> include it in chan_sip.c as well as your custom application.
> I did the same thing and it works fine for me.
>
Or check how we've implemented that part in the CHANNEL() dialplan function.
Using that interface is much more reliable. It calls a function in the channel interface
that reports the IP address.
/O
> Thanks,
> Santosh.
>
> Alex Massover wrote:
>> Hi!
>>
>> I also want to access sip_pvt from custom application, I'm trying to follow your suggestion but AFAIU:
>> sip_pvt is defined in chan_sip.c and there's no header that I can include, so there's no way to access sip_pvt from custom application?
>>
>> Accessing ((struct sip_pvt *) chan->tech_pvt)->callid results in "error: dereferencing pointer to incomplete type"
>>
>> Do I miss something? I'm using 1.4.
>>
>> --
>> Best Regards,
>> Alex Massover
>> VoIP R&D TL
>> Jajah Inc.
>>
>>
>>> -----Original Message-----
>>> From: asterisk-dev-bounces at lists.digium.com [mailto:asterisk-dev-
>>> bounces at lists.digium.com] On Behalf Of Kai Hoerner
>>> Sent: Monday, November 16, 2009 9:28 AM
>>> To: Asterisk Developers Mailing List
>>> Subject: Re: [asterisk-dev] How to get SIP packet source ip address in
>>> asterisk application
>>>
>>> Hi,
>>>
>>> i suggest you leave the authentication to the asterisk SIP stack and
>>> only let the authenticated peer enter the right context that contains
>>> your call to Application().
>>>
>>>
>>> if you really plan to implement authentication on your own (i see no
>>> good reason for that) you should start by looking at the "ast_channel"
>>> and "sip_pvt" structs. "sip_pvt" holds all information about the active
>>> SIP "dialog" (i.e. "call" in this case)
>>>
>>> channel->tech_pvt is a pointer from the ast_channel abstraction to the
>>> SIP tech-specific object. (of type sip_pvt)
>>> Before accessing any of its properties you want to check if the channel
>>> is type SIP.
>>>
>>> http://www.asterisk.org/doxygen/asterisk1.6.2/structsip__pvt.html
>>>
>>>
>>> ast guy schrieb:
>>>
>>>> Hi,
>>>>
>>>> I have made an application an asterisk. Can any one tell how do I
>>>>
>>> get
>>>
>>>> the source IP address of the SIP packets inside my app_Application()?
>>>> Application only gets the ast_channel variable and *data passed to
>>>>
>>> it.
>>>
>>>> SIP Call is being forwarded to my application from some Service
>>>> Provider. So when app_Applicaiton() is in execute state then I want
>>>>
>>> to
>>>
>>>> get the sip source packet ip address and then authenticate it.
>>>>
>>>> Regards,
>>>> /ag
>>>>
>>>> _______________________________________________
>>>> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>>>>
>>>> asterisk-dev mailing list
>>>> To UNSUBSCRIBE or update options visit:
>>>> http://lists.digium.com/mailman/listinfo/asterisk-dev
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>>>
>>> asterisk-dev mailing list
>>> To UNSUBSCRIBE or update options visit:
>>> http://lists.digium.com/mailman/listinfo/asterisk-dev
>>>
>>> This mail was received via Mail-SeCure System.
>>>
>>>
>>
>>
>> This mail was sent via Mail-SeCure System.
>>
>>
>>
>> _______________________________________________
>> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>>
>> asterisk-dev mailing list
>> To UNSUBSCRIBE or update options visit:
>> http://lists.digium.com/mailman/listinfo/asterisk-dev
>>
>>
>
>
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-dev
---
* Olle E Johansson - oej at edvina.net
* Cell phone +46 70 593 68 51, Office +46 8 96 40 20, Sweden
More information about the asterisk-dev
mailing list