source: mainline/uspace/srv/net/inetsrv/inetsrv.h

Last change on this file was 1bbc6dc, checked in by Jiri Svoboda <jiri@…>, 9 months ago

Network configuration persistence.

nconfsrv is folded into inetsrv
DHCP is disabled when a static address is configured on a link

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/*
2 * Copyright (c) 2024 Jiri Svoboda
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 inetsrv
30 * @{
31 */
32/**
33 * @file
34 * @brief
35 */
36
37#ifndef INETSRV_H_
38#define INETSRV_H_
39
40#include <adt/list.h>
41#include <stdbool.h>
42#include <inet/addr.h>
43#include <inet/eth_addr.h>
44#include <inet/iplink.h>
45#include <ipc/loc.h>
46#include <sif.h>
47#include <stddef.h>
48#include <stdint.h>
49#include <types/inet.h>
50#include <async.h>
51
52/** Inet Client */
53typedef struct {
54 async_sess_t *sess;
55 uint8_t protocol;
56 link_t client_list;
57} inet_client_t;
58
59/** Inetping Client */
60typedef struct {
61 /** Callback session */
62 async_sess_t *sess;
63 /** Session identifier */
64 uint16_t ident;
65 /** Link to client list */
66 link_t client_list;
67} inetping_client_t;
68
69/** Inetping6 Client */
70typedef struct {
71 /** Callback session */
72 async_sess_t *sess;
73 /** Session identifier */
74 uint16_t ident;
75 /** Link to client list */
76 link_t client_list;
77} inetping6_client_t;
78
79typedef struct {
80 /** Local link ID */
81 service_id_t link_id;
82 /** Source address */
83 inet_addr_t src;
84 /** Destination address */
85 inet_addr_t dest;
86 /** Type of service */
87 uint8_t tos;
88 /** Protocol */
89 uint8_t proto;
90 /** Time to live */
91 uint8_t ttl;
92 /** Identifier */
93 uint32_t ident;
94 /** Do not fragment */
95 bool df;
96 /** More fragments */
97 bool mf;
98 /** Offset of fragment into datagram, in bytes */
99 size_t offs;
100 /** Packet data */
101 void *data;
102 /** Packet data size in bytes */
103 size_t size;
104} inet_packet_t;
105
106typedef struct {
107 link_t link_list;
108 service_id_t svc_id;
109 char *svc_name;
110 async_sess_t *sess;
111 iplink_t *iplink;
112 size_t def_mtu;
113 eth_addr_t mac;
114 bool mac_valid;
115} inet_link_t;
116
117/** Link information needed for autoconfiguration */
118typedef struct {
119 service_id_t svc_id;
120 char *svc_name;
121} inet_link_cfg_info_t;
122
123/** Address object */
124typedef struct {
125 /** Link to list of addresses */
126 link_t addr_list;
127 /** Address object ID */
128 sysarg_t id;
129 /** Network address */
130 inet_naddr_t naddr;
131 /** Underlying IP link */
132 inet_link_t *ilink;
133 /** Address name */
134 char *name;
135 /** Temporary object */
136 bool temp;
137} inet_addrobj_t;
138
139/** Static route configuration */
140typedef struct {
141 link_t sroute_list;
142 /** ID */
143 sysarg_t id;
144 /** Destination network */
145 inet_naddr_t dest;
146 /** Router via which to route packets */
147 inet_addr_t router;
148 /** Route name */
149 char *name;
150 /** Temporary route */
151 bool temp;
152} inet_sroute_t;
153
154typedef enum {
155 /** Destination is on this network node */
156 dt_local,
157 /** Destination is directly reachable */
158 dt_direct,
159 /** Destination is behind a router */
160 dt_router
161} inet_dir_type_t;
162
163/** Direction (next hop) to a destination */
164typedef struct {
165 /** Route type */
166 inet_dir_type_t dtype;
167 /** Address object (direction) */
168 inet_addrobj_t *aobj;
169 /** Local destination address */
170 inet_addr_t ldest;
171} inet_dir_t;
172
173/** Internet server configuration */
174typedef struct {
175 /** Configuration file path */
176 char *cfg_path;
177} inet_cfg_t;
178
179extern inet_cfg_t *cfg;
180
181extern errno_t inet_ev_recv(inet_client_t *, inet_dgram_t *);
182extern errno_t inet_recv_packet(inet_packet_t *);
183extern errno_t inet_route_packet(inet_dgram_t *, uint8_t, uint8_t, int);
184extern errno_t inet_get_srcaddr(inet_addr_t *, uint8_t, inet_addr_t *);
185extern errno_t inet_recv_dgram_local(inet_dgram_t *, uint8_t);
186
187#endif
188
189/** @}
190 */
Note: See TracBrowser for help on using the repository browser.