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