On 25.10.2022 19:11, Ross McKillop via Users wrote:

I would have expected $socket_in(port) to contain the actual port that was used (53235) and $socket_in(advertised_port) to contain the port that is advertised as the listening port for that socket (e.g. 7700) - however $socket_in(port) contains 7700 and $socket_in(advertised_port) is null.

Is this the intended behaviour and, if so, is there any way to access the *actual* destination port that was used (even if it’s ephemeral)?

Any advice anyone can offer would be much appreciated :)

Hey, Ross!

Regarding $socket: there is the READ-ONLY $socket_in [1], concerning the ingress traffic and $socket_out [2], READ-WRITE and fully optional, controlling the egress traffic.  And an OpenSIPS listener MAY additionally have an "advertised" component, for scenarios where it's sitting behind a NAT.

I can't think of many good ways of fetching/printing the ephemeral source port allocated by the Operating System for a TCP connection:

* Request time: you cannot print it while processing the INVITE since the source port is not even allocated until you run the very last t_relay() * Reply time: replies will be routed using topmost Via, so *maybe* you have a chance at printing this port, by looking at the topmost Via header (OpenSIPS-generated), using transformations [3].  Even if OpenSIPS strips this header during loose_route(), you should still have access to it thanks to the "SIP message lumps" lazy evaluation mechanism.

Still: may I ask why you need the "egress ephemeral source port" information?  Maybe there is an alternative to the problem itself!

[1]: https://opensips.org/Documentation/Script-CoreVar-3-4#socket_in
[2]: https://opensips.org/Documentation/Script-CoreVar-3-4#socket_out
[3]: https://www.opensips.org/Documentation/Script-Tran-3-4

Best regards,

--
Liviu Chircu
www.twitter.com/liviuchircu  |www.opensips-solutions.com
OpenSIPS eBootcamp 5-16 Dec |www.opensips.org/training
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to