1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 //! TCP/IP specific information for use by WinSock2 compatible applications.
7 use ctypes::c_int;
8 use shared::in6addr::IN6_ADDR;
9 use shared::inaddr::IN_ADDR;
10 use shared::minwindef::{ULONG, USHORT};
11 use shared::ws2def::{ADDRESS_FAMILY, SCOPE_ID};
12 pub const IFF_UP: ULONG = 0x00000001;
13 pub const IFF_BROADCAST: ULONG = 0x00000002;
14 pub const IFF_LOOPBACK: ULONG = 0x00000004;
15 pub const IFF_POINTTOPOINT: ULONG = 0x00000008;
16 pub const IFF_MULTICAST: ULONG = 0x00000010;
17 pub const IP_OPTIONS: c_int = 1;
18 pub const IP_HDRINCL: c_int = 2;
19 pub const IP_TOS: c_int = 3;
20 pub const IP_TTL: c_int = 4;
21 pub const IP_MULTICAST_IF: c_int = 9;
22 pub const IP_MULTICAST_TTL: c_int = 10;
23 pub const IP_MULTICAST_LOOP: c_int = 11;
24 pub const IP_ADD_MEMBERSHIP: c_int = 12;
25 pub const IP_DROP_MEMBERSHIP: c_int = 13;
26 pub const IP_DONTFRAGMENT: c_int = 14;
27 pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 15;
28 pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 16;
29 pub const IP_BLOCK_SOURCE: c_int = 17;
30 pub const IP_UNBLOCK_SOURCE: c_int = 18;
31 pub const IP_PKTINFO: c_int = 19;
32 pub const IP_RECEIVE_BROADCAST: c_int = 22;
33 pub const IP_RECVDSTADDR: c_int = 25;
34 UNION!{union SOCKADDR_IN6_LH_u {
35     [u32; 1],
36     sin6_scope_id sin6_scope_id_mut: ULONG,
37     sin6_scope_struct sin6_scope_struct_mut: SCOPE_ID,
38 }}
39 STRUCT!{struct SOCKADDR_IN6_LH {
40     sin6_family: ADDRESS_FAMILY,
41     sin6_port: USHORT,
42     sin6_flowinfo: ULONG,
43     sin6_addr: IN6_ADDR,
44     u: SOCKADDR_IN6_LH_u,
45 }}
46 pub type PSOCKADDR_IN6_LH = *mut SOCKADDR_IN6_LH;
47 STRUCT!{struct IP_MREQ {
48     imr_multiaddr: IN_ADDR,
49     imr_interface: IN_ADDR,
50 }}
51 pub type PIP_MREQ = *mut IP_MREQ;
52 pub const IPV6_HOPOPTS: c_int = 1;
53 pub const IPV6_HDRINCL: c_int = 2;
54 pub const IPV6_UNICAST_HOPS: c_int = 4;
55 pub const IPV6_MULTICAST_IF: c_int = 9;
56 pub const IPV6_MULTICAST_HOPS: c_int = 10;
57 pub const IPV6_MULTICAST_LOOP: c_int = 11;
58 pub const IPV6_ADD_MEMBERSHIP: c_int = 12;
59 pub const IPV6_JOIN_GROUP: c_int = IPV6_ADD_MEMBERSHIP;
60 pub const IPV6_DROP_MEMBERSHIP: c_int = 13;
61 pub const IPV6_LEAVE_GROUP: c_int = IPV6_DROP_MEMBERSHIP;
62 pub const IPV6_DONTFRAG: c_int = 14;
63 pub const IPV6_PKTINFO: c_int = 19;
64 pub const IPV6_HOPLIMIT: c_int = 21;
65 pub const IPV6_PROTECTION_LEVEL: c_int = 23;
66 pub const IPV6_RECVIF: c_int = 24;
67 pub const IPV6_RECVDSTADDR: c_int = 25;
68 pub const IPV6_CHECKSUM: c_int = 26;
69 pub const IPV6_V6ONLY: c_int = 27;
70 pub const IPV6_IFLIST: c_int = 28;
71 pub const IPV6_ADD_IFLIST: c_int = 29;
72 pub const IPV6_DEL_IFLIST: c_int = 30;
73 pub const IPV6_UNICAST_IF: c_int = 31;
74 pub const IPV6_RTHDR: c_int = 32;
75 pub const IPV6_RECVRTHDR: c_int = 38;
76 pub const IPV6_TCLASS: c_int = 39;
77 pub const IPV6_RECVTCLASS: c_int = 40;
78 STRUCT!{struct IPV6_MREQ {
79     ipv6mr_multiaddr: IN6_ADDR,
80     ipv6mr_interface: ULONG,
81 }}
82 pub type PIPV6_MREQ = *mut IPV6_MREQ;
83 STRUCT!{struct IN_PKTINFO {
84     ipi_addr: IN_ADDR,
85     ipi_ifindex: ULONG,
86 }}
87 pub type PIN_PKTINFO = *mut IN_PKTINFO;
88 STRUCT!{struct IN6_PKTINFO {
89     ipi6_addr: IN6_ADDR,
90     ipi6_ifindex: ULONG,
91 }}
92 pub type PIN6_PKTINFO = *mut IN6_PKTINFO;
93