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

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

do not intermix low-level IPC methods with async framework methods

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