etc/services - sync with NetBSD-8
[minix.git] / minix / net / lwip / ipsock.h
blob0e8a8302f24586554b653f23b9d192e095bf7e2e
1 #ifndef MINIX_NET_LWIP_IPSOCK_H
2 #define MINIX_NET_LWIP_IPSOCK_H
4 /* IP-level socket, shared by TCP, UDP, and RAW. */
5 struct ipsock {
6 struct sock ip_sock; /* socket object, MUST be first */
7 unsigned int ip_flags; /* all socket flags */
8 size_t ip_sndbuf; /* send buffer size */
9 size_t ip_rcvbuf; /* receive buffer size */
13 * Socket flags. In order to reduce memory consumption, all these flags are
14 * stored in the same field (ipsock.ip_flags) and thus must not overlap between
15 * the same users of the field, and that is why they are all here. For
16 * example, UDPF/PKTF/IPF should all be unique, and TCPF/IPF should be unique,
17 * but UDPF/PKTF may overlap with TCPF and UDPF may overlap with RAWF. In
18 * practice, we have no UDPF or RAWF flags and plenty of space to make all
19 * flags unique anyway.
21 #define IPF_IPV6 0x0000001 /* socket is IPv6 */
22 #define IPF_V6ONLY 0x0000002 /* socket is IPv6 only */
24 #define PKTF_RECVINFO 0x0000010 /* receive ancillary PKTINFO */
25 #define PKTF_RECVTTL 0x0000020 /* receive ancillary TTL */
26 #define PKTF_RECVTOS 0x0000040 /* receive ancillary TOS */
27 #define PKTF_MCAWARE 0x0000080 /* owner is multicast aware */
29 #define TCPF_CONNECTING 0x0001000 /* attempting to connect */
30 #define TCPF_SENT_FIN 0x0002000 /* send FIN when possible */
31 #define TCPF_RCVD_FIN 0x0004000 /* received FIN from peer */
32 #define TCPF_FULL 0x0008000 /* PCB send buffer is full */
33 #define TCPF_OOM 0x0010000 /* memory allocation failed */
35 #define ipsock_get_sock(ip) (&(ip)->ip_sock)
36 #define ipsock_is_ipv6(ip) ((ip)->ip_flags & IPF_IPV6)
37 #define ipsock_is_v6only(ip) ((ip)->ip_flags & IPF_V6ONLY)
38 #define ipsock_get_flags(ip) ((ip)->ip_flags)
39 #define ipsock_get_flag(ip,fl) ((ip)->ip_flags & (fl))
40 #define ipsock_set_flag(ip,fl) ((ip)->ip_flags |= (fl))
41 #define ipsock_clear_flag(ip,fl) ((ip)->ip_flags &= ~(fl))
42 #define ipsock_get_sndbuf(ip) ((ip)->ip_sndbuf)
43 #define ipsock_get_rcvbuf(ip) ((ip)->ip_rcvbuf)
46 * IP-level option pointers. This is necessary because even though lwIP's
47 * TCP, UDP, and RAW PCBs share the same initial fields, the C standard does
48 * not permit generic access to such initial fields (due to both possible
49 * padding differences and strict-aliasing rules). The fields in this
50 * structure are therefore pointers to the initial fields of each of the PCB
51 * structures. If lwIP ever groups its IP PCB fields into a single structure
52 * and uses that structure as first field of each of the other PCBs, then we
53 * will be able to replace this structure with a pointer to the IP PCB instead.
54 * For convenience we also carry the send and receive buffer limits here.
56 struct ipopts {
57 ip_addr_t *local_ip;
58 ip_addr_t *remote_ip;
59 uint8_t *tos;
60 uint8_t *ttl;
61 size_t sndmin;
62 size_t sndmax;
63 size_t rcvmin;
64 size_t rcvmax;
67 struct ifdev;
69 void ipsock_init(void);
70 int ipsock_socket(struct ipsock * ip, int domain, size_t sndbuf, size_t rcvbuf,
71 struct sock ** sockp);
72 void ipsock_clone(struct ipsock * ip, struct ipsock * newip, sockid_t newid);
73 void ipsock_get_any_addr(struct ipsock * ip, ip_addr_t * ipaddr);
74 int ipsock_check_src_addr(struct ipsock * ip, ip_addr_t * ipaddr,
75 int allow_mcast, struct ifdev ** ifdevp);
76 int ipsock_get_src_addr(struct ipsock * ip, const struct sockaddr * addr,
77 socklen_t addr_len, endpoint_t user_endpt, ip_addr_t * local_ip,
78 uint16_t local_port, int allow_mcast, ip_addr_t * ipaddr,
79 uint16_t * portp);
80 int ipsock_get_dst_addr(struct ipsock * ip, const struct sockaddr * addr,
81 socklen_t addr_len, const ip_addr_t * local_addr, ip_addr_t * dst_addr,
82 uint16_t * dst_port);
83 void ipsock_put_addr(struct ipsock * ip, struct sockaddr * addr,
84 socklen_t * addr_len, ip_addr_t * ipaddr, uint16_t port);
85 int ipsock_setsockopt(struct ipsock * ip, int level, int name,
86 const struct sockdriver_data * data, socklen_t len,
87 struct ipopts * ipopts);
88 int ipsock_getsockopt(struct ipsock * ip, int level, int name,
89 const struct sockdriver_data * data, socklen_t * len,
90 struct ipopts * ipopts);
91 void ipsock_get_info(struct kinfo_pcb * ki, const ip_addr_t * local_ip,
92 uint16_t local_port, const ip_addr_t * remote_ip,
93 uint16_t remote_port);
95 #endif /* !MINIX_NET_LWIP_IPSOCK_H */