PJSIP: Change the user part of the Contact Header

Hello,

I try to change the user part of the contact header. I have configured a SIP trunk.
If I made an outbound call the INVITE message contains always the following contact header sip:asterisk@192.168.40.33.

I have trying some changes in the pjsip.conf but nothing works. I’ve got always the same contact header.

Can I change the user part in the contact header?

Thank a lot!

The only requirement on Contact headers is that they be recognizable by the entity that sets them and should route the response back to that entity. The user part does not have to represent anything meaningful in the real world.

What is the source of your requirement for semantics beyond those required by the RFCs?

Hello,

Sorry, I have seen the first post missing the contact header example. Asterisk always includes the following contact header sip:asterisk@192.168.1.11

I need the possibility to configure the value of the user port.
Especially I replace the value ‘asterisk’ with the user part of the from header.

For example, a SIP device with the phone number 12345 make an outgoing call to the SIP trunk.
The INVITE message of the SIP trunk should contains the following contact header sip:12345@192.168.1.11 instead of sip:asterisk@192.168.1.11.

There is no valid reason why this should be necessary. As I already said, your device seems to be reading more into the Contact header than it is allowed to read into it.

As David mentions there should be no reason to do this, and as a result there is no ability to configure or change this without code modifcations.

Does that mean there is not a way to change the hardset ‘asterisk’ to some other value?

I don’t believe we’ve added a way to set such a thing, no. If we did it would be mentioned in the documentation for the pjsip.conf configuration.

Would you happen to know where this is set in source code?

It would start from ast_sip_create_dialog_uac in res_pjsip.c and trickle down from there. I don’t know precisely where.

ok, thanks! I will try and locate.

This seams like what I’m after, I may be mistaken though, I tried setting and doesn’t seam to change anything. Do you know what this does?

			<configOption name="contact_user" default="">
				<synopsis>Force the user on the outgoing Contact header to this value.</synopsis>
				<description><para>
					On outbound requests, force the user portion of the Contact header to this value.
				</para></description>
			</configOption>

It appears to set the Contact user as documented, at least from looking at the code which is also in res_pjsip.c. I don’t know anything else about it.

Not sure what I miss-typed the first time, but this does work and changes the default ‘asterisk’ to the the value set.

Thanks,

Are you setting this in pjsip.conf or in the dialplan? We have a requirement from a carrier to dynamically set the contact for calls and I was looking for a way to do this.

I’d go with a supplier that implements SIP. The user part of the contact has no meaning to anything except the system that sent the Contact header. Often it doesn’t even have a meaning t that system.

For anyone wondering about this today it’s well documented.

;[mytrunk]
;type=registration
;contact_user=1234567890 ; On outgoing requests, force the user portion of the Contact
; header to this value (default: “”)

;[endpoint]
;contact_user=1234567890 ; On outgoing requests, force the user portion of the Contact
; header to this value (default: “”)

1 Like