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