Title: ip_arrived()


Depending on the destination ip address of its second parameter,
ip_arrived(ip_port, pack) does one of several things:

1) If the destination ip address is the ip address of the ip port associated with the ethernet port, ip_arrived() calls ip_port_arrive() for the packet.

2) If the destination ip address is the ip address of another ip port, ip_arrived() also calls ip_port_arrived(). This time, however, the first argument passed to ip_port_arrived() is the other port. Note that for this to take place, an input route to the other ip port must exist.

3) If the destination ip address is not the address of another ip port but it is in the same network as another ip port, ip_arrived() sends the packet out the other interface. Again, an input route to the other ip port for this destination must exist.

4) If the destination ip address is not the address of another ip port and it is not in the same network as another ip port, ip_arrived() sends the packet out to the gateway for this network. Again, an input route (including the gateway) to the other ip port for this destination must exist.

5) If the destination ip address is not the ip address of the ip port but an input route for the destination exists and is associated with the same ip port as the packet arrived, an icmp redirect message is sent to the source (provided the source is on the same network) and the packet is then sent. If the source of the ip packet is not on the same network as the ip port, the packet is dropped.

If an ip packet arrives on an ethernet interface, ip_eth_arrived() strips off a packet's ethernet header before handing the packet off to ip_arrived().