public static List <SIPChannel> ParseSIPChannelsNode(IPAddress localIP, ushort localPort)
        {
            var sipChannels = new List <SIPChannel>();
            var udpChannel  = new SIPUDPChannel(new IPEndPoint(localIP, localPort));

            sipChannels.Add(udpChannel);
            return(sipChannels);
        }
        public static List <SIPChannel> ParseSIPChannelsNode(List <SIPAccount> accounts)
        {
            var sipChannels = new List <SIPChannel>();

            foreach (SIPAccount account in accounts)
            {
                if (PortListen(sipChannels, account))
                {
                    continue;
                }
                IPEndPoint localEP    = new IPEndPoint(account.LocalIP, account.LocalPort);
                var        udpChannel = new SIPUDPChannel(localEP);
                sipChannels.Add(udpChannel);
            }
            return(sipChannels);
        }
        public static List <SIPChannel> ParseSIPChannelsNode(List <SIPAccount> accounts)
        {
            List <SIPChannel> channels = new List <SIPChannel>();

            foreach (var user in accounts)
            {
                bool hasPort = channels.Any(d => d.SIPChannelEndPoint.Port == user.LocalPort);
                if (hasPort)
                {
                    continue;
                }
                SIPChannel udpChannel = new SIPUDPChannel(new IPEndPoint(user.LocalIP, user.LocalPort));
                channels.Add(udpChannel);
            }
            return(channels);
        }
        public static List <SIPChannel> ParseSIPChannelsNode(IPAddress localIP, ushort localPort, ProtocolType msgProtocol)
        {
            List <SIPChannel> channels = new List <SIPChannel>();
            SIPChannel        channel  = null;

            if (msgProtocol == ProtocolType.Udp)
            {
                channel = new SIPUDPChannel(new IPEndPoint(localIP, localPort));
                channels.Add(channel);
            }
            else if (msgProtocol == ProtocolType.Tcp)
            {
                channel = new SIPUDPChannel(new IPEndPoint(localIP, localPort));
                channels.Add(channel);
                channel = new SIPTCPChannel(new IPEndPoint(localIP, localPort));
                channels.Add(channel);
            }
            return(channels);
        }
        public static List <SIPChannel> ParseSIPChannelsNode(SIPAccount sipAccount)
        {
            var channels = new List <SIPChannel>();

            var ipEndPoint = new IPEndPoint(sipAccount.LocalIP, sipAccount.LocalPort);

            SIPChannel channel = null;

            if (sipAccount.MsgProtocol == ProtocolType.Udp)
            {
                channel = new SIPUDPChannel(ipEndPoint);
                channels.Add(channel);
            }
            else if (sipAccount.MsgProtocol == ProtocolType.Tcp)
            {
                channel = new SIPUDPChannel(ipEndPoint);
                channels.Add(channel);
                channel = new SIPTCPChannel(ipEndPoint);
                channels.Add(channel);
            }
            return(channels);
        }
        public static List <SIPChannel> ParseSIPChannelsNode(XmlNode sipChannelsNode, int port = 0)
        {
            var sipChannels = new List <SIPChannel>();

            foreach (XmlNode sipSocketNode in sipChannelsNode.ChildNodes)
            {
                logger.Debug("Creating SIP Channel for " + sipSocketNode.OuterXml + ".");

                var localSocket = sipSocketNode.InnerText;

                var protocol = SIPProtocolsEnum.udp;
                if (sipSocketNode.Attributes.GetNamedItem(SIP_PROTOCOL_PARAMETER) != null)
                {
                    protocol = SIPProtocolsType.GetProtocolType(sipSocketNode.Attributes.GetNamedItem(SIP_PROTOCOL_PARAMETER).Value);
                }

                var nodeSIPEndPoints = GetSIPEndPoints(localSocket, protocol, port);

                foreach (var sipEndPoint in nodeSIPEndPoints)
                {
                    try
                    {
                        switch (protocol)
                        {
                        case SIPProtocolsEnum.udp:
                        {
                            logger.Debug(" attempting to create SIP UDP channel for " + sipEndPoint.GetIPEndPoint() + ".");
                            var udpChannel = new SIPUDPChannel(sipEndPoint.GetIPEndPoint());
                            sipChannels.Add(udpChannel);
                        }
                        break;

                        case SIPProtocolsEnum.tcp:
                        {
                            logger.Debug(" attempting to create SIP TCP channel for " + sipEndPoint.GetIPEndPoint() + ".");

                            var tcpChannel = new SIPTCPChannel(sipEndPoint.GetIPEndPoint());
                            sipChannels.Add(tcpChannel);
                        }
                        break;

                        case SIPProtocolsEnum.tls:
                            if (sipSocketNode.Attributes.GetNamedItem(CERTIFICATE_PATH_PARAMETER) == null)
                            {
                                logger.Warn("Could not create SIPTLSChannel from XML configuration node as no " + CERTIFICATE_PATH_PARAMETER + " attribute was present.");
                            }
                            else
                            {
                                var certificateType = "machinestore";
                                if (sipSocketNode.Attributes.GetNamedItem(CERTIFICATE_TYPE_PARAMETER) != null)
                                {
                                    certificateType = sipSocketNode.Attributes.GetNamedItem(CERTIFICATE_TYPE_PARAMETER).Value;
                                }

                                var certificatePath        = (sipSocketNode.Attributes.GetNamedItem(CERTIFICATE_PATH_PARAMETER) != null) ? sipSocketNode.Attributes.GetNamedItem(CERTIFICATE_PATH_PARAMETER).Value : null;
                                var certificateKeyPassword = (sipSocketNode.Attributes.GetNamedItem(CERTIFICATE_KEY_PASSWORD_PARAMETER) != null) ? sipSocketNode.Attributes.GetNamedItem(CERTIFICATE_KEY_PASSWORD_PARAMETER).Value : String.Empty;
                                logger.Debug(" attempting to create SIP TLS channel for " + sipEndPoint.GetIPEndPoint() + " and certificate type of " + certificateType + " at " + certificatePath + ".");
                                var certificate = LoadCertificate(certificateType, certificatePath, certificateKeyPassword);
                                if (certificate != null)
                                {
                                    var tlsChannel = new SIPTLSChannel(certificate, sipEndPoint.GetIPEndPoint());
                                    sipChannels.Add(tlsChannel);
                                }
                                else
                                {
                                    logger.Warn("A SIP TLS channel was not created because the certificate could not be loaded.");
                                }
                            }
                            break;

                        default:
                            logger.Warn("Could not create a SIP channel for protocol " + protocol + ".");
                            break;
                        }
                    }
                    catch (Exception excp)
                    {
                        logger.Warn("Exception SIPTransportConfig Adding SIP Channel for " + sipEndPoint + ". " + excp.Message);
                    }
                }
            }

            return(sipChannels);
        }