Files | |
file | arp.c |
ARP module implementation. | |
file | arp.h |
ARP module. | |
Data Structures | |
struct | arp_device |
ARP device specific data. More... | |
struct | arp_globals |
ARP global data. More... | |
struct | arp_header |
ARP protocol header. More... | |
struct | arp_proto |
ARP protocol specific data. More... | |
struct | arp_trans |
ARP address translation record. More... | |
ARP operation codes definitions | |
#define | ARPOP_REPLY 2 |
REPLY operation code. | |
#define | ARPOP_REQUEST 1 |
REQUEST operation code. | |
Defines | |
#define | ARP_TRANS_WAIT 1000000 |
Number of microseconds to wait for an ARP reply. | |
#define | NAME "arp" |
ARP module name. | |
Typedefs | |
typedef arp_device | arp_device_t |
Type definition of the ARP device specific data. | |
typedef arp_globals | arp_globals_t |
Type definition of the ARP global data. | |
typedef arp_header | arp_header_t |
Type definition of an ARP protocol header. | |
typedef arp_proto | arp_proto_t |
Type definition of the ARP protocol specific data. | |
typedef arp_trans | arp_trans_t |
Type definition of the ARP address translation record. | |
Functions | |
static int | arp_clean_cache_req (int arp_phone) |
static void | arp_clear_addr (arp_addr_t *addresses) |
static int | arp_clear_address_req (int arp_phone, device_id_t device_id, services_t protocol, measured_string_t *address) |
static void | arp_clear_device (arp_device_t *device) |
Clear the device specific data. | |
static int | arp_clear_device_req (int arp_phone, device_id_t device_id) |
static void | arp_clear_trans (arp_trans_t *trans) |
static int | arp_device_message (device_id_t device_id, services_t service, services_t protocol, measured_string_t *address) |
Register the device. | |
static int | arp_mtu_changed_message (device_id_t device_id, size_t mtu) |
Update the device content length according to the new MTU value. | |
static int | arp_proto_create (arp_proto_t **proto, services_t service, measured_string_t *address) |
Create new protocol specific data. | |
static int | arp_receive_message (device_id_t device_id, packet_t *packet) |
Process the received ARP packet. | |
static void | arp_receiver (ipc_callid_t iid, ipc_call_t *icall) |
Process IPC messages from the registered device driver modules. | |
static int | arp_send_request (device_id_t device_id, services_t protocol, measured_string_t *target, arp_device_t *device, arp_proto_t *proto) |
static int | arp_translate_message (device_id_t device_id, services_t protocol, measured_string_t *target, measured_string_t **translation) |
Return the hardware address for the given protocol address. | |
DEVICE_MAP_DECLARE (arp_cache, arp_device_t) | |
ARP address cache. | |
GENERIC_CHAR_MAP_DECLARE (arp_addr, arp_trans_t) | |
ARP address map. | |
int | il_initialize (int net_phone) |
Module initialization. | |
int | il_module_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, size_t *count) |
Process the internetwork layer module message. | |
INT_MAP_DECLARE (arp_protos, arp_proto_t) | |
ARP protocol map. | |
int | main (int argc, char *argv[]) |
Main entry point. | |
Variables | |
arp_globals_t | arp_globals |
ARP global data. |
typedef struct arp_device arp_device_t |
typedef struct arp_globals arp_globals_t |
typedef struct arp_header arp_header_t |
typedef struct arp_proto arp_proto_t |
typedef struct arp_trans arp_trans_t |
static void arp_clear_device | ( | arp_device_t * | device | ) | [static] |
static int arp_device_message | ( | device_id_t | device_id, | |
services_t | service, | |||
services_t | protocol, | |||
measured_string_t * | address | |||
) | [static] |
Register the device.
Create new device entry in the cache or update the protocol address if the device with the device identifier and the driver service exists.
[in] | device_id | Device identifier. |
[in] | service | Device driver service. |
[in] | protocol | Protocol service. |
[in] | address | Actual device protocol address. |
EEXIST if another device with the same device identifier and different driver service exists.
ENOMEM if there is not enough memory left.
Other error codes as defined for the measured_strings_return() function.
static int arp_mtu_changed_message | ( | device_id_t | device_id, | |
size_t | mtu | |||
) | [static] |
static int arp_proto_create | ( | arp_proto_t ** | proto, | |
services_t | service, | |||
measured_string_t * | address | |||
) | [static] |
Create new protocol specific data.
Allocate and return the needed memory block as the proto parameter.
[out] | proto | Allocated protocol specific data. |
[in] | service | Protocol module service. |
[in] | address | Actual protocol device address. |
ENOMEM if there is not enough memory left.
static int arp_receive_message | ( | device_id_t | device_id, | |
packet_t * | packet | |||
) | [static] |
Process the received ARP packet.
Update the source hardware address if the source entry exists or the packet is targeted to my protocol address.
Respond to the ARP request if the packet is the ARP request and is targeted to my address.
[in] | device_id | Source device identifier. |
[in,out] | packet | Received packet. |
One on success and the packet has been reused.
EINVAL if the packet is too small to carry an ARP packet.
EINVAL if the received address lengths differs from the registered values.
ENOENT if the device is not found in the cache.
ENOENT if the protocol for the device is not found in the cache.
ENOMEM if there is not enough memory left.
static void arp_receiver | ( | ipc_callid_t | iid, | |
ipc_call_t * | icall | |||
) | [static] |
static int arp_translate_message | ( | device_id_t | device_id, | |
services_t | protocol, | |||
measured_string_t * | target, | |||
measured_string_t ** | translation | |||
) | [static] |
Return the hardware address for the given protocol address.
Send the ARP request packet if the hardware address is not found in the cache.
[in] | device_id | Device identifier. |
[in] | protocol | Protocol service. |
[in] | target | Target protocol address. |
[out] | translation | Where the hardware address of the target is stored. |
EAGAIN if the caller should try again.
Other error codes in case of error.
DEVICE_MAP_DECLARE | ( | arp_cache | , | |
arp_device_t | ||||
) |
GENERIC_CHAR_MAP_DECLARE | ( | arp_addr | , | |
arp_trans_t | ||||
) |
int il_initialize | ( | int | net_phone | ) |
int il_module_message | ( | ipc_callid_t | callid, | |
ipc_call_t * | call, | |||
ipc_call_t * | answer, | |||
size_t * | count | |||
) |
Process the internetwork layer module message.
[in] | callid | Message identifier. |
[in] | call | Message parameters. |
[out] | answer | Answer. |
[out] | count | Number of arguments of the answer. |
ENOTSUP if the message is not known.
INT_MAP_DECLARE | ( | arp_protos | , | |
arp_proto_t | ||||
) |
int main | ( | int | argc, | |
char * | argv[] | |||
) |