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
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 |
|
---|
33 | /** @file
|
---|
34 | * ARP module.
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef NET_ARP_H_
|
---|
38 | #define NET_ARP_H_
|
---|
39 |
|
---|
40 | #include <fibril_synch.h>
|
---|
41 |
|
---|
42 | #include <ipc/ipc.h>
|
---|
43 | #include <ipc/services.h>
|
---|
44 |
|
---|
45 | #include <net/device.h>
|
---|
46 | #include <net/packet.h>
|
---|
47 | #include <net_hardware.h>
|
---|
48 | #include <adt/generic_char_map.h>
|
---|
49 | #include <adt/int_map.h>
|
---|
50 | #include <adt/measured_strings.h>
|
---|
51 |
|
---|
52 | /** Type definition of the ARP device specific data.
|
---|
53 | * @see arp_device
|
---|
54 | */
|
---|
55 | typedef struct arp_device arp_device_t;
|
---|
56 |
|
---|
57 | /** Type definition of the ARP global data.
|
---|
58 | * @see arp_globals
|
---|
59 | */
|
---|
60 | typedef struct arp_globals arp_globals_t;
|
---|
61 |
|
---|
62 | /** Type definition of the ARP protocol specific data.
|
---|
63 | * @see arp_proto
|
---|
64 | */
|
---|
65 | typedef struct arp_proto arp_proto_t;
|
---|
66 |
|
---|
67 | /** ARP address map.
|
---|
68 | *
|
---|
69 | * Translates addresses.
|
---|
70 | * @see generic_char_map.h
|
---|
71 | */
|
---|
72 | GENERIC_CHAR_MAP_DECLARE(arp_addr, measured_string_t);
|
---|
73 |
|
---|
74 | /** ARP address cache.
|
---|
75 | *
|
---|
76 | * Maps devices to the ARP device specific data.
|
---|
77 | * @see device.h
|
---|
78 | */
|
---|
79 | DEVICE_MAP_DECLARE(arp_cache, arp_device_t);
|
---|
80 |
|
---|
81 | /** ARP protocol map.
|
---|
82 | *
|
---|
83 | * Maps protocol identifiers to the ARP protocol specific data.
|
---|
84 | * @see int_map.h
|
---|
85 | */
|
---|
86 | INT_MAP_DECLARE(arp_protos, arp_proto_t);
|
---|
87 |
|
---|
88 | /** ARP device specific data. */
|
---|
89 | struct arp_device {
|
---|
90 | /** Actual device hardware address. */
|
---|
91 | measured_string_ref addr;
|
---|
92 | /** Actual device hardware address data. */
|
---|
93 | char *addr_data;
|
---|
94 | /** Broadcast device hardware address. */
|
---|
95 | measured_string_ref broadcast_addr;
|
---|
96 | /** Broadcast device hardware address data. */
|
---|
97 | char *broadcast_data;
|
---|
98 | /** Device identifier. */
|
---|
99 | device_id_t device_id;
|
---|
100 | /** Hardware type. */
|
---|
101 | hw_type_t hardware;
|
---|
102 | /** Packet dimension. */
|
---|
103 | packet_dimension_t packet_dimension;
|
---|
104 | /** Device module phone. */
|
---|
105 | int phone;
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * Protocol map.
|
---|
109 | * Address map for each protocol.
|
---|
110 | */
|
---|
111 | arp_protos_t protos;
|
---|
112 |
|
---|
113 | /** Device module service. */
|
---|
114 | services_t service;
|
---|
115 | };
|
---|
116 |
|
---|
117 | /** ARP global data. */
|
---|
118 | struct arp_globals {
|
---|
119 | /** ARP address cache. */
|
---|
120 | arp_cache_t cache;
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * The client connection processing function.
|
---|
124 | * The module skeleton propagates its own one.
|
---|
125 | */
|
---|
126 | async_client_conn_t client_connection;
|
---|
127 |
|
---|
128 | /** Networking module phone. */
|
---|
129 | int net_phone;
|
---|
130 | /** Safety lock. */
|
---|
131 | fibril_rwlock_t lock;
|
---|
132 | };
|
---|
133 |
|
---|
134 | /** ARP protocol specific data. */
|
---|
135 | struct arp_proto {
|
---|
136 | /** Actual device protocol address. */
|
---|
137 | measured_string_ref addr;
|
---|
138 | /** Actual device protocol address data. */
|
---|
139 | char *addr_data;
|
---|
140 | /** Address map. */
|
---|
141 | arp_addr_t addresses;
|
---|
142 | /** Protocol service. */
|
---|
143 | services_t service;
|
---|
144 | };
|
---|
145 |
|
---|
146 | #endif
|
---|
147 |
|
---|
148 | /** @}
|
---|
149 | */
|
---|