PJSUA: Set From userpart when making a call

AW
Andreas Wehrmann
Wed, Nov 27, 2019 9:15 AM

Hey there,

I was wondering whether there is a way to set the userpart of
the From header when making a call with PJSUA's pjsua_call_make_call().

Looking at the code, and assuming I'm not overlooking something, it
doesn't seem to be possible.
From what I understand, the From header is constructed with what is
configured in the account that is used for the call.

My scenario is the following:
I'm writing a gateway to translate between VoIP and a digital radio network.
The gateway is to be registered with a PBX and is to forward calls from
the radio network
to the registrar by translating radio calls to SIP calls (and vice
versa: SIP->radio network).

Each participant of the radio network has their own ID (think: telephone
number)
and VoIP users must be able to call back radio users.
For this reason I'd like to set the radio user's number in the From
header header when calling the PBX,
so that they see not only who is calling but also to give them the
ability to call back.

My current approach is to patch PJSUA by introducing another member to
pjsua_call_setting
(probably not the right place, but would serve my purposes) that takes a
pj_str_t which contains the userpart to be put in the From header.
In the function itself, it would check whether the string is not empty
and take that string instead of what's configured with the account.

Best Regards,

Andreas Wehrmann

Hey there, I was wondering whether there is a way to set the userpart of the From header when making a call with PJSUA's pjsua_call_make_call(). Looking at the code, and assuming I'm not overlooking something, it doesn't seem to be possible. From what I understand, the From header is constructed with what is configured in the account that is used for the call. My scenario is the following: I'm writing a gateway to translate between VoIP and a digital radio network. The gateway is to be registered with a PBX and is to forward calls from the radio network to the registrar by translating radio calls to SIP calls (and vice versa: SIP->radio network). Each participant of the radio network has their own ID (think: telephone number) and VoIP users must be able to call back radio users. For this reason I'd like to set the radio user's number in the From header header when calling the PBX, so that they see not only who is calling but also to give them the ability to call back. My current approach is to patch PJSUA by introducing another member to pjsua_call_setting (probably not the right place, but would serve my purposes) that takes a pj_str_t which contains the userpart to be put in the From header. In the function itself, it would check whether the string is not empty and take that string instead of what's configured with the account. Best Regards, Andreas Wehrmann
SF
Skale Franz
Wed, Nov 27, 2019 9:49 AM

Hi Andreas,
IMHO, you should be able to "rewrite" any header by using the pjsip_module mod_default_handler.

E.g.:
/* The module instance. /
static pjsip_module mod_default_handler =
{
NULL, NULL,        /
prev, next.    /
{ "mod-default-handler", 19 },  /
Name.    /
-1,          /
Id      /
PJSIP_MOD_PRIORITY_APPLICATION+99,  /
Priority          /
NULL,        /
load()    /
NULL,        /
start()    /
NULL,        /
stop()    /
NULL,        /
unload()    /
NULL,                /
on_rx_request()  /
NULL,        /
on_rx_response()  /
&default_mod_on_tx_request, /
on_tx_request()  /
NULL,          /
on_tx_response()  /
NULL,        /
on_tsx_state()  */

};

So, for the purpose of rewriting the from header, you could save the header (temp)
rewrite it by changing the FROM header, then replace it in the linked list and at the end, insert it after the VIA Header.

E.g. my program adds the UA to any outgoing request (add User Agent)
static pj_status_t default_mod_on_tx_request(pjsip_tx_data *tdata){

/* Add User-Agent header */

pj_str_t user_agent;
char tmp[80];
const pj_str_t USER_AGENT = { "User-Agent", 10};
pjsip_hdr *h;

pj_ansi_snprintf(tmp, sizeof(tmp), "Dummy SUA v%s/%s",
pj_get_version(), PJ_OS_NAME);
pj_strdup2_with_null(tdata->pool, &user_agent, tmp);

h = (pjsip_hdr*) pjsip_generic_string_hdr_create(tdata->pool,
&USER_AGENT,
&user_agent);
pjsip_msg_add_hdr(tdata->msg, h);

return PJ_SUCCESS;

}

Take a look at these functions:

https://www.pjsip.org/pjsip/docs/html/group__PJSIP__MSG__MSG.htm

Best regards
Franz

Citycom Telekommunikation GmbH
Gadollaplatz 1
8010 Graz | Austria


Von: pjsip pjsip-bounces@lists.pjsip.org im Auftrag von Andreas Wehrmann a.wehrmann@yandex.com
Gesendet: Mittwoch, 27. November 2019 10:15
An: pjsip@lists.pjsip.org
Betreff: [pjsip] PJSUA: Set From userpart when making a call

Hey there,

I was wondering whether there is a way to set the userpart of
the From header when making a call with PJSUA's pjsua_call_make_call().

Looking at the code, and assuming I'm not overlooking something, it
doesn't seem to be possible.
From what I understand, the From header is constructed with what is
configured in the account that is used for the call.

My scenario is the following:
I'm writing a gateway to translate between VoIP and a digital radio network.
The gateway is to be registered with a PBX and is to forward calls from
the radio network
to the registrar by translating radio calls to SIP calls (and vice
versa: SIP->radio network).

Each participant of the radio network has their own ID (think: telephone
number)
and VoIP users must be able to call back radio users.
For this reason I'd like to set the radio user's number in the From
header header when calling the PBX,
so that they see not only who is calling but also to give them the
ability to call back.

My current approach is to patch PJSUA by introducing another member to
pjsua_call_setting
(probably not the right place, but would serve my purposes) that takes a
pj_str_t which contains the userpart to be put in the From header.
In the function itself, it would check whether the string is not empty
and take that string instead of what's configured with the account.

Best Regards,

Andreas Wehrmann


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

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

Hi Andreas, IMHO, you should be able to "rewrite" any header by using the pjsip_module mod_default_handler. E.g.: /* The module instance. */ static pjsip_module mod_default_handler = { NULL, NULL, /* prev, next. */ { "mod-default-handler", 19 }, /* Name. */ -1, /* Id */ PJSIP_MOD_PRIORITY_APPLICATION+99, /* Priority */ NULL, /* load() */ NULL, /* start() */ NULL, /* stop() */ NULL, /* unload() */ NULL, /* on_rx_request() */ NULL, /* on_rx_response() */ &default_mod_on_tx_request, /* on_tx_request() */ NULL, /* on_tx_response() */ NULL, /* on_tsx_state() */ }; So, for the purpose of rewriting the from header, you could save the header (temp) rewrite it by changing the FROM header, then replace it in the linked list and at the end, insert it after the VIA Header. E.g. my program adds the UA to any outgoing request (add User Agent) static pj_status_t default_mod_on_tx_request(pjsip_tx_data *tdata){ /* Add User-Agent header */ pj_str_t user_agent; char tmp[80]; const pj_str_t USER_AGENT = { "User-Agent", 10}; pjsip_hdr *h; pj_ansi_snprintf(tmp, sizeof(tmp), "Dummy SUA v%s/%s", pj_get_version(), PJ_OS_NAME); pj_strdup2_with_null(tdata->pool, &user_agent, tmp); h = (pjsip_hdr*) pjsip_generic_string_hdr_create(tdata->pool, &USER_AGENT, &user_agent); pjsip_msg_add_hdr(tdata->msg, h); return PJ_SUCCESS; } Take a look at these functions: https://www.pjsip.org/pjsip/docs/html/group__PJSIP__MSG__MSG.htm Best regards Franz Citycom Telekommunikation GmbH Gadollaplatz 1 8010 Graz | Austria ________________________________________ Von: pjsip <pjsip-bounces@lists.pjsip.org> im Auftrag von Andreas Wehrmann <a.wehrmann@yandex.com> Gesendet: Mittwoch, 27. November 2019 10:15 An: pjsip@lists.pjsip.org Betreff: [pjsip] PJSUA: Set From userpart when making a call Hey there, I was wondering whether there is a way to set the userpart of the From header when making a call with PJSUA's pjsua_call_make_call(). Looking at the code, and assuming I'm not overlooking something, it doesn't seem to be possible. From what I understand, the From header is constructed with what is configured in the account that is used for the call. My scenario is the following: I'm writing a gateway to translate between VoIP and a digital radio network. The gateway is to be registered with a PBX and is to forward calls from the radio network to the registrar by translating radio calls to SIP calls (and vice versa: SIP->radio network). Each participant of the radio network has their own ID (think: telephone number) and VoIP users must be able to call back radio users. For this reason I'd like to set the radio user's number in the From header header when calling the PBX, so that they see not only who is calling but also to give them the ability to call back. My current approach is to patch PJSUA by introducing another member to pjsua_call_setting (probably not the right place, but would serve my purposes) that takes a pj_str_t which contains the userpart to be put in the From header. In the function itself, it would check whether the string is not empty and take that string instead of what's configured with the account. Best Regards, Andreas Wehrmann _______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
AW
Andreas Wehrmann
Wed, Nov 27, 2019 10:47 AM

On 27.11.19 10:49, Skale Franz wrote:

Hi Andreas,
IMHO, you should be able to "rewrite" any header by using the pjsip_module mod_default_handler.

Best regards
Franz

Citycom Telekommunikation GmbH
Gadollaplatz 1
8010 Graz | Austria


Howdy,

Thanks for the suggestion but I don't really like this approach for this
particular use-case.
I know that the "From" header is set once when the INVITE session is
created and kept throughout the lifetime of the session.
Being able to influence what is set when the session is created seems to
me to be the cleaner and easier approach because
I'd need to do it only once and not need any extra modules which is why
I brought this up in the first place.

@Franz - Out of interest: Are you using pjsua or pjsip directly?

Best Regards,
Andreas

On 27.11.19 10:49, Skale Franz wrote: > Hi Andreas, > IMHO, you should be able to "rewrite" any header by using the pjsip_module mod_default_handler. > > Best regards > Franz > > Citycom Telekommunikation GmbH > Gadollaplatz 1 > 8010 Graz | Austria > > ________________________________________ > Howdy, Thanks for the suggestion but I don't really like this approach for this particular use-case. I know that the "From" header is set once when the INVITE session is created and kept throughout the lifetime of the session. Being able to influence what is set when the session is created seems to me to be the cleaner and easier approach because I'd need to do it only once and not need any extra modules which is why I brought this up in the first place. @Franz - Out of interest: Are you using pjsua or pjsip directly? Best Regards, Andreas
SF
Skale Franz
Wed, Nov 27, 2019 11:11 AM

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


Von: pjsip pjsip-bounces@lists.pjsip.org im Auftrag von Andreas Wehrmann a.wehrmann@yandex.com
Gesendet: Mittwoch, 27. November 2019 11:47
An: pjsip@lists.pjsip.org
Betreff: Re: [pjsip] PJSUA: Set From userpart when making a call

On 27.11.19 10:49, Skale Franz wrote:

Hi Andreas,
IMHO, you should be able to "rewrite" any header by using the pjsip_module mod_default_handler.

Best regards
Franz

Citycom Telekommunikation GmbH
Gadollaplatz 1
8010 Graz | Austria


Howdy,

Thanks for the suggestion but I don't really like this approach for this
particular use-case.
I know that the "From" header is set once when the INVITE session is
created and kept throughout the lifetime of the session.
Being able to influence what is set when the session is created seems to
me to be the cleaner and easier approach because
I'd need to do it only once and not need any extra modules which is why
I brought this up in the first place.

@Franz - Out of interest: Are you using pjsua or pjsip directly?

Best Regards,
Andreas


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

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

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 ________________________________________ Von: pjsip <pjsip-bounces@lists.pjsip.org> im Auftrag von Andreas Wehrmann <a.wehrmann@yandex.com> Gesendet: Mittwoch, 27. November 2019 11:47 An: pjsip@lists.pjsip.org Betreff: Re: [pjsip] PJSUA: Set From userpart when making a call On 27.11.19 10:49, Skale Franz wrote: > Hi Andreas, > IMHO, you should be able to "rewrite" any header by using the pjsip_module mod_default_handler. > > Best regards > Franz > > Citycom Telekommunikation GmbH > Gadollaplatz 1 > 8010 Graz | Austria > > ________________________________________ > Howdy, Thanks for the suggestion but I don't really like this approach for this particular use-case. I know that the "From" header is set once when the INVITE session is created and kept throughout the lifetime of the session. Being able to influence what is set when the session is created seems to me to be the cleaner and easier approach because I'd need to do it only once and not need any extra modules which is why I brought this up in the first place. @Franz - Out of interest: Are you using pjsua or pjsip directly? Best Regards, Andreas _______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
SF
Skale Franz
Wed, Nov 27, 2019 11:33 AM

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@lists.pjsip.org
Betreff: AW: [pjsip] 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


Von: pjsip pjsip-bounces@lists.pjsip.org im Auftrag von Andreas Wehrmann a.wehrmann@yandex.com
Gesendet: Mittwoch, 27. November 2019 11:47
An: pjsip@lists.pjsip.org
Betreff: Re: [pjsip] PJSUA: Set From userpart when making a call

On 27.11.19 10:49, Skale Franz wrote:

Hi Andreas,
IMHO, you should be able to "rewrite" any header by using the pjsip_module mod_default_handler.

Best regards
Franz

Citycom Telekommunikation GmbH
Gadollaplatz 1
8010 Graz | Austria


Howdy,

Thanks for the suggestion but I don't really like this approach for this
particular use-case.
I know that the "From" header is set once when the INVITE session is
created and kept throughout the lifetime of the session.
Being able to influence what is set when the session is created seems to
me to be the cleaner and easier approach because
I'd need to do it only once and not need any extra modules which is why
I brought this up in the first place.

@Franz - Out of interest: Are you using pjsua or pjsip directly?

Best Regards,
Andreas


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

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

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@lists.pjsip.org Betreff: AW: [pjsip] 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 ________________________________________ Von: pjsip <pjsip-bounces@lists.pjsip.org> im Auftrag von Andreas Wehrmann <a.wehrmann@yandex.com> Gesendet: Mittwoch, 27. November 2019 11:47 An: pjsip@lists.pjsip.org Betreff: Re: [pjsip] PJSUA: Set From userpart when making a call On 27.11.19 10:49, Skale Franz wrote: > Hi Andreas, > IMHO, you should be able to "rewrite" any header by using the pjsip_module mod_default_handler. > > Best regards > Franz > > Citycom Telekommunikation GmbH > Gadollaplatz 1 > 8010 Graz | Austria > > ________________________________________ > Howdy, Thanks for the suggestion but I don't really like this approach for this particular use-case. I know that the "From" header is set once when the INVITE session is created and kept throughout the lifetime of the session. Being able to influence what is set when the session is created seems to me to be the cleaner and easier approach because I'd need to do it only once and not need any extra modules which is why I brought this up in the first place. @Franz - Out of interest: Are you using pjsua or pjsip directly? Best Regards, Andreas _______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
AW
Andreas Wehrmann
Wed, Nov 27, 2019 12:06 PM

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@lists.pjsip.org
Betreff: AW: [pjsip] 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

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@lists.pjsip.org > Betreff: AW: [pjsip] 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