public void B2BInviteTransactionStatefulProxyTest() { SIPTransactionEngine transactionEngine1 = new SIPTransactionEngine(); SIPTransport sipTransport1 = new SIPTransport(SIPDNSManager.Resolve, transactionEngine1, true, false); IPEndPoint sipTransport1EndPoint = new IPEndPoint(IPAddress.Loopback, 3000); sipTransport1.AddSIPChannel(new SIPUDPChannel(sipTransport1EndPoint)); SIPAppServerCore statefulProxyCore1 = new SIPAppServerCore(sipTransport1, null, statefulProxyCore1_StatefulProxyLogEvent, null, null, null); SIPTransactionEngine transactionEngine2 = new SIPTransactionEngine(); SIPTransport sipTransport2 = new SIPTransport(SIPDNSManager.Resolve, transactionEngine2, true, false); IPEndPoint sipTransport2EndPoint = new IPEndPoint(IPAddress.Loopback, 3001); sipTransport2.AddSIPChannel(new SIPUDPChannel(sipTransport2EndPoint)); SIPAppServerCore statefulProxyCore2 = new SIPAppServerCore(sipTransport2, statefulProxyCore2_GetCanonicalDomain, statefulProxyCore2_StatefulProxyLogEvent, null, null, null); sipTransport1.SIPRequestOutTraceEvent += sipTransport1_SIPRequestOutTraceEvent; sipTransport1.SIPResponseInTraceEvent += sipTransport1_SIPResponseInTraceEvent; sipTransport2.SIPRequestInTraceEvent += sipTransport2_SIPRequestInTraceEvent; sipTransport2.SIPResponseOutTraceEvent += sipTransport2_SIPResponseOutTraceEvent; SIPRequest inviteRequest = GetInviteRequest(sipTransport1EndPoint, null, sipTransport2EndPoint); UACInviteTransaction uacInvite = sipTransport1.CreateUACTransaction(inviteRequest, new SIPEndPoint(SIPProtocolsEnum.udp, sipTransport2EndPoint), new SIPEndPoint(SIPProtocolsEnum.udp, sipTransport1EndPoint), null); uacInvite.SendInviteRequest(new SIPEndPoint(SIPProtocolsEnum.udp, sipTransport2EndPoint), inviteRequest); Thread.Sleep(200); // Check the NUnit Console.Out to make sure there are SIP requests and responses being displayed. sipTransport1.Shutdown(); sipTransport2.Shutdown(); }
public void Call(SIPCallDescriptor sipCallDescriptor) { try { m_uacCallDescriptor = sipCallDescriptor; SIPRequest uacInviteRequest = GetInviteRequest(m_uacCallDescriptor.Uri, sipCallDescriptor); if (sipCallDescriptor.MangleResponseSDP && sipCallDescriptor.MangleIPAddress != null) { uacInviteRequest.Header.ProxyReceivedFrom = sipCallDescriptor.MangleIPAddress.ToString(); } uacInviteRequest.Body = sipCallDescriptor.Content; uacInviteRequest.Header.ContentType = sipCallDescriptor.ContentType; uacInviteRequest.LocalSIPEndPoint = m_blackhole; uacInviteRequest.RemoteSIPEndPoint = m_blackhole; // Now that we have a destination socket create a new UAC transaction for forwarded leg of the call. m_uacTransaction = m_sipTransport.CreateUACTransaction(uacInviteRequest, m_blackhole, m_blackhole, null); if (m_uacTransaction.CDR != null) { m_uacTransaction.CDR.Owner = m_uacOwner; m_uacTransaction.CDR.AdminMemberId = m_uacAdminMemberId; m_uacTransaction.CDR.DialPlanContextID = (m_uacCallDescriptor != null) ? m_uacCallDescriptor.DialPlanContextID : Guid.Empty; } //uacTransaction.UACInviteTransactionInformationResponseReceived += ServerInformationResponseReceived; //uacTransaction.UACInviteTransactionFinalResponseReceived += ServerFinalResponseReceived; //uacTransaction.UACInviteTransactionTimedOut += ServerTimedOut; //uacTransaction.TransactionTraceMessage += TransactionTraceMessage; m_uacTransaction.SendInviteRequest(m_blackhole, m_uacTransaction.TransactionRequest); SIPRequest uasInviteRequest = uacInviteRequest.Copy(); uasInviteRequest.LocalSIPEndPoint = m_blackhole; uasInviteRequest.RemoteSIPEndPoint = m_blackhole; uasInviteRequest.Header.Vias.TopViaHeader.Branch = CallProperties.CreateBranchId(); m_uasTransaction = m_sipTransport.CreateUASTransaction(uasInviteRequest, m_blackhole, m_blackhole, null); SetOwner(sipCallDescriptor.ToSIPAccount.Owner, sipCallDescriptor.ToSIPAccount.AdminMemberId); //m_uasTransaction.TransactionTraceMessage += TransactionTraceMessage; //m_uasTransaction.UASInviteTransactionTimedOut += ClientTimedOut; //m_uasTransaction.UASInviteTransactionCancelled += (t) => { }; QueueNewCall_External(this); CallTrying.Invoke(this, null); } catch (Exception excp) { logger.Error("Exception SIPB2BUserAgent Call. " + excp.Message); } }
public void CreateTransactionUnitTest() { Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name); string sipRequestStr = "INVITE sip:[email protected];switchtag=902888 SIP/2.0" + m_CRLF + "Record-Route: <sip:2.3.4.5;ftag=9307C640-33C;lr=on>" + m_CRLF + "Via: SIP/2.0/UDP 5.6.7.2:5060" + m_CRLF + "Via: SIP/2.0/UDP 1.2.3.4;branch=z9hG4bKa7ac.2bfad091.0" + m_CRLF + "From: \"unknown\" <sip:00.000.00.0>;tag=9307C640-33C" + m_CRLF + "To: <sip:[email protected]>" + m_CRLF + "Date: Thu, 21 Feb 2008 01:46:30 GMT" + m_CRLF + "Call-ID: A8706191-DF5511DC-B886ED7B-395C3F7E" + m_CRLF + "Supported: timer,100rel" + m_CRLF + "Min-SE: 1800" + m_CRLF + "Cisco-Guid: 2825897321-3746894300-3095653755-962346878" + m_CRLF + "User-Agent: Cisco-SIPGateway/IOS-12.x" + m_CRLF + "Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, COMET, REFER, SUBSCRIBE, NOTIFY, INFO" + m_CRLF + "CSeq: 101 INVITE" + m_CRLF + "Max-Forwards: 5" + m_CRLF + "Timestamp: 1203558390" + m_CRLF + "Contact: <sip:1.2.3.4:5060>" + m_CRLF + "Expires: 180" + m_CRLF + "Allow-Events: telephone-event" + m_CRLF + "Content-Type: application/sdp" + m_CRLF + "Content-Length: 370" + m_CRLF + m_CRLF + "v=0" + m_CRLF + "o=CiscoSystemsSIP-GW-UserAgent 9312 7567 IN IP4 00.00.00.0" + m_CRLF + "s=SIP Call" + m_CRLF + "c=IN IP4 00.000.00.0" + m_CRLF + "t=0 0" + m_CRLF + "m=audio 16434 RTP/AVP 8 0 4 18 3 101" + m_CRLF + "c=IN IP4 00.000.00.0" + m_CRLF + "a=rtpmap:8 PCMA/8000" + m_CRLF + "a=rtpmap:0 PCMU/8000" + m_CRLF + "a=rtpmap:4 G723/8000" + m_CRLF + "a=fmtp:4 annexa=no" + m_CRLF + "a=rtpmap:18 G729/8000" + m_CRLF + "a=fmtp:18 annexb=no" + m_CRLF + "a=rtpmap:3 GSM/8000" + m_CRLF + "a=rtpmap:101 telepho"; SIPRequest request = SIPRequest.ParseSIPRequest(sipRequestStr); SIPTransactionEngine transactionEngine = new SIPTransactionEngine(); SIPTransport sipTransport = new SIPTransport(MockSIPDNSManager.Resolve, transactionEngine); SIPEndPoint dummySIPEndPoint = new SIPEndPoint(new IPEndPoint(IPAddress.Loopback, 1234)); SIPTransaction transaction = sipTransport.CreateUACTransaction(request, dummySIPEndPoint, dummySIPEndPoint, null); Assert.IsTrue(transaction.TransactionRequest.URI.ToString() == "sip:[email protected];switchtag=902888", "Transaction request URI was incorrect."); }
public void SendSIPRequest(SIPRequest sipRequest, string dstSocket) { //ResetSIPResponse(); if (sipRequest.Method == SIPMethodsEnum.INVITE) { //m_inviteRequest = sipRequest; UACInviteTransaction inviteTransaction = m_sipTransport.CreateUACTransaction(sipRequest, IPSocket.GetIPEndPoint(dstSocket), m_sipTransport.GetTransportContact(null), SIPProtocolsEnum.UDP); inviteTransaction.UACInviteTransactionInformationResponseReceived += new SIPTransactionResponseReceivedDelegate(TransactionInformationResponseReceived); inviteTransaction.UACInviteTransactionFinalResponseReceived += new SIPTransactionResponseReceivedDelegate(TransactionFinalResponseReceived); m_sipTransport.SendSIPReliable(inviteTransaction); } else { SIPNonInviteTransaction sipTransaction = m_sipTransport.CreateNonInviteTransaction(sipRequest, IPSocket.GetIPEndPoint(dstSocket), m_sipTransport.GetTransportContact(null), SIPProtocolsEnum.UDP); sipTransaction.NonInviteTransactionFinalResponseReceived += new SIPTransactionResponseReceivedDelegate(TransactionFinalResponseReceived); m_sipTransport.SendSIPReliable(sipTransaction); } }
/// <summary> /// Sends a re-INVITE request to the remote call party with the supplied SDP. /// </summary> /// <param name="sdp">The SDP to send to the remote call party.</param> public void SendReInviteRequest(SDP sdp) { if (Dialogue == null) { logger.LogWarning("No dialog available, re-INVITE request cannot be sent."); } else { var reinviteRequest = Dialogue.GetInDialogRequest(SIPMethodsEnum.INVITE); reinviteRequest.Header.UserAgent = m_userAgent; reinviteRequest.Header.ContentType = m_sdpContentType; reinviteRequest.Body = sdp.ToString(); reinviteRequest.Header.Supported = SIPExtensionHeaders.PRACK; if (m_uac != null) { reinviteRequest.Header.Contact = m_uac.ServerTransaction.TransactionRequest.Header.Contact; reinviteRequest.SetSendFromHints(m_uac.ServerTransaction.TransactionRequest.LocalSIPEndPoint); } else if (m_uas != null) { reinviteRequest.Header.Contact = m_uas.ClientTransaction.TransactionFinalResponse.Header.Contact; reinviteRequest.SetSendFromHints(m_uas.ClientTransaction.TransactionFinalResponse.LocalSIPEndPoint); } else { reinviteRequest.Header.Contact = new List <SIPContactHeader>() { SIPContactHeader.GetDefaultSIPContactHeader() }; } UACInviteTransaction reinviteTransaction = m_transport.CreateUACTransaction(reinviteRequest, m_outboundProxy); reinviteTransaction.SendReliableRequest(); } }