Net::SIP::NATHelper::Base(3pm) | User Contributed Perl Documentation | Net::SIP::NATHelper::Base(3pm) |
Net::SIP::NATHelper::Base - rewrite SDP and transport RTP for NAT
This module helps with doing NAT. It is implicitly used in do_nat from Net::SIP::StatelessProxy.
It cares about the rewriting the SDP bodies, forwarding RTP data for active sessions and expiring sessions.
NAT_BASIC consists of "<[ CALLID, CSEQ, IDFROM, IDTO, URI_FROM, URI_TO ]">.
IDFROM and IDTO represent the sides of the session, while SIDE helps to pick the right side for allocation, e.g. if SIDE is 0 the sockets will be allocated on the IDFROM side, if it is 1 it will be on the IDTO side. Thus for Requests SIDE will be 0, while for responses it will be 1.
CALLID and CSEQ are used to identify the SIP transaction, for which the NAT will be done, while IDSIDE is either IDFROM or IDTO (see below) depending on the side, where the packet came in.
URI_FROM and URI_TO are primarily for information.
The methode will return the \@list of new media in the format needed by replace_media_listen in Net::SIP::SDP, e.g tuples of "[ip,base_port]".
If the allocation of sockets failed (because of resource constraints) it will return undef. This will usually cause the caller do simply not forward the packet and wait for the reetransmit (at least for UDP).
IDFROM and IDTO represent the sides of the session, e.g. for the activation to succeed there had to be an allocate_sockets call for each of these sides.
PARAM is an optional hash reference. If given it will be added as user information to the new session and given back in the information hash returned by close_session etc. URI_FROM and URI_TO will be added to PARAM as "uri_from" and "uri_to".
The method returns two items: The first is information about the session like returned in close_session, the second is a flag, which is true, if the activation was for an already astablished session.
The method is usually called whenever a SDP body is given and on ACK requests.
This will cause the close of the session described by the arguments (which have the same meaning like in activate_session). Usually called for BYE or CANCEL requests. For CANCEL it will be called with CSEQ (because it should cancel a specific transaction) while for BYE it will called with CSEQ undef, because it should end all sessions in this call.
It will return a list with infos about all closed sessions. Each of these infos is a reference to a hash with the following items:
Stateless proxies should forward the packet even if the session did not exist, because the packet might be a retransmit referring to an already closed session.
With %ARGS the behavior can be customized:
Each of these callbacks should be invoked once the file descriptor gets readable and the callback will then forward the received packet to the other side of the session.
To use this function you might need to know the interna of the session objects (see source code), but in most cases it is enough to know, that session objects have a method info_as_hash which will return infos about the session as hash like described in close_session.
Returns reference to array of allocated media, each item in the array is "[ ADDR,BASE_PORT,\@SOCKS,\@TARGETS ]", where ADDR is NEW_ADDR, BASE_PORT the base port for the allocated sockets, @SOCKS the allocated sockets and @TARGETS the "sockaddr" of the original targets, e.g. where it needs to forward the data received on the sockets.
If not all necssary sockets could be allocated it will allocate none and return "()".
This method might be redefined to better control resource allocation or to cache temporally unused resources together with unget_rtp_sockets.
Together with get_rtp_sockets it could be redefined to not destroy resources but to cache them for future use.
This value can be used to determine if expire needs to be called at all.
2023-02-04 | perl v5.36.0 |