1 #ifndef MINIX_NET_LWIP_LWIP_H
2 #define MINIX_NET_LWIP_LWIP_H
4 #include <minix/drivers.h>
5 #include <minix/sockevent.h>
6 #include <minix/rmib.h>
7 #include <netinet/in.h>
12 #include "lwiphooks.h"
20 * The standard sockaddr_dl is an absolute pain, because the actual structure
21 * is dynamically sized, while the standard definition is neither the minimum
22 * nor the maximum size. We use our own version, which uses the maximum size
23 * that we will ever produce and accept. This greatly simplifies dealing with
24 * this structure while also limiting stack usage a bit.
27 uint8_t sdlx_len
; /* actual length of this structure */
28 sa_family_t sdlx_family
; /* address family, always AF_LINK */
29 uint16_t sdlx_index
; /* interface index */
30 uint8_t sdlx_type
; /* interface type (IFT_) */
31 uint8_t sdlx_nlen
; /* interface name length, w/o nul */
32 uint8_t sdlx_alen
; /* link-layer address length */
33 uint8_t sdlx_slen
; /* selector length, always 0 */
34 uint8_t sdlx_data
[IFNAMSIZ
+ NETIF_MAX_HWADDR_LEN
];
37 STATIC_SOCKADDR_MAX_ASSERT(sockaddr_in
);
38 STATIC_SOCKADDR_MAX_ASSERT(sockaddr_in6
);
39 STATIC_SOCKADDR_MAX_ASSERT(sockaddr_dlx
);
41 /* This is our own, much smaller internal version of sockaddr_storage. */
44 struct sockaddr_in sin
;
45 struct sockaddr_in6 sin6
;
46 struct sockaddr_dlx sdlx
;
49 /* Number of bits in each of the types of IP addresses. */
50 #define IP4_BITS 32 /* number of bits in an IPv4 address */
51 #define IP6_BITS 128 /* number of bits in an IPv6 address */
54 * Each socket module maintains its own set of sockets, but all sockets must be
55 * given globally unique identifiers. Therefore, we use these modifier masks,
56 * which are bitwise OR'ed with the per-module socket identifiers.
58 #define SOCKID_TCP 0x00000000
59 #define SOCKID_UDP 0x00100000
60 #define SOCKID_RAW 0x00200000
61 #define SOCKID_RT 0x00400000
62 #define SOCKID_LNK 0x00800000
65 * Static remote MIB node identifiers for nodes that are dynamically numbered
66 * on NetBSD, because they do not have a corresponding protocol family number.
68 #define NET_INTERFACES (PF_MAX) /* net.interfaces (TODO) */
69 #define NET_BPF (PF_MAX + 1) /* net.bpf */
71 #define ROOT_EUID 0 /* effective user ID of superuser */
74 * Function declarations. Modules with more extended interfaces have their own
79 void mempool_init(void);
80 unsigned int mempool_cur_buffers(void);
81 unsigned int mempool_max_buffers(void);
84 struct pbuf
**pchain_end(struct pbuf
* pbuf
);
85 size_t pchain_size(struct pbuf
* pbuf
);
88 int addrpol_get_label(const ip_addr_t
* ipaddr
);
89 int addrpol_get_scope(const ip_addr_t
* ipaddr
, int is_src
);
92 void tcpsock_init(void);
93 sockid_t
tcpsock_socket(int domain
, int protocol
, struct sock
** sock
,
94 const struct sockevent_ops
** ops
);
97 void udpsock_init(void);
98 sockid_t
udpsock_socket(int domain
, int protocol
, struct sock
** sock
,
99 const struct sockevent_ops
** ops
);
102 void rawsock_init(void);
103 sockid_t
rawsock_socket(int domain
, int protocol
, struct sock
** sock
,
104 const struct sockevent_ops
** ops
);
107 void loopif_init(void);
108 ssize_t
loopif_cksum(struct rmib_call
* call
, struct rmib_node
* node
,
109 struct rmib_oldp
* oldp
, struct rmib_newp
* newp
);
112 void lnksock_init(void);
113 sockid_t
lnksock_socket(int type
, int protocol
, struct sock
** sock
,
114 const struct sockevent_ops
** ops
);
117 void mibtree_init(void);
118 void mibtree_register_inet(int domain
, int protocol
, struct rmib_node
* node
);
119 void mibtree_register_lwip(struct rmib_node
* node
);
122 void ifconf_init(void);
123 int ifconf_ioctl(struct sock
* sock
, unsigned long request
,
124 const struct sockdriver_data
* data
, endpoint_t user_endpt
);
127 u_int
bpf_filter_ext(const struct bpf_insn
* pc
, const struct pbuf
* pbuf
,
128 const u_char
* packet
, u_int total
, u_int len
);
130 #endif /* !MINIX_NET_LWIP_LWIP_H */