Pjsip identify match question

Hello,
I am trying to match ip address and header at the same time. Is it possible to do it?
This is how i tried:

[transport-udp205]
type = transport
protocol = udp
bind = 0.0.0.0:5060

[transport-udp206]
type = transport
protocol = udp
bind = 0.0.0.0:5070

;-------------205----------------
[kamailio205-aor]
type = aor
contact = sip:185.88.7.138:5060

[kamailio205]
type = identify
endpoint = kamailio205
match = 185.88.7.138
match_header =  Preference: 1

;match_header = /\.\*: \.\*/
;match_header = /CSeq: \.\*/
;match_header=From: /<sip:31291142665@185\.88\.7\.138>/
;match_header=To: /<sip:\\.\\*:5060\\.\\*/

;t38_udptl = yes
;t38_udptl_ec = redundancy

[kamailio205]
type = endpoint
transport = transport-udp205
fax_detect=yes
aors = kamailio205-aor
identify_by = header, ip
context = netgsm205
dtmf_mode = rfc4733
disallow = all
;allow = g729
allow = alaw
allow = ulaw
allow = gsm
allow = g729
;allow=g722
;allow=h263
;allow=h263p
;qualify=yes
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 121
direct_media = no
inband_progress = yes
language = tr
;-------------205----------------

;-------------206----------------

[kamailio206-aor]
type = aor
contact = sip:185.88.7.138:5070

[kamailio206]
type = identify
endpoint = kamailio206
match = 185.88.7.138
match_header = Preference: 2
;match_header = Preference: 2
;match_header = /\.\*: \.\*/
;match_header=From: /<sip:3129112665@185\.88\.7\.138>/
;match_header = User-Agent: Something Unique 1.0.0
;<sip:3129112665@185\.88\.7\.138>
;match_header=To: /<sip:\\.\\*:5070\\.\\*/
;match_header=To: /^"\\.\\*"<sip:\\.\\*@\\.\\*>$/
;match_header = "Contact=sip:*.*:5070"
;match_header = To: /"05550834505"<sip:05550834505@185.88.7.138>/
;match_header=From: /<sip:alice@127\\.0\\.0\\.1>/
[kamailio206]
type = endpoint
transport = transport-udp206
aors = kamailio206-aor
identify_by = header, ip
context = netgsm206
dtmf_mode = rfc4733
rewrite_contact = yes
disallow = all
;allow = g729
allow = alaw
allow = ulaw
allow = gsm
allow = g729
;allow=g722
;allow=h263
;allow=h263p
;qualify=yes
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 121
direct_media = no
inband_progress = yes
language = tr
;-------------206----------------

I tried many options but no success. I have to match ip address so i can not give it up. And i need to match header as well.

Thank you.

No. If either the IP or the header match, then it matches.

Hello,
If i use only header_match, then i am getting No matching endpoint found from OPTIONS requests.

Can i write header_match with regex for bot invite and options.

And what is the format for regex?

Thank you.

I don’t speak regex so can’t help with that.

But is it possible to write it. Does pjsip header_match understand regex?
Found this btw https://gerrit.asterisk.org/c/asterisk/+/9721/
But could not manage to do it this way.

Yes, it supports regex[1].

[1] Asterisk 20 Configuration_res_pjsip_endpoint_identifier_ip - Asterisk Project - Asterisk Project Wiki

Hello,
I am trying to use match_header.
This is what i tried so far;

match_header = To: <sip:xxx.xxx.xxx.xxx:5070>
;match_header= To: /<sip:.:5070./
;match_header= To: /<sip:.:5070./

Even if i am writing regex wrong, isn’t this should work match_header = To: <sip:xxx.xxx.xxx.xxx:5070>
Sip package is something like this. I am writing exact value to match_header.

image

I can’t see what i am doing wrong. Need help with this.
Asterisk version: Asterisk 16.30.0

Edit: My main objective is handling ip:port info.
If i use something like this it works.
match_header = To: /.sip:xxx.xxx.xxx.xxx./
or
match_header = To: <sip:xxx.xxx.xxx.xxx>

But if i add port info ;
match_header = To: /.sip:xxx.xxx.xxx.xxx:5060./
or
match_header = To: <sip:xxx.xxx.xxx.xxx:5060>
It does not work.

Port is most important part for me.

Thank you.

Hi

Please upgrade as Asterisk 16 is very old

also what are you trying to acomplich as matching on To: sound extreamly wrong
normaly you do that part in the dialplan
match is to difirendicate who is calling and not what they are dialing

can you please descripe what you are trying to do, as it sound like you have misunderstand key parts of asterisk

Hello,
What I’m trying to do is, I want to receive a call at the “A” endpoint if it comes to port 5060, and to the “B” endpoint if it comes to port 5070.
But there is this part to; I have to give response OPTIONS packages as well.
And calls are coming from fixed IP address.

Sender IP address My IP address
xxx.xxx.xxx.xxx:5060 —>>> xxx.xxx.xxx.xxx:5070
I need to receive this call in the endpoint “A”

Sender IP address My IP address
xxx.xxx.xxx.xxx:5060 —>>> xxx.xxx.xxx.xxx:5060
I need to receive this call in the endpoint “B”

If this possible, i am open to every possible solution.

Thank you.

What I find interesting here:
The threadstarter defined two transports, one with port 5060 and one with 5070. He assigned one to one endpoint and the other to another one.

I always thought that if someone does that it would match the corresponding endpoint because of the assigned transport.

Edit:
I just read the docs and the transport of an endpoint is only for sending sip messages, not for receiving.

That is a non common way of doing seperation
I’ll recoment that you do this in stead

send calls to

<sip:205@XXX.XXX.XXX.XXX>

or to

<sip:206@XXX.XXX.XXX.XXX>

and then in the dialplan make a


exten => 205,1,NoOp(Call to A)
exten => 206,1,NoOp(Call to B)
```