示例#1
0
        private static TlfNet CreateIpNet(string number, Scv scv)
        {
            TlfNet net = new TlfNet();

            net.Id = "Net_ATS_IP_" + scv.Id;

            Rs <GwTlfRs> rs = Top.Registry.GetRs <GwTlfRs>(number);
            string       ScvIp;

            if (rs.Content == null)
            {
                //Si el recurso no tiene contenido actualizado, la IP es de los datos de configuración (principal)
                string id;
                ScvIp = scv.GetProxyIp(out id);
                if (rs.IsUnreferenced)
                {
                    //Para que recién creado por defecto aparezca sin aspa, le añado un recurso
                    GwTlfRs proxyRs = new GwTlfRs();
                    proxyRs.GwIp = ScvIp;
                    rs.Reset(null, proxyRs);
                }
            }
            else
            {
                //Utilizo los datos del recurso (actualizado con el activo)
                ScvIp = ((GwTlfRs)rs.Content).GwIp;
            }
            SipLine line = new SipLine(rs, ScvIp, true);

            net.Lines.Add(line);
            net.RsTypes.Add(new RsIdxType(net.Lines.Count - 1, 0, TipoInterface.TI_IP_PROXY));
            net.Routes.Add(0);
            return(net);
        }
示例#2
0
        public TlfNet GetNet(uint prefix, string number, ref StrNumeroAbonado altRoute)
        {
            string idEquipo;

            if (prefix == Cd40Cfg.ATS_DST)
            {
                ulong num;

                if (ulong.TryParse(number, out num))
                {
                    int centralId = -1;

                    foreach (NumeracionATS centralAts in _SystemCfg.PlanNumeracionATS)
                    {
                        bool foundCentralAts = false;
                        centralId++;

                        foreach (RangosSCV range in centralAts.RangosOperador)
                        {
                            if ((range.Inicial <= num) && (range.Final >= num))
                            {
                                if (!string.IsNullOrEmpty(range.IdAbonado))
                                {
                                    altRoute               = new StrNumeroAbonado();
                                    altRoute.Prefijo       = range.IdPrefijo;
                                    altRoute.NumeroAbonado = range.IdAbonado;
                                }

                                foundCentralAts = true;
                                break;
                            }
                        }

                        if (!foundCentralAts)
                        {
                            foreach (RangosSCV range in centralAts.RangosPrivilegiados)
                            {
                                if ((range.Inicial <= num) && (range.Final >= num))
                                {
                                    if (!string.IsNullOrEmpty(range.IdAbonado))
                                    {
                                        altRoute               = new StrNumeroAbonado();
                                        altRoute.Prefijo       = range.IdPrefijo;
                                        altRoute.NumeroAbonado = range.IdAbonado;
                                    }

                                    foundCentralAts = true;
                                    break;
                                }
                            }
                        }

                        if (foundCentralAts)
                        {
                            int    route = 0;
                            TlfNet net   = new TlfNet();
                            net.Id = "Net_ATS_" + centralId;

                            foreach (PlanRutas ruta in centralAts.ListaRutas)
                            {
                                // Primero van las rutas directas y luego el resto
                                route = (ruta.TipoRuta == "D") ? route : ++route;

                                foreach (string trunk in ruta.ListaTroncales)
                                {
                                    foreach (PlanRecursos recurso in _SystemCfg.GetTrunkResources(trunk))
                                    {
                                        Rs <GwTlfRs> rs   = Top.Registry.GetRs <GwTlfRs>(recurso.IdRecurso);
                                        string       rsIp = GetGwRsIp(recurso.IdRecurso, out idEquipo);
                                        SipLine      line = new SipLine(rs, rsIp);

                                        net.Lines.Add(line);
                                        net.RsTypes.Add(new RsIdxType(net.Lines.Count - 1, route, recurso.Tipo));
                                        net.Routes.Add(route);
                                    }
                                }
                            }

                            /*
                             *
                             *  Los recursos dentro de un troncal ya no se ordenan primero los de R2
                             *  y luego los de N-5 (tal y como se hizo para ACC). Se ordenan primero lado A
                             *  y luego lado B (Según Encamina (02/06) ).
                             *  Incidencia #2521
                             * net.RsTypes.Sort(delegate(RsIdxType a, RsIdxType b)
                             * {
                             *  if (a.ruta == b.ruta)
                             *      return a.TipoInteface - b.TipoInteface;
                             *  if (a.ruta < b.ruta)
                             *      return -1;
                             *
                             *  return 1;
                             * });
                             */
                            return(net);
                        }
                    }
                    //Devuelve una red vacía si no lo encuentra en la configuración
                    _Logger.Info("Linea no encontrada para prefijo {0} {1}", prefix, number);
                    TlfNet emptyNet = new TlfNet();
                    emptyNet.Id = "Net_ATS_" + centralId;
                    return(emptyNet);
                }
            }
            // Por acceso indirecto, el prefijo PP
            // se comporta como un abonado con marcación
            else if (prefix == Cd40Cfg.PP_DST)
            {
                TlfNet       net = new TlfNet();
                Rs <GwTlfRs> rs  = null;
                net.Id = "Net_" + "SEGURIDAD";
                //Busca el equipo que le da servicio, pasarela o proxy
                string rsIp = GetGwRsIp(number, out idEquipo);
                if (idEquipo != null)
                {
                    rs = Top.Registry.GetRs <GwTlfRs>(number);
                }
                if (rs == null)
                {
                    //o nuestro proxy si es un teléfono IP no configurado
                    if ((rsIp == null) || (idEquipo == null))
                    {
                        rsIp = GetProxyIp(out idEquipo);
                        rs   = Top.Registry.GetRs <GwTlfRs>(idEquipo);
                    }
                    _Logger.Warn("Number not found in configurated resources {0}, use {1} instead", number, idEquipo);
                }
                //rs.Reset(null, new GwTlfRs());
                if (rs != null)
                {
                    _Logger.Debug("Resource found for {0}: {1}", number, rs.Id);

                    SipLine line = new SipLine(rs, rsIp);
                    net.Lines.Add(line);
                    net.Routes.Add(0);
                    net.RsTypes.Add(new RsIdxType(net.Lines.Count - 1, 0, TipoInterface.TI_BL));
                }
                else
                {
                    _Logger.Error("{0} not found in conf resources {0} and proxy not found either.", number, idEquipo);
                }
                return(net);
            }
            else if (prefix == Cd40Cfg.UNKNOWN_DST) //Destinos entrantes que no están configurados
            {
                TlfNet net = new TlfNet();
                net.Id = "Net_" + "SEGURIDAD";
                string rsIp = GetProxyIp(out idEquipo);
                if (rsIp != null)
                {
                    Rs <GwTlfRs> rs      = Top.Registry.GetRs <GwTlfRs>(idEquipo);
                    GwTlfRs      proxyRs = new GwTlfRs();
                    proxyRs.GwIp = rsIp;
                    rs.Reset(null, proxyRs);

                    SipLine line = new SipLine(rs, rsIp);
                    net.Lines.Add(line);
                    net.Routes.Add(0);
                    net.RsTypes.Add(new RsIdxType(net.Lines.Count - 1, 0, TipoInterface.TI_BL));

                    return(net);
                }
            }
            else if (prefix == Cd40Cfg.IP_DST)
            {
                TlfNet net = new TlfNet();
                net.Id = "Net_" + "SEGURIDAD";
                string rsIp = GetProxyIp(out idEquipo);
                if (rsIp != null)
                {
                    Rs <GwTlfRs> rs      = Top.Registry.GetRs <GwTlfRs>(idEquipo);
                    GwTlfRs      proxyRs = new GwTlfRs();
                    proxyRs.GwIp = rsIp;
                    rs.Reset(null, proxyRs);

                    SipLine line = new SipLine(rs, rsIp);
                    net.Lines.Add(line);
                    net.Routes.Add(0);
                    net.RsTypes.Add(new RsIdxType(net.Lines.Count - 1, 0, TipoInterface.TI_BL));

                    return(net);
                }
            }
            else
            {
                foreach (ListaRedes red in _SystemCfg.PlanRedes)
                {
                    if (red.Prefijo == prefix)
                    {
                        TlfNet net = new TlfNet();
                        net.Id = "Net_" + red.IdRed;

                        foreach (PlanRecursos recurso in red.ListaRecursos)
                        {
                            string       rsIp;
                            Rs <GwTlfRs> rs = Top.Registry.GetRs <GwTlfRs>(recurso.IdRecurso);
                            rsIp = GetGwRsIp(recurso.IdRecurso, out idEquipo);
                            SipLine line = new SipLine(rs, rsIp);

                            net.Lines.Add(line);
                            net.RsTypes.Add(new RsIdxType(net.Lines.Count - 1, altRoute != null ? 1000 : 0, TipoInterface.TI_AB));
                            // Si altRoute es distinto de null es que estamos obteniendo la red
                            // de salida alternativa para un numero ATS. Esta red sólo se tiene
                            // que usar cuando no podemos salir por la propia red ATS, por eso
                            // ponemos un valor elevado de ruta de modo que se coja en GetDetourPath
                            net.Routes.Add(altRoute != null ? 1000 : 0);
                        }

                        return(net);
                    }
                }
            }

            return(null);
        }