/// <summary>This method handles IPPackets that come from Brunet, i.e., /// abroad. </summary> /// <param name="packet"> The packet from Brunet.</param> /// <param name="ret">An ISender to send data to the Brunet node that sent /// the packet.</param> public virtual void HandleIPIn(MemBlock packet, ISender ret) { Address addr = _conn_handler.GetAddress(ret); if (_translator != null) { try { packet = _translator.Translate(packet, addr); } catch (Exception e) { if (ProtocolLog.Exceptions.Enabled) { ProtocolLog.Write(ProtocolLog.Exceptions, e.ToString()); } return; } } IPPacket ipp = new IPPacket(packet); if (!_address_resolver.Check(ipp.SourceIP, addr)) { Address other = _address_resolver.Resolve(ipp.SourceIP); if (other == null) { MissedMapping(ipp.SSourceIP, addr); return; } else if (other != addr) { ProtocolLog.WriteIf(IpopLog.ResolverLog, String.Format( "IP:P2P Mismatch IP: {0}, Claimed P2P: {1}, Local P2P: {2}", ipp.SourceIP, addr, other)); return; } } if (IpopLog.PacketLog.Enabled) { ProtocolLog.Write(IpopLog.PacketLog, String.Format( "Incoming packet:: IP src: {0}, IP dst: {1}, p2p " + "from: {2}, size: {3}", ipp.SSourceIP, ipp.SDestinationIP, ret, packet.Length)); } WriteIP(packet); }
/// <summary>This method handles IPPackets that come from Brunet, i.e., /// abroad. </summary> /// <param name="packet"> The packet from Brunet.</param> /// <param name="ret">An ISender to send data to the Brunet node that sent /// the packet.</param> public virtual void HandleIPIn(MemBlock packet, ISender ret) { if (_secure_senders && !(ret is SecurityAssociation)) { return; } Address addr = null; if (ret is SecurityAssociation) { ret = ((SecurityAssociation)ret).Sender; } if (ret is AHSender) { addr = ((AHSender)ret).Destination; } else { ProtocolLog.Write(IpopLog.PacketLog, String.Format( "Incoming packet was not from an AHSender: {0}.", ret)); return; } if (_translator != null) { try { packet = _translator.Translate(packet, addr); } catch (Exception e) { if (ProtocolLog.Exceptions.Enabled) { ProtocolLog.Write(ProtocolLog.Exceptions, e.ToString()); } return; } } IPPacket ipp = new IPPacket(packet); try { if (!_address_resolver.Check(ipp.SourceIP, addr)) { return; } } catch (AddressResolutionException ex) { if (ex.Issue == AddressResolutionException.Issues.DoesNotExist) { ProtocolLog.WriteIf(IpopLog.ResolverLog, "Notifying remote node of " + " missing address: " + addr + ":" + ipp.SSourceIP); ISender sender = new AHExactSender(AppNode.Node, addr); AppNode.Node.Rpc.Invoke(sender, null, "Ipop.NoSuchMapping", ipp.SSourceIP); return; } else { throw; } } if (IpopLog.PacketLog.Enabled) { ProtocolLog.Write(IpopLog.PacketLog, String.Format( "Incoming packet:: IP src: {0}, IP dst: {1}, p2p " + "from: {2}, size: {3}", ipp.SSourceIP, ipp.SDestinationIP, ret, packet.Length)); } WriteIP(packet); }