source: mainline/uspace/srv/net/inetsrv/inetsrv.h@ 901b302

ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 901b302 was b4edc96, checked in by Jiri Svoboda <jiri@…>, 4 years ago

Rename and move addr48_t to eth_addr_t

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 * Copyright (c) 2021 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 <stddef.h>
47#include <stdint.h>
48#include <types/inet.h>
49#include <async.h>
50
51/** Inet Client */
52typedef struct {
53 async_sess_t *sess;
54 uint8_t protocol;
55 link_t client_list;
56} inet_client_t;
57
58/** Inetping Client */
59typedef struct {
60 /** Callback session */
61 async_sess_t *sess;
62 /** Session identifier */
63 uint16_t ident;
64 /** Link to client list */
65 link_t client_list;
66} inetping_client_t;
67
68/** Inetping6 Client */
69typedef struct {
70 /** Callback session */
71 async_sess_t *sess;
72 /** Session identifier */
73 uint16_t ident;
74 /** Link to client list */
75 link_t client_list;
76} inetping6_client_t;
77
78typedef struct {
79 /** Local link ID */
80 service_id_t link_id;
81 /** Source address */
82 inet_addr_t src;
83 /** Destination address */
84 inet_addr_t dest;
85 /** Type of service */
86 uint8_t tos;
87 /** Protocol */
88 uint8_t proto;
89 /** Time to live */
90 uint8_t ttl;
91 /** Identifier */
92 uint32_t ident;
93 /** Do not fragment */
94 bool df;
95 /** More fragments */
96 bool mf;
97 /** Offset of fragment into datagram, in bytes */
98 size_t offs;
99 /** Packet data */
100 void *data;
101 /** Packet data size in bytes */
102 size_t size;
103} inet_packet_t;
104
105typedef struct {
106 link_t link_list;
107 service_id_t svc_id;
108 char *svc_name;
109 async_sess_t *sess;
110 iplink_t *iplink;
111 size_t def_mtu;
112 eth_addr_t mac;
113 bool mac_valid;
114} inet_link_t;
115
116typedef struct {
117 link_t addr_list;
118 sysarg_t id;
119 inet_naddr_t naddr;
120 inet_link_t *ilink;
121 char *name;
122} inet_addrobj_t;
123
124/** Static route configuration */
125typedef struct {
126 link_t sroute_list;
127 sysarg_t id;
128 /** Destination network */
129 inet_naddr_t dest;
130 /** Router via which to route packets */
131 inet_addr_t router;
132 char *name;
133} inet_sroute_t;
134
135typedef enum {
136 /** Destination is on this network node */
137 dt_local,
138 /** Destination is directly reachable */
139 dt_direct,
140 /** Destination is behind a router */
141 dt_router
142} inet_dir_type_t;
143
144/** Direction (next hop) to a destination */
145typedef struct {
146 /** Route type */
147 inet_dir_type_t dtype;
148 /** Address object (direction) */
149 inet_addrobj_t *aobj;
150 /** Local destination address */
151 inet_addr_t ldest;
152} inet_dir_t;
153
154extern errno_t inet_ev_recv(inet_client_t *, inet_dgram_t *);
155extern errno_t inet_recv_packet(inet_packet_t *);
156extern errno_t inet_route_packet(inet_dgram_t *, uint8_t, uint8_t, int);
157extern errno_t inet_get_srcaddr(inet_addr_t *, uint8_t, inet_addr_t *);
158extern errno_t inet_recv_dgram_local(inet_dgram_t *, uint8_t);
159
160#endif
161
162/** @}
163 */
Note: See TracBrowser for help on using the repository browser.