ADC Home > Reference Library > Reference > Darwin > KPI Reference
|
in_arp.h |
Includes: | <sys/kernel_types.h> |
inet_arp_handle_input |
errno_t inet_arp_handle_input( ifnet_t ifp, u_int16_t arpop, const struct sockaddr_dl *sender_hw, const struct sockaddr_in *sender_ip, const struct sockaddr_in *target_ip);
interface
arp_op
sender_hw
sender_ip
target_ip
0 on success or an errno error value on failure.
This function should be called by code that handles
inbound arp packets. The caller should parse the ARP packet to
pull out the operation and the relevant addresses. If a response
is required, the proto_media_send_arp function will be called.
This function will lookup the sender in the routing table and
add an arp entry if necessary. Any queued packets waiting for
the arp resolution will also be transmitted.
inet_arp_init_ifaddr |
void inet_arp_init_ifaddr( ifnet_t interface, ifaddr_t ipaddr);
interface
ipaddr
This function should be called in two places, when an IP
address is added and when the hardware address changes. This
function will setup the ifaddr_t for use with the IP ARP
functions. This function will also trigger the transmission of a
gratuitous ARP packet.
When the SIOCSIFADDR ioctl is handled, the data parameter will
be an ifaddr_t. If this is an IP address, inet_arp_init_ifaddr
should be called. This is usually performed in the protocol
attachment's ioctl handler.
When the event handler for the protocol attachment receives a
KEV_DL_LINK_ADDRESS_CHANGED event, the event handler should call
inet_arp_init_ifaddr for each interface ip address.
For an example, see bsd/net/ether_inet_pr_module.c in xnu.
Search for inet_arp_init_ifaddr.
inet_arp_lookup |
errno_t inet_arp_lookup( ifnet_t interface, const struct sockaddr_in *ip_dest, struct sockaddr_dl *ll_dest, size_t ll_dest_len, route_t hint, mbuf_t packet);
interface
ip_dest
ll_dest
ll_dest_len
hint
packet
May return an error such as EHOSTDOWN or ENETUNREACH. If this function returns EJUSTRETURN, the packet has been queued and will be sent when an arp response is received. If any other value is returned, the caller is responsible for disposing of the packet.
This function will check the routing table for a cached
arp entry or trigger an arp query to resolve the ip address to a
link-layer address.
Arp entries are stored in the routing table. This function will
lookup the ip destination in the routing table. If the
destination requires forwarding to a gateway, the route of the
gateway will be looked up. The route entry is inspected to
determine if the link layer destination address is known. If
unknown, the arp generation function for IP attached to the
interface is called to create an arp request packet.
|