For each ip port that uses an ethernet port (as opposed to a psip port), there will be one arp port.
typedef struct arp_port
ap_flags can be one or more of the following:
#define APF_EMPTY 0
#define APF_ARP_RD_IP 0x4
#define APF_ARP_RD_SP 0x8
#define APF_ARP_WR_IP 0x10
#define APF_ARP_WR_SP 0x20
#define APF_INADDR_SET 0x100
#define APF_MORE2WRITE 0x200
#define APF_CLIENTREQ 0x400
#define APF_CLIENTWRITE 0x1000
#define APF_SUSPEND 0x2000
Most of the flags are used to either indicate the state of the arp port or the state of a current read or write and are therefore somewhat uninteresting. An exception is APF_CLIENTREQ; APF_CLIENTREQ is set if an arp-request packet has been sent out but a reply has not yet been received.
#define APS_INITIAL 0x00
#define APS_GETADDR 0x01
#define APS_ARPSTART 0x10
#define APS_ARPPROTO 0x20
#define APS_ARPMAIN 0x40
#define APS_ERROR 0x80
APS_ARPMAIN is the arp port's normal operational state. All states except for APS_ERROR are initialization states.
int ap_eth_port, ap_ip_port:
ap_eth_port and ap_ip_port are the ip port and the ip port's associated ethernet port and are the ports that receive the arp broadcasts that detail the ip address to ethernet port mappings.
The index of the arp port's associated ethernet file descriptor within eth_fd_table.
The ethernet address of the underlying ethernet port.
The ip address of the associated ip port.
When an arp-request is sent out, a timer is set (to which ap_timer points). If an arp-reply is not received for this arp-request within a half second, arp_timeout() is called. If fewer than four arp-requests have already been sent out, arp_timeout() simply calls setup_write() to send out another arp-request. If four arp-requests have already been sent out, the arp table entry is marked as unreachable and client_reply() is called to alert interested ip file descriptors.
When an arp-reply or an arp-request packet is being created, the values of these 3 fields are used to get the target ethernet and ip addresses and the write code (either ARP_REQUEST or ARP_REPLY).
If an entry for a destination ip address cannot be found in the arp table, this ip address is placed in the ap_req_ipaddr field. When the arp port is able to send out the arp request, the ap_req_ipaddr field is copied to the ap_write_ipaddr field.
Four arp-requests are allowed to resolve the ip address held in the ap_req_ipaddr field.
ap_arp_func is set to ipeth_arp_reply().