Net::SIP::StatelessProxy(3pm) | User Contributed Perl Documentation | Net::SIP::StatelessProxy(3pm) |
Net::SIP::StatelessProxy - Simple implementation of a stateless proxy
..
This package implements a simple stateless SIP proxy. Basic idea is that the proxy has either a single or two legs and that the packets are exchanged between those legs, e.g. packets incoming on one leg will be forwarded through the other leg.
Because this is a stateless proxy no retransmits will be done by the proxy.
If the proxy should work as a registrar too it should be put after a Net::SIP::Registrar in a Net::SIP::ReceiveChain.
While forwarding the proxy will be insert itself into the packet, e.g. it will add Via and Record-Route header while forwarding requests.
Additionally it will rewrite the Contact header while forwarding packets (see below), e.g. if the Contact header points to some client it will rewrite it, so that it points to the proxy and if it already points to the proxy it will rewrite it back so that it again points to the client.
A working default implementation is provided. If you want to implement your own: the callbacks gets the arguments contact, incoming_leg and outgoing_leg and force_rewrite. For rewriting a contact of user@host the legs will be Net::SIP::Leg objects. For rewriting the contact back outgoing_leg can be either a leg object and you should check if it is the expected leg. Or it is a scalar reference which you should fill with the leg extracted from the contact. The function should return the new contact or nothing if there was nothing to rewrite or the rewrite failed.
Note that some servers apply length limitations to the contact so the function should not return too long values.
If not defined, then RC4 will be used with a (pseudo)random key, 4 byte (pseudo)random seed and 4 byte MAC (md5) over seed and data.
Called from the dispatcher on incoming packets. The packet will be rewritten ("Via" and "Record-Route" headers added, Contact modified) and then the packet will be forwarded.
For requests it can determine the target of the forwarded packet by looking at the route or if no route it looks at the URI. For responses it looks at the next Via header.
Return values are like forward_outgoing in Net::SIP::Leg, e.g. it will return "[code,text]" on error or "()" on success, where success can be that the packet was rewritten or that there was no need to touch it.
2023-02-04 | perl v5.36.0 |