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

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

Cleanup ip.

  • Property mode set to 100644
File size: 4.6 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. */
104struct ip_netif {
105 /** ARP module. Assigned if using ARP. */
106 module_ref arp;
107 /** Broadcast address. */
108 in_addr_t broadcast;
109 /** Device identifier. */
110 device_id_t device_id;
111 /** Indicates whether using DHCP. */
112 int dhcp;
113 /** IP version. */
114 int ipv;
115 /** Packet dimension. */
116 packet_dimension_t packet_dimension;
117 /** Netif module phone. */
118 int phone;
119 /** Routing table. */
120 ip_routes_t routes;
121 /** Indicates whether IP routing is enabled. */
122 int routing;
123 /** Netif module service. */
124 services_t service;
125 /** Device state. */
126 device_state_t state;
127};
128
129/** IP protocol specific data. */
130struct ip_proto {
131 /** Protocol module phone. */
132 int phone;
133 /** Protocol number. */
134 int protocol;
135 /** Protocol packet receiving function. */
136 tl_received_msg_t received_msg;
137 /** Protocol module service. */
138 services_t service;
139};
140
141/** IP route specific data. */
142struct ip_route {
143 /** Target address. */
144 in_addr_t address;
145 /** Gateway. */
146 in_addr_t gateway;
147 /** Parent netif. */
148 ip_netif_ref netif;
149 /** Target network mask. */
150 in_addr_t netmask;
151};
152
153/** IP global data. */
154struct ip_globals {
155 /** Default client connection function for support modules. */
156 async_client_conn_t client_connection;
157 /** Default gateway. */
158 ip_route_t gateway;
159 /** Safety lock. */
160 fibril_rwlock_t lock;
161 /** Known support modules. */
162 modules_t modules;
163 /** Networking module phone. */
164 int net_phone;
165 /** Registered network interfaces. */
166 ip_netifs_t netifs;
167 /** Netifs safeyt lock. */
168 fibril_rwlock_t netifs_lock;
169 /** Packet counter. */
170 uint16_t packet_counter;
171 /** Registered protocols. */
172 ip_protos_t protos;
173 /** Protocols safety lock. */
174 fibril_rwlock_t protos_lock;
175};
176
177#endif
178
179/** @}
180 */
Note: See TracBrowser for help on using the repository browser.