Address Resolution Protocol (ARP) Service
[Inter-networking layer]


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 Documentation

typedef struct arp_device arp_device_t

Type definition of the ARP device specific data.

See also:
arp_device

Definition at line 52 of file arp.h.

typedef struct arp_globals arp_globals_t

Type definition of the ARP global data.

See also:
arp_globals

Definition at line 57 of file arp.h.

typedef struct arp_header arp_header_t

Type definition of an ARP protocol header.

See also:
arp_header

Definition at line 85 of file arp.c.

typedef struct arp_proto arp_proto_t

Type definition of the ARP protocol specific data.

See also:
arp_proto

Definition at line 62 of file arp.h.

typedef struct arp_trans arp_trans_t

Type definition of the ARP address translation record.

See also:
arp_trans

Definition at line 67 of file arp.h.


Function Documentation

static void arp_clear_device ( arp_device_t device  )  [static]

Clear the device specific data.

Parameters:
[in] device Device specific data.

Definition at line 142 of file arp.c.

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.

Parameters:
[in] device_id Device identifier.
[in] service Device driver service.
[in] protocol Protocol service.
[in] address Actual device protocol address.
Returns:
EOK on success.

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.

Definition at line 484 of file arp.c.

static int arp_mtu_changed_message ( device_id_t  device_id,
size_t  mtu 
) [static]

Update the device content length according to the new MTU value.

Parameters:
[in] device_id Device identifier.
[in] mtu New MTU value.
Returns:
ENOENT if device is not found.

EOK on success.

Definition at line 395 of file arp.c.

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.

Parameters:
[out] proto Allocated protocol specific data.
[in] service Protocol module service.
[in] address Actual protocol device address.
Returns:
EOK on success.

ENOMEM if there is not enough memory left.

Definition at line 248 of file arp.c.

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.

Parameters:
[in] device_id Source device identifier.
[in,out] packet Received packet.
Returns:
EOK on success and the packet is no longer needed.

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.

Definition at line 291 of file arp.c.

static void arp_receiver ( ipc_callid_t  iid,
ipc_call_t icall 
) [static]

Process IPC messages from the registered device driver modules.

Parameters:
[in] iid Message identifier.
[in,out] icall Message parameters.

Definition at line 420 of file arp.c.

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.

Parameters:
[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.
Returns:
EOK on success.

EAGAIN if the caller should try again.

Other error codes in case of error.

Definition at line 705 of file arp.c.

DEVICE_MAP_DECLARE ( arp_cache  ,
arp_device_t   
)

ARP address cache.

Maps devices to the ARP device specific data.

See also:
device.h

GENERIC_CHAR_MAP_DECLARE ( arp_addr  ,
arp_trans_t   
)

ARP address map.

Translates addresses.

See also:
generic_char_map.h

int il_initialize ( int  net_phone  ) 

Module initialization.

This has to be implemented in user code.

Parameters:
[in] net_phone Networking module phone.
Returns:
EOK on success.

Other error codes as defined for each specific module initialize function.

Definition at line 629 of file arp.c.

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.

Parameters:
[in] callid Message identifier.
[in] call Message parameters.
[out] answer Answer.
[out] count Number of arguments of the answer.
Returns:
EOK on success.

ENOTSUP if the message is not known.

See also:
arp_interface.h

IS_NET_ARP_MESSAGE()

Definition at line 838 of file arp.c.

INT_MAP_DECLARE ( arp_protos  ,
arp_proto_t   
)

ARP protocol map.

Maps protocol identifiers to the ARP protocol specific data.

See also:
int_map.h

int main ( int  argc,
char *  argv[] 
)

Main entry point.

Parameters:
[in] argc Nmber of arguments in argv vector (ignored).
[in] argv Cmdline argument vector (ignored).
Returns:
Error code.
Driver debug level is set here.

Definition at line 911 of file arp.c.


Generated on Thu Jun 2 07:45:55 2011 for HelenOS/USB by  doxygen 1.4.7