[OpenSIPS-Users] check_source_address()

Mark Farmer farmorg at gmail.com
Thu Apr 25 10:11:05 EDT 2019


Thanks so much for helping with this.

I have applied the suggested config but the result is the same. OpenSIPS
routes the RE-INVITE to itself and it never gets routed back to the
Asterisk box.
If the 2nd Route header in the RE-INVITE is the IP of the other interface -
will that not always be the case? It's as though the 2nd Route header needs
to be changed to have the IP of the Asterisk server.

Sanitized RE-INVITE from provider:

INVITE sip:asterisk at my.host.name:5060 SIP/2.0
Max-Forwards: 67
Session-Expires: 1800;refresher=uac
Min-SE: 600
Supported: timer
Route:
<sip:pub.lic.ip.addr:5060;r2=on;lr;ftag=26907c86-afbc-4626-b8f2-fb901de15f17;did=7e4.6832a52>
Route:
<sip:10.98.0.53;r2=on;lr;ftag=26907c86-afbc-4626-b8f2-fb901de15f17;did=7e4.6832a52>
To: "Test User" <sip:01572729012 at pub.lic.ip.addr
>;tag=26907c86-afbc-4626-b8f2-fb901de15f17
From: <sip:+447872542107 at prov.ider.ip.addr>;tag=3765189400-415903398
Call-ID: 4dfc3a95-7488-448c-b015-438e806eccae
CSeq: 2 INVITE
Allow: UPDATE,INFO,OPTIONS,BYE,INVITE,ACK,CANCEL
Via:
SIP/2.0/UDP prov.ider.ip.addr:5060;branch=z9hG4bK66abd71f0399f743ce9ff2e625aeb636
Contact: <sip:+447872542107 at prov.ider.ip.addr:5060>
Content-Type: application/sdp
Accept: application/sdp
Content-Length: 263

v=0
o=sbc-uk-bs13b 454176 454177 IN IP4 prov.ider.ip.addr
s=sip call
c=IN IP4 prov.ider.ip.addr
t=0 0
a=sendonly
m=audio 42458 RTP/AVP 8 101
b=RR:3000
b=RS:1000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20
a=maxptime:40

-------------------------------------------

And the next Re-INVITE to itself:

INVITE
sip:10.98.0.53;r2=on;lr;ftag=26907c86-afbc-4626-b8f2-fb901de15f17;did=7e4.6832a52
SIP/2.0
Max-Forwards: 66
Session-Expires: 1800;refresher=uac
Min-SE: 600
Supported: timer
To: "Test User" <sip:01572729012 at 10.98.0.102
>;tag=26907c86-afbc-4626-b8f2-fb901de15f17
From: <sip:447872542107 at 10.98.0.53>;tag=3765189400-415903398
Call-ID: 4dfc3a95-7488-448c-b015-438e806eccae
CSeq: 2 INVITE
Allow: UPDATE,INFO,OPTIONS,BYE,INVITE,ACK,CANCEL
Via: SIP/2.0/UDP 109.234.226.243:5060;branch=z9hG4bKc156.ac684935.0
Via: SIP/2.0/UDP 147.152.17.42:5060
;branch=z9hG4bK66abd71f0399f743ce9ff2e625aeb636
Contact: <sip:+447872542107 at prov.ider.ip.addr:5060>
Content-Type: application/sdp
Accept: application/sdp
Content-Length: 263

v=0
o=sbc-uk-bs13b 454176 454177 IN IP4 prov.ider.ip.addr
s=sip call
c=IN IP4 prov.ider.ip.addr
t=0 0
a=sendonly
m=audio 42458 RTP/AVP 8 101
b=RR:3000
b=RS:1000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20
a=maxptime:40

-------------------------------------

Perhaps I'm missing the point?

Mark.


On Thu, 25 Apr 2019 at 14:10, Liviu Chircu <liviu at opensips.org> wrote:

> On 24.04.2019 20:10, Mark Farmer wrote:
> > Sure, I'll send the pcap off list.
>
> It seems you are performing an interface switching operation when
> routing out,
> which leads to a double Record-Route header.  While this is completely
> fine,
> you should be aware that OpenSIPS handles a double RR'ed mid-dialog
> request by
> routing the request to itself exactly once, as it consumes the top-level
> Route
> header field.
>
> So, you definitely don't have to provision and mark OpenSIPS as a trunk,
> since
> that will likely break some other logic of your script (e.g. I see it
> now returns
> 404 in the pcap).  Rather, just extend your possible sources of traffic
> and keep
> applying loose_route() to those mid-dialog requests, then route them out:
>
> if (check_source_address("1","$avp(trunk_attrs)")) {
>      # request comes from trunks
>      xlog ("MF - $rm FROM $avp(trunk_attrs)");
>      setflag(IS_TRUNK);
> } else if (has_totag() && is_myself("$si")) {
>      setflag(IS_MYSELF);
> } else {
>      send_reply("403", "Forbidden");
>      exit;
> }
>
> if (has_totag()) {
>      ...
>      if (!loose_route())
>          send_reply("404", "Not Here");
>      else
>          t_relay();
>      exit;
> }
>
> Regards,
>
> --
> Liviu Chircu
> OpenSIPS Developer
> http://www.opensips-solutions.com
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>


-- 
Mark Farmer
farmorg at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20190425/97f413af/attachment.html>


More information about the Users mailing list