Mac Developer Library

Developer

in_arp.h Reference

Options
Deployment Target:

On This Page

in_arp.h Reference

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Not Applicable

Objective-C

@import Kernel;

Included Headers

  • <sys/kernel_types.h>

Functions

  • Declaration

    Objective-C

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

    Parameters

    interface

    The interface the packet was received on.

    arp_op

    The arp operation, ARPOP_REQUEST or ARPOP_REPLY

    sender_hw

    The sender hardware address from the arp payload.

    sender_ip

    The sender IP address from the arp payload.

    target_ip

    The target IP address from the arp payload.

    Return Value

    0 on success or an errno error value on failure.

    Discussion

    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.

    Import Statement

    Objective-C

    #include <in_arp.h>;

    Availability

    Available in OS X v10.4 and later.

  • Declaration

    Objective-C

    void inet_arp_init_ifaddr ( ifnet_t interface, ifaddr_t ipaddr );

    Parameters

    interface

    The interface the packet was received on.

    ipaddr

    The ip interface address.

    Discussion

    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.

    Import Statement

    Objective-C

    #include <in_arp.h>;

    Availability

    Available in OS X v10.4 and later.

  • Declaration

    Objective-C

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

    Parameters

    interface

    The interface the packet is being sent on.

    ip_dest

    The ip destination of the packet.

    ll_dest

    On output, the link-layer destination.

    ll_dest_len

    The length of the buffer for ll_dest.

    hint

    Any routing hint passed down from the protocol.

    packet

    The packet being transmitted.

    Return Value

    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.

    Discussion

    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.

    Import Statement

    Objective-C

    #include <in_arp.h>;

    Availability

    Available in OS X v10.4 and later.