public override void ProcessPackage(Package package, AbstractNetworkDevice sender) { //Порт, на который пришел пакет int port = ConnectedDevices.First(x => x.Value == sender).Key; string stage; //Адресован ли пакет нам if (package.EndIP.Peek().Equals(InterfaceAdresses[port].IP)) { //Убираем верхний адрес в пакете //Если ничего нет больше - пакет адресован роутеру, //если есть - надо слать дальше package.EndIP.Pop(); if (package.EndIP.Count == 0) { package.EndIP.Push(InterfaceAdresses[port].IP); stage = Name + " (" + InterfaceAdresses[port] + ") received package " + package + "from " + package.StartIP; Logger.WriteLine(stage); package.AddStage(stage); package.PackageState = Package.State.RECEIVED; PackageManager.AddPackage(package); return; } //Пересылка дальше //проверка по PROXY-таблице bool ispass = is_pass(package); if (!ispass) { stage = Name + " (" + InterfaceAdresses[port] + ") DENIED package " + package; Logger.WriteLine(stage); package.AddStage(stage); package.PackageState = Package.State.DENIED; PackageManager.AddPackage(package); return; } //Проверка по таблице маршрутизации Route route = get_route(package.EndIP.Peek()); if (route == null) { stage = Name + " (" + InterfaceAdresses[port] + ") DON'T find route for package " + package; Logger.WriteLine(stage); package.AddStage(stage); package.PackageState = Package.State.NO_ROUTE; PackageManager.AddPackage(package); return; } if (route.NextRouter != null) { package.EndIP.Push(route.NextRouter); } send(package, route.PortNo); } else { package.PackageState = Package.State.REJECTED; stage = Name + " (" + InterfaceAdresses[0] + ") rejected package " + package; Logger.WriteLine(stage); package.AddStage(stage); PackageManager.AddPackage(package); } }