예제 #1
0
        private SipServerAgent serverAgent;        // Used for receiving requests

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="settings">The <see cref="SipCoreSettings" />.</param>
        public SipBasicCore(SipCoreSettings settings)
            : base(settings)
        {
            this.clientAgent = new SipClientAgent(this, this);
            this.serverAgent = new SipServerAgent(this, this);

            base.SetRouter(this);
            base.Agents.Add(clientAgent);
            base.Agents.Add(serverAgent);
        }
예제 #2
0
        //---------------------------------------------------------------------
        // Static members

        /// <summary>
        /// Loads the settings from the application configuration.
        /// </summary>
        /// <param name="keyPrefix">The configuration key prefix.</param>
        /// <returns>The loaded <see cref="SipCoreSettings" />.</returns>\
        /// <remarks>
        /// <div class="tablediv">
        /// <table class="dtTABLE" cellspacing="0" ID="Table1">
        /// <tr valign="top">
        /// <th width="1">Setting</th>
        /// <th width="1">Default</th>
        /// <th width="90%">Description</th>
        /// </tr>
        /// <tr valign="top">
        ///     <td>LocalContact</td>
        ///     <td>(see note)</td>
        ///     <td>
        ///     <para>
        ///     Specifies necessary information to be included in the <b>Contact</b> header in
        ///     requests and responses generated by the core.  This can be a full contact heading
        ///     with a display name, SIP URI, and contact parameters, or just an IP address or
        ///     host name.  Full SIP URIs will be used <i>as is</i> when used in a <b>Contact</b>
        ///     header.  A SIP URI will be generated on the fly from an IP address or host by adding
        ///     the port and transport parameter based on the actual transport used.  This defaults to
        ///     the first active IP address found on the machine.
        ///     </para>
        ///     <note>
        ///     SIP URIs with parameters (such as "transport=tcp") <b>must be surrounded by angle brackets:</b>
        ///     "&lt;" and "&gt;".
        ///     </note>
        ///     </td>
        /// </tr>
        /// <tr valign="top">
        ///     <td>OutboundProxy</td>
        ///     <td>(none)</td>
        ///     <td>
        ///     Specifies outbound proxy SIP URI where the core should route all
        ///     outbound SIP requests.  Set this to <c>null</c> to route requests
        ///     directly to their destination.
        ///     </td>
        /// </tr>
        /// <tr valign="top">
        ///     <td>UserAgent</td>
        ///     <td>LillTek SIP &lt;version&gt;</td>
        ///     <td>
        ///     Specifies the value to use as the <b>User-Agent</b> header for SIP messages.
        ///     </td>
        /// </tr>
        /// <tr valign="top">
        ///     <td>ServerAgent</td>
        ///     <td>LillTek SIP &lt;version&gt;</td>
        ///     <td>
        ///     Specifies the value to use as the <b>Server</b> header for SIP messages.
        ///     </td>
        /// </tr>
        /// <tr valign="top">
        ///     <td>AutoAuthenticate</td>
        ///     <td>yes</td>
        ///     <td>
        ///     Indicates that the core should automatically handle authentication
        ///     challenges from proxies and remote SIP endpoints by computing
        ///     appropriate response and resubmitting the request.
        ///     </td>
        /// </tr>
        /// <tr valign="top">
        ///     <td>UserName</td>
        ///     <td>(none)</td>
        ///     <td>
        ///     The account name used for authenticating with downstream SIP trunking proxies.
        ///     </td>
        /// </tr>
        /// <tr valign="top">
        ///     <td>Password</td>
        ///     <td>(none)</td>
        ///     <td>
        ///     The password name to use for authentication purposes.
        ///     </td>
        /// </tr>
        /// <tr valign="top">
        ///     <td>TraceMode</td>
        ///     <td><see cref="SipTraceMode.None" /></td>
        ///     <td>
        ///     Indicates whether the SIP core should generate <see cref="NetTrace" />
        ///     diagnostics.  Note that <b>Diagnostics.TraceEnable[#]=0:LillTek.SIP</b> must
        ///     also be set for this to work.  Valid values are: <see cref="SipTraceMode.None" />,
        ///     <see cref="SipTraceMode.Send" />, <see cref="SipTraceMode.Receive" />, and
        ///     <see cref="SipTraceMode.All" />.
        ///     </td>
        /// </tr>
        /// <tr valign="top">
        ///     <td>ServerTransactionTTL</td>
        ///     <td>15m</td>
        ///     <td>
        ///     The maximum time a server side transaction will be maintained.  Transactions
        ///     that have existed for longer than this will be terminated.  This helps
        ///     prevent memory leaks due to hung or crashed server transaction handlers.
        ///     </td>
        /// </tr>
        /// <tr valign="top">
        ///     <td>EarlyDialogTTL</td>
        ///     <td>90s</td>
        ///     <td>
        ///     The maximum time an early dialog will be maintained by the core if the
        ///     dialog isn't confirmed by the client.
        ///     </td>
        /// </tr>
        /// <tr valign="top">
        ///     <td>BkInterval</td>
        ///     <td>250ms</td>
        ///     <td>
        ///     The interval which the core should wake up to perform background tasks.
        ///     </td>
        /// </tr>
        /// <tr valign="top">
        ///     <td>TransportBkInterval</td>
        ///     <td>1s</td>
        ///     <td>
        ///     The interval at which transport background activities should be performed.
        ///     </td>
        /// </tr>
        /// <tr valign="top">
        ///     <td>Transport[#]</td>
        ///     <td>(see note)</td>
        ///     <td>
        ///     <para>
        ///     The transport settings are loaded from the "Transport" subsection
        ///     array.  See <see cref="SipTransportSettings.LoadConfig" /> for
        ///     information on the settings loaded from each of these subsections.
        ///     </para>
        ///     <para>
        ///     This defaults to a single UDP transport binding to all network
        ///     interfaces on port 5060.
        ///     </para>
        ///     </td>
        /// </tr>
        /// </table>
        /// </div>
        /// </remarks>
        public static SipCoreSettings LoadConfig(string keyPrefix)
        {
            var config     = new Config(keyPrefix);
            var settings   = new SipCoreSettings();
            var transports = config.GetSectionKeyArray("Transport");

            settings.LocalContact         = config.Get("LocalContact", settings.LocalContact);
            settings.AutoAuthenticate     = config.Get("AutoAuthenticate", settings.AutoAuthenticate);
            settings.UserName             = config.Get("UserName", settings.UserName);
            settings.Password             = config.Get("Password", settings.Password);
            settings.TraceMode            = config.Get <SipTraceMode>("TraceMode", settings.TraceMode);
            settings.UserAgent            = config.Get("UserAgent", settings.UserAgent);
            settings.ServerAgent          = config.Get("ServerAgent", settings.ServerAgent);
            settings.ServerTransactionTTL = config.Get("ServerTransactionTTL", settings.ServerTransactionTTL);
            settings.EarlyDialogTTL       = config.Get("EarlyDialogTTL", settings.EarlyDialogTTL);
            settings.BkInterval           = config.Get("BkInterval", settings.BkInterval);
            settings.TransportBkInterval  = config.Get("TransportBkInterval", settings.TransportBkInterval);

            string uri;

            uri = config.Get("OutboundProxy", (string)settings.OutboundProxyUri);
            if (string.IsNullOrWhiteSpace(uri))
            {
                settings.OutboundProxyUri = null;  // Treat blank as null
            }
            else
            {
                try
                {
                    settings.OutboundProxyUri = new SipUri(uri);
                }
                catch (Exception e)
                {
                    SysLog.LogException(e, "Cannot parse SIP Core setting [OutboundProxy].");
                }
            }

            settings.TransportSettings = new SipTransportSettings[transports.Length];
            for (int i = 0; i < transports.Length; i++)
            {
                settings.TransportSettings[i] = SipTransportSettings.LoadConfig(transports[i]);
            }

            return(settings);
        }
예제 #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="settings">The <see cref="SipCoreSettings" />.</param>
 public SipClientCore(SipCoreSettings settings)
     : base(settings)
 {
 }