Net::S...Request(3pm)
๐ Net::S...Request โ aka the SIP request wrangler ๐
okay so bestie, this is Net::SIP::Request, a lil User Contributed Perl Documentation moment. It's the class you reach for when you've got SIP request packets and you need to, like, do stuff with them. ๐
โจ NAME โจ
Net::SIP::Request โ handling SIP request packets. that's the whole vibe. requests. handled. ๐
๐ธ SYNOPSIS ๐ธ
my $req = Net::SIP::Request->new( 'INVITE',... );
my $ack = $req->create_ack();
literally two lines and you're already out here making ACKs. iconic. ๐
๐ฆ DESCRIPTION ๐ฆ
So Net::SIP::Request is a subclass of Net::SIP::Packet โ like, it inherited the whole Packet family's genetics and then got its own extra personality. ๐งฌ
What's it bring to the table? Methods to:
- create responses to requests ๐
- authorize requests ๐
that's it, that's the job. no cap.
๐ฅ EXAMPLES ๐ฅ
okay this is the part where it all clicks, so pay attention bestie:
# create INVITE request
my $invite = Net::SIP::Request->new(
'INVITE', 'sip:you@example.com',
{ from => ..., to => ... },
Net::SIP::SDP->new( ... )
);
# somehow send request and retrieve response $resp
...
if ( $resp->code eq '401' or $resp->code eq '407' ) {
# need to authorize request
$invite->authorize( $resp, [ username, password ] );
# somehow send again and retrieve response $resp
...
}
if ( $resp->code ~m{^[2345]\d\d} ) {
# got final response, send ACK
my $ack = $invite->create_ack( $resp );
# somehow send $ack
...
}
so you build the INVITE, you send it (the ... is you, doing the sending, no judgment ๐), and then:
- got a
401or407? that's the server being like "authorize first pls" โ hit it withauthorizeand try again ๐ช - got a final response matching
^[2345]\d\d? slay, that's final โ build your ACK withcreate_ackand yeet it back. โ
๐ CONSTRUCTOR ๐
Inherited from Net::SIP::Packet. See there. ๐ (it's not keeping secrets, it's just literally the parent's constructor)
๐ METHODS ๐
methodโ gets you the method of the request. like, which one is it. the method. that one. ๐ฎuriโ gets you the URI part of the request. ๐บ๏ธset_uri ( STRING )โ sets the URI of the request to STRING. boom, changed. โจset_cseq ( NUMBER )โ sets the sequence number of the"CSeq"header to NUMBER. (yes the original says "if", we all know it means "of", moving on ๐ซถ)create_ack ( RESPONSE )โ returns aNet::SIP::Requestobject for an ACK request, for that specific situation whereNet::SIP::ResponseRESPONSE was the reply you got for packet$self. it's giving "okay noted, acknowledging." ๐ฌcreate_cancelโ returns aNet::SIP::Requestobject that cancels the request in$self. the โ "actually, never mind" of SIP.create_response ( CODE, [MSG,] [ \%HEADER, BODY ] )โ returns aNet::SIP::Responsepacket for the received request$self, with the numerical code CODE and text message MSG. the response's header gets based on the request, but you can add to it or override it with %HEADER. ๐ง
and here's the cute part: if MSG isn't given (like, the argument is missing, or the second argument is already the %HEADER), then a builtin message for the code gets used instead. no MSG, no problem. ๐
for all the deets on %HEADER and BODY, go look at new_from_parts in Net::SIP::Packet.
authorize ( RESPONSE, AUTH )โ tries to authorize request$selfbased on the info in RESPONSE (which is a401or407"Authorization required" response, so you know it's that kind of party) plus AUTH. ๐โจ
and AUTH can be any of these three shapes, depending on your situation:
[ user,pass ]โ when one global authorization info exists for all realms ๐{ realm1 => [ user1,pass1 ], realm2 => [ user2,pass2 ],... }โ when you've got different credentials for different realms ๐๏ธ- a callback,
callback(realm)->[user,pass]โ when you want to compute it on the fly ๐ช
the realms that need authorizing get read straight out of RESPONSE, so you don't have to go hunting.
โ ๏ธ heads up: the request $self gets modified in-place. no copy, no undo. if a modification actually happened โ like, if (parts of) the authorization requests could be resolved โ it returns TRUE, otherwise FALSE.
also important, no cap: this only supports RFC2617 with md5 and empty qop or qop'auth'. it does NOT do md5-sess or qops like'auth-int'. so don't come at it with those, it will not eat. ๐
๐ THE SIGN-OFF ๐
and that's the page, bestie! ๐ซถ this was perl v5.40.1, dated 2025-12-07, brought to you by the User Contributed Perl Documentation girlies. go forth and handle those requests. periodt. ๐๐
๐ฆ where this page comes from
- ubuntu resolute: libnet-sip-perl 0.840-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-sip-perl 0.840-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms