.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::SIP::StatelessProxy 3pm" .TH Net::SIP::StatelessProxy 3pm "2023-09-29" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::SIP::StatelessProxy \- Simple implementation of a stateless proxy .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&.. .SH "DESCRIPTION" .IX Header "DESCRIPTION" This package implements a simple stateless \s-1SIP\s0 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. .PP Because this is a stateless proxy no retransmits will be done by the proxy. .PP If the proxy should work as a registrar too it should be put after a Net::SIP::Registrar in a Net::SIP::ReceiveChain. .PP While forwarding the proxy will be insert itself into the packet, e.g. it will add \fBVia\fR and \fBRecord-Route\fR header while forwarding requests. .PP Additionally it will rewrite the \fBContact\fR header while forwarding packets (see below), e.g. if the \fBContact\fR 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. .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .ie n .IP "new ( %ARGS )" 4 .el .IP "new ( \f(CW%ARGS\fR )" 4 .IX Item "new ( %ARGS )" Creates a new stateless proxy. With \f(CW%ARGS\fR the behavior can be influenced: .RS 4 .IP "dispatcher" 8 .IX Item "dispatcher" The Net::SIP::Dispatcher object managing the proxy. .IP "rewrite_contact" 8 .IX Item "rewrite_contact" Callback which is used in rewriting \fBContact\fR headers. If one puts user@host in it or if it is called with \fBforce_rewrite\fR then it should rewrite it and if one puts something without '@' it should try to rewrite it back or return \fB()\fR if it cannot be rewritten back. .Sp A working default implementation is provided. If you want to implement your own: the callbacks gets the arguments \fBcontact\fR, \&\fBincoming_leg\fR and \fBoutgoing_leg\fR and \fBforce_rewrite\fR. For rewriting a contact of user@host the legs will be Net::SIP::Leg objects. For rewriting the contact back \fBoutgoing_leg\fR 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. .Sp Note that some servers apply length limitations to the contact so the function should not return too long values. .IP "rewrite_crypt" 8 .IX Item "rewrite_crypt" If you want to have your own encryption for the rewritten contact you should defined a subroutine here, which gets \f(CW\*(C`data\*(C'\fR as the first and \f(CW\*(C`dir\*(C'\fR as the second parameter and should return the de/encrypted data. If \f(CW\*(C`dir\*(C'\fR is +1 it should encrypt and on \-1 it should decrypt. The optional third argument \f(CW\*(C`add2mac\*(C'\fR should be included in calculation and verification of the \s-1MAC.\s0 The function should return the encrypted/decrypted data or undef if decryption failed because the \s-1MAC\s0 did not match. .Sp If not defined, then \s-1RC4\s0 will be used with a (pseudo)random key, 4 byte (pseudo)random seed and 4 byte \s-1MAC\s0 (md5) over seed and data. .IP "nathelper" 8 .IX Item "nathelper" Optional Net::SIP::NATHelper::* object. When given it will be used to do \s-1NAT,\s0 e.g. if the incoming and outgoing legs are different it will rewrite the \s-1SDP\s0 bodies to use local sockets and the nathelper will transfer the \s-1RTP\s0 data between the local and the original sockets. .IP "force_rewrite" 8 .IX Item "force_rewrite" Usually the contact header will only be rewritten, if the incoming and outgoing leg are different. With this option one can force the rewrite, even if they are the same. .RE .RS 4 .RE .SH "METHODS" .IX Header "METHODS" .IP "receive ( \s-1PACKET, LEG, FROM\s0 )" 4 .IX Item "receive ( PACKET, LEG, FROM )" \&\s-1PACKET\s0 is the incoming packet, \&\s-1LEG\s0 is the Net::SIP::Leg where the packet arrived and \s-1FROM\s0 is the \f(CW"ip:port"\fR of the sender. .Sp Called from the dispatcher on incoming packets. The packet will be rewritten (\f(CW\*(C`Via\*(C'\fR and \f(CW\*(C`Record\-Route\*(C'\fR headers added, \&\fBContact\fR modified) and then the packet will be forwarded. .Sp For requests it can determine the target of the forwarded packet by looking at the route or if no route it looks at the \s-1URI.\s0 For responses it looks at the next \fBVia\fR header. .IP "do_nat ( \s-1PACKET, INCOMING_LEG, OUTGOING_LEG\s0 )" 4 .IX Item "do_nat ( PACKET, INCOMING_LEG, OUTGOING_LEG )" This will be called from \fBreceive\fR while forwarding data. If \fBnathelper\fR is defined it will be used to rewrite \s-1SDP\s0 bodies and update nathelpers internal states to forward \s-1RTP\s0 data. .Sp Return values are like \fBforward_outgoing\fR in Net::SIP::Leg, e.g. it will return \f(CW\*(C`[code,text]\*(C'\fR on error or \f(CW\*(C`()\*(C'\fR on success, where success can be that the packet was rewritten or that there was no need to touch it. .SH "UNDOCUMENTED METHODS" .IX Header "UNDOCUMENTED METHODS" .IP "idside2hash" 4 .IX Item "idside2hash"