internal TSIP_Uri GetProxyCSCFUri(Boolean lr) { TSIP_Uri uri = null; if (mLayerTransport != null && mLayerTransport.Transports.Count > 0) { TSIP_Transport transport = mLayerTransport.Transports[0]; if (transport != null) { Boolean ipv6 = TNET_Socket.IsIPv6Type(transport.Type); Boolean quote_ip = (ipv6 && !String.IsNullOrEmpty(mProxyHost) && mProxyHost.Contains(":")) /* IPv6 IP string?*/; String uriString = String.Format("{0}:{1}{2}{3}:{4};{5};transport={6}", transport.Scheme, quote_ip ? "[" : "", mProxyHost, quote_ip ? "]" : "", mProxyPort, lr ? "lr" : "", transport.Protocol ); uri = TSIP_ParserUri.Parse(uriString); } } return(uri); }
protected TSIP_Transport(TSIP_Stack stack, String host, ushort port, TNET_Socket.tnet_socket_type_t type, String description) : base(host, port, type, description) { mStack = stack; mScheme = TNET_Socket.IsTLSType(type) ? "sips" : "sip"; if (TNET_Socket.IsStreamType(type)) { mProtocol = "tcp"; if (TNET_Socket.IsTLSType(type)) { mViaProtocol = "TLS"; mService = "SIPS+D2T"; } else { mViaProtocol = "TCP"; mService = "SIP+D2T"; } } else { mProtocol = "udp"; mViaProtocol = "UDP"; mService = "SIP+D2U"; } }
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 }
private Boolean SendBytes(EndPoint toEP, byte[] bytes) { if (TNET_Socket.IsStreamType(this.Type)) { TSK_Debug.Error("Not implemented"); return(false); } else { return(base.SendTo(toEP, bytes) > 0); } }
internal Boolean AddTransport(String localHost, ushort localPort, TNET_Socket.tnet_socket_type_t type, String description) { TSIP_Transport transport = TNET_Socket.IsStreamType(type) ? (TSIP_Transport) new TSIP_TransportTCP(mStack, localHost, localPort, TNET_Socket.IsIPv6Type(type), description) : (TSIP_Transport) new TSIP_TransportUDP(mStack, localHost, localPort, TNET_Socket.IsIPv6Type(type), description); if (transport != null) { // FIXME:DO not forget to call "transport.NetworkEvent -= this.TSIP_Transport_NetworkEvent;" before removing the transport transport.NetworkEvent += this.TSIP_Transport_NetworkEvent; mTransports.Add(transport); } return(transport != null); }
internal TSIP_Uri GetUri(Boolean lr) { Boolean ipv6 = TNET_Socket.IsIPv6Type(this.Type); String uristring = String.Format("{0}:{1}{2}{3}:{4};{5};transport={6}", this.Scheme, ipv6 ? "[" : String.Empty, mStack.AoRIP, ipv6 ? "]" : String.Empty, mStack.AoRPort, lr ? "lr" : String.Empty, this.Protocol); TSIP_Uri uri = TSIP_ParserUri.Parse(uristring); uri.HostType = ipv6 ? tsip_host_type_t.IPv6 : tsip_host_type_t.IPv4; return(uri); }
public Boolean Send(String branch, TSIP_Message msg, String destIP, ushort destPort) { /* Add Via and update AOR, IPSec headers, SigComp ... * ACK sent from the transaction layer will contains a Via header and should not be updated * CANCEL will have the same Via and Contact headers as the request it cancel */ if (msg.IsRequest && (!msg.IsACK || (msg.IsACK && msg.FirstVia == null)) && !msg.IsCANCEL) { this.AddViaToMessage(branch, msg); /* should be done before tsip_transport_msg_update() which could use the Via header */ this.AddAoRToMessage(msg); /* AoR */ this.UpdateMessage(msg); /* IPSec, SigComp, ... */ } else if (msg.IsResponse) { /* AoR for responses which have a contact header (e.g. 183/200 INVITE) */ if (msg.Contact != null) { this.AddAoRToMessage(msg); } /* RFC 3581 - 4. Server Behavior * When a server compliant to this specification (which can be a proxy * or UAS) receives a request, it examines the topmost Via header field * value. If this Via header field value contains an "rport" parameter * with no value, it MUST set the value of the parameter to the source * port of the request. */ if (msg.FirstVia.RPort == 0) { msg.FirstVia.RPort = msg.FirstVia.Port; } } // serialize the message byte [] bytes = msg.ToBytes(); if (bytes.Length > 1300) { /* RFC 3261 - 18.1.1 Sending Requests (FIXME) * If a request is within 200 bytes of the path MTU, or if it is larger * than 1300 bytes and the path MTU is unknown, the request MUST be sent * using an RFC 2914 [43] congestion controlled transport protocol, such * as TCP. If this causes a change in the transport protocol from the * one indicated in the top Via, the value in the top Via MUST be * changed. This prevents fragmentation of messages over UDP and * provides congestion control for larger messages. However, * implementations MUST be able to handle messages up to the maximum * datagram packet size. For UDP, this size is 65,535 bytes, including * IP and UDP headers. */ } /* === SigComp === */ /* === Send the message === */ //if (/*TNET_Socket.IsIPSec()*/false) //{ // return false; //} //else //{ return(this.SendBytes(TNET_Socket.CreateEndPoint(destIP, destPort), bytes)); //} }