Rev 4704 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 3466 | mejdrech | 1 | /* |
| 3912 | mejdrech | 2 | * Copyright (c) 2009 Lukas Mejdrech |
| 3466 | 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 | |||
| 3912 | mejdrech | 29 | /** @addtogroup ip |
| 30 | * @{ |
||
| 3466 | mejdrech | 31 | */ |
| 32 | |||
| 4704 | mejdrech | 33 | /** @file |
| 34 | * IP module. |
||
| 3466 | mejdrech | 35 | */ |
| 36 | |||
| 3846 | mejdrech | 37 | #ifndef __NET_IP_H__ |
| 38 | #define __NET_IP_H__ |
||
| 3466 | mejdrech | 39 | |
| 4582 | mejdrech | 40 | #include <fibril_sync.h> |
| 4558 | mejdrech | 41 | |
| 3466 | mejdrech | 42 | #include <ipc/ipc.h> |
| 4505 | mejdrech | 43 | #include <ipc/services.h> |
| 3466 | mejdrech | 44 | |
| 4243 | mejdrech | 45 | #include "../../include/device.h" |
| 4558 | mejdrech | 46 | #include "../../include/inet.h" |
| 4505 | mejdrech | 47 | #include "../../include/ip_interface.h" |
| 3466 | mejdrech | 48 | |
| 4505 | mejdrech | 49 | #include "../../structures/int_map.h" |
| 50 | #include "../../structures/generic_field.h" |
||
| 4192 | mejdrech | 51 | #include "../../structures/module_map.h" |
| 52 | |||
| 4704 | mejdrech | 53 | /** Type definition of the IP global data. |
| 54 | * @see ip_globals |
||
| 55 | */ |
||
| 56 | typedef struct ip_globals ip_globals_t; |
||
| 57 | |||
| 58 | /** Type definition of the IP network interface specific data. |
||
| 59 | * @see ip_netif |
||
| 60 | */ |
||
| 3666 | mejdrech | 61 | typedef struct ip_netif ip_netif_t; |
| 4704 | mejdrech | 62 | |
| 63 | /** Type definition of the IP network interface specific data pointer. |
||
| 64 | * @see ip_netif |
||
| 65 | */ |
||
| 3666 | mejdrech | 66 | typedef ip_netif_t * ip_netif_ref; |
| 67 | |||
| 4704 | mejdrech | 68 | /** Type definition of the IP protocol specific data. |
| 69 | * @see ip_proto |
||
| 70 | */ |
||
| 3846 | mejdrech | 71 | typedef struct ip_proto ip_proto_t; |
| 4704 | mejdrech | 72 | |
| 73 | /** Type definition of the IP protocol specific data pointer. |
||
| 74 | * @see ip_proto |
||
| 75 | */ |
||
| 3846 | mejdrech | 76 | typedef ip_proto_t * ip_proto_ref; |
| 77 | |||
| 4704 | mejdrech | 78 | /** Type definition of the IP route specific data. |
| 79 | * @see ip_route |
||
| 80 | */ |
||
| 4505 | mejdrech | 81 | typedef struct ip_route ip_route_t; |
| 4704 | mejdrech | 82 | |
| 83 | /** Type definition of the IP route specific data pointer. |
||
| 84 | * @see ip_route |
||
| 85 | */ |
||
| 4505 | mejdrech | 86 | typedef ip_route_t * ip_route_ref; |
| 87 | |||
| 4704 | mejdrech | 88 | /** IP network interfaces. |
| 89 | * Maps devices to the IP network interface specific data. |
||
| 90 | * @see device.h |
||
| 91 | */ |
||
| 3666 | mejdrech | 92 | DEVICE_MAP_DECLARE( ip_netifs, ip_netif_t ) |
| 93 | |||
| 4704 | mejdrech | 94 | /** IP registered protocols. |
| 95 | * Maps protocols to the IP protocol specific data. |
||
| 96 | * @see int_map.h |
||
| 97 | */ |
||
| 3846 | mejdrech | 98 | INT_MAP_DECLARE( ip_protos, ip_proto_t ) |
| 99 | |||
| 4704 | mejdrech | 100 | /** IP routing table. |
| 101 | * @see generic_field.h |
||
| 102 | */ |
||
| 4505 | mejdrech | 103 | GENERIC_FIELD_DECLARE( ip_routes, ip_route_t ) |
| 104 | |||
| 4704 | mejdrech | 105 | /** IP network interface specific data. |
| 106 | */ |
||
| 3685 | mejdrech | 107 | struct ip_netif{ |
| 4704 | mejdrech | 108 | /** Device identifier. |
| 109 | */ |
||
| 3846 | mejdrech | 110 | device_id_t device_id; |
| 4704 | mejdrech | 111 | /** Netif module service. |
| 112 | */ |
||
| 4505 | mejdrech | 113 | services_t service; |
| 4704 | mejdrech | 114 | /** Netif module phone. |
| 115 | */ |
||
| 3666 | mejdrech | 116 | int phone; |
| 4704 | mejdrech | 117 | /** ARP module. |
| 118 | * Assigned if using ARP. |
||
| 119 | */ |
||
| 4192 | mejdrech | 120 | module_ref arp; |
| 4704 | mejdrech | 121 | /** IP version. |
| 122 | */ |
||
| 3685 | mejdrech | 123 | int ipv; |
| 4704 | mejdrech | 124 | /** Indicates whether using DHCP. |
| 125 | */ |
||
| 3685 | mejdrech | 126 | int dhcp; |
| 4704 | mejdrech | 127 | /** Indicates whether IP routing is enabled. |
| 128 | */ |
||
| 4695 | mejdrech | 129 | int routing; |
| 4704 | mejdrech | 130 | /** Device state. |
| 131 | */ |
||
| 4505 | mejdrech | 132 | device_state_t state; |
| 4704 | mejdrech | 133 | /** Broadcast address. |
| 134 | */ |
||
| 3846 | mejdrech | 135 | in_addr_t broadcast; |
| 4704 | mejdrech | 136 | /** Routing table. |
| 137 | */ |
||
| 4505 | mejdrech | 138 | ip_routes_t routes; |
| 139 | /** Reserved packet prefix length. |
||
| 140 | */ |
||
| 141 | size_t prefix; |
||
| 142 | /** Maximal packet content length. |
||
| 143 | */ |
||
| 144 | size_t content; |
||
| 145 | /** Reserved packet suffix length. |
||
| 146 | */ |
||
| 147 | size_t suffix; |
||
| 148 | /** Packet address length. |
||
| 149 | * The hardware address length is used. |
||
| 150 | */ |
||
| 151 | size_t addr_len; |
||
| 3666 | mejdrech | 152 | }; |
| 153 | |||
| 4704 | mejdrech | 154 | /** IP protocol specific data. |
| 155 | */ |
||
| 3846 | mejdrech | 156 | struct ip_proto{ |
| 4704 | mejdrech | 157 | /** Protocol number. |
| 158 | */ |
||
| 3846 | mejdrech | 159 | int protocol; |
| 4704 | mejdrech | 160 | /** Protocol module service. |
| 161 | */ |
||
| 4505 | mejdrech | 162 | services_t service; |
| 4704 | mejdrech | 163 | /** Protocol module phone. |
| 164 | */ |
||
| 3846 | mejdrech | 165 | int phone; |
| 4704 | mejdrech | 166 | /** Protocol packet receiving function. |
| 167 | */ |
||
| 4558 | mejdrech | 168 | tl_received_msg_t received_msg; |
| 3846 | mejdrech | 169 | }; |
| 170 | |||
| 4704 | mejdrech | 171 | /** IP route specific data. |
| 172 | */ |
||
| 4505 | mejdrech | 173 | struct ip_route{ |
| 4704 | mejdrech | 174 | /** Target address. |
| 175 | */ |
||
| 4505 | mejdrech | 176 | in_addr_t address; |
| 4704 | mejdrech | 177 | /** Target network mask. |
| 178 | */ |
||
| 4505 | mejdrech | 179 | in_addr_t netmask; |
| 4704 | mejdrech | 180 | /** Gateway. |
| 181 | */ |
||
| 4505 | mejdrech | 182 | in_addr_t gateway; |
| 4704 | mejdrech | 183 | /** Parent netif. |
| 184 | */ |
||
| 4505 | mejdrech | 185 | ip_netif_ref netif; |
| 186 | }; |
||
| 187 | |||
| 4704 | mejdrech | 188 | /** IP global data. |
| 189 | */ |
||
| 3685 | mejdrech | 190 | struct ip_globals{ |
| 4704 | mejdrech | 191 | /** Networking module phone. |
| 192 | */ |
||
| 4505 | mejdrech | 193 | int net_phone; |
| 4704 | mejdrech | 194 | /** Registered network interfaces. |
| 195 | */ |
||
| 3666 | mejdrech | 196 | ip_netifs_t netifs; |
| 4704 | mejdrech | 197 | /** Netifs safeyt lock. |
| 198 | */ |
||
| 4582 | mejdrech | 199 | fibril_rwlock_t netifs_lock; |
| 4704 | mejdrech | 200 | /** Registered protocols. |
| 201 | */ |
||
| 3846 | mejdrech | 202 | ip_protos_t protos; |
| 4704 | mejdrech | 203 | /** Protocols safety lock. |
| 204 | */ |
||
| 4582 | mejdrech | 205 | fibril_rwlock_t protos_lock; |
| 4704 | mejdrech | 206 | /** Default gateway. |
| 207 | */ |
||
| 4505 | mejdrech | 208 | ip_route_t gateway; |
| 4704 | mejdrech | 209 | /** Known support modules. |
| 210 | */ |
||
| 4192 | mejdrech | 211 | modules_t modules; |
| 4704 | mejdrech | 212 | /** Default client connection function for support modules. |
| 213 | */ |
||
| 4351 | mejdrech | 214 | async_client_conn_t client_connection; |
| 4704 | mejdrech | 215 | /** Packet counter. |
| 216 | */ |
||
| 4505 | mejdrech | 217 | uint16_t packet_counter; |
| 4704 | mejdrech | 218 | /** Safety lock. |
| 219 | */ |
||
| 4582 | mejdrech | 220 | fibril_rwlock_t lock; |
| 3666 | mejdrech | 221 | }; |
| 222 | |||
| 3466 | mejdrech | 223 | #endif |
| 224 | |||
| 225 | /** @} |
||
| 226 | */ |