---
name: "Net::SIP::NATHelper::Server"
section: "3pm"
platform: "linux"
package: "libnet-sip-perl"
version: "0.838-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Net::SIP::NATHelper::Server"
---

# Net::SIP::NATHelper::Server(3pm)

server for Net::SIP::NATHelper::Client

## NAME

Net::SIP::NATHelper::Server - server for Net::SIP::NATHelper::Client

## DESCRIPTION

This module is a wrapper around Net::SIP::NATHelper::Base and will receive it's instructions from Net::SIP::NATHelper::Client using RPC via sockets.

## CONSTRUCTOR

- new ( \[ HELPER \], @FDS )

  Will create an object which listens on all file descriptors given in FDS for RPC from clients.

  If HELPER is given and a Net::SIP::NATHelper::Base object or derived it will be used, otherwise the helper will be created.

## METHODS

- do\_command ( FD )

  Called when FD is available for reading. Calls **accept** on FD and reads the RPC packet from the resulting file descriptor, executes it and returns result back.

  Currently implemented commands are "allocate","activate" and "close" which will map to the local methods **allocate\_sockets**, **activate\_session** and **close\_session**.

  One might redefine or add commands by changing `"$self->{commands}"`. The key of this hash reference is the command name and the value is the callback.

  Unknown commands will be ignored, e.g nothing returned.

- loop

  This will loop over all file descriptors it gets from **callbacks** in Net::SIP::NATHelper::Base and the file descriptors for the RPC sockets.

  When file descriptors gets available for reading it will execute the callbacks, e.g. forward the RTP data or call **do\_command**. In regular intervals it will call **expire** from Net::SIP::NATHelper::Base to expire the RTP sockets and sessions.

- allocate\_sockets ( ... )

  Calls **allocate\_sockets** of the local Net::SIP::NATHelper::Base object. Takes and returns the same arguments.

- activate\_session ( ... )

  Calls **activate\_session** of the local Net::SIP::NATHelper::Base object. Takes the same arguments and returns 1 if the session was newly activated, -1 if it was activated before and false if activation failed. Updates callbacks into the event loop.

- close\_session ( ... )

  Calls **activate\_session** of the local Net::SIP::NATHelper::Base object. Takes the same arguments and returns the number of closed sessions. Updates callbacks into the event loop.

- expire ( ... )

  Calls **expire** of the local Net::SIP::NATHelper::Base object. Takes the same arguments and returns the number of expired sessions. Updates callbacks into the event loop if necessary.

## BUGS

The local event loop should be pluggable, so that other implementations could be used. Right now it's a hard coded loop using select.
