| [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
|
|---|
| 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 |
|
|---|
| [849ed54] | 45 | #include <net_device.h>
|
|---|
| 46 | #include <net_hardware.h>
|
|---|
| 47 | #include <adt/generic_char_map.h>
|
|---|
| 48 | #include <adt/int_map.h>
|
|---|
| 49 | #include <adt/measured_strings.h>
|
|---|
| [21580dd] | 50 |
|
|---|
| 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 device specific data pointer.
|
|---|
| 58 | * @see arp_device
|
|---|
| 59 | */
|
|---|
| 60 | typedef arp_device_t * arp_device_ref;
|
|---|
| 61 |
|
|---|
| [a64c64d] | 62 | /** Type definition of the ARP global data.
|
|---|
| 63 | * @see arp_globals
|
|---|
| 64 | */
|
|---|
| 65 | typedef struct arp_globals arp_globals_t;
|
|---|
| 66 |
|
|---|
| [21580dd] | 67 | /** Type definition of the ARP protocol specific data.
|
|---|
| 68 | * @see arp_proto
|
|---|
| 69 | */
|
|---|
| 70 | typedef struct arp_proto arp_proto_t;
|
|---|
| 71 |
|
|---|
| 72 | /** Type definition of the ARP protocol specific data pointer.
|
|---|
| 73 | * @see arp_proto
|
|---|
| 74 | */
|
|---|
| 75 | typedef arp_proto_t * arp_proto_ref;
|
|---|
| 76 |
|
|---|
| [a64c64d] | 77 | /** ARP address map.
|
|---|
| 78 | * Translates addresses.
|
|---|
| 79 | * @see generic_char_map.h
|
|---|
| 80 | */
|
|---|
| 81 | GENERIC_CHAR_MAP_DECLARE(arp_addr, measured_string_t)
|
|---|
| 82 |
|
|---|
| [21580dd] | 83 | /** ARP address cache.
|
|---|
| 84 | * Maps devices to the ARP device specific data.
|
|---|
| 85 | * @see device.h
|
|---|
| 86 | */
|
|---|
| [aadf01e] | 87 | DEVICE_MAP_DECLARE(arp_cache, arp_device_t)
|
|---|
| [21580dd] | 88 |
|
|---|
| 89 | /** ARP protocol map.
|
|---|
| 90 | * Maps protocol identifiers to the ARP protocol specific data.
|
|---|
| 91 | * @see int_map.h
|
|---|
| 92 | */
|
|---|
| [aadf01e] | 93 | INT_MAP_DECLARE(arp_protos, arp_proto_t)
|
|---|
| [21580dd] | 94 |
|
|---|
| 95 | /** ARP device specific data.
|
|---|
| 96 | */
|
|---|
| 97 | struct arp_device{
|
|---|
| 98 | /** Actual device hardware address.
|
|---|
| 99 | */
|
|---|
| [aadf01e] | 100 | measured_string_ref addr;
|
|---|
| [21580dd] | 101 | /** Actual device hardware address data.
|
|---|
| 102 | */
|
|---|
| [aadf01e] | 103 | char * addr_data;
|
|---|
| [21580dd] | 104 | /** Broadcast device hardware address.
|
|---|
| 105 | */
|
|---|
| [aadf01e] | 106 | measured_string_ref broadcast_addr;
|
|---|
| [21580dd] | 107 | /** Broadcast device hardware address data.
|
|---|
| 108 | */
|
|---|
| [aadf01e] | 109 | char * broadcast_data;
|
|---|
| [a64c64d] | 110 | /** Device identifier.
|
|---|
| [21580dd] | 111 | */
|
|---|
| [a64c64d] | 112 | device_id_t device_id;
|
|---|
| 113 | /** Hardware type.
|
|---|
| 114 | */
|
|---|
| 115 | hw_type_t hardware;
|
|---|
| 116 | /** Packet dimension.
|
|---|
| 117 | */
|
|---|
| 118 | packet_dimension_t packet_dimension;
|
|---|
| [21580dd] | 119 | /** Device module phone.
|
|---|
| 120 | */
|
|---|
| [aadf01e] | 121 | int phone;
|
|---|
| [21580dd] | 122 | /** Protocol map.
|
|---|
| 123 | * Address map for each protocol.
|
|---|
| 124 | */
|
|---|
| [aadf01e] | 125 | arp_protos_t protos;
|
|---|
| [a64c64d] | 126 | /** Device module service.
|
|---|
| [21580dd] | 127 | */
|
|---|
| [aadf01e] | 128 | services_t service;
|
|---|
| [21580dd] | 129 | };
|
|---|
| 130 |
|
|---|
| 131 | /** ARP global data.
|
|---|
| 132 | */
|
|---|
| 133 | struct arp_globals{
|
|---|
| [a64c64d] | 134 | /** ARP address cache.
|
|---|
| 135 | */
|
|---|
| 136 | arp_cache_t cache;
|
|---|
| 137 | /** The client connection processing function.
|
|---|
| 138 | * The module skeleton propagates its own one.
|
|---|
| 139 | */
|
|---|
| 140 | async_client_conn_t client_connection;
|
|---|
| [21580dd] | 141 | /** Networking module phone.
|
|---|
| 142 | */
|
|---|
| [aadf01e] | 143 | int net_phone;
|
|---|
| [21580dd] | 144 | /** Safety lock.
|
|---|
| 145 | */
|
|---|
| [aadf01e] | 146 | fibril_rwlock_t lock;
|
|---|
| [a64c64d] | 147 | };
|
|---|
| 148 |
|
|---|
| 149 | /** ARP protocol specific data.
|
|---|
| 150 | */
|
|---|
| 151 | struct arp_proto{
|
|---|
| 152 | /** Actual device protocol address.
|
|---|
| [21580dd] | 153 | */
|
|---|
| [a64c64d] | 154 | measured_string_ref addr;
|
|---|
| 155 | /** Actual device protocol address data.
|
|---|
| [21580dd] | 156 | */
|
|---|
| [a64c64d] | 157 | char * addr_data;
|
|---|
| 158 | /** Address map.
|
|---|
| 159 | */
|
|---|
| 160 | arp_addr_t addresses;
|
|---|
| 161 | /** Protocol service.
|
|---|
| 162 | */
|
|---|
| 163 | services_t service;
|
|---|
| [21580dd] | 164 | };
|
|---|
| 165 |
|
|---|
| 166 | #endif
|
|---|
| 167 |
|
|---|
| 168 | /** @}
|
|---|
| 169 | */
|
|---|