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

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

streamline internetworking layer

  • IPC method renaming

NET_IL_DEVICE → NET_IP_DEVICE
NET_IL_PACKET_SPACE → NET_IP_PACKET_SPACE
NET_IL_SEND → NET_IP_SEND

The original methods were actually not generic methods of the IL layer (used by the lower layers), but specific methods of the IP module
and used by the higher layers. The original naming was rather confusing.

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