private void ResetCNonce() { if (!String.IsNullOrEmpty(mQop)) { mCnonce = TSK_MD5.Compute(TSK_String.Random()); mNc = 1; } }
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 }
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"); } }
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); }
/// <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); }