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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a53ed3a was b7fd2a0, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

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