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