source: mainline/uspace/srv/net/il/ip/ip.h@ a64c64d

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a64c64d was a64c64d, checked in by Lukas Mejdrech <lukasmejdrech@…>, 15 years ago
  • code reorganization (no functional change)
  • Property mode set to 100644
File size: 4.8 KB
RevLine 
[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 ip
30 * @{
31 */
32
33/** @file
34 * IP module.
35 */
36
37#ifndef __NET_IP_H__
38#define __NET_IP_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/inet.h"
47#include "../../include/ip_interface.h"
48
49#include "../../structures/int_map.h"
50#include "../../structures/generic_field.h"
51#include "../../structures/module_map.h"
52
53/** Type definition of the IP global data.
54 * @see ip_globals
55 */
56typedef struct ip_globals ip_globals_t;
57
58/** Type definition of the IP network interface specific data.
59 * @see ip_netif
60 */
61typedef struct ip_netif ip_netif_t;
62
63/** Type definition of the IP network interface specific data pointer.
64 * @see ip_netif
65 */
66typedef ip_netif_t * ip_netif_ref;
67
68/** Type definition of the IP protocol specific data.
69 * @see ip_proto
70 */
71typedef struct ip_proto ip_proto_t;
72
73/** Type definition of the IP protocol specific data pointer.
74 * @see ip_proto
75 */
76typedef ip_proto_t * ip_proto_ref;
77
78/** Type definition of the IP route specific data.
79 * @see ip_route
80 */
81typedef struct ip_route ip_route_t;
82
83/** Type definition of the IP route specific data pointer.
84 * @see ip_route
85 */
86typedef ip_route_t * ip_route_ref;
87
88/** IP network interfaces.
89 * Maps devices to the IP network interface specific data.
90 * @see device.h
91 */
[aadf01e]92DEVICE_MAP_DECLARE(ip_netifs, ip_netif_t)
[21580dd]93
94/** IP registered protocols.
95 * Maps protocols to the IP protocol specific data.
96 * @see int_map.h
97 */
[aadf01e]98INT_MAP_DECLARE(ip_protos, ip_proto_t)
[21580dd]99
100/** IP routing table.
101 * @see generic_field.h
102 */
[aadf01e]103GENERIC_FIELD_DECLARE(ip_routes, ip_route_t)
[21580dd]104
105/** IP network interface specific data.
106 */
107struct ip_netif{
108 /** ARP module.
109 * Assigned if using ARP.
110 */
[aadf01e]111 module_ref arp;
[a64c64d]112 /** Broadcast address.
[21580dd]113 */
[a64c64d]114 in_addr_t broadcast;
115 /** Device identifier.
116 */
117 device_id_t device_id;
[21580dd]118 /** Indicates whether using DHCP.
119 */
[aadf01e]120 int dhcp;
[a64c64d]121 /** IP version.
[21580dd]122 */
[a64c64d]123 int ipv;
124 /** Packet dimension.
[21580dd]125 */
[a64c64d]126 packet_dimension_t packet_dimension;
127 /** Netif module phone.
[21580dd]128 */
[a64c64d]129 int phone;
[21580dd]130 /** Routing table.
131 */
[aadf01e]132 ip_routes_t routes;
[a64c64d]133 /** Indicates whether IP routing is enabled.
[21580dd]134 */
[a64c64d]135 int routing;
136 /** Netif module service.
137 */
138 services_t service;
139 /** Device state.
140 */
141 device_state_t state;
[21580dd]142};
143
144/** IP protocol specific data.
145 */
146struct ip_proto{
147 /** Protocol module phone.
148 */
[aadf01e]149 int phone;
[a64c64d]150 /** Protocol number.
151 */
152 int protocol;
[21580dd]153 /** Protocol packet receiving function.
154 */
155 tl_received_msg_t received_msg;
[a64c64d]156 /** Protocol module service.
157 */
158 services_t service;
[21580dd]159};
160
161/** IP route specific data.
162 */
163struct ip_route{
164 /** Target address.
165 */
[aadf01e]166 in_addr_t address;
[21580dd]167 /** Gateway.
168 */
[aadf01e]169 in_addr_t gateway;
[21580dd]170 /** Parent netif.
171 */
[aadf01e]172 ip_netif_ref netif;
[a64c64d]173 /** Target network mask.
174 */
175 in_addr_t netmask;
[21580dd]176};
177
178/** IP global data.
179 */
180struct ip_globals{
[a64c64d]181 /** Default client connection function for support modules.
182 */
183 async_client_conn_t client_connection;
184 /** Default gateway.
185 */
186 ip_route_t gateway;
187 /** Safety lock.
188 */
189 fibril_rwlock_t lock;
190 /** Known support modules.
191 */
192 modules_t modules;
[21580dd]193 /** Networking module phone.
194 */
[aadf01e]195 int net_phone;
[21580dd]196 /** Registered network interfaces.
197 */
[aadf01e]198 ip_netifs_t netifs;
[21580dd]199 /** Netifs safeyt lock.
200 */
[aadf01e]201 fibril_rwlock_t netifs_lock;
[a64c64d]202 /** Packet counter.
203 */
204 uint16_t packet_counter;
[21580dd]205 /** Registered protocols.
206 */
[aadf01e]207 ip_protos_t protos;
[21580dd]208 /** Protocols safety lock.
209 */
[aadf01e]210 fibril_rwlock_t protos_lock;
[21580dd]211};
212
213#endif
214
215/** @}
216 */
Note: See TracBrowser for help on using the repository browser.