ifndef _WS2IPDEF_
define _WS2IPDEF_

include winapifamily.inc
include in6addr.inc

sockaddr_in6_old	STRUC
sin6_family		SWORD ?
sin6_port		WORD ?
sin6_flowinfo		ULONG ?
sin6_addr		IN6_ADDR <>
sockaddr_in6_old	ENDS

sockaddr_gen		UNION
Address			SOCKADDR <>
AddressIn		SOCKADDR_IN <>
AddressIn6		sockaddr_in6_old <>
sockaddr_gen		ENDS

INTERFACE_INFO		STRUC
iiFlags			ULONG ?
iiAddress		sockaddr_gen <>
iiBroadcastAddress	sockaddr_gen <>
iiNetmask		sockaddr_gen <>
INTERFACE_INFO		ENDS
LPINTERFACE_INFO	typedef ptr INTERFACE_INFO

INTERFACE_INFO_EX	STRUC
iiFlags			ULONG ?
iiAddress		SOCKET_ADDRESS <>
iiBroadcastAddress	SOCKET_ADDRESS <>
iiNetmask		SOCKET_ADDRESS <>
INTERFACE_INFO_EX	ENDS
LPINTERFACE_INFO_EX	typedef ptr INTERFACE_INFO_EX

IFF_UP			equ 0x00000001
IFF_BROADCAST		equ 0x00000002
IFF_LOOPBACK		equ 0x00000004
IFF_POINTTOPOINT	equ 0x00000008
IFF_MULTICAST		equ 0x00000010


IP_OPTIONS		equ 1
IP_HDRINCL		equ 2
IP_TOS			equ 3
IP_TTL			equ 4
IP_MULTICAST_IF		equ 9
IP_MULTICAST_TTL	equ 10
IP_MULTICAST_LOOP	equ 11
IP_ADD_MEMBERSHIP	equ 12
IP_DROP_MEMBERSHIP	equ 13
IP_DONTFRAGMENT		equ 14
IP_ADD_SOURCE_MEMBERSHIP equ 15
IP_DROP_SOURCE_MEMBERSHIP equ 16
IP_BLOCK_SOURCE		equ 17
IP_UNBLOCK_SOURCE	equ 18
IP_PKTINFO		equ 19
IP_HOPLIMIT		equ 21
IP_RECEIVE_BROADCAST	equ 22
IP_RECVIF		equ 24
IP_RECVDSTADDR		equ 25
IP_IFLIST		equ 28
IP_ADD_IFLIST		equ 29
IP_DEL_IFLIST		equ 30
IP_UNICAST_IF		equ 31
IP_RTHDR		equ 32
IP_RECVRTHDR		equ 38
IP_TCLASS		equ 39
IP_RECVTCLASS		equ 40
IP_ORIGINAL_ARRIVAL_IF	equ 47
IP_ECN			equ 50
IP_PKTINFO_EX		equ 51
IP_WFP_REDIRECT_RECORDS equ 60
IP_WFP_REDIRECT_CONTEXT equ 70

IP_UNSPECIFIED_TYPE_OF_SERVICE equ -1

IPV6_ADDRESS_BITS	equ RTL_BITS_OF(IN6_ADDR)

SOCKADDR_IN6_LH		STRUC
sin6_family		ADDRESS_FAMILY ?
sin6_port		WORD ?
sin6_flowinfo		ULONG ?
sin6_addr		IN6_ADDR <>
UNION
 sin6_scope_id		ULONG ?
 sin6_scope_struct	SCOPE_ID <>
ENDS
SOCKADDR_IN6_LH		ENDS
PSOCKADDR_IN6_LH	typedef ptr SOCKADDR_IN6_LH
LPSOCKADDR_IN6_LH	typedef ptr SOCKADDR_IN6_LH


if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
SOCKADDR_IN6_W2KSP1	STRUC
sin6_family		SWORD ?
sin6_port		WORD ?
sin6_flowinfo		ULONG ?
sin6_addr		IN6_ADDR <>
sin6_scope_id		ULONG ?
SOCKADDR_IN6_W2KSP1	ENDS
PSOCKADDR_IN6_W2KSP1	typedef ptr SOCKADDR_IN6_W2KSP1
LPSOCKADDR_IN6_W2KSP1	typedef ptr SOCKADDR_IN6_W2KSP1
endif


if (NTDDI_VERSION GE NTDDI_VISTA)
SOCKADDR_IN6		typedef SOCKADDR_IN6_LH
PSOCKADDR_IN6		typedef ptr SOCKADDR_IN6_LH
LPSOCKADDR_IN6		typedef ptr SOCKADDR_IN6_LH
elseif(NTDDI_VERSION GE NTDDI_WIN2KSP1)
SOCKADDR_IN6		typedef SOCKADDR_IN6_W2KSP1
PSOCKADDR_IN6		typedef ptr SOCKADDR_IN6_W2KSP1
LPSOCKADDR_IN6		typedef ptr SOCKADDR_IN6_W2KSP1
else
SOCKADDR_IN6		typedef SOCKADDR_IN6_LH
PSOCKADDR_IN6		typedef ptr SOCKADDR_IN6_LH
LPSOCKADDR_IN6		typedef ptr SOCKADDR_IN6_LH
endif

SOCKADDR_INET		UNION
Ipv4			SOCKADDR_IN <>
Ipv6			SOCKADDR_IN6 <>
si_family		ADDRESS_FAMILY ?
SOCKADDR_INET		ENDS
PSOCKADDR_INET		typedef ptr SOCKADDR_INET

SOCKADDR_IN6_PAIR	STRUC
SourceAddress		PSOCKADDR_IN6 ?
DestinationAddress	PSOCKADDR_IN6 ?
SOCKADDR_IN6_PAIR	ENDS
PSOCKADDR_IN6_PAIR	typedef ptr SOCKADDR_IN6_PAIR

SS_PORT macro ssp
	exitm<(((ssp)).sin_port)>
	endm

if (NTDDI_VERSION GE NTDDI_WIN2KSP1)

IN6ADDR_ANY_INIT	equ <{0}>
IN6ADDR_LOOPBACK_INIT	equ <{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}>
IN6ADDR_ALLNODESONNODE_INIT equ <{0xff,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1}>
IN6ADDR_ALLNODESONLINK_INIT equ {0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,0x01}>
IN6ADDR_ALLROUTERSONLINK_INIT equ {0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,0x02}>
IN6ADDR_ALLMLDV2ROUTERSONLINK_INIT equ <{0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,0x16}>
IN6ADDR_TEREDOINITIALLINKLOCALADDRESS_INIT equ <{0xfe,0x80,0,0,0,0,0,0,0,0,0xff,0xff,0xff,0xff,0xff,0xfe}>
IN6ADDR_TEREDOOLDLINKLOCALADDRESSXP_INIT equ <{0xfe,0x80,0,0,0,0,0,0,0,0,'T','E','R','E','D','O'}>
IN6ADDR_TEREDOOLDLINKLOCALADDRESSVISTA_INIT equ <{0xfe,0x80,0,0,0,0,0,0,0,0,0xff,0xff,0xff,0xff,0xff,0xff}>
IN6ADDR_LINKLOCALPREFIX_INIT equ <{ 0xfe, 0x80, }>
IN6ADDR_MULTICASTPREFIX_INIT equ <{ 0xff, 0x00, }>
IN6ADDR_SOLICITEDNODEMULTICASTPREFIX_INIT equ <{0xff,2,0,0,0,0,0,0,0,0,0,1,0xff,}>
IN6ADDR_V4MAPPEDPREFIX_INIT equ <{0,0,0,0,0,0,0,0,0,0,0xff,0xff,}>
IN6ADDR_6TO4PREFIX_INIT equ <{ 0x20, 0x02, }>
IN6ADDR_TEREDOPREFIX_INIT equ <{ 0x20, 0x01, 0x00, 0x00, }>
IN6ADDR_TEREDOPREFIX_INIT_OLD equ <{ 0x3f, 0xfe, 0x83, 0x1f, }>
IN6ADDR_ULAPREFIX_INIT	equ <{0xfc }>
IN6ADDR_SITELOCALPREFIX_INIT equ <{0xfe, 0xc0 }>
IN6ADDR_6BONETESTPREFIX_INIT equ <{ 0x3f, 0xfe }>

IN6ADDR_LINKLOCALPREFIX_LENGTH equ 64
IN6ADDR_MULTICASTPREFIX_LENGTH equ 8
IN6ADDR_SOLICITEDNODEMULTICASTPREFIX_LENGTH equ 104
IN6ADDR_V4MAPPEDPREFIX_LENGTH equ 96
IN6ADDR_6TO4PREFIX_LENGTH equ 16
IN6ADDR_TEREDOPREFIX_LENGTH equ 32


externdef		scopeid_unspecified:SCOPE_ID

externdef		in4addr_any:IN_ADDR
externdef		in4addr_loopback:IN_ADDR
externdef		in4addr_broadcast:IN_ADDR
externdef		in4addr_allnodesonlink:IN_ADDR
externdef		in4addr_allroutersonlink:IN_ADDR
externdef		in4addr_alligmpv3routersonlink:IN_ADDR
externdef		in4addr_allteredohostsonlink:IN_ADDR
externdef		in4addr_linklocalprefix:IN_ADDR
externdef		in4addr_multicastprefix:IN_ADDR

externdef		in6addr_any:IN6_ADDR
externdef		in6addr_loopback:IN6_ADDR
externdef		in6addr_allnodesonnode:IN6_ADDR
externdef		in6addr_allnodesonlink:IN6_ADDR
externdef		in6addr_allroutersonlink:IN6_ADDR
externdef		in6addr_allmldv2routersonlink:IN6_ADDR
externdef		in6addr_teredoinitiallinklocaladdress:IN6_ADDR
externdef		in6addr_linklocalprefix:IN6_ADDR
externdef		in6addr_multicastprefix:IN6_ADDR
externdef		in6addr_solicitednodemulticastprefix:IN6_ADDR
externdef		in6addr_v4mappedprefix:IN6_ADDR
externdef		in6addr_6to4prefix:IN6_ADDR
externdef		in6addr_teredoprefix:IN6_ADDR
externdef		in6addr_teredoprefix_old:IN6_ADDR

endif ;; (NTDDI_VERSION GE NTDDI_WIN2KSP1)

SIO_GET_INTERFACE_LIST	equ _IOR('t', 127, ULONG)
SIO_GET_INTERFACE_LIST_EX equ _IOR('t', 126, ULONG)
SIO_SET_MULTICAST_FILTER equ _IOW('t', 125, ULONG)
SIO_GET_MULTICAST_FILTER equ _IOW('t', 124 OR IOC_IN, ULONG)
SIOCSIPMSFILTER		equ SIO_SET_MULTICAST_FILTER
SIOCGIPMSFILTER		equ SIO_GET_MULTICAST_FILTER

SIOCSMSFILTER		equ _IOW('t', 126, ULONG)
SIOCGMSFILTER		equ _IOW('t', 127 OR IOC_IN, ULONG)

if (NTDDI_VERSION GE NTDDI_VISTASP1)

IDEAL_SEND_BACKLOG_IOCTLS equ 1

SIO_IDEAL_SEND_BACKLOG_QUERY equ _IOR('t', 123, ULONG)
SIO_IDEAL_SEND_BACKLOG_CHANGE equ _IO('t', 122)

endif

MCAST_JOIN_GROUP	equ 41
MCAST_LEAVE_GROUP	equ 42
MCAST_BLOCK_SOURCE	equ 43
MCAST_UNBLOCK_SOURCE	equ 44
MCAST_JOIN_SOURCE_GROUP equ 45
MCAST_LEAVE_SOURCE_GROUP equ 46

MULTICAST_MODE_TYPE	typedef SDWORD
MCAST_INCLUDE		equ 0
MCAST_EXCLUDE		equ 1

IP_MREQ			STRUC
imr_multiaddr		IN_ADDR <>
imr_interface		IN_ADDR <>
IP_MREQ			ENDS
PIP_MREQ		typedef ptr IP_MREQ

IP_MREQ_SOURCE		STRUC
imr_multiaddr		IN_ADDR <>
imr_sourceaddr		IN_ADDR <>
imr_interface		IN_ADDR <>
IP_MREQ_SOURCE		ENDS
PIP_MREQ_SOURCE		typedef ptr IP_MREQ_SOURCE

IP_MSFILTER		STRUC
imsf_multiaddr		IN_ADDR <>
imsf_interface		IN_ADDR <>
imsf_fmode		MULTICAST_MODE_TYPE ?
imsf_numsrc		ULONG ?
imsf_slist		IN_ADDR 1 dup(<>)
IP_MSFILTER		ENDS
PIP_MSFILTER		typedef ptr IP_MSFILTER

IP_MSFILTER_SIZE macro NumSources
	exitm<(IP_MSFILTER - IN_ADDR + (NumSources) * IN_ADDR)>
	endm

IPV6_HOPOPTS		equ 1
IPV6_HDRINCL		equ 2
IPV6_UNICAST_HOPS	equ 4
IPV6_MULTICAST_IF	equ 9
IPV6_MULTICAST_HOPS	equ 10
IPV6_MULTICAST_LOOP	equ 11
IPV6_ADD_MEMBERSHIP	equ 12
IPV6_JOIN_GROUP		equ IPV6_ADD_MEMBERSHIP
IPV6_DROP_MEMBERSHIP	equ 13
IPV6_LEAVE_GROUP	equ IPV6_DROP_MEMBERSHIP
IPV6_DONTFRAG		equ 14
IPV6_PKTINFO		equ 19
IPV6_HOPLIMIT		equ 21
IPV6_PROTECTION_LEVEL	equ 23
IPV6_RECVIF		equ 24
IPV6_RECVDSTADDR	equ 25
IPV6_CHECKSUM		equ 26
IPV6_V6ONLY		equ 27
IPV6_IFLIST		equ 28
IPV6_ADD_IFLIST		equ 29
IPV6_DEL_IFLIST		equ 30
IPV6_UNICAST_IF		equ 31
IPV6_RTHDR		equ 32
IPV6_RECVRTHDR		equ 38
IPV6_TCLASS		equ 39
IPV6_RECVTCLASS		equ 40
IPV6_ECN		equ 50
IPV6_PKTINFO_EX		equ 51
IPV6_WFP_REDIRECT_RECORDS equ 60
IPV6_WFP_REDIRECT_CONTEXT equ 70

IP_UNSPECIFIED_HOP_LIMIT equ -1

IP_PROTECTION_LEVEL	equ IPV6_PROTECTION_LEVE

PROTECTION_LEVEL_UNRESTRICTED equ 10
PROTECTION_LEVEL_EDGERESTRICTED equ 20
PROTECTION_LEVEL_RESTRICTED equ 30

if (NTDDI_VERSION LT NTDDI_VISTA)
PROTECTION_LEVEL_DEFAULT equ PROTECTION_LEVEL_EDGERESTRICTED
else
PROTECTION_LEVEL_DEFAULT equ (-1)
endif

IPV6_MREQ		STRUC
ipv6mr_multiaddr	IN6_ADDR <>
ipv6mr_interface	ULONG ?
IPV6_MREQ		ENDS
PIPV6_MREQ		typedef ptr IPV6_MREQ

if (NTDDI_VERSION GE NTDDI_WINXP)

GROUP_REQ		STRUC
gr_interface		ULONG ?
gr_group		SOCKADDR_STORAGE <>
GROUP_REQ		ENDS
PGROUP_REQ		typedef ptr GROUP_REQ

GROUP_SOURCE_REQ	STRUC
gsr_interface		ULONG ?
gsr_group		SOCKADDR_STORAGE <>
gsr_source		SOCKADDR_STORAGE <>
GROUP_SOURCE_REQ	ENDS
PGROUP_SOURCE_REQ	typedef ptr GROUP_SOURCE_REQ

GROUP_FILTER		STRUC
gf_interface		ULONG ?
gf_group		SOCKADDR_STORAGE <>
gf_fmode		MULTICAST_MODE_TYPE ?
gf_numsrc		ULONG ?
gf_slist		SOCKADDR_STORAGE 1 dup(<>)
GROUP_FILTER		ENDS
PGROUP_FILTER		typedef ptr GROUP_FILTER

GROUP_FILTER_SIZE macro numsrc
	exitm<(GROUP_FILTER - SOCKADDR_STORAGE + (numsrc) * SOCKADDR_STORAGE)>
	endm

endif

IN_PKTINFO		STRUC
ipi_addr		IN_ADDR <>
ipi_ifindex		ULONG ?
IN_PKTINFO		ENDS
PIN_PKTINFO		typedef ptr IN_PKTINFO

if (IN_PKTINFO NE 8)
    .err<IN_PKTINFO>
endif

IN6_PKTINFO		STRUC
ipi6_addr		IN6_ADDR <>
ipi6_ifindex		ULONG ?
IN6_PKTINFO		ENDS
PIN6_PKTINFO		typedef ptr IN6_PKTINFO

if (IN6_PKTINFO NE 20)
    .err<IN6_PKTINFO>
endif


IN_PKTINFO_EX		STRUC
pkt_info		IN_PKTINFO <>
scope_id		SCOPE_ID <>
IN_PKTINFO_EX		ENDS
PIN_PKTINFO_EX		typedef ptr IN_PKTINFO_EX

if (IN_PKTINFO_EX NE 12)
    .err<IN_PKTINFO_EX>
endif

IN6_PKTINFO_EX		STRUC
pkt_info		IN6_PKTINFO <>
scope_id		SCOPE_ID <>
IN6_PKTINFO_EX		ENDS
PIN6_PKTINFO_EX		typedef ptr IN6_PKTINFO_EX

if (IN6_PKTINFO_EX NE 24)
    .err<IN6_PKTINFO_EX>
endif

INET_ADDRSTRLEN		equ 22
INET6_ADDRSTRLEN	equ 65

TCP_OFFLOAD_NO_PREFERENCE equ 0
TCP_OFFLOAD_NOT_PREFERRED equ 1
TCP_OFFLOAD_PREFERRED	equ 2

TCP_EXPEDITED_1122	equ 0x0002
TCP_KEEPALIVE		equ 3
TCP_MAXSEG		equ 4
TCP_MAXRT		equ 5
TCP_STDURG		equ 6
TCP_NOURG		equ 7
TCP_ATMARK		equ 8
TCP_NOSYNRETRIES	equ 9
TCP_TIMESTAMPS		equ 10
TCP_OFFLOAD_PREFERENCE	equ 11
TCP_CONGESTION_ALGORITHM equ 12
TCP_DELAY_FIN_ACK	equ 13

endif
