Re: PJSUA: Set From userpart when making a call

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

 



On 27.11.19 12:33, Skale Franz wrote:
Hi Andreas,
i found out, that you can get the INFO of every request in the default module by calling:
PJ_LOG(3,(THIS_FILE, "default_mod_on_tx_request: INFO: %s", pjsip_tx_data_get_info(tdata)));
Prints:
APP  ....default_mod_on_tx_request: INFO: Request msg INVITE/cseq=24079 (tdta0x558cefd79ad8)

So you can write a fancy block by comparing the info and then limit the rx request by using e.g:
pj_str_t info = pj_str(pjsip_tx_data_get_info(tdata));
if ( pj_stristr(&info, pj_str("INVITE")) != NULL ) {
  ... do something
}

Only a thought...

Best regards
Franz

Citycom Telekommunikation GmbH
Gadollaplatz 1
8010 Graz | Austria

________________________________________
Von: Skale Franz
Gesendet: Mittwoch, 27. November 2019 12:11
An: pjsip@xxxxxxxxxxxxxxx
Betreff: AW:  PJSUA: Set From userpart when making a call

Hi Andreas,
i concur, the option should exists.
Rewriting the header must be much easier.

E.g.
to print the user portion of the from header, you have to:
Snippet:
pjsip_fromto_hdr *from;
if ( ( from = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_FROM, NULL)) == NULL )
     PJ_LOG(3,(THIS_FILE, "default_mod_on_tx_request: No FROM header in message"));
   else {
     pjsip_sip_uri *sip_uri = (pjsip_sip_uri*)pjsip_uri_get_uri(from->uri);
     PJ_LOG(3,(THIS_FILE, "default_mod_on_tx_request: From: %s", sip_uri->user.ptr));
   }
What strikes me is, that there's no exact exaplanation how to rewrite headers.
So,i was forced to read the pjsip plugin source of asterisk.
Still learning btw.

I use pj-sua.
Currently i'm writing on a loop check which calls an external
number and then, with the help of a fabulous Beronet Berofix,
route it back to check is external calls are working for different providers.
Quality assurance, as you may call it.

Best regards
Franz

Citycom Telekommunikation GmbH
Gadollaplatz 1
8010 Graz | Austria
________________________________________

This seems to be fragile, also as I understand the string returned by pjsip_tx_data_get_info() is supposed to be for human consumption. Actually, rewriting headers is not that hard if you know the API a little bit; I'm just not comfortable with rewriting the 'basic' headers. I just want the thing to work without having to manipulate something afterwards; which to me seems error prone. Also, it'd add another layer of something that can go wrong; I don't really want that.

As a side-note on your previous mail: Using pjsua you can easily add headers to outgoing requests by providing a msg_data parameter to various pjsua_call functions. Also, the User-Agent can actually be specified in the pjsua_config struct when setting up PJSUA; here I am referring to your previous example of course.


Best Regards,
Andreas


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

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
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