/// <summary>This method handles IPPackets that come from the TAP Device, i.e., /// local system.</summary> /// <remarks>Currently this supports HandleMulticast (ip[0] >= 244 && /// ip[0]<=239), HandleDns (dport = 53 and ip[3] == 1), dhcp (sport 68 and /// dport 67.</remarks> /// <param name="packet">The packet from the TAP device</param> /// <param name="from"> This should always be the tap device</param> protected virtual void HandleIPOut(EthernetPacket packet, ISender ret) { IPPacket ipp = new IPPacket(packet.Payload); if (IpopLog.PacketLog.Enabled) { ProtocolLog.Write(IpopLog.PacketLog, String.Format( "Outgoing {0} packet::IP src: {1}, IP dst: {2}", ipp.Protocol, ipp.SSourceIP, ipp.SDestinationIP)); } if (!IsLocalIP(ipp.SourceIP)) { HandleNewStaticIP(packet.SourceAddress, ipp.SourceIP); return; } UdpPacket udpp = null; switch (ipp.Protocol) { case IPPacket.Protocols.Udp: udpp = new UdpPacket(ipp.Payload); if (udpp.SourcePort == _dhcp_client_port && udpp.DestinationPort == _dhcp_server_port) { if (HandleDhcp(ipp)) { return; } } else if (udpp.DestinationPort == 53 && ipp.DestinationIP.Equals(_dhcp_server.ServerIP)) { if (HandleDns(ipp)) { return; } } break; } if (ipp.DestinationIP[0] >= 224 && ipp.DestinationIP[0] <= 239) { // We don't want to send Brunet multicast packets over IPOP! if (udpp != null && udpp.DestinationPort == IPHandler.mc_port) { return; } else if (HandleMulticast(ipp)) { return; } } if (ipp.DestinationIP.Equals(IPPacket.BroadcastAddress)) { if (HandleBroadcast(ipp)) { return; } } if (HandleOther(ipp)) { return; } if (_dhcp_server == null || ipp.DestinationIP.Equals(_dhcp_server.ServerIP)) { return; } Address target = null; try { target = _address_resolver.Resolve(ipp.DestinationIP) as AHAddress; } catch (AddressResolutionException ex) { if (ex.Issue != AddressResolutionException.Issues.DoesNotExist) { throw; } // Otherwise nothing to do, mapping doesn't exist... } if (target != null) { if (IpopLog.PacketLog.Enabled) { ProtocolLog.Write(IpopLog.PacketLog, String.Format( "Brunet destination ID: {0}", target)); } SendIP(target, packet.Payload); _ondemand.Set(target); } }
public void ConnectTo(Address dst) { _ondemand.Set(dst); }