source: mainline/uspace/srv/net/il/arp/arp.h@ 73ac2e9

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 73ac2e9 was 854151c, checked in by Martin Decky <martin@…>, 15 years ago

store addresses as uint8_t values (char can be both signed or unsigned depending on platform)
improve MAC address printouts

  • Property mode set to 100644
File size: 4.2 KB
RevLine 
[21580dd]1/*
2 * Copyright (c) 2009 Lukas Mejdrech
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup arp
[e9caf47]30 * @{
[21580dd]31 */
32
33/** @file
[e9caf47]34 * ARP module.
[21580dd]35 */
36
[e9caf47]37#ifndef NET_ARP_H_
38#define NET_ARP_H_
[21580dd]39
40#include <fibril_synch.h>
41
42#include <ipc/ipc.h>
43#include <ipc/services.h>
44
[e526f08]45#include <net/device.h>
[e9caf47]46#include <net/packet.h>
[849ed54]47#include <net_hardware.h>
48#include <adt/generic_char_map.h>
49#include <adt/int_map.h>
50#include <adt/measured_strings.h>
[21580dd]51
52/** Type definition of the ARP device specific data.
[e9caf47]53 * @see arp_device
[21580dd]54 */
[e9caf47]55typedef struct arp_device arp_device_t;
[21580dd]56
[a64c64d]57/** Type definition of the ARP global data.
[e9caf47]58 * @see arp_globals
[a64c64d]59 */
[e9caf47]60typedef struct arp_globals arp_globals_t;
[a64c64d]61
[21580dd]62/** Type definition of the ARP protocol specific data.
[e9caf47]63 * @see arp_proto
[21580dd]64 */
[e9caf47]65typedef struct arp_proto arp_proto_t;
[21580dd]66
[fc3dba14]67/** Type definition of the ARP address translation record.
68 * @see arp_trans
69 */
70typedef struct arp_trans arp_trans_t;
71
[a64c64d]72/** ARP address map.
[e9caf47]73 *
74 * Translates addresses.
75 * @see generic_char_map.h
[a64c64d]76 */
[fc3dba14]77GENERIC_CHAR_MAP_DECLARE(arp_addr, arp_trans_t);
[a64c64d]78
[21580dd]79/** ARP address cache.
[e9caf47]80 *
81 * Maps devices to the ARP device specific data.
82 * @see device.h
[21580dd]83 */
[e9caf47]84DEVICE_MAP_DECLARE(arp_cache, arp_device_t);
[21580dd]85
86/** ARP protocol map.
[e9caf47]87 *
88 * Maps protocol identifiers to the ARP protocol specific data.
89 * @see int_map.h
[21580dd]90 */
[e9caf47]91INT_MAP_DECLARE(arp_protos, arp_proto_t);
[21580dd]92
[e9caf47]93/** ARP device specific data. */
94struct arp_device {
95 /** Actual device hardware address. */
[fc3dba14]96 measured_string_t *addr;
[e9caf47]97 /** Actual device hardware address data. */
[854151c]98 uint8_t *addr_data;
[e9caf47]99 /** Broadcast device hardware address. */
[fc3dba14]100 measured_string_t *broadcast_addr;
[e9caf47]101 /** Broadcast device hardware address data. */
[854151c]102 uint8_t *broadcast_data;
[e9caf47]103 /** Device identifier. */
[a64c64d]104 device_id_t device_id;
[e9caf47]105 /** Hardware type. */
[a64c64d]106 hw_type_t hardware;
[e9caf47]107 /** Packet dimension. */
[a64c64d]108 packet_dimension_t packet_dimension;
[e9caf47]109 /** Device module phone. */
[aadf01e]110 int phone;
[e9caf47]111
112 /**
113 * Protocol map.
114 * Address map for each protocol.
[21580dd]115 */
[aadf01e]116 arp_protos_t protos;
[e9caf47]117
118 /** Device module service. */
[aadf01e]119 services_t service;
[21580dd]120};
121
[e9caf47]122/** ARP global data. */
123struct arp_globals {
124 /** ARP address cache. */
[a64c64d]125 arp_cache_t cache;
[e9caf47]126
127 /**
128 * The client connection processing function.
129 * The module skeleton propagates its own one.
[a64c64d]130 */
131 async_client_conn_t client_connection;
[e9caf47]132
133 /** Networking module phone. */
[aadf01e]134 int net_phone;
[e9caf47]135 /** Safety lock. */
[fc3dba14]136 fibril_mutex_t lock;
[a64c64d]137};
138
[e9caf47]139/** ARP protocol specific data. */
140struct arp_proto {
141 /** Actual device protocol address. */
[4eca056]142 measured_string_t *addr;
[e9caf47]143 /** Actual device protocol address data. */
[854151c]144 uint8_t *addr_data;
[e9caf47]145 /** Address map. */
[a64c64d]146 arp_addr_t addresses;
[e9caf47]147 /** Protocol service. */
[a64c64d]148 services_t service;
[21580dd]149};
150
[fc3dba14]151/** ARP address translation record. */
152struct arp_trans {
153 /**
154 * Hardware address for the translation. NULL denotes an incomplete
155 * record with possible waiters.
[854151c]156 */
[fc3dba14]157 measured_string_t *hw_addr;
158 /** Condition variable used for waiting for completion of the record. */
159 fibril_condvar_t cv;
160};
161
[21580dd]162#endif
163
164/** @}
165 */
[fc3dba14]166
Note: See TracBrowser for help on using the repository browser.