/usr/include/lwipv6.h is in liblwipv6-dev 1.5a-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | /**
* @file
*/
/* This is part of LWIPv6
* Developed for the Ale4NET project
* Application Level Environment for Networking
*
* Copyright 2004 Renzo Davoli University of Bologna - Italy
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _LWIPV6_H
#define _LWIPV6_H
#include <stdio.h>
#include <stdlib.h> /* timeval */
#include <stdint.h> /* uint32_t */
#include <errno.h>
#include <sys/poll.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#ifndef AF_UNSPEC
#define AF_UNSPEC 0
#endif
#ifndef PF_UNSPEC
#define PF_UNSPEC AF_UNSPEC
#endif
#ifndef AF_INET
#define AF_INET 2
#endif
#ifndef PF_INET
#define PF_INET AF_INET
#endif
#ifndef AF_INET6
#define AF_INET6 10
#endif
#ifndef PF_INET6
#define PF_INET6 AF_INET6
#endif
#ifndef AF_NETLINK
#define AF_NETLINK 16
#endif
#ifndef PF_NETLINK
#define PF_NETLINK AF_NETLINK
#endif
#ifndef AF_PACKET
#define AF_PACKET 17
#endif
#ifndef PF_PACKET
#define PF_PACKET AF_PACKET
#endif
struct ip_addr {
uint32_t addr[4];
};
#define IP4_ADDRX(ip4ax, a,b,c,d) \
(ip4ax) = htonl(((uint32_t)((a) & 0xff) << 24) | ((uint32_t)((b) & 0xff) << 16) | \
((uint32_t)((c) & 0xff) << 8) | (uint32_t)((d) & 0xff))
#define IP64_PREFIX (htonl(0xffff))
#define IP6_ADDR(ipaddr, a,b,c,d,e,f,g,h) ({ \
(ipaddr)->addr[0] = htonl((uint32_t)(((a) & 0xffff) << 16) | ((b) & 0xffff)); \
(ipaddr)->addr[1] = htonl((((c) & 0xffff) << 16) | ((d) & 0xffff)); \
(ipaddr)->addr[2] = htonl((((e) & 0xffff) << 16) | ((f) & 0xffff)); \
(ipaddr)->addr[3] = htonl((((g) & 0xffff) << 16) | ((h) & 0xffff)); } )
#define IP64_ADDR(ipaddr, a,b,c,d) ({ \
(ipaddr)->addr[0] = 0; \
(ipaddr)->addr[1] = 0; \
(ipaddr)->addr[2] = IP64_PREFIX; \
IP4_ADDRX(((ipaddr)->addr[3]),(a),(b),(c),(d)); })
#define IP64_MASKADDR(ipaddr, a,b,c,d) do { \
(ipaddr)->addr[0] = 0xffffffff; \
(ipaddr)->addr[1] = 0xffffffff; \
(ipaddr)->addr[2] = 0xffffffff; \
IP4_ADDRX(((ipaddr)->addr[3]),(a),(b),(c),(d)); } while (0)
#define IP_ADDR_IS_V4(ipaddr) \
(((ipaddr)->addr[0] == 0) && \
((ipaddr)->addr[1] == 0) && \
((ipaddr)->addr[2] == IP64_PREFIX))
/* if set use IPv6 AUTOCONF */
#define NETIF_FLAG_AUTOCONF 0x800U
/* if set this interface supports Router Advertising */
#define NETIF_FLAG_RADV 0x2000U
#define NETIF_STD_FLAGS (NETIF_FLAG_AUTOCONF)
#define NETIF_ADD_FLAGS (NETIF_FLAG_AUTOCONF | NETIF_FLAG_RADV)
/** if set, the interface is configured using DHCP */
#define NETIF_FLAG_DHCP 0x4000U
#define NETIF_IFUP_FLAGS (NETIF_FLAG_DHCP)
/* netif creation with standard flags */
#define lwip_vdeif_add(S,A) lwip_add_vdeif((S),(A),NETIF_STD_FLAGS)
#define lwip_tapif_add(S,A) lwip_add_tapif((S),(A),NETIF_STD_FLAGS)
#define lwip_tunif_add(S,A) lwip_add_tunif((S),(A),NETIF_STD_FLAGS)
#define lwip_slirpif_add(S,A) lwip_add_slirpif((S),(A),0)
#define lwip_ifup(N) lwip_ifup_flags((N),0)
#define lwip_ifup_dhcp(N) lwip_ifup_flags((N),NETIF_FLAG_DHCP)
#ifndef LWIPV6DL
typedef void (*lwipvoidfun)();
extern const struct ip_addr ip_addr_any;
#define IP_ADDR_ANY ((struct ip_addr *)&ip_addr_any)
struct netif;
struct sockaddr;
struct stack;
struct msghdr;
/* constructor and destructors are automagically called when lwipv6
* gets loaded/unloaded as a shared library.
* lwip_init/lwip_fini are for static linking only */
void lwip_init(void);
void lwip_fini(void);
void lwip_thread_new(void (* thread)(void *arg), void *arg);
/* old interface */
struct stack *lwip_stack_new(void);
void lwip_stack_free(struct stack *stack);
#define LWIP_STACK_FLAG_FORWARDING 1
#define LWIP_STACK_FLAG_USERFILTER 0x2
#define LWIP_STACK_FLAG_UF_NAT 0x10000
typedef int (* lwip_capfun) (void);
/* new api */
struct stack *lwip_add_stack(unsigned long flags);
struct stack *lwip_add_stack_cap(unsigned long flags, lwip_capfun capfun);
void lwip_del_stack(struct stack *stack);
struct stack *lwip_stack_get(void);
void lwip_stack_set(struct stack *stack);
unsigned long lwip_stack_flags_get(struct stack *stackid);
void lwip_stack_flags_set(struct stack *stackid, unsigned long flags);
struct netif *lwip_add_vdeif(struct stack *stack, void *arg, int flags);
struct netif *lwip_add_tapif(struct stack *stack, void *arg, int flags);
struct netif *lwip_add_tunif(struct stack *stack, void *arg, int flags);
struct netif *lwip_add_slirpif(struct stack *stack, void *arg, int flags);
int lwip_add_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask);
int lwip_del_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask);
int lwip_add_route(struct stack *stack, struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags);
int lwip_del_route(struct stack *stack, struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags);
int lwip_ifup_flags(struct netif *netif, int flags);
int lwip_ifdown(struct netif *netif);
int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen);
int lwip_shutdown(int s, int how);
int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen);
int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen);
int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
int lwip_close(int s);
int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen);
int lwip_listen(int s, int backlog);
ssize_t lwip_recv(int s, void *mem, int len, unsigned int flags);
ssize_t lwip_read(int s, void *mem, int len);
ssize_t lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
struct sockaddr *from, socklen_t *fromlen);
ssize_t lwip_send(int s, const void *dataptr, int size, unsigned int flags);
ssize_t lwip_sendto(int s, const void *dataptr, int size, unsigned int flags,
const struct sockaddr *to, socklen_t tolen);
ssize_t lwip_recvmsg(int fd, struct msghdr *msg, int flags);
ssize_t lwip_sendmsg(int fd, const struct msghdr *msg, int flags);
int lwip_msocket(struct stack *stack, int domain, int type, int protocol);
int lwip_socket(int domain, int type, int protocol);
ssize_t lwip_write(int s, void *dataptr, int size);
int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
struct timeval *timeout);
int lwip_pselect(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
const struct timespec *timeout, const sigset_t *sigmask);
int lwip_poll(struct pollfd *fds, nfds_t nfds, int timeout);
int lwip_ppoll(struct pollfd *fds, nfds_t nfds,
const struct timespec *timeout, const sigset_t *sigmask);
int lwip_ioctl(int s, long cmd, void *argp);
int lwip_fcntl64(int s, int cmd, long arg);
int lwip_fcntl(int s, int cmd, long arg);
struct iovec;
ssize_t lwip_writev(int s, struct iovec *vector, int count);
ssize_t lwip_readv(int s, struct iovec *vector, int count);
void lwip_radv_load_config(struct stack *stack,FILE *filein);
int lwip_radv_load_configfile(struct stack *stack,void *arg);
int lwip_event_subscribe(lwipvoidfun cb, void *arg, int fd, int how);
/* Allows binding to TCP/UDP sockets below 1024 */
#define LWIP_CAP_NET_BIND_SERVICE 1<<10
/* Allow broadcasting, listen to multicast */
#define LWIP_CAP_NET_BROADCAST 1<<11
/* Allow interface configuration */
#define LWIP_CAP_NET_ADMIN 1<<12
/* Allow use of RAW sockets */
/* Allow use of PACKET sockets */
#define LWIP_CAP_NET_RAW 1<<13
/* add/delete a slirp port forwarding rule.
src/srcport is the local address/port (in the native stack)
dest/destport is the virtual address/port where all the
traffic to src/srcport must be forwarded */
#define SLIRP_LISTEN_UDP 0x1000
#define SLIRP_LISTEN_TCP 0x2000
#define SLIRP_LISTEN_UNIXSTREAM 0x3000
#define SLIRP_LISTEN_TYPEMASK 0x7000
#define SLIRP_LISTEN_ONCE 0x8000
int lwip_slirp_listen_add(struct netif *slirpif,
struct ip_addr *dest, int destport,
const void *src, int srcport, int flags);
int lwip_slirp_listen_del(struct netif *slirpif,
struct ip_addr *dest, int destport,
const void *src, int srcport, int flags);
#else /* Dynamic Loading */
#include <dlfcn.h>
struct ip_addr *pip_addr_any;
#define IP_ADDR_ANY ((struct ip_addr *)pip_addr_any)
struct netif;
typedef struct netif *pnetif;
typedef struct stack *pstack;
typedef pnetif (*pnetiffun)();
typedef pstack (*pstackfun)();
typedef int (*lwiplongfun)();
typedef ssize_t (*lwipssizetfun)();
typedef void (*lwipvoidfun)();
pstackfun lwip_stack_new,lwip_stack_new_cap;
lwipvoidfun lwip_stack_free;
pstackfun lwip_stack_get;
lwipvoidfun lwip_stack_set;
lwipvoidfun lwip_thread_new;
pnetiffun lwip_add_vdeif, lwip_add_tapif, lwip_add_tunif, lwip_add_slirpif;
lwiplongfun lwip_add_addr,
lwip_del_addr,
lwip_add_route,
lwip_del_route,
lwip_ifup_flags,
lwip_ifdown,
lwip_accept,
lwip_bind,
lwip_shutdown,
lwip_getpeername,
lwip_getsockname,
lwip_getsockopt,
lwip_setsockopt,
lwip_close,
lwip_connect,
lwip_listen,
lwip_socket,
lwip_select,
lwip_pselect,
lwip_poll,
lwip_ppoll,
lwip_ioctl,
lwip_msocket,
lwip_event_subscribe;
lwipssizetfun lwip_recv,
lwip_read,
lwip_recvfrom,
lwip_send,
lwip_sendto,
lwip_recvmsg,
lwip_sendmsg,
lwip_write,
lwip_writev,
lwip_readv;
/* Added by Diego Billi */
lwiplongfun lwip_radv_load_configfile;
static inline void *loadlwipv6dl()
{
struct lwipname2fun {
char *funcname;
lwiplongfun *f;
} lwiplibtab[] = {
{"lwip_stack_new", (lwiplongfun*)&lwip_stack_new},
{"lwip_stack_new_cap", (lwiplongfun*)&lwip_stack_new_cap},
{"lwip_stack_free", (lwiplongfun*)&lwip_stack_free},
{"lwip_stack_get", (lwiplongfun*)&lwip_stack_get},
{"lwip_stack_set", (lwiplongfun*)&lwip_stack_set},
{"lwip_add_addr", &lwip_add_addr},
{"lwip_del_addr", &lwip_del_addr},
{"lwip_add_route", &lwip_add_route},
{"lwip_del_route", &lwip_del_route},
{"lwip_ifup_flags", &lwip_ifup},
{"lwip_ifdown", &lwip_ifdown},
{"lwip_accept", &lwip_accept},
{"lwip_bind", &lwip_bind},
{"lwip_shutdown", &lwip_shutdown},
{"lwip_getpeername", &lwip_getpeername},
{"lwip_getsockname", &lwip_getsockname},
{"lwip_getsockopt", &lwip_getsockopt},
{"lwip_setsockopt", &lwip_setsockopt},
{"lwip_close", &lwip_close},
{"lwip_connect", &lwip_connect},
{"lwip_listen", &lwip_listen},
{"lwip_recv", &lwip_recv},
{"lwip_read", &lwip_read},
{"lwip_recvfrom", &lwip_recvfrom},
{"lwip_send", &lwip_send},
{"lwip_sendto", &lwip_sendto},
{"lwip_recvmsg", &lwip_recvmsg},
{"lwip_sendmsg", &lwip_sendmsg},
{"lwip_socket", &lwip_socket},
{"lwip_write", &lwip_write},
{"lwip_select", &lwip_select},
{"lwip_pselect", &lwip_pselect},
{"lwip_poll", &lwip_poll},
{"lwip_ppoll", &lwip_ppoll},
{"lwip_ioctl", &lwip_ioctl},
{"lwip_readv", &lwip_readv},
{"lwip_writev", &lwip_writev},
{"lwip_msocket", &lwip_msocket},
{"lwip_add_vdeif", (lwiplongfun *)(&lwip_add_vdeif)},
{"lwip_add_tapif", (lwiplongfun *)(&lwip_add_tapif)},
{"lwip_add_tunif", (lwiplongfun *)(&lwip_add_tunif)},
{"lwip_add_slirpif", (lwiplongfun *)(&lwip_add_slirpif)},
{"lwip_radv_load_configfile", (lwiplongfun *)(&lwip_radv_load_configfile)},
{"lwip_thread_new", (lwipvoidfun*) (&lwip_thread_new)},
{"lwip_event_subscribe", (lwipvoidfun*) (&lwip_event_subscribe)}
};
int i;
void *lwiphandle = dlopen("liblwipv6.so",RTLD_NOW);
if(lwiphandle == NULL) {
errno=ENOENT;
} else {
for (i=0; i<(sizeof(lwiplibtab)/sizeof(struct lwipname2fun)); i++)
*lwiplibtab[i].f = dlsym(lwiphandle,lwiplibtab[i].funcname);
pip_addr_any = dlsym(lwiphandle,"ip_addr_any");
}
return lwiphandle;
}
#endif
#endif
|