C# Class SIPSorcery.AppServer.DialPlan.DialStringParser

This class builds a list of calls from a dial plan Dial string. The dial string is an evolving thing and depending on the type of dial plan it can take different forms. Some forms are specific to a certain type of dial plan, for example an Asterisk formatted dial plan can have a long list of options to pass in the dial string whereas in a Ruby dial plan there are more elegant mechanisms. Each different type of dial string needs to be described here or there will be processing errors as the different options get overlooked or forgotten. The original dial strings from the Asterisk formatted dial plans can only forward to a SINGLE destination and use a form of: Dial(username,password,${EXTEN}@sip.provider.com[,FromUser[,SendToSocket]]) The second iteration dial string commands can forward to MULTIPLE destinations and use a form of: Dial(123@provider1&provider2|[email protected]|provider4&456@provider5[,trace]) The From header processing involves special behaviour as it can be customised in different ways. The rules are: 1. By default the From header on the request that initiated the forward will be passed through, 2.
Show file Open project: sipsorcery/sipsorcery Class Usage Examples

Public Properties

Property Type Description
PublicIPAddress System.Net.IPAddress

Public Methods

Method Description
DialStringParser ( SIPTransport sipTransport, string owner, SIPAccount sipAccount, List sipProviders, SIPAssetGetDelegate getSIPAccount, SIPAssetGetListDelegate getRegistrarBindings, GetCanonicalDomainDelegate getCanonicalDomainDelegate, SIPMonitorLogDelegate logDelegate, string dialplanName ) : NUnit.Framework

GetForwardsForLocalLeg ( SIPRequest sipRequest, SIPAccount sipAccount, List customHeaders, string customContentType, string customContent, string options, string callersNetworkId, string fromDisplayName, string fromUsername, string fromHost, CRMHeaders contact ) : List

Creates a list of calls based on the registered contacts for a user registration.

GetForwardsForRedirect ( SIPURI redirectURI, SIPCallDescriptor callDescriptor ) : List
ParseDialString ( DialPlanContextsEnum dialPlanType, SIPRequest sipRequest, string command, List customHeaders, string customContentType, string customContent, string callersNetworkId, string fromDisplayName, string fromUsername, string fromHost, CRMHeaders contact, CustomerServiceLevels serviceLevel ) : Queue>

Parses a dial string that has been used in a dial plan Dial command. The format of the dial string is likely to continue to evolve, check the class summary for the different formats available. This method determines which format the dial string is in and passes off to the appropriate method to build the call list.

SubstituteRequestVars ( SIPRequest request, string substituteString ) : string

Substitutes the special characters with variables from the SIP request.

Private Methods

Method Description
GetForwardsForExternalLeg ( SIPRequest sipRequest, SIPURI callLegURI, string customContentType, string customContent, string fromDisplayName, string fromUsername, string fromHost, CRMHeaders contact ) : SIPCallDescriptor

Can't be used for local destinations!

IsURIInQueue ( Queue callQueue, string callURI ) : bool
ParseAsteriskDialString ( string data, SIPRequest sipRequest ) : SIPCallDescriptor

Builds the call list based on the original dial plan SwitchCall format. This will result in only a single call leg with a single forward destination. Examples of the dial string in a dial plan command are: exten = number,priority,Switch(username,password,new number[,From[,SendTo[,Trace]]]) or sys.Dial("username,password,${dst}@provider")

ParseFromHeaderOption ( string customFromHeader, SIPRequest sipRequest, string username, string forwardURIHost ) : SIPFromHeader

The From header on forwarded calls can be customised. This method parses the dial plan option for the From header field or lack of it field and produces the From header string that will be used for forwarded calls.

ParseScriptDialString ( SIPRequest sipRequest, string command, List customHeaders, string customContentType, string customContent, string callersNetworkId, string fromDisplayName, string fromUsername, string fromHost, CRMHeaders contact ) : Queue>

Processes dial strings using the multi-legged format. Each leg is separated from the proceeding one by the | character and each subsequent leg will only be used if all the forwards in the preceeding one fail. Within each leg the forwards are separated by the & character. Example: Dial(123@provider1&provider2|[email protected]|provider4&456@provider5[,trace])

Method Details

DialStringParser() public method

public DialStringParser ( SIPTransport sipTransport, string owner, SIPAccount sipAccount, List sipProviders, SIPAssetGetDelegate getSIPAccount, SIPAssetGetListDelegate getRegistrarBindings, GetCanonicalDomainDelegate getCanonicalDomainDelegate, SIPMonitorLogDelegate logDelegate, string dialplanName ) : NUnit.Framework
sipTransport SIPSorcery.SIP.SIPTransport
owner string
sipAccount SIPSorcery.SIP.App.SIPAccount The SIP account that was called and resulted in the dialplan executing. Will be null if the /// execution was not initated by a call to a SIP account call such as if a web callback occurs.
sipProviders List
getSIPAccount SIPAssetGetDelegate
getRegistrarBindings SIPAssetGetListDelegate
getCanonicalDomainDelegate GetCanonicalDomainDelegate
logDelegate SIPMonitorLogDelegate
dialplanName string Used to ensure that a call leg cannot create a B2B call that loops into the same dial plan.
return NUnit.Framework

GetForwardsForLocalLeg() public method

Creates a list of calls based on the registered contacts for a user registration.
public GetForwardsForLocalLeg ( SIPRequest sipRequest, SIPAccount sipAccount, List customHeaders, string customContentType, string customContent, string options, string callersNetworkId, string fromDisplayName, string fromUsername, string fromHost, CRMHeaders contact ) : List
sipRequest SIPSorcery.SIP.SIPRequest
sipAccount SIPSorcery.SIP.App.SIPAccount
customHeaders List
customContentType string
customContent string
options string
callersNetworkId string
fromDisplayName string
fromUsername string
fromHost string
contact SIPSorcery.SIP.App.CRMHeaders
return List

GetForwardsForRedirect() public method

public GetForwardsForRedirect ( SIPURI redirectURI, SIPCallDescriptor callDescriptor ) : List
redirectURI SIPSorcery.SIP.SIPURI
callDescriptor SIPSorcery.SIP.App.SIPCallDescriptor
return List

ParseDialString() public method

Parses a dial string that has been used in a dial plan Dial command. The format of the dial string is likely to continue to evolve, check the class summary for the different formats available. This method determines which format the dial string is in and passes off to the appropriate method to build the call list.
public ParseDialString ( DialPlanContextsEnum dialPlanType, SIPRequest sipRequest, string command, List customHeaders, string customContentType, string customContent, string callersNetworkId, string fromDisplayName, string fromUsername, string fromHost, CRMHeaders contact, CustomerServiceLevels serviceLevel ) : Queue>
dialPlanType DialPlanContextsEnum The type of dialplan that generated the Dial command.
sipRequest SIPSorcery.SIP.SIPRequest The SIP Request that originated this command. Can be null if the call was not initiated by a SIP request such as /// by a HTTP web service.
command string The Dial command string being parsed.
customHeaders List If non-empty contains a list of custom SIP headers that will be added to the forwarded request.
customContentType string If set indicates a custom content type header is required on the forwarded request and it /// overrides any other value.
customContent string If set indicates a custom body is required on the forwarded request and it /// overrides any other value.
callersNetworkId string If the call originated from a locally administered account this will hold the account's /// networkid which is used to determine if two local accounts are on the same network and therefore should have their SDP /// left alone.
fromDisplayName string If set will be used the From header display name instead of the value from the originating SIP request.
fromUsername string If set will be used the From header user name instead of the value from the originating SIP request.
fromHost string If set will be used the From header host instead of the value from the originating SIP request.
contact SIPSorcery.SIP.App.CRMHeaders
serviceLevel CustomerServiceLevels
return Queue>

SubstituteRequestVars() public static method

Substitutes the special characters with variables from the SIP request.
public static SubstituteRequestVars ( SIPRequest request, string substituteString ) : string
request SIPSorcery.SIP.SIPRequest
substituteString string
return string

Property Details

PublicIPAddress public static property

public static IPAddress,System.Net PublicIPAddress
return System.Net.IPAddress