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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since e9563c3 was 609243f4, checked in by Martin Decky <martin@…>, 14 years ago

cherrypick general networking improvements from lp:~helenos-nicf/helenos/nicf (after sanitization)
remove obsolete networking drivers
this renders the networking non-functional for the time being

  • Property mode set to 100644
File size: 4.2 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 <async.h>
41#include <fibril_synch.h>
42#include <ipc/services.h>
43#include <net/device.h>
44#include <net/inet.h>
45#include <ip_interface.h>
46#include <adt/int_map.h>
47#include <adt/generic_field.h>
48#include <adt/module_map.h>
49
50/** Type definition of the IP global data.
51 * @see ip_globals
52 */
53typedef struct ip_globals ip_globals_t;
54
55/** Type definition of the IP network interface specific data.
56 * @see ip_netif
57 */
58typedef struct ip_netif ip_netif_t;
59
60/** Type definition of the IP protocol specific data.
61 * @see ip_proto
62 */
63typedef struct ip_proto ip_proto_t;
64
65/** Type definition of the IP route specific data.
66 * @see ip_route
67 */
68typedef struct ip_route ip_route_t;
69
70/** IP network interfaces.
71 * Maps devices to the IP network interface specific data.
72 * @see device.h
73 */
74DEVICE_MAP_DECLARE(ip_netifs, ip_netif_t);
75
76/** IP registered protocols.
77 * Maps protocols to the IP protocol specific data.
78 * @see int_map.h
79 */
80INT_MAP_DECLARE(ip_protos, ip_proto_t);
81
82/** IP routing table.
83 * @see generic_field.h
84 */
85GENERIC_FIELD_DECLARE(ip_routes, ip_route_t);
86
87/** IP network interface specific data. */
88struct ip_netif {
89 /** ARP module. Assigned if using ARP. */
90 module_t *arp;
91 /** Broadcast address. */
92 in_addr_t broadcast;
93 /** Device identifier. */
94 nic_device_id_t device_id;
95 /** Indicates whether using DHCP. */
96 int dhcp;
97 /** IP version. */
98 int ipv;
99 /** Packet dimension. */
100 packet_dimension_t packet_dimension;
101 /** Netif module session. */
102 async_sess_t *sess;
103 /** Routing table. */
104 ip_routes_t routes;
105 /** Indicates whether IP routing is enabled. */
106 int routing;
107 /** Netif module service. */
108 services_t service;
109 /** Device state. */
110 nic_device_state_t state;
111};
112
113/** IP protocol specific data. */
114struct ip_proto {
115 /** Protocol module session. */
116 async_sess_t *sess;
117 /** Protocol number. */
118 int protocol;
119 /** Protocol packet receiving function. */
120 tl_received_msg_t received_msg;
121 /** Protocol module service. */
122 services_t service;
123};
124
125/** IP route specific data. */
126struct ip_route {
127 /** Target address. */
128 in_addr_t address;
129 /** Gateway. */
130 in_addr_t gateway;
131 /** Parent netif. */
132 ip_netif_t *netif;
133 /** Target network mask. */
134 in_addr_t netmask;
135};
136
137/** IP global data. */
138struct ip_globals {
139 /** Default gateway. */
140 ip_route_t gateway;
141 /** Safety lock. */
142 fibril_rwlock_t lock;
143 /** Known support modules. */
144 modules_t modules;
145 /** Networking module session. */
146 async_sess_t *net_sess;
147 /** Registered network interfaces. */
148 ip_netifs_t netifs;
149 /** Netifs safeyt lock. */
150 fibril_rwlock_t netifs_lock;
151 /** Packet counter. */
152 uint16_t packet_counter;
153 /** Registered protocols. */
154 ip_protos_t protos;
155 /** Protocols safety lock. */
156 fibril_rwlock_t protos_lock;
157};
158
159#endif
160
161/** @}
162 */
Note: See TracBrowser for help on using the repository browser.