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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 779a47d was e526f08, checked in by Jakub Jermar <jakub@…>, 15 years ago

Move net_device.h to standard library.

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