[pjsip] Missing host and port in Contact- header- URI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Benny,

You are right. Now it works fine. Thank you for your quick help!

Best regards,
Helmut



-----Urspr?ngliche Nachricht-----
Von: pjsip-bounces at lists.pjsip.org [mailto:pjsip-bounces at lists.pjsip.org] Im Auftrag von Benny Prijono
Gesendet: Donnerstag, 4. Oktober 2007 18:02
An: pjsip embedded/DSP SIP discussion
Betreff: Re: [pjsip] Missing host and port in Contact- header- URI

Helmut Wolf wrote:
> Hi Benny,
> 
> In stateful_proxy.c --> proxy_on_rx_request:
> 
> Example: I am receiving an REGISTER- Request with an Contact header like:
> 
> Contact: <sip:192.168.16.168:7176>;methods="INVITE, MESSAGE, INFO, SUBSCRIBE, OPTIONS, BYE, CANCEL, NOTIFY, ACK, REFER"
> 
> Now I want to get the IP and Port from the contact header using the following code in proxy_on_rx_request():
> 
> pjsip_contact_hdr *hcontact;
> pjsip_sip_uri *uri;
> 
> hcontact = (pjsip_contact_hdr*) pjsip_msg_find_hdr (rdata->msg_info.msg, PJSIP_H_CONTACT, NULL);
> 		
> if (hcontact != NULL)
> 	uri = (pjsip_sip_uri*)hcontact->uri;
> ...
> 
> The contact header is found but uri->host is null and uri->port is 0. How can I get this ?

Aha!

That's because hcontact->uri is not a pjsip_sip_uri, but rather it's 
a pjsip_name_addr!

To get the pjsip_sip_uri, you need to do this:

      uri = (pjsip_sip_uri*) pjsip_uri_get_uri(hcontact->uri);

which more or less means "get me the URI inside the name-addr, or if 
you are not a name-addr, then return yourself".

cheers,
  -benny


> Best regards,
> Helmut


_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip at lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org




[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux