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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since dba3e2c was 1c7ba2da, checked in by Jiri Svoboda <jiri@…>, 13 years ago

inetsrv can use inet/addr.h from libc for address types.

  • Property mode set to 100644
File size: 4.4 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 <sys/types.h>
46#include <async.h>
47
48/** Inet Client */
49typedef struct {
50 async_sess_t *sess;
51 uint8_t protocol;
52 link_t client_list;
53} inet_client_t;
54
55/** Inetping Client */
56typedef struct {
57 /** Callback session */
58 async_sess_t *sess;
59 /** Session identifier */
60 uint16_t ident;
61 /** Link to client list */
62 link_t client_list;
63} inetping_client_t;
64
65/** Address object info */
66typedef struct {
67 /** Network address */
68 inet_naddr_t naddr;
69 /** Link service ID */
70 sysarg_t ilink;
71 /** Address object name */
72 char *name;
73} inet_addr_info_t;
74
75/** IP link info */
76typedef struct {
77 /** Link service name */
78 char *name;
79 /** Default MTU */
80 size_t def_mtu;
81} inet_link_info_t;
82
83/** Static route info */
84typedef struct {
85 /** Destination network address */
86 inet_naddr_t dest;
87 /** Router address */
88 inet_addr_t router;
89 /** Static route name */
90 char *name;
91} inet_sroute_info_t;
92
93typedef struct {
94 /** Source address */
95 inet_addr_t src;
96 /** Destination address */
97 inet_addr_t dest;
98 /** Type of service */
99 uint8_t tos;
100 /** Protocol */
101 uint8_t proto;
102 /** Time to live */
103 uint8_t ttl;
104 /** Identifier */
105 uint16_t ident;
106 /** Do not fragment */
107 bool df;
108 /** More fragments */
109 bool mf;
110 /** Offset of fragment into datagram, in bytes */
111 size_t offs;
112 /** Packet data */
113 void *data;
114 /** Packet data size in bytes */
115 size_t size;
116} inet_packet_t;
117
118typedef struct {
119 inet_addr_t src;
120 inet_addr_t dest;
121 uint8_t tos;
122 void *data;
123 size_t size;
124} inet_dgram_t;
125
126typedef struct {
127 link_t link_list;
128 service_id_t svc_id;
129 char *svc_name;
130 async_sess_t *sess;
131 iplink_t *iplink;
132 size_t def_mtu;
133} inet_link_t;
134
135typedef struct {
136 link_t addr_list;
137 sysarg_t id;
138 inet_naddr_t naddr;
139 inet_link_t *ilink;
140 char *name;
141} inet_addrobj_t;
142
143/** Static route configuration */
144typedef struct {
145 link_t sroute_list;
146 sysarg_t id;
147 /** Destination network */
148 inet_naddr_t dest;
149 /** Router via which to route packets */
150 inet_addr_t router;
151 char *name;
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
173typedef struct {
174 inet_addr_t src;
175 inet_addr_t dest;
176 uint16_t seq_no;
177 void *data;
178 size_t size;
179} inetping_sdu_t;
180
181extern int inet_ev_recv(inet_client_t *, inet_dgram_t *);
182extern int inet_recv_packet(inet_packet_t *);
183extern int inet_route_packet(inet_dgram_t *, uint8_t, uint8_t, int);
184extern int inet_get_srcaddr(inet_addr_t *, uint8_t, inet_addr_t *);
185extern int 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.