Net::SIP(3pm)

✨ NAME ✨

Net::SIP β€” the Framework SIP situation, aka Voice Over IP, aka RFC3261 πŸ’… (it's a perl manual page, section 3pm, if you were wondering 🫢)


πŸŽ€ SYNOPSIS πŸŽ€

...

(yes bestie, the synopsis is literally three dots. it's giving mysterious. it's giving "read the DESCRIPTION, babe" πŸ’€)


πŸ’– DESCRIPTION πŸ’–

okay so Net::SIP is not one thing, it's a whole ensemble cast. It's made of packages that handle the SIP packets themselves, packages for transporting those packets, packages for processing them, and then β€” sitting on top like a crown πŸ‘‘ β€” a simplified layer for all the common tasks.

Also (and the original really does spell it "Addionally", we love a typo moment ✨) there's Net::SIP::Util, which gives you utility functions, and Net::SIP::Debug, which gives you a debugging layer that literally all of these packages use. The big one in there is the function invoke_callback, and it's the function used for all callbacks unless the documentation says otherwise. Bestie, this function is so versatile β€” it supports a whole variety of different callback styles. main character energy fr fr 🌟

If you're doing your first little simple application, start with Net::SIP::Simple, no notes, that's the move. And if that's no longer enough for you (growth! we love to see it 🌱), go look at the details of Net::SIP::Dispatcher, Net::SIP::Endpoint, Net::SIP::Register and Net::SIP::StatelessProxy. And yeah, those packages are each well documented on their own, but ngl the functionality and the design are best understood if you go look at how they get used in the source of Net::SIP::Simple. iykyk 🧚

πŸ¦‹ SIP packet handling πŸ¦‹

  • Net::SIP::Packet β€” the base class for handling SIP packets, and it gives you ways to parse, construct and manipulate SIP packets. the foundation, the blueprint, the mother πŸ’…
  • Net::SIP::Request β€” derived from Net::SIP::Packet, and it handles the request packets. It gives you ways to create special requests like ACK or CANCEL based on previous requests and responses, to create responses based on requests, and to do authorization of requests. multitasking queen πŸ‘‘
  • Net::SIP::Response β€” derived from Net::SIP::Packet, and it handles the response packets. short king, does its job 🌸
  • Net::SIP::SDP β€” handles the SDP bodies from SIP packets. Gives you ways to parse and construct these bodies, to get media information out of them, and to manipulate the SDP data for NAT etc. the glow-up artist of the packet world ✨

🌈 Transport of SIP packets 🌈

  • Net::SIP::Leg β€” encapsulates the socket for transport of packets. Gives you a way to find out if a target is reachable through this socket. And it prepares incoming, outgoing and forwarding packets by removing or adding headers like Via and Record-Route. the little packet stylist πŸŽ€
  • Net::SIP::Dispatcher β€” handles new packets coming in through a Net::SIP::Leg. Delivers outgoing packets through the appropriate Net::SIP::Leg. Handles timeouts and retransmission of outgoing packets, lookup of the appropriate leg through DNS, etc. the traffic controller of the whole vibe 🚦
  • Net::SIP::Dispatcher::Eventloop β€” a simple implementation of an event loop for handling socket events and timers. It can be replaced to integrate into other event loops, like Tk, Lib::Event or POE. modular? we stan 🫢

πŸ’œ Processing of SIP packets, application layer πŸ’œ

  • Net::SIP::Endpoint β€” implements a SIP endpoint (UAC,UAS). Gives you ways to INVITE or BYE calls, or to handle incoming calls. The calls themselves get handled by Net::SIP::Endpoint::Context. so many layers, so much lore πŸ“š
  • Net::SIP::Registrar β€” a simple implementation of a registrar. iconic, no further questions πŸ’…
  • Net::SIP::StatelessProxy β€” a simple implementation of a stateless proxy. And heads up: stateful proxies should probably be implemented by putting multiple Net::SIP::Endpoints together. teamwork makes the dream work 🧚
  • Net::SIP::Blocker β€” can block requests by method name with a custom error code. it's giving bouncer at the club 🚫✨
  • Net::SIP::ReceiveChain β€” can contain various objects for processing objects (yes, that's what it says, we're being faithful here 😭). Useful in connection with Net::SIP::Authorize.
  • Net::SIP::Redirect β€” works together with a registrar and redirects requests. go that way, bestie ➑️
  • Net::SIP::Authorize β€” if you put it into a Net::SIP::ReceiveChain it requests and checks authorization, and it gives only authorized requests to the next member of the chain. no VIP pass, no entry 🎟️

πŸ“ Simplified Layer for common tasks πŸ“

  • Net::SIP::Simple β€” gives you a simple layer for common tasks and tests, like sending a voice message to somebody, receiving a message, or even implementing an answer machine. And together with Net::SIP::Simple::RTP it's possible to handle simple RTP data (PCMU/8000). the starter pack, the beginner's blessing 🌸

πŸ’€ Error handling πŸ’€

Unless the docs say otherwise, the common way to propagate errors is to raise an exception, e.g. call die(). This can especially happen when you're parsing packets from strings β€” so unless you want to crash your application on bad input (and bestie, you do not πŸ™ˆ), you should catch these exceptions with eval.

no cap: unhandled exceptions are not a personality trait. wrap it in eval, protect your peace 🫢

πŸŽ€ EXPORTS πŸŽ€

By default, nothing is exported. nothing. zero. the bag is empty until you ask πŸ’…

There are various arguments for exporting:

  • :alias β€” exports constants as aliases for the Net::SIP::* packages, e.g. 'Simple' for 'Net::SIP::Simple', 'Registrar' for 'Net::SIP::Registrar', 'Packet' for 'Net::SIP::Packet', 'NATHelper_Client' for 'Net::SIP::NATHelper::Client' etc. nickname privileges only ✨
  • :util β€” exports everything (tag ':all') from Net::SIP::Util. the whole toolbox, dumped on the table 🧰
  • :debug β€” exports the default exports from Net::SIP::Debug. the default default, but make it debug πŸ›
  • :all β€” everything from ':debug', ':util' and ':alias'. yes, all of it. go off πŸ‘‘
  • rtp=MINPORT-MAXPORT or rtp:MINPORT-MAXPORT β€” sets the range of ports to be used for creating RTP sockets to MINPORT..MAXPORT. This affects Net::SIP::Util::create_rtp_sockets. keep your ports on a leash πŸŽ€
  • debug=LEVEL or debug:LEVEL β€” sets the Debugging level to LEVEL. turn the volume up πŸ”₯
  • string β€” strings where the first character is upper case will be interpreted as aliases for Net::SIP::* and it will try to export it. If the first character is lower case it will try to import it from Net::SIP::Util. case-sensitive behaviour, uppercase = export, lowercase = import, periodt πŸ’…

🌟 EXAMPLES 🌟

use Net::SIP 'invoke_callback'; # use Net::SIP::Util 'invoke_callback'
use Net::SIP ':debug';          # use Net::SIP::Debug
use Net::SIP ':util';           # use Net::SIP::Util ':all'

use Net::SIP ':alias';
Packet->new( ... );             # Net::SIP::Packet->new( ... )

# restrict rtp sockets from command line
perl -MNet::SIP=rtp:4000-4010 program.pl

look at those comments doing the explaining for us, we love a self-documenting moment πŸ˜­πŸ’–


πŸ› BUGS πŸ›

Support for TCP and SIPS is not, or not fully, implemented. that's the whole bug report. no elaboration. we respect the brevity πŸ’€


This module, and the modules in the Net::SIP hierarchy that are distributed together with this module, are copyright (c) 2006-2013, Steffen Ullrich. All Rights Reserved. These modules are free software. They may be used, redistributed and/or modified under the same terms as Perl itself. πŸ’–


and that's the whole page, bestie 🫢 this was written for perl v5.40.1 and dated 2025-12-07 β€” so yeah, shoutout to that version and that date, they're the ones holding this whole thing down πŸ‘‘βœ¨ bye mwah πŸ’…πŸŒΈ

πŸ“¦ where this page comes from