Skip to main content

mod_osp — Open Settlement Protocol Routing

mod_osp integrates FreeSWITCH with an Open Settlement Protocol (OSP) clearinghouse. On an inbound call, the osplookup dialplan application contacts the configured OSP server to obtain one or more authorized destinations, then populates channel variables that the dialplan uses to bridge the call. When a route fails, ospnext retrieves the next destination from the same authorization response without a new server round-trip. After the call ends, the module's reporting state handler automatically sends a usage indication back to the OSP server.

The module is appropriate when interconnect partners or a wholesale carrier require OSP-based authorization and CDR reporting. It supports SIP, H.323, IAX, and Skype signaling protocols and can operate in either direct (FreeSWITCH is the originating device) or indirect (FreeSWITCH sits behind an access proxy) work mode.

Loading the Module

The module is not present in the default vanilla modules.conf.xml and is not loaded automatically. Add the following line to autoload_configs/modules.conf.xml to enable it at startup, or load it at runtime from fs_cli:

load mod_osp

The module requires the OSP Toolkit (libosp) to be installed on the system before compiling. See the Dependencies section below.

Configuration: osp.conf.xml

mod_osp reads autoload_configs/osp.conf.xml. The file contains a <settings> block for global options and a <profiles> block where each <profile> describes one OSP provider connection. Up to eight service-point-url entries may be listed per profile.

Global Settings Parameters

ParameterPurposeAccepted ValuesDefault
debug-infoEnable verbose debug loggingenabled, disableddisabled
log-levelLog level used for debug messagesconsole, alert, crit, error, warning, notice, info, debugdebug
crypto-hardwareUse hardware crypto acceleration via OSP Toolkitenabled, disableddisabled
default-protocolSignaling protocol to use when the outbound module is not recognizedsip, h323, iax, skypesip
sipSIP endpoint: FreeSWITCH module and profile to use for SIP legsmodule="<name>" profile="<name>"module="sofia" profile="external"
h323H.323 endpoint module and profilemodule="<name>" profile="<name>"not set
iaxIAX endpoint module and profilemodule="<name>" profile="<name>"not set
skypeSkype endpoint module and profilemodule="<name>" profile="<name>"not set

Profile Parameters

ParameterPurposeAccepted ValuesDefault
service-point-urlURL of an OSP service point (repeatable, up to 8)HTTP or HTTPS URLrequired
device-ipIP:port FreeSWITCH reports to the OSP server as its own addressaddress:portnone
ssl-lifetimeSSL session lifetime in secondsinteger300
http-max-connectionsMaximum concurrent HTTP connections to the OSP server1100020
http-persistenceHTTP keep-alive duration in secondsinteger60
http-retry-delaySeconds to wait between HTTP retries0100
http-retry-limitMaximum number of HTTP retries01002
http-timeoutHTTP request timeout in milliseconds2006000010000
work-modeWhether FreeSWITCH is the edge device (direct) or sits behind a proxy (indirect)direct, indirectdirect
service-typeOSP service requestedvoice, npqueryvoice
max-destinationsMaximum number of destinations to request per authorization11212

Example excerpt from osp.conf.xml

<configuration name="osp.conf" description="OSP Module Configuration">
<settings>
<param name="debug-info" value="disabled"/>
<param name="log-level" value="info"/>
<param name="crypto-hardware" value="disabled"/>
<param name="sip" module="sofia" profile="external"/>
<param name="default-protocol" value="sip"/>
</settings>

<profiles>
<profile name="default">
<param name="service-point-url" value="http://127.0.0.1:5045/osp"/>
<param name="device-ip" value="127.0.0.1:5080"/>
<param name="ssl-lifetime" value="300"/>
<param name="http-max-connections" value="20"/>
<param name="http-persistence" value="60"/>
<param name="http-retry-delay" value="0"/>
<param name="http-retry-limit" value="2"/>
<param name="http-timeout" value="10000"/>
<param name="work-mode" value="direct"/>
<param name="service-type" value="voice"/>
<param name="max-destinations" value="12"/>
</profile>
</profiles>
</configuration>

Dialplan Applications

ApplicationPurposeArguments
osplookupQuery the OSP server for authorized routes and populate routing channel variables[profile-name]
ospnextAdvance to the next destination returned by a previous osplookup(none)

osplookup

Sends an OSP Authorization Request (AuthReq) to the named profile's service point. On success it sets osp_auto_route to a bridge string for the first destination and records the transaction handle and routing metadata in channel variables. If the optional profile-name argument is omitted, the profile named default is used.

<action application="osplookup" data="default"/>
<action application="bridge" data="${osp_auto_route}"/>

ospnext

Reads the transaction handle stored by osplookup and retrieves the next destination from the OSP server's earlier response. Updates osp_auto_route with the new bridge string and increments osp_route_count. Call this when a bridge fails and you want to try the next authorized route.

<action application="ospnext"/>
<action application="bridge" data="${osp_auto_route}"/>

API Commands

CommandPurposeSyntax
ospDisplay current module settings and profile statusosp status

fs_cli example

freeswitch@> osp status

The output lists global flags (debug-info, log-level, crypto-hardware, configured endpoints, default-protocol) followed by each profile's parameters and whether its OSP provider handle is active.

Channel Variables

Variables the module reads (input)

VariableSet / ReadPurpose
osp_source_deviceReadActual source device IP for indirect mode (overrides the caller network address)
osp_source_nidReadSource network ID passed to the OSP server
osp_custom_info_1osp_custom_info_8ReadUp to eight custom info strings included in the AuthReq
osp_networkid_userparamReadDestination network ID user parameter name for outbound URI construction
osp_networkid_uriparamReadDestination network ID URI parameter name for outbound URI
osp_outstring_userparamReadFixed outbound user parameter string
osp_outstring_uriparamReadFixed outbound URI parameter string
osp_user_phoneReadWhen true, appends user=phone to the outbound Request-URI
osp_outbound_proxyReadOutbound SIP proxy IP address

Variables the module sets (output)

VariableSet / ReadPurpose
osp_profile_nameSet/ReadName of the OSP profile used for this call; read back by ospnext and the reporting handler
osp_transaction_handleSet/ReadOSP Toolkit transaction handle (integer); read back by ospnext and the reporting handler
osp_transaction_idSet/ReadOSP transaction ID (uint64); read back by ospnext and the reporting handler
osp_lookup_statusSetReturn status of the osplookup application
osp_next_statusSetReturn status of the ospnext application
osp_route_totalSet/ReadTotal number of destinations returned by the OSP server; read back by ospnext and the reporting handler
osp_route_countSet/ReadIndex of the current destination (starts at 1, incremented by ospnext); read back by ospnext and the reporting handler
osp_auto_routeSetBridge string for the current destination; unset when no more routes remain
osp_termination_causeSet/ReadTermination cause code for the attempted destination; cleared when routing succeeds; read back by ospnext and the reporting handler

Dependencies

mod_osp requires the OSP Toolkit library (libosp) from TransNexus, which is not included in the FreeSWITCH source tree and is not built by default. The toolkit headers must be installed under osp/ (e.g., /usr/include/osp/osp.h) before the module can be compiled.

Source: src/mod/applications/mod_osp, conf/vanilla/autoload_configs/osp.conf.xml