private void ResetCNonce()
 {
     if (!String.IsNullOrEmpty(mQop))
     {
         mCnonce = TSK_MD5.Compute(TSK_String.Random());
         mNc     = 1;
     }
 }
示例#2
0
        internal TSIP_DialogLayer(TSIP_Stack stack)
        {
            mStack   = stack;
            mDialogs = new Dictionary <Int64, TSIP_Dialog>();
#if WINDOWS_PHONE
            mMutex = new Mutex(false, TSK_String.Random());
#else
            mMutex = new Mutex();
#endif
        }
        internal TSIP_TransportLayer(TSIP_Stack stack)
        {
            mStack      = stack;
            mTransports = new List <TSIP_Transport>();
#if WINDOWS_PHONE
            mMutex = new Mutex(false, TSK_String.Random());
#else
            mMutex = new Mutex();
#endif
        }
        internal TSIP_TransacLayer(TSIP_Stack stack)
        {
            mSipStack     = stack;
            mTransactions = new Dictionary <Int64, TSIP_Transac>();
            mReliable     = TNET_Socket.IsStreamType(mSipStack.ProxyType);
#if WINDOWS_PHONE
            mMutex = new Mutex(false, TSK_String.Random());
#else
            mMutex = new Mutex();
#endif
        }
示例#5
0
        internal const Int64 SHUTDOWN_TIMEOUT = 2000; /* miliseconds. */

        internal TSIP_Dialog(tsip_dialog_type_t type, String callId, TSip_Session session)
        {
            mId           = sUniqueId++;
            mRecordRoutes = new List <TSIP_HeaderRecordRoute>();
            mChallenges   = new List <TSIP_Challenge>();

            mPaths          = new List <TSIP_Uri>();
            mServiceRoutes  = new List <TSIP_Uri>();
            mAssociatedUris = new List <TSIP_Uri>();

            mState = tsip_dialog_state_t.Initial;
            mType  = type;

            mCallId     = String.IsNullOrEmpty(callId) ? TSIP_HeaderCallId.RandomCallId() : callId;
            mSipSession = session;

            /* Sets some default values */
            mExpires   = TSip_Session.DEFAULT_EXPIRES;
            mTagLocal  = TSK_String.Random();
            mCSeqValue = (UInt32) new Random().Next();

            /*=== SIP Session ===*/
            if (mSipSession != null)
            {
                mExpires  = mSipSession.Expires;
                mUriLocal = !String.IsNullOrEmpty(callId) /* Server Side */ ? mSipSession.UriTo : mSipSession.UriFrom;
                if (mSipSession.UriTo != null)
                {
                    mUriRemote       = mSipSession.UriTo;
                    mUriRemoteTarget = mSipSession.UriTo;
                }
                else
                {
                    mUriRemote       = mSipSession.UriFrom;
                    mUriRemoteTarget = mSipSession.Stack.Realm;
                }
            }
            else
            {
                TSK_Debug.Error("Invalid Sip Session");
            }
        }
示例#6
0
/* #line 124 "./ragel/tsip_parser_uri.rl" */

    public static TSIP_Uri Parse(String data)
    {
        if (String.IsNullOrEmpty(data))
        {
            return(null);
        }

        int cs  = 0;
        int p   = 0;
        int pe  = data.Length;
        int eof = pe;

        int ts = 0, te = 0;
        int act = 0;

        TSIP_Uri uri = TSIP_Uri.Create(tsip_uri_type_t.Unknown);

        int tag_start = 0;


/* #line 395 "../Parsers/TSIP_ParserUri.cs" */
        {
            cs  = tsip_machine_parser_uri_start;
            ts  = -1;
            te  = -1;
            act = 0;
        }

/* #line 145 "./ragel/tsip_parser_uri.rl" */

/* #line 405 "../Parsers/TSIP_ParserUri.cs" */
        {
            sbyte _klen;
            short _trans;
            sbyte _acts;
            sbyte _nacts;
            short _keys;

            if (p == pe)
            {
                goto _test_eof;
            }
            if (cs == 0)
            {
                goto _out;
            }
_resume:
            _acts  = _tsip_machine_parser_uri_from_state_actions[cs];
            _nacts = _tsip_machine_parser_uri_actions[_acts++];
            while (_nacts-- > 0)
            {
                switch (_tsip_machine_parser_uri_actions[_acts++])
                {
                case 12:
/* #line 1 "./ragel/tsip_parser_uri.rl" */
                { ts = p; }
                break;

/* #line 426 "../Parsers/TSIP_ParserUri.cs" */
                default: break;
                }
            }

            _keys  = _tsip_machine_parser_uri_key_offsets[cs];
            _trans = (short)_tsip_machine_parser_uri_index_offsets[cs];

            _klen = _tsip_machine_parser_uri_single_lengths[cs];
            if (_klen > 0)
            {
                short _lower = _keys;
                short _mid;
                short _upper = (short)(_keys + _klen - 1);
                while (true)
                {
                    if (_upper < _lower)
                    {
                        break;
                    }

                    _mid = (short)(_lower + ((_upper - _lower) >> 1));
                    if (data[p] < _tsip_machine_parser_uri_trans_keys[_mid])
                    {
                        _upper = (short)(_mid - 1);
                    }
                    else if (data[p] > _tsip_machine_parser_uri_trans_keys[_mid])
                    {
                        _lower = (short)(_mid + 1);
                    }
                    else
                    {
                        _trans += (short)(_mid - _keys);
                        goto _match;
                    }
                }
                _keys  += (short)_klen;
                _trans += (short)_klen;
            }

            _klen = _tsip_machine_parser_uri_range_lengths[cs];
            if (_klen > 0)
            {
                short _lower = _keys;
                short _mid;
                short _upper = (short)(_keys + (_klen << 1) - 2);
                while (true)
                {
                    if (_upper < _lower)
                    {
                        break;
                    }

                    _mid = (short)(_lower + (((_upper - _lower) >> 1) & ~1));
                    if (data[p] < _tsip_machine_parser_uri_trans_keys[_mid])
                    {
                        _upper = (short)(_mid - 2);
                    }
                    else if (data[p] > _tsip_machine_parser_uri_trans_keys[_mid + 1])
                    {
                        _lower = (short)(_mid + 2);
                    }
                    else
                    {
                        _trans += (short)((_mid - _keys) >> 1);
                        goto _match;
                    }
                }
                _trans += (short)_klen;
            }

_match:
            _trans = (short)_tsip_machine_parser_uri_indicies[_trans];
_eof_trans:
            cs = _tsip_machine_parser_uri_trans_targs[_trans];

            if (_tsip_machine_parser_uri_trans_actions[_trans] == 0)
            {
                goto _again;
            }

            _acts  = _tsip_machine_parser_uri_trans_actions[_trans];
            _nacts = _tsip_machine_parser_uri_actions[_acts++];
            while (_nacts-- > 0)
            {
                switch (_tsip_machine_parser_uri_actions[_acts++])
                {
                case 0:
/* #line 36 "./ragel/tsip_parser_uri.rl" */
                {
                    tag_start = p;
                }
                break;

                case 1:
/* #line 41 "./ragel/tsip_parser_uri.rl" */
                { uri.Scheme = "sip"; uri.Type = tsip_uri_type_t.Sip; }
                break;

                case 2:
/* #line 42 "./ragel/tsip_parser_uri.rl" */
                { uri.Scheme = "sips"; uri.Type = tsip_uri_type_t.Sips; }
                break;

                case 3:
/* #line 43 "./ragel/tsip_parser_uri.rl" */
                { uri.Scheme = "tel"; uri.Type = tsip_uri_type_t.Tel; }
                break;

                case 4:
/* #line 46 "./ragel/tsip_parser_uri.rl" */
                { uri.HostType = tsip_host_type_t.IPv4; }
                break;

                case 5:
/* #line 47 "./ragel/tsip_parser_uri.rl" */
                { uri.HostType = tsip_host_type_t.IPv6; }
                break;

                case 6:
/* #line 48 "./ragel/tsip_parser_uri.rl" */
                { uri.HostType = tsip_host_type_t.Hostname; }
                break;

                case 7:
/* #line 54 "./ragel/tsip_parser_uri.rl" */
                {
                    uri.UserName = TSK_RagelState.Parser.GetString(data, p, tag_start);
                }
                break;

                case 8:
/* #line 58 "./ragel/tsip_parser_uri.rl" */
                {
                    uri.Password = TSK_RagelState.Parser.GetString(data, p, tag_start);
                }
                break;

                case 9:
/* #line 70 "./ragel/tsip_parser_uri.rl" */
                {
                    TSK_Param param = TSK_RagelState.Parser.GetParam(data, p, tag_start);
                    if (param != null)
                    {
                        uri.Params.Add(param);
                    }
                }
                break;

                case 10:
/* #line 84 "./ragel/tsip_parser_uri.rl" */
                { { cs = 26; if (true)
                    {
                        goto _again;
                    }
                  } }
                  break;

                case 13:
/* #line 1 "./ragel/tsip_parser_uri.rl" */
                { te = p + 1; }
                break;

                case 14:
/* #line 97 "./ragel/tsip_parser_uri.rl" */
                { te = p + 1; {
                      uri.Host = TSK_RagelState.Scanner.GetString(data, ts, te);
                      if (uri.HostType == tsip_host_type_t.IPv6)
                      {
                          uri.Host = TSK_String.UnQuote(uri.Host, '[', ']');
                      }
                  } }
                  break;

                case 15:
/* #line 88 "./ragel/tsip_parser_uri.rl" */
                { te = p; p--; {
                      if (TSK_String.Contains(data.Substring(te), (pe - te), "@"))
                      {
                          { cs = 18; if (true)
                    {
                        goto _again;
                    }
                          }
                      }
                  } }
                  break;

                case 16:
/* #line 94 "./ragel/tsip_parser_uri.rl" */
                { te = p; p--; { } }
                break;

                case 17:
/* #line 97 "./ragel/tsip_parser_uri.rl" */
                { te = p; p--; {
                      uri.Host = TSK_RagelState.Scanner.GetString(data, ts, te);
                      if (uri.HostType == tsip_host_type_t.IPv6)
                      {
                          uri.Host = TSK_String.UnQuote(uri.Host, '[', ']');
                      }
                  } }
                  break;

                case 18:
/* #line 105 "./ragel/tsip_parser_uri.rl" */
                { te = p; p--; {
                      ts++;
                      uri.Port = (ushort)TSK_RagelState.Scanner.GetInt32(data, ts, te);
                  } }
                  break;

                case 19:
/* #line 110 "./ragel/tsip_parser_uri.rl" */
                { te = p; p--; {  } }
                break;

                case 20:
/* #line 111 "./ragel/tsip_parser_uri.rl" */
                { te = p; p--; {  } }
                break;

                case 21:
/* #line 94 "./ragel/tsip_parser_uri.rl" */
                { { p = ((te)) - 1; } { } }
                break;

                case 22:
/* #line 97 "./ragel/tsip_parser_uri.rl" */
                { { p = ((te)) - 1; } {
                      uri.Host = TSK_RagelState.Scanner.GetString(data, ts, te);
                      if (uri.HostType == tsip_host_type_t.IPv6)
                      {
                          uri.Host = TSK_String.UnQuote(uri.Host, '[', ']');
                      }
                  } }
                  break;

                case 23:
/* #line 110 "./ragel/tsip_parser_uri.rl" */
                { { p = ((te)) - 1; } {  } }
                break;

/* #line 615 "../Parsers/TSIP_ParserUri.cs" */
                default: break;
                }
            }

_again:
            _acts  = _tsip_machine_parser_uri_to_state_actions[cs];
            _nacts = _tsip_machine_parser_uri_actions[_acts++];
            while (_nacts-- > 0)
            {
                switch (_tsip_machine_parser_uri_actions[_acts++])
                {
                case 11:
/* #line 1 "./ragel/tsip_parser_uri.rl" */
                { ts = -1; }
                break;

/* #line 629 "../Parsers/TSIP_ParserUri.cs" */
                default: break;
                }
            }

            if (cs == 0)
            {
                goto _out;
            }
            if (++p != pe)
            {
                goto _resume;
            }
            _test_eof : {}
            if (p == eof)
            {
                if (_tsip_machine_parser_uri_eof_trans[cs] > 0)
                {
                    _trans = (short)(_tsip_machine_parser_uri_eof_trans[cs] - 1);
                    goto _eof_trans;
                }
            }

            _out : {}
        }

/* #line 146 "./ragel/tsip_parser_uri.rl" */

        if (cs <
/* #line 653 "../Parsers/TSIP_ParserUri.cs" */
            26
/* #line 147 "./ragel/tsip_parser_uri.rl" */
            )
        {
            TSK_Debug.Error("Failed to parse SIP/SIPS/TEL URI");
            uri.Dispose();
            return(null);
        }

        return(uri);
    }
/* #line 133 "./ragel/tsip_parser_header_From.rl" */

        public static TSIP_HeaderFrom Parse(String data)
        {
            int             cs       = 0;
            int             p        = 0;
            int             pe       = data.Length;
            int             eof      = pe;
            TSIP_HeaderFrom hdr_from = new TSIP_HeaderFrom();

            int tag_start = 0;


/* #line 392 "../Headers/TSIP_HeaderFrom.cs" */
            {
                cs = tsip_machine_parser_header_From_start;
            }

/* #line 145 "./ragel/tsip_parser_header_From.rl" */

/* #line 399 "../Headers/TSIP_HeaderFrom.cs" */
            {
                sbyte _klen;
                short _trans;
                sbyte _acts;
                sbyte _nacts;
                short _keys;

                if (p == pe)
                {
                    goto _test_eof;
                }
                if (cs == 0)
                {
                    goto _out;
                }
_resume:
                _keys  = _tsip_machine_parser_header_From_key_offsets[cs];
                _trans = (short)_tsip_machine_parser_header_From_index_offsets[cs];

                _klen = _tsip_machine_parser_header_From_single_lengths[cs];
                if (_klen > 0)
                {
                    short _lower = _keys;
                    short _mid;
                    short _upper = (short)(_keys + _klen - 1);
                    while (true)
                    {
                        if (_upper < _lower)
                        {
                            break;
                        }

                        _mid = (short)(_lower + ((_upper - _lower) >> 1));
                        if (data[p] < _tsip_machine_parser_header_From_trans_keys[_mid])
                        {
                            _upper = (short)(_mid - 1);
                        }
                        else if (data[p] > _tsip_machine_parser_header_From_trans_keys[_mid])
                        {
                            _lower = (short)(_mid + 1);
                        }
                        else
                        {
                            _trans += (short)(_mid - _keys);
                            goto _match;
                        }
                    }
                    _keys  += (short)_klen;
                    _trans += (short)_klen;
                }

                _klen = _tsip_machine_parser_header_From_range_lengths[cs];
                if (_klen > 0)
                {
                    short _lower = _keys;
                    short _mid;
                    short _upper = (short)(_keys + (_klen << 1) - 2);
                    while (true)
                    {
                        if (_upper < _lower)
                        {
                            break;
                        }

                        _mid = (short)(_lower + (((_upper - _lower) >> 1) & ~1));
                        if (data[p] < _tsip_machine_parser_header_From_trans_keys[_mid])
                        {
                            _upper = (short)(_mid - 2);
                        }
                        else if (data[p] > _tsip_machine_parser_header_From_trans_keys[_mid + 1])
                        {
                            _lower = (short)(_mid + 2);
                        }
                        else
                        {
                            _trans += (short)((_mid - _keys) >> 1);
                            goto _match;
                        }
                    }
                    _trans += (short)_klen;
                }

_match:
                _trans = (short)_tsip_machine_parser_header_From_indicies[_trans];
                cs     = _tsip_machine_parser_header_From_trans_targs[_trans];

                if (_tsip_machine_parser_header_From_trans_actions[_trans] == 0)
                {
                    goto _again;
                }

                _acts  = _tsip_machine_parser_header_From_trans_actions[_trans];
                _nacts = _tsip_machine_parser_header_From_actions[_acts++];
                while (_nacts-- > 0)
                {
                    switch (_tsip_machine_parser_header_From_actions[_acts++])
                    {
                    case 0:
/* #line 32 "./ragel/tsip_parser_header_From.rl" */
                    {
                        tag_start = p;
                    }
                    break;

                    case 1:
/* #line 36 "./ragel/tsip_parser_header_From.rl" */
                    {
                        int len = (int)(p - tag_start);
                        if (hdr_from != null && hdr_from.Uri == null)
                        {
                            if ((hdr_from.Uri = TSIP_ParserUri.Parse(data.Substring(tag_start, len))) != null && !String.IsNullOrEmpty(hdr_from.DisplayName))
                            {
                                hdr_from.Uri.DisplayName = hdr_from.DisplayName;
                            }
                        }
                    }
                    break;

                    case 2:
/* #line 45 "./ragel/tsip_parser_header_From.rl" */
                    {
                        hdr_from.DisplayName = TSK_RagelState.Parser.GetString(data, p, tag_start);
                        hdr_from.DisplayName = TSK_String.UnQuote(hdr_from.DisplayName);
                    }
                    break;

                    case 3:
/* #line 50 "./ragel/tsip_parser_header_From.rl" */
                    {
                        hdr_from.Tag = TSK_RagelState.Parser.GetString(data, p, tag_start);
                    }
                    break;

                    case 4:
/* #line 54 "./ragel/tsip_parser_header_From.rl" */
                    {
                        hdr_from.Params = TSK_RagelState.Parser.AddParam(data, p, tag_start, hdr_from.Params);
                    }
                    break;

                    case 5:
/* #line 58 "./ragel/tsip_parser_header_From.rl" */
                    {
                    }
                    break;

/* #line 514 "../Headers/TSIP_HeaderFrom.cs" */
                    default: break;
                    }
                }

_again:
                if (cs == 0)
                {
                    goto _out;
                }
                if (++p != pe)
                {
                    goto _resume;
                }
                _test_eof : {}
                _out      : {}
            }

/* #line 146 "./ragel/tsip_parser_header_From.rl" */

            if (cs <
/* #line 531 "../Headers/TSIP_HeaderFrom.cs" */
                108
/* #line 147 "./ragel/tsip_parser_header_From.rl" */
                )
            {
                TSK_Debug.Error("Failed to parse SIP 'From' header.");
                hdr_from.Dispose();
                hdr_from = null;
            }

            return(hdr_from);
        }
示例#8
0
        internal override Boolean Start(TSIP_Request request)
        {
            if (request != null && !base.Running)
            {
                /* Add branch to the new client transaction
                 * IMPORTANT: CANCEL will have the same Via and Contact headers as the request it cancel
                 */
                if (request.IsCANCEL)
                {
                    base.Branch = request.FirstVia != null ? request.FirstVia.Branch : "doubango";
                }
                else
                {
                    base.Branch = String.Format("{0}_{1}", TSIP_Transac.MAGIC_COOKIE, TSK_String.Random());
                }

                base.Running = true;
                mRequest     = request;

                return(base.ExecuteAction((Int32)FSMAction.Send, request));
            }
            return(false);
        }
示例#9
0
/* #line 137 "./ragel/tsip_parser_header_Route.rl" */

        public static List <TSIP_HeaderRoute> Parse(String data)
        {
            int cs  = 0;
            int p   = 0;
            int pe  = data.Length;
            int eof = pe;
            List <TSIP_HeaderRoute> hdr_routes = new List <TSIP_HeaderRoute>();
            TSIP_HeaderRoute        curr_route = null;

            int tag_start = 0;



/* #line 324 "../Headers/TSIP_HeaderRoute.cs" */
            {
                cs = tsip_machine_parser_header_Route_start;
            }

/* #line 151 "./ragel/tsip_parser_header_Route.rl" */

/* #line 331 "../Headers/TSIP_HeaderRoute.cs" */
            {
                sbyte _klen;
                short _trans;
                sbyte _acts;
                sbyte _nacts;
                short _keys;

                if (p == pe)
                {
                    goto _test_eof;
                }
                if (cs == 0)
                {
                    goto _out;
                }
_resume:
                _keys  = _tsip_machine_parser_header_Route_key_offsets[cs];
                _trans = (short)_tsip_machine_parser_header_Route_index_offsets[cs];

                _klen = _tsip_machine_parser_header_Route_single_lengths[cs];
                if (_klen > 0)
                {
                    short _lower = _keys;
                    short _mid;
                    short _upper = (short)(_keys + _klen - 1);
                    while (true)
                    {
                        if (_upper < _lower)
                        {
                            break;
                        }

                        _mid = (short)(_lower + ((_upper - _lower) >> 1));
                        if (data[p] < _tsip_machine_parser_header_Route_trans_keys[_mid])
                        {
                            _upper = (short)(_mid - 1);
                        }
                        else if (data[p] > _tsip_machine_parser_header_Route_trans_keys[_mid])
                        {
                            _lower = (short)(_mid + 1);
                        }
                        else
                        {
                            _trans += (short)(_mid - _keys);
                            goto _match;
                        }
                    }
                    _keys  += (short)_klen;
                    _trans += (short)_klen;
                }

                _klen = _tsip_machine_parser_header_Route_range_lengths[cs];
                if (_klen > 0)
                {
                    short _lower = _keys;
                    short _mid;
                    short _upper = (short)(_keys + (_klen << 1) - 2);
                    while (true)
                    {
                        if (_upper < _lower)
                        {
                            break;
                        }

                        _mid = (short)(_lower + (((_upper - _lower) >> 1) & ~1));
                        if (data[p] < _tsip_machine_parser_header_Route_trans_keys[_mid])
                        {
                            _upper = (short)(_mid - 2);
                        }
                        else if (data[p] > _tsip_machine_parser_header_Route_trans_keys[_mid + 1])
                        {
                            _lower = (short)(_mid + 2);
                        }
                        else
                        {
                            _trans += (short)((_mid - _keys) >> 1);
                            goto _match;
                        }
                    }
                    _trans += (short)_klen;
                }

_match:
                _trans = (short)_tsip_machine_parser_header_Route_indicies[_trans];
                cs     = _tsip_machine_parser_header_Route_trans_targs[_trans];

                if (_tsip_machine_parser_header_Route_trans_actions[_trans] == 0)
                {
                    goto _again;
                }

                _acts  = _tsip_machine_parser_header_Route_trans_actions[_trans];
                _nacts = _tsip_machine_parser_header_Route_actions[_acts++];
                while (_nacts-- > 0)
                {
                    switch (_tsip_machine_parser_header_Route_actions[_acts++])
                    {
                    case 0:
/* #line 31 "./ragel/tsip_parser_header_Route.rl" */
                    {
                        tag_start = p;
                    }
                    break;

                    case 1:
/* #line 35 "./ragel/tsip_parser_header_Route.rl" */
                    {
                        if (curr_route == null)
                        {
                            curr_route = new TSIP_HeaderRoute();
                        }
                    }
                    break;

                    case 2:
/* #line 41 "./ragel/tsip_parser_header_Route.rl" */
                    {
                        if (curr_route != null)
                        {
                            curr_route.DisplayName = TSK_RagelState.Parser.GetString(data, p, tag_start);
                            curr_route.DisplayName = TSK_String.UnQuote(curr_route.DisplayName);
                        }
                    }
                    break;

                    case 3:
/* #line 48 "./ragel/tsip_parser_header_Route.rl" */
                    {
                        if (curr_route != null && curr_route.Uri == null)
                        {
                            int len = (int)(p - tag_start);
                            if ((curr_route.Uri = TSIP_ParserUri.Parse(data.Substring(tag_start, len))) != null && !String.IsNullOrEmpty(curr_route.DisplayName))
                            {
                                curr_route.Uri.DisplayName = curr_route.DisplayName;
                            }
                        }
                    }
                    break;

                    case 4:
/* #line 58 "./ragel/tsip_parser_header_Route.rl" */
                    {
                        if (curr_route != null)
                        {
                            curr_route.Params = TSK_RagelState.Parser.AddParam(data, p, tag_start, curr_route.Params);
                        }
                    }
                    break;

                    case 5:
/* #line 64 "./ragel/tsip_parser_header_Route.rl" */
                    {
                        if (curr_route != null)
                        {
                            hdr_routes.Add(curr_route);
                            curr_route = null;
                        }
                    }
                    break;

                    case 6:
/* #line 71 "./ragel/tsip_parser_header_Route.rl" */
                    {
                    }
                    break;

/* #line 462 "../Headers/TSIP_HeaderRoute.cs" */
                    default: break;
                    }
                }

_again:
                if (cs == 0)
                {
                    goto _out;
                }
                if (++p != pe)
                {
                    goto _resume;
                }
                _test_eof : {}
                _out      : {}
            }

/* #line 152 "./ragel/tsip_parser_header_Route.rl" */

            if (cs <
/* #line 479 "../Headers/TSIP_HeaderRoute.cs" */
                92
/* #line 153 "./ragel/tsip_parser_header_Route.rl" */
                )
            {
                TSK_Debug.Error("Failed to parse SIP 'Route' header.");
                hdr_routes.Clear();
                hdr_routes = null;
                curr_route.Dispose();
                curr_route = null;
            }

            return(hdr_routes);
        }
示例#10
0
        /// <summary>
        /// add Via header using the transport config
        /// </summary>
        /// <param name="branch"></param>
        /// <param name="msg"></param>
        private Boolean AddViaToMessage(String branch, TSIP_Message msg)
        {
            String ip;
            ushort port;

            if (!this.GetLocalIpAndPort(out ip, out port))
            {
                return(false);
            }

#if WINDOWS_PHONE
            if (port == 0 && (mStack.AoRPort != 0 && !String.IsNullOrEmpty(mStack.AoRIP)))
            {
                port = mStack.AoRPort;
                ip   = mStack.AoRIP;
            }
#endif

            /* is there a Via header? */
            if (msg.FirstVia == null)
            {
                /*	RFC 3261 - 18.1.1 Sending Requests
                 *              Before a request is sent, the client transport MUST insert a value of
                 *              the "sent-by" field into the Via header field.  This field contains
                 *              an IP address or host name, and port.  The usage of an FQDN is
                 *              RECOMMENDED.  This field is used for sending responses under certain
                 *              conditions, described below.  If the port is absent, the default
                 *              value depends on the transport.  It is 5060 for UDP, TCP and SCTP,
                 *              5061 for TLS.
                 */
                msg.FirstVia = new TSIP_HeaderVia(TSIP_HeaderVia.PROTO_NAME_DEFAULT, TSIP_HeaderVia.PROTO_VERSION_DEFAULT,
                                                  this.ViaProtocol, ip, (UInt16)port);
                msg.FirstVia.Params.Add(new TSK_Param("rport"));
            }

            /* updates the branch */
            if (!String.IsNullOrEmpty(branch))
            {
                msg.FirstVia.Branch = branch;
            }
            else
            {
                msg.FirstVia.Branch = String.Format("{0}_{1}", TSIP_Transac.MAGIC_COOKIE, TSK_String.Random());
            }

            /* multicast case */
            if (false)
            {
                /*	RFC 3261 - 18.1.1 Sending Requests (FIXME)
                 *              A client that sends a request to a multicast address MUST add the
                 *              "maddr" parameter to its Via header field value containing the
                 *              destination multicast address, and for IPv4, SHOULD add the "ttl"
                 *              parameter with a value of 1.  Usage of IPv6 multicast is not defined
                 *              in this specification, and will be a subject of future
                 *              standardization when the need arises.
                 */
            }

            /*
             * comp=sigcomp; sigcomp-id=
             */

            return(true);
        }