1 #ifndef MINIX_NET_LWIP_PKTSOCK_H
2 #define MINIX_NET_LWIP_PKTSOCK_H
6 /* Packet-level socket, shared by UDP and RAW. */
8 struct ipsock pkt_ipsock
; /* IP socket object, MUST be first */
9 struct pbuf
*pkt_rcvhead
; /* receive buffer, first packet */
10 struct pbuf
**pkt_rcvtailp
; /* receive buffer, last ptr-ptr */
11 size_t pkt_rcvlen
; /* receive buffer, length in bytes */
12 struct mcast_head pkt_mcast
; /* multicast membership list */
13 ip6_addr_p_t pkt_srcaddr
; /* IPV6_PKTINFO: source address */
14 uint32_t pkt_ifindex
; /* IPV6_KPTINFO: interface index */
17 #define pktsock_get_ipsock(pkt) (&(pkt)->pkt_ipsock)
18 #define pktsock_get_ifindex(pkt) ((pkt)->pkt_ifindex)
20 /* Options when sending packets. */
22 uint8_t pkto_flags
; /* packet send flags (PKTOF_) */
23 uint8_t pkto_tos
; /* type of service for the packet */
24 uint8_t pkto_ttl
; /* time-to-live for the packet */
25 uint8_t pkto_mcast_ttl
; /* time-to-live for multicast packet */
26 ip6_addr_p_t pkto_srcaddr
; /* IPV6_PKTINFO: source address */
27 unsigned int pkto_ifindex
; /* IPV6_PKTINFO: interface index */
30 #define PKTOF_TTL 0x01 /* send packet with custom TTL value */
31 #define PKTOF_TOS 0x02 /* send packet with custom TOS value */
32 #define PKTOF_PKTINFO 0x04 /* send packet with src addr, on if. */
34 int pktsock_socket(struct pktsock
* pkt
, int domain
, size_t sndbuf
,
35 size_t rcvbuf
, struct sock
** sockp
);
36 int pktsock_test_input(struct pktsock
* pkt
, struct pbuf
* pbuf
);
37 void pktsock_input(struct pktsock
* pkt
, struct pbuf
* pbuf
,
38 const ip_addr_t
* srcaddr
, uint16_t port
);
39 int pktsock_get_pktinfo(struct pktsock
* pkt
, struct pktopt
* pkto
,
40 struct ifdev
** ifdevp
, ip_addr_t
* src_addrp
);
41 int pktsock_get_ctl(struct pktsock
* pkt
, const struct sockdriver_data
* ctl
,
42 socklen_t ctl_len
, struct pktopt
* pkto
);
43 int pktsock_get_data(struct pktsock
* pkt
, const struct sockdriver_data
* data
,
44 size_t len
, struct pbuf
* pbuf
);
45 int pktsock_pre_recv(struct sock
* sock
, endpoint_t user_endpt
, int flags
);
46 int pktsock_recv(struct sock
* sock
, const struct sockdriver_data
* data
,
47 size_t len
, size_t * off
, const struct sockdriver_data
* ctl
,
48 socklen_t ctl_len
, socklen_t
* ctl_off
, struct sockaddr
* addr
,
49 socklen_t
* addr_len
, endpoint_t user_endpt
, int flags
, size_t min
,
51 int pktsock_test_recv(struct sock
* sock
, size_t min
, size_t * size
);
52 void pktsock_set_mcaware(struct pktsock
* pkt
);
53 int pktsock_setsockopt(struct pktsock
* pkt
, int level
, int name
,
54 const struct sockdriver_data
* data
, socklen_t len
,
55 struct ipopts
* ipopts
);
56 int pktsock_getsockopt(struct pktsock
* pkt
, int level
, int name
,
57 const struct sockdriver_data
* data
, socklen_t
* len
,
58 struct ipopts
* ipopts
);
59 void pktsock_shutdown(struct pktsock
* pkt
, unsigned int mask
);
60 void pktsock_close(struct pktsock
* pkt
);
61 size_t pktsock_get_recvlen(struct pktsock
* pkt
);
63 #endif /* !MINIX_NET_LWIP_PKTSOCK_H */