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