Title: arp_port

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

int ap_flags;
int ap_state;
int ap_eth_port;
int ap_ip_port;
int ap_eth_fd;
ether_addr_t ap_ethaddr;
ipaddr_t ap_ipaddr;
timer_t ap_timer;

ether_addr_t ap_write_ethaddr;
ipaddr_t ap_write_ipaddr;
int ap_write_code;

ipaddr_t ap_req_ipaddr;
int ap_req_count;

arp_func_t ap_arp_func;
} arp_port_t;
int ap_flags:

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.

int ap_state:

#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.

int ap_eth_fd:

The index of the arp port's associated ethernet file descriptor within eth_fd_table[].

ether_addr_t ap_ethaddr:

The ethernet address of the underlying ethernet port.

ipaddr_t ap_ipaddr:

The ip address of the associated ip port.

timer_t ap_timer:

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.

ether_addr_t ap_write_ethaddr:
ipaddr_t ap_write_ipaddr:
int ap_write_code:

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).

ipaddr_t ap_req_ipaddr:

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.

int ap_req_count:

Four arp-requests are allowed to resolve the ip address held in the ap_req_ipaddr field.

arp_func_t ap_arp_func:

ap_arp_func is set to ipeth_arp_reply().