FIONREAD = IOC_OUT or { get # bytes to read }
((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
(Longint(Byte('f')) shl 8) or 127;
FIONBIO = IOC_IN or { set/clear non-blocking i/o }
((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
(Longint(Byte('f')) shl 8) or 126;
FIOASYNC = IOC_IN or { set/clear async i/o }
((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
(Longint(Byte('f')) shl 8) or 125;
const
{ Protocols }
IPPROTO_IP = 0; { Dummy }
IPPROTO_ICMP = 1; { Internet Control Message Protocol }
IPPROTO_IGMP = 2; { Internet Group Management Protocol}
IPPROTO_GGP = 3; { Gateway }
IPPROTO_TCP = 6; { TCP }
IPPROTO_PUP = 12; { PUP }
IPPROTO_UDP = 17; { User Datagram Protocol }
IPPROTO_IDP = 22; { XNS IDP }
IPPROTO_ND = 77; { UNOFFICIAL Net Disk Protocol }
IPPROTO_RAW = 255;
IPPROTO_MAX = 256;
{ Port/socket numbers: network standard functions}
{ Options for use with [gs]etsockopt at the IP level. }
IP_OPTIONS = 1;
IP_MULTICAST_IF = 2; { set/get IP multicast interface }
IP_MULTICAST_TTL = 3; { set/get IP multicast timetolive }
IP_MULTICAST_LOOP = 4; { set/get IP multicast loopback }
IP_ADD_MEMBERSHIP = 5; { add an IP group membership }
IP_DROP_MEMBERSHIP = 6; { drop an IP group membership }
IP_DEFAULT_MULTICAST_TTL = 1; { normally limit m'casts to 1 hop }
IP_DEFAULT_MULTICAST_LOOP = 1; { normally hear sends if a member }
IP_MAX_MEMBERSHIPS = 20; { per socket; must fit in one mbuf }
{ This is used instead of -1, since the
TSocket type is unsigned.}
{ The following may be used in place of the address family, socket type, or
protocol in a call to WSASocket to indicate that the corresponding value
should be taken from the supplied WSAPROTOCOL_INFO structure instead of the
parameter itself.
}
SO_DEBUG = $0001; { turn on debugging info recording }
SO_ACCEPTCONN = $0002; { socket has had listen() }
SO_REUSEADDR = $0004; { allow local address reuse }
SO_KEEPALIVE = $0008; { keep connections alive }
SO_DONTROUTE = $0010; { just use interface addresses }
SO_BROADCAST = $0020; { permit sending of broadcast msgs }
SO_USELOOPBACK = $0040; { bypass hardware when possible }
SO_LINGER = $0080; { linger on close if data present }
SO_OOBINLINE = $0100; { leave received OOB data in line }
SO_DONTLINGER = $ff7f;
{ Additional options. }
SO_SNDBUF = $1001; { send buffer size }
SO_RCVBUF = $1002; { receive buffer size }
SO_SNDLOWAT = $1003; { send low-water mark }
SO_RCVLOWAT = $1004; { receive low-water mark }
SO_SNDTIMEO = $1005; { send timeout }
SO_RCVTIMEO = $1006; { receive timeout }
SO_ERROR = $1007; { get error status and clear }
SO_TYPE = $1008; { get socket type }
{ Options for connect and disconnect data and options. Used only by
non-TCP/IP transports such as DECNet, OSI TP4, etc. }
AF_UNSPEC = 0; { unspecified }
AF_UNIX = 1; { local to host (pipes, portals) }
AF_INET = 2; { internetwork: UDP, TCP, etc. }
AF_IMPLINK = 3; { arpanet imp addresses }
AF_PUP = 4; { pup protocols: e.g. BSP }
AF_CHAOS = 5; { mit CHAOS protocols }
AF_IPX = 6; { IPX and SPX }
AF_NS = 6; { XEROX NS protocols }
AF_ISO = 7; { ISO protocols }
AF_OSI = AF_ISO; { OSI is ISO }
AF_ECMA = 8; { european computer manufacturers }
AF_DATAKIT = 9; { datakit protocols }
AF_CCITT = 10; { CCITT protocols, X.25 etc }
AF_SNA = 11; { IBM SNA }
AF_DECnet = 12; { DECnet }
AF_DLI = 13; { Direct data link interface }
AF_LAT = 14; { LAT }
AF_HYLINK = 15; { NSC Hyperchannel }
AF_APPLETALK = 16; { AppleTalk }
AF_NETBIOS = 17; { NetBios-style addresses }
AF_VOICEVIEW = 18; { VoiceView }
AF_FIREFOX = 19; { FireFox }
AF_UNKNOWN1 = 20; { Somebody is using this! }
AF_BAN = 21; { Banyan }
AF_ATM = 22; { Native ATM Services }
AF_INET6 = 23; { Internetwork Version 6 }
AF_MAX = 24;
type
{ Structure used by kernel to store most addresses. }
PSockAddr = ^TSockAddr;
TSockAddr = TSockAddrIn;
{ Structure used by kernel to pass protocol information in raw sockets. }
PSockProto = ^TSockProto;
TSockProto = packed record
sp_family: u_short;
sp_protocol: u_short;
end;
const
{ Protocol families, same as address families for now. }
{ Error return codes from gethostbyname() and gethostbyaddr()
(when using the resolver). Note that these errors are
retrieved via WSAGetLastError() and must therefore follow
the rules for avoiding clashes with error numbers from
specific implementations or language run-time systems.
For this reason the codes are based at WSABASEERR+1001.
Note also that [WSA]NO_ADDRESS is defined only for
compatibility purposes. }
{ Windows Sockets errors redefined as regular Berkeley error constants.
These are commented out in Windows NT to avoid conflicts with errno.h.
Use the WSA constants instead. }
PFlowspec = ^TFlowspec;
TFlowspec = packed record
TokenRate : LongInt; { In Bytes/sec }
TokenBucketSize : LongInt; { In Bytes }
PeakBandwidth : LongInt; { In Bytes/sec }
Latency : LongInt; { In microseconds }
DelayVariation : LongInt; { In microseconds }
LevelOfGuarantee : Guarantee; { Guaranteed, Predictive }
{ or Best Effort }
CostOfCall : LongInt; { Reserved for future use, }
{ must be set to 0 now }
NetworkAvailability : LongInt; { read-only: }
{ 1 if accessible, }
{ 0 if not }
end;
PQOS = ^TQualityOfService;
TQualityOfService = packed record
SendingFlowspec :TFlowspec; { the flow spec for data sending }
ReceivingFlowspec :TFlowspec; { the flow spec for data receiving }
ProviderSpecific :TWSABuf; { additional provider specific stuff }
end;
const
{ WinSock 2 extension -- manifest constants for return values of the
condition function}
{ WinSock 2 extension -- data type for WSAEnumNetworkEvents() }
type
PWSANETWORKEVENTS = ^TWSANETWORKEVENTS;
TWSANETWORKEVENTS = packed record
lNetworkEvents :u_long;
iErrorCode : array [0..FD_MAX_EVENTS-1] of u_int;
end;
{WinSock 2 extension -- WSAPROTOCOL_INFO structure and associated
manifest constants}
PGUID = ^TGUID;
TGUID = packed record
Data1 :u_long;
Data2 :u_short;
Data3 :u_short;
Data4 : array [0..8-1] of u_char;
end;
const
MAX_PROTOCOL_CHAIN = 7;
BASE_PROTOCOL = 1;
LAYERED_PROTOCOL = 0;
type
PWSAPROTOCOLCHAIN = ^TWSAPROTOCOLCHAIN;
TWSAPROTOCOLCHAIN = packed record
ChainLen : Integer; { the length of the chain, }
{ length = 0 means layered protocol, }
{ length = 1 means base protocol, }
{ length > 1 means protocol chain }
ChainEntries : array[0..MAX_PROTOCOL_CHAIN-1] of DWORD; { a list of dwCatalogEntryIds }
end;
SIO_ASSOCIATE_HANDLE = IOC_IN or IOC_WS2 or 1;
SIO_ENABLE_CIRCULAR_QUEUEING = IOC_VOID or IOC_WS2 or 2;
SIO_FIND_ROUTE = IOC_OUT or IOC_WS2 or 3;
SIO_FLUSH = IOC_VOID or IOC_WS2 or 4;
SIO_GET_BROADCAST_ADDRESS = IOC_OUT or IOC_WS2 or 5;
SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT or IOC_WS2 or 6;
SIO_GET_QOS = IOC_INOUT or IOC_WS2 or 7;
SIO_GET_GROUP_QOS = IOC_INOUT or IOC_WS2 or 8;
SIO_MULTIPOINT_LOOPBACK = IOC_IN or IOC_WS2 or 9;
SIO_MULTICAST_SCOPE = IOC_IN or IOC_WS2 or 10;
SIO_SET_QOS = IOC_IN or IOC_WS2 or 11;
SIO_SET_GROUP_QOS = IOC_IN or IOC_WS2 or 12;
SIO_TRANSLATE_HANDLE = IOC_INOUT or IOC_WS2 or 13;
function WSAMakeASyncReply(Buflen, Error: Word): Longint;
function WSAMakeSelectReply(Event, Error: Word): Longint;
function WSAGetAsyncBuflen(Param: Longint): Word;
function WSAGetAsyncError(Param: Longint): Word;
function WSAGetSelectEvent(Param: Longint): Word;
function WSAGetSelectError(Param: Longint): Word;
implementation
const
winsocket = 'ws2_32.dll';
function WSAMakeASyncReply;
begin
WSAMakeASyncReply:= MakeLong(Buflen, Error);
end;
function WSAMakeSelectReply;
begin
WSAMakeSelectReply:= MakeLong(Event, Error);
end;
function WSAGetAsyncBuflen;
begin
WSAGetAsyncBuflen:= LOWORD(Param);
end;
function WSAGetAsyncError;
begin
WSAGetAsyncError:= HIWORD(Param);
end;
function WSAGetSelectEvent;
begin
WSAGetSelectEvent:= LOWORD(Param);
end;
function WSAGetSelectError;
begin
WSAGetSelectError:= HIWORD(Param);
end;
function accept;
external winsocket name 'accept';
function bind;
external winsocket name 'bind';
function closesocket;
external winsocket name 'closesocket';
function connect;
external winsocket name 'connect';
function getpeername;
external winsocket name 'getpeername';
function getsockname;
external winsocket name 'getsockname';
function getsockopt;
external winsocket name 'getsockopt';
function htonl;
external winsocket name 'htonl';
function htons;
external winsocket name 'htons';
function inet_addr;
external winsocket name 'inet_addr';
function inet_ntoa;
external winsocket name 'inet_ntoa';
function ioctlsocket;
external winsocket name 'ioctlsocket';
function listen;
external winsocket name 'listen';
function ntohl;
external winsocket name 'ntohl';
function ntohs;
external winsocket name 'ntohs';
function recv;
external winsocket name 'recv';
function recvfrom;
external winsocket name 'recvfrom';
function select;
external winsocket name 'select';
function send;
external winsocket name 'send';
function sendto;
external winsocket name 'sendto';
function setsockopt;
external winsocket name 'setsockopt';
function shutdown;
external winsocket name 'shutdown';
function socket;
external winsocket name 'socket';
function gethostbyaddr;
external winsocket name 'gethostbyaddr';
function gethostbyname;
external winsocket name 'gethostbyname';
function getprotobyname;
external winsocket name 'getprotobyname';
function getprotobynumber;
external winsocket name 'getprotobynumber';
function getservbyname;
external winsocket name 'getservbyname';
function getservbyport;
external winsocket name 'getservbyport';
function gethostname;
external winsocket name 'gethostname';
function WSAAsyncSelect;
external winsocket name 'WSAAsyncSelect';
function WSARecvEx;
external winsocket name 'WSARecvEx';
function WSAAsyncGetHostByAddr;
external winsocket name 'WSAAsyncGetHostByAddr';
function WSAAsyncGetHostByName;
external winsocket name 'WSAAsyncGetHostByName';
function WSAAsyncGetProtoByNumber;
external winsocket name 'WSAAsyncGetProtoByNumber';
function WSAAsyncGetprotoByName;
external winsocket name 'WSAAsyncGetprotoByName';
function WSAAsyncGetServByPort;
external winsocket name 'WSAAsyncGetServByPort';
function WSAAsyncGetServByName;
external winsocket name 'WSAAsyncGetServByName';
function WSACancelAsyncRequest;
external winsocket name 'WSACancelAsyncRequest';
function WSASetBlockingHook;
external winsocket name 'WSASetBlockingHook';
function WSAUnhookBlockingHook;
external winsocket name 'WSAUnhookBlockingHook';
function WSAGetLastError;
external winsocket name 'WSAGetLastError';
procedure WSASetLastError;
external winsocket name 'WSASetLastError';
function WSACancelBlockingCall;
external winsocket name 'WSACancelBlockingCall';
function WSAIsBlocking;
external winsocket name 'WSAIsBlocking';
function WSAStartup;
external winsocket name 'WSAStartup';
function WSACleanup;
external winsocket name 'WSACleanup';
{$IFDEF UNICODE}
function WSASetService;
external winsocket name 'WSASetServiceW';
function WSAGetServiceClassNameByClassId;
external winsocket name 'WSAGetServiceClassNameByClassIdW';
function WSAEnumNameSpaceProviders;
external winsocket name 'WSAEnumNameSpaceProvidersW';
function WSAGetServiceClassInfo;
external winsocket name 'WSAGetServiceClassInfoW';
function WSAInstallServiceClass;
external winsocket name 'WSAInstallServiceClassW';
function WSALookupServiceNext;
external winsocket name 'WSALookupServiceNextW';
function WSALookupServiceBegin;
external winsocket name 'WSALookupServiceBeginW';
function WSAStringToAddress;
external winsocket name 'WSAStringToAddressW';
function WSAAddressToString;
external winsocket name 'WSAAddressToStringW';
function WSASocket;
external winsocket name 'WSASocketW';
function WSAEnumProtocols;
external winsocket name 'WSAEnumProtocolsW';
function WSADuplicateSocket;
external winsocket name 'WSADuplicateSocketW';
{$ELSE}
function WSASetService;
external winsocket name 'WSASetServiceA';
function WSAGetServiceClassNameByClassId;
external winsocket name 'WSAGetServiceClassNameByClassIdA';
function WSAEnumNameSpaceProviders;
external winsocket name 'WSAEnumNameSpaceProvidersA';
function WSAGetServiceClassInfo;
external winsocket name 'WSAGetServiceClassInfoA';
function WSAInstallServiceClass;
external winsocket name 'WSAInstallServiceClassA';
function WSALookupServiceNext;
external winsocket name 'WSALookupServiceNextA';
function WSALookupServiceBegin;
external winsocket name 'WSALookupServiceBeginA';
function WSAStringToAddress;
external winsocket name 'WSAStringToAddressA';
function WSAAddressToString;
external winsocket name 'WSAAddressToStringA';
function WSASocket;
external winsocket name 'WSASocketA';
function WSAEnumProtocols;
external winsocket name 'WSAEnumProtocolsA';
function WSADuplicateSocket;
external winsocket name 'WSADuplicateSocketA';
{$ENDIF} { UNICODE}
function WSALookupServiceEnd;
external winsocket name 'WSALookupServiceEnd';
function WSARemoveServiceClass;
external winsocket name 'WSARemoveServiceClass';
function WSAWaitForMultipleEvents;
external winsocket name 'WSAWaitForMultipleEvents';
function WSASetEvent;
external winsocket name 'WSASetEvent';
function WSASendTo;
external winsocket name 'WSASendTo';
function WSASendDisconnect;
external winsocket name 'WSASendDisconnect';
function WSASend;
external winsocket name 'WSASend';
function WSAResetEvent;
external winsocket name 'WSAResetEvent';
function WSARecvFrom;
external winsocket name 'WSARecvFrom';
function WSARecvDisconnect;
external winsocket name 'WSARecvDisconnect';
function WSARecv;
external winsocket name 'WSARecv';
function WSAIoctl;
external winsocket name 'WSAIoctl';
function WSAJoinLeaf;
external winsocket name 'WSAJoinLeaf';
function WSANtohl;
external winsocket name 'WSANtohl';
function WSANtohs;
external winsocket name 'WSANtohs';
function WSAHtons;
external winsocket name 'WSAHtons';
function WSAHtonl;
external winsocket name 'WSAHtonl';
function WSAGetQOSByName;
external winsocket name 'WSAGetQOSByName';
function WSAGetOverlappedResult;
external winsocket name 'WSAGetOverlappedResult';
function WSAEventSelect;
external winsocket name 'WSAEventSelect';
function WSAEnumNetworkEvents;
external winsocket name 'WSAEnumNetworkEvents';
function WSACreateEvent;
external winsocket name 'WSACreateEvent';
function WSAConnect;
external winsocket name 'WSAConnect';
function WSACloseEvent;
external winsocket name 'WSACloseEvent';
function WSAAccept;
external winsocket name 'WSAAccept';
function TransmitFile;
external winsocket name 'TransmitFile';
{ $HDR$}
{**********************************************************************}
{ Unit archived using Team Coherence }
{ Team Coherence is Copyright 2002 by Quality Software Components }
{ }
{ For further information / comments, visit our WEB site at }
{ http://www.TeamCoherence.com }
{**********************************************************************}
{}
{ $Log: 10425: IdWinSock2.pas
{
{ Rev 1.2 4/20/03 1:54:08 PM RLebeau
{ Updated to better support C++Builder by adding $EXTERNSYM defines to most of
{ the interface declarations, so that they won't be included in the
{ auto-generated HPP file. The native winsock2.h header file is used instead.
{
{ Updated with more of the latest WinSock2 defines and declarations.
}
{
{ Rev 1.1 3/22/2003 09:55:58 PM JPMugaas
{ Commented out definition for TGUID. It is not needed because that is in D4,
{ D5, D6, and D7. It could cause conflicts with other code.
{ Fixed bug where a space would cause the WSACreateEvent not to load.
}
{
{ Rev 1.0 2002.11.12 11:00:26 PM czhower
}
//-------------------------------------------------------------
//
// Borland Delphi Runtime Library
// <API> interface unit
//
// Portions created by Microsoft are
// Copyright (C) 1995-1999 Microsoft Corporation.
// All Rights Reserved.
//
// The original file is: Winsock2.h from CBuilder5 distribution.
// The original Pascal code is: winsock2.pas, released 03 Mar 2001.
// The initial developer of the Pascal code is Alex Konshin
// (alexk@mtgroup.ru).
//-------------------------------------------------------------
{ Winsock2.h -- definitions to be used with the WinSock 2 DLL and WinSock 2 applications.
This header file corresponds to version 2.2.x of the WinSock API specification.
This file includes parts which are Copyright (c) 1982-1986 Regents
of the University of California. All rights reserved.
The Berkeley Software License Agreement specifies the terms and
conditions for redistribution. }
// Note that the original unit is copyrighted by the original author and I did obtain his
// permission to port and use this as part of Indy - J. Peter Mugaas
// 2002-01-28 - Hadi Hariri. Fixes for C++ Builder. Thanks to Chuck Smith.
// 2001 - Oct -25 J. Peter Mugaas
// Made adjustments for Indy usage by
// 1) including removing Trace logging
// 2) renaming and consolidating some .INC files as appropriate
// 3) modifying the unit to follow Indy conventions
// 4) Adding TransmitFile support for the HTTP Server
// 5) Removing all static loading code that was IFDEF'ed. {Do not Localize}
// 2001 - Mar - 1 Alex Konshin
// Revision 3
// converted by Alex Konshin, mailto:alexk@mtgroup.ru
// revision 3, March,1 2001
// Define the current Winsock version. To build an earlier Winsock version
// application redefine this value prior to including Winsock2.h
const
{$EXTERNALSYM WINSOCK_VERSION}
WINSOCK_VERSION = $0202;
WINSOCK2_DLL = 'WS2_32.DLL'; {Do not Localize}
type
{$EXTERNALSYM u_char}
u_char = Byte;
{$EXTERNALSYM u_short}
u_short = Word;
{$EXTERNALSYM u_int}
//u_int = DWORD;
u_int = Integer;
{$EXTERNALSYM u_long}
u_long = DWORD;
// The new type to be used in all instances which refer to sockets.
{$EXTERNALSYM TSocket}
TSocket = u_int;
type
// the following emits are a workaround to the name conflicts
// with the winsock2 header files
(*$HPPEMIT '#include <winsock2.h>'*)
(*$HPPEMIT '#include <ws2tcpip.h>'*)
(*$HPPEMIT '#include <wsipx.h>'*)
(*$HPPEMIT '#include <wsnwlink.h>'*)
(*$HPPEMIT '#include <wsnetbs.h>'*)
(*$HPPEMIT '#include <ws2atm.h>'*)
(*$HPPEMIT ''*)
(*$HPPEMIT 'namespace Idwinsock2'*)
(*$HPPEMIT '{'*)
(*$HPPEMIT ' typedef fd_set *PFDSet;'*) // due to name conflict with procedure FD_SET
(*$HPPEMIT ' typedef fd_set TFDSet;'*) // due to name conflict with procedure FD_SET
(*$HPPEMIT '}'*)
(*$HPPEMIT ''*)
// the following emits are to ensure all supported versions
// of C++Builder know about the latest winsock2 structures
(*$HPPEMIT '// versions of Builder prior to 6.0 are missing some of the newer WinSock2 defines'*)
(*$HPPEMIT '#ifdef __BORLANDC__'*)
(*$HPPEMIT '#if (__BORLANDC__ < 0x560) // prior to BCB6'*)
(*$HPPEMIT 'typedef struct in_pktinfo {'*)
(*$HPPEMIT ' IN_ADDR ipi_addr; // destination IPv4 address'*)
(*$HPPEMIT ' UINT ipi_ifindex; // received interface index'*)
(*$HPPEMIT '} IN_PKTINFO;'*)
(*$HPPEMIT ''*)
(*$HPPEMIT 'typedef struct in6_pktinfo {'*)
(*$HPPEMIT ' IN6_ADDR ipi6_addr; // destination IPv6 address'*)
(*$HPPEMIT ' UINT ipi6_ifindex; // received interface index'*)
(*$HPPEMIT '} IN6_PKTINFO;'*)
(*$HPPEMIT ''*)
(*$HPPEMIT 'typedef struct addrinfo {'*)
(*$HPPEMIT ' int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */'*)
(*$HPPEMIT ' int ai_family; /* PF_xxx */'*)
(*$HPPEMIT ' int ai_socktype; /* SOCK_xxx */'*)
(*$HPPEMIT ' int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */'*)
(*$HPPEMIT ' size_t ai_addrlen; /* Length of ai_addr */'*)
(*$HPPEMIT ' char *ai_canonname; /* Canonical name for nodename */'*)
(*$HPPEMIT ' struct sockaddr *ai_addr; /* Binary address */'*)
(*$HPPEMIT ' struct addrinfo *ai_next; /* Next structure in linked list */'*)
(*$HPPEMIT '} ADDRINFO, FAR * LPADDRINFO;'*)
(*$HPPEMIT '#endif'*)
(*$HPPEMIT '#if (__BORLANDC__ < 0x550) // prior to BCB5'*)
(*$HPPEMIT 'typedef struct _INTERFACE_INFO_EX'*)
(*$HPPEMIT '{'*)
(*$HPPEMIT ' u_long iiFlags; /* Interface flags */'*)
(*$HPPEMIT ' SOCKET_ADDRESS iiAddress; /* Interface address */'*)
(*$HPPEMIT ' SOCKET_ADDRESS iiBroadcastAddress; /* Broadcast address */'*)
(*$HPPEMIT ' SOCKET_ADDRESS iiNetmask; /* Network mask */'*)
(*$HPPEMIT '} INTERFACE_INFO_EX, FAR * LPINTERFACE_INFO_EX;'*)
(*$HPPEMIT '#endif'*)
(*$HPPEMIT '#endif'*)
{$NODEFINE PFDSet}
PFDSet = ^TFDSet;
{$NODEFINE TFDSet}
TFDSet = packed record
fd_count: u_int;
fd_array: array[0..FD_SETSIZE-1] of TSocket;
end;
// get # bytes to read
{$EXTERNALSYM FIONREAD}
FIONREAD = IOC_OUT or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('f') shl 8) or 127; {Do not Localize}
// set/clear non-blocking i/o
{$EXTERNALSYM FIONBIO}
FIONBIO = IOC_IN or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('f') shl 8) or 126; {Do not Localize}
// set/clear async i/o
{$EXTERNALSYM FIOASYNC}
FIOASYNC = IOC_IN or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('f') shl 8) or 125; {Do not Localize}
// Socket I/O Controls
// set high watermark
{$EXTERNALSYM SIOCSHIWAT}
SIOCSHIWAT = IOC_IN or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('s') shl 8) or 0; {Do not Localize}
// get high watermark
{$EXTERNALSYM SIOCGHIWAT}
SIOCGHIWAT = IOC_OUT or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('s') shl 8) or 1; {Do not Localize}
// set low watermark
{$EXTERNALSYM SIOCSLOWAT}
SIOCSLOWAT = IOC_IN or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('s') shl 8) or 2; {Do not Localize}
// get low watermark
{$EXTERNALSYM SIOCGLOWAT}
SIOCGLOWAT = IOC_OUT or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('s') shl 8) or 3; {Do not Localize}
// at oob mark?
{$EXTERNALSYM SIOCATMARK}
SIOCATMARK = IOC_OUT or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('s') shl 8) or 7; {Do not Localize}
// Structures returned by network data base library, taken from the
// BSD file netdb.h. All addresses are supplied in host order, and
// returned in network order (suitable for use in system calls).
type
{$EXTERNALSYM hostent}
hostent = packed record
h_name: PChar; // official name of host
h_aliases: ^PChar; // alias list
h_addrtype: Smallint; // host address type
h_length: Smallint; // length of address
case Byte of
0: (h_address_list: ^PChar);
1: (h_addr: PChar); // address, for backward compat
end;
THostEnt = hostent;
PHostEnt = ^THostEnt;
// It is assumed here that a network number
// fits in 32 bits.
{$EXTERNALSYM netent}
netent = packed record
n_name: PChar; // official name of net
n_aliases: ^PChar; // alias list
n_addrtype: Smallint; // net address type
n_net: u_long; // network #
end;
TNetEnt = netent;
PNetEnt = ^TNetEnt;
{$EXTERNALSYM servent}
servent = packed record
s_name: PChar; // official service name
s_aliases: ^PChar; // alias list
{$IFDEF _WIN64}
s_proto: PChar; // protocol to use
s_port: Smallint; // port #
{$ELSE}
s_port: Smallint; // port #
s_proto: PChar; // protocol to use
{$ENDIF}
end;
TServEnt = servent;
PServEnt = ^TServEnt;
{$EXTERNALSYM protoent}
protoent = packed record
p_name: PChar; // official protocol name
p_aliases: ^PChar; // alias list
p_proto: Smallint; // protocol #
end;
TProtoEnt = protoent;
PProtoEnt = ^TProtoEnt;
// Constants and structures defined by the internet system,
// Per RFC 790, September 1981, taken from the BSD file netinet/in.h.
const
// Protocols
{$EXTERNALSYM IPPROTO_IP}
IPPROTO_IP = 0; // dummy for IP
{$EXTERNALSYM IPPROTO_ICMP}
IPPROTO_ICMP = 1; // control message protocol
{$EXTERNALSYM IPPROTO_IGMP}
IPPROTO_IGMP = 2; // group management protocol
{$EXTERNALSYM IPPROTO_GGP}
IPPROTO_GGP = 3; // gateway^2 (deprecated)
{$EXTERNALSYM IPPROTO_TCP}
IPPROTO_TCP = 6; // TCP
{$EXTERNALSYM IPPROTO_PUP}
IPPROTO_PUP = 12; // pup
{$EXTERNALSYM IPPROTO_UDP}
IPPROTO_UDP = 17; // UDP - user datagram protocol
{$EXTERNALSYM IPPROTO_IDP}
IPPROTO_IDP = 22; // xns idp
{$EXTERNALSYM IPPROTO_ND}
IPPROTO_ND = 77; // UNOFFICIAL net disk proto
// This is used instead of -1, since the TSocket type is unsigned.
{$EXTERNALSYM INVALID_SOCKET}
INVALID_SOCKET = TSocket(not(0));
{$EXTERNALSYM SOCKET_ERROR}
SOCKET_ERROR = -1;
// The following may be used in place of the address family, socket type, or
// protocol in a call to WSASocket to indicate that the corresponding value
// should be taken from the supplied WSAPROTOCOL_INFO structure instead of the
// parameter itself.
{$EXTERNALSYM FROM_PROTOCOL_INFO}
FROM_PROTOCOL_INFO = -1;
// winsock 2 extension -- new options
{$EXTERNALSYM SO_GROUP_ID}
SO_GROUP_ID = $2001; // ID of a socket group
{$EXTERNALSYM SO_GROUP_PRIORITY}
SO_GROUP_PRIORITY = $2002; // the relative priority within a group
{$EXTERNALSYM SO_MAX_MSG_SIZE}
SO_MAX_MSG_SIZE = $2003; // maximum message size
{$EXTERNALSYM SO_PROTOCOL_INFOA}
SO_PROTOCOL_INFOA = $2004; // WSAPROTOCOL_INFOA structure
{$EXTERNALSYM SO_PROTOCOL_INFOW}
SO_PROTOCOL_INFOW = $2005; // WSAPROTOCOL_INFOW structure
{$EXTERNALSYM SO_PROTOCOL_INFO}
{$IFDEF UNICODE}
SO_PROTOCOL_INFO = SO_PROTOCOL_INFOW;
{$ELSE}
SO_PROTOCOL_INFO = SO_PROTOCOL_INFOA;
{$ENDIF}
{$EXTERNALSYM PVD_CONFIG}
PVD_CONFIG = $3001; // configuration info for service provider
{$EXTERNALSYM SO_CONDITIONAL_ACCEPT}
SO_CONDITIONAL_ACCEPT = $3002; // enable true conditional accept:
// connection is not ack-ed to the
// other side until conditional
// function returns CF_ACCEPT
// Structure used by kernel to pass protocol information in raw sockets.
{$EXTERNALSYM sockproto}
sockproto = packed record
sp_family : u_short;
sp_protocol : u_short;
end;
TSockProto = sockproto;
PSockProto = ^TSockProto;
{ Error return codes from gethostbyname() and gethostbyaddr()
(when using the resolver). Note that these errors are
retrieved via WSAGetLastError() and must therefore follow
the rules for avoiding clashes with error numbers from
specific implementations or language run-time systems.
For this reason the codes are based at WSABASEERR+1001.
Note also that [WSA]NO_ADDRESS is defined only for
compatibility purposes. }
// Authoritative Answer: Host not found
{$EXTERNALSYM WSAHOST_NOT_FOUND}
WSAHOST_NOT_FOUND = WSABASEERR+1001;
{$EXTERNALSYM HOST_NOT_FOUND}
HOST_NOT_FOUND = WSAHOST_NOT_FOUND;
// Non-Authoritative: Host not found, or SERVERFAIL
{$EXTERNALSYM WSATRY_AGAIN}
WSATRY_AGAIN = WSABASEERR+1002;
{$EXTERNALSYM TRY_AGAIN}
TRY_AGAIN = WSATRY_AGAIN;
// Valid name, no data record of requested type
{$EXTERNALSYM WSANO_DATA}
WSANO_DATA = WSABASEERR+1004;
{$EXTERNALSYM no_data}
NO_DATA = WSANO_DATA;
// no address, look for MX record
{$EXTERNALSYM WSANO_ADDRESS}
WSANO_ADDRESS = WSANO_DATA;
{$EXTERNALSYM no_address}
NO_ADDRESS = WSANO_ADDRESS;
// Define QOS related error return codes
{$EXTERNALSYM WSA_QOS_RECEIVERS}
WSA_QOS_RECEIVERS = WSABASEERR+1005; // at least one reserve has arrived
{$EXTERNALSYM WSA_QOS_SENDERS}
WSA_QOS_SENDERS = WSABASEERR+1006; // at least one path has arrived
{$EXTERNALSYM WSA_QOS_NO_SENDERS}
WSA_QOS_NO_SENDERS = WSABASEERR+1007; // there are no senders
{$EXTERNALSYM WSA_QOS_NO_RECEIVERS}
WSA_QOS_NO_RECEIVERS = WSABASEERR+1008; // there are no receivers
{$EXTERNALSYM WSA_QOS_REQUEST_CONFIRMED}
WSA_QOS_REQUEST_CONFIRMED = WSABASEERR+1009; // reserve has been confirmed
{$EXTERNALSYM WSA_QOS_ADMISSION_FAILURE}
WSA_QOS_ADMISSION_FAILURE = WSABASEERR+1010; // error due to lack of resources
{$EXTERNALSYM WSA_QOS_POLICY_FAILURE}
WSA_QOS_POLICY_FAILURE = WSABASEERR+1011; // rejected for administrative reasons - bad credentials
{$EXTERNALSYM WSA_QOS_BAD_STYLE}
WSA_QOS_BAD_STYLE = WSABASEERR+1012; // unknown or conflicting style
{$EXTERNALSYM WSA_QOS_BAD_OBJECT}
WSA_QOS_BAD_OBJECT = WSABASEERR+1013; // problem with some part of the filterspec or providerspecific buffer in general
{$EXTERNALSYM WSA_QOS_TRAFFIC_CTRL_ERROR}
WSA_QOS_TRAFFIC_CTRL_ERROR = WSABASEERR+1014; // problem with some part of the flowspec
{$EXTERNALSYM WSA_QOS_GENERIC_ERROR}
WSA_QOS_GENERIC_ERROR = WSABASEERR+1015; // general error
{$EXTERNALSYM WSA_QOS_ESERVICETYPE}
WSA_QOS_ESERVICETYPE = WSABASEERR+1016; // invalid service type in flowspec
{$EXTERNALSYM WSA_QOS_EFLOWSPEC}
WSA_QOS_EFLOWSPEC = WSABASEERR+1017; // invalid flowspec
{$EXTERNALSYM WSA_QOS_EPROVSPECBUF}
WSA_QOS_EPROVSPECBUF = WSABASEERR+1018; // invalid provider specific buffer
{$EXTERNALSYM WSA_QOS_EFILTERSTYLE}
WSA_QOS_EFILTERSTYLE = WSABASEERR+1019; // invalid filter style
{$EXTERNALSYM WSA_QOS_EFILTERTYPE}
WSA_QOS_EFILTERTYPE = WSABASEERR+1020; // invalid filter type
{$EXTERNALSYM WSA_QOS_EFILTERCOUNT}
WSA_QOS_EFILTERCOUNT = WSABASEERR+1021; // incorrect number of filters
{$EXTERNALSYM WSA_QOS_EOBJLENGTH}
WSA_QOS_EOBJLENGTH = WSABASEERR+1022; // invalid object length
{$EXTERNALSYM WSA_QOS_EFLOWCOUNT}
WSA_QOS_EFLOWCOUNT = WSABASEERR+1023; // incorrect number of flows
{$EXTERNALSYM WSA_QOS_EUNKOWNPSOBJ}
WSA_QOS_EUNKOWNPSOBJ = WSABASEERR+1024; // unknown object in provider specific buffer
{$EXTERNALSYM WSA_QOS_EPOLICYOBJ}
WSA_QOS_EPOLICYOBJ = WSABASEERR+1025; // invalid policy object in provider specific buffer
{$EXTERNALSYM WSA_QOS_EFLOWDESC}
WSA_QOS_EFLOWDESC = WSABASEERR+1026; // invalid flow descriptor in the list
{$EXTERNALSYM WSA_QOS_EPSFLOWSPEC}
WSA_QOS_EPSFLOWSPEC = WSABASEERR+1027; // inconsistent flow spec in provider specific buffer
{$EXTERNALSYM WSA_QOS_EPSFILTERSPEC}
WSA_QOS_EPSFILTERSPEC = WSABASEERR+1028; // invalid filter spec in provider specific buffer
{$EXTERNALSYM WSA_QOS_ESDMODEOBJ}
WSA_QOS_ESDMODEOBJ = WSABASEERR+1029; // invalid shape discard mode object in provider specific buffer
{$EXTERNALSYM WSA_QOS_ESHAPERATEOBJ}
WSA_QOS_ESHAPERATEOBJ = WSABASEERR+1030; // invalid shaping rate object in provider specific buffer
{$EXTERNALSYM WSA_QOS_RESERVED_PETYPE}
WSA_QOS_RESERVED_PETYPE = WSABASEERR+1031; // reserved policy element in provider specific buffer
{ Windows Sockets errors redefined as regular Berkeley error constants.
These are commented out in Windows NT to avoid conflicts with errno.h.
Use the WSA constants instead. }
{ WinSock 2 extension -- WSABUF and QOS struct, include qos.h }
{ to pull in FLOWSPEC and related definitions }
{$EXTERNALSYM WSABUF}
WSABUF = packed record
len: u_long;{ the length of the buffer }
buf: PChar; { the pointer to the buffer }
end;
TWSABuf = WSABUF;
PWSABuf = ^TWSABuf;
{$EXTERNALSYM LPWSABUF}
LPWSABUF = PWSABUF;
{$EXTERNALSYM FLOWSPEC}
FLOWSPEC = packed record
TokenRate, // In Bytes/sec
TokenBucketSize, // In Bytes
PeakBandwidth, // In Bytes/sec
Latency, // In microseconds
DelayVariation : LongInt;// In microseconds
ServiceType : TServiceType;
MaxSduSize, MinimumPolicedSize : LongInt;// In Bytes
end;
TFlowSpec = FLOWSPEC;
{$EXTERNALSYM PFLOWSPEC}
PFLOWSPEC = ^TFlowSpec;
{$EXTERNALSYM LPFLOWSPEC}
LPFLOWSPEC = PFLOWSPEC;
{$EXTERNALSYM QOS}
QOS = packed record
SendingFlowspec: TFlowSpec; { the flow spec for data sending }
ReceivingFlowspec: TFlowSpec; { the flow spec for data receiving }
ProviderSpecific: TWSABuf; { additional provider specific stuff }
end;
TQualityOfService = QOS;
PQOS = ^QOS;
{$EXTERNALSYM LPQOS}
LPQOS = PQOS;
const
{$EXTERNALSYM SERVICETYPE_NOTRAFFIC}
SERVICETYPE_NOTRAFFIC = $00000000; // No data in this direction
{$EXTERNALSYM SERVICETYPE_BESTEFFORT}
SERVICETYPE_BESTEFFORT = $00000001; // Best Effort
{$EXTERNALSYM SERVICETYPE_CONTROLLEDLOAD}
SERVICETYPE_CONTROLLEDLOAD = $00000002; // Controlled Load
{$EXTERNALSYM SERVICETYPE_GUARANTEED}
SERVICETYPE_GUARANTEED = $00000003; // Guaranteed
{$EXTERNALSYM SERVICETYPE_NETWORK_UNAVAILABLE}
SERVICETYPE_NETWORK_UNAVAILABLE = $00000004; // Used to notify change to user
{$EXTERNALSYM SERVICETYPE_GENERAL_INFORMATION}
SERVICETYPE_GENERAL_INFORMATION = $00000005; // corresponds to "General Parameters" defined by IntServ
{$EXTERNALSYM SERVICETYPE_NOCHANGE}
SERVICETYPE_NOCHANGE = $00000006; // used to indicate that the flow spec contains no change from any previous one
// to turn on immediate traffic control, OR this flag with the ServiceType field in the FLOWSPEC
{$EXTERNALSYM SERVICE_IMMEDIATE_TRAFFIC_CONTROL}
SERVICE_IMMEDIATE_TRAFFIC_CONTROL = $80000000;
// WinSock 2 extension -- manifest constants for return values of the condition function
{$EXTERNALSYM CF_ACCEPT}
CF_ACCEPT = $0000;
{$EXTERNALSYM CF_REJECT}
CF_REJECT = $0001;
{$EXTERNALSYM CF_DEFER}
CF_DEFER = $0002;
// WinSock 2 extension -- data type and manifest constants for socket groups
{$EXTERNALSYM SG_UNCONSTRAINED_GROUP}
SG_UNCONSTRAINED_GROUP = $01;
{$EXTERNALSYM SG_CONSTRAINED_GROUP}
SG_CONSTRAINED_GROUP = $02;
type
{$EXTERNALSYM GROUP}
GROUP = DWORD;
// WinSock 2 extension -- data type for WSAEnumNetworkEvents()
{$EXTERNALSYM wsanetworkevents}
WSANETWORKEVENTS = record
lNetworkEvents: LongInt;
iErrorCode: Array[0..FD_MAX_EVENTS-1] of Integer;
end;
TWSANetworkEvents = WSANETWORKEVENTS;
PWSANetworkEvents = ^TWSANetworkEvents;
{$EXTERNALSYM LPWSANETWORKEVENTS}
LPWSANETWORKEVENTS = PWSANetworkEvents;
//TransmitFile types used for the TransmitFile API function in WinNT/2000/XP
type
{$EXTERNALSYM WSAPROTOCOLCHAIN}
WSAPROTOCOLCHAIN = record
ChainLen: Integer; // the length of the chain,
// length = 0 means layered protocol,
// length = 1 means base protocol,
// length > 1 means protocol chain
ChainEntries: Array[0..MAX_PROTOCOL_CHAIN-1] of LongInt; // a list of dwCatalogEntryIds
end;
TWSAProtocolChain = WSAPROTOCOLCHAIN;
{$EXTERNALSYM LPWSAPROTOCOLCHAIN}
LPWSAPROTOCOLCHAIN = ^TWSAProtocolChain;
{$EXTERNALSYM SIO_ASSOCIATE_HANDLE}
SIO_ASSOCIATE_HANDLE = IOC_IN or IOC_WS2 or 1;
{$EXTERNALSYM SIO_ENABLE_CIRCULAR_QUEUEING}
SIO_ENABLE_CIRCULAR_QUEUEING = IOC_VOID or IOC_WS2 or 2;
{$EXTERNALSYM SIO_FIND_ROUTE}
SIO_FIND_ROUTE = IOC_OUT or IOC_WS2 or 3;
{$EXTERNALSYM SIO_FLUSH}
SIO_FLUSH = IOC_VOID or IOC_WS2 or 4;
{$EXTERNALSYM SIO_GET_BROADCAST_ADDRESS}
SIO_GET_BROADCAST_ADDRESS = IOC_OUT or IOC_WS2 or 5;
{$EXTERNALSYM SIO_GET_EXTENSION_FUNCTION_POINTER}
SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT or IOC_WS2 or 6;
{$EXTERNALSYM SIO_GET_QOS}
SIO_GET_QOS = IOC_INOUT or IOC_WS2 or 7;
{$EXTERNALSYM SIO_GET_GROUP_QOS}
SIO_GET_GROUP_QOS = IOC_INOUT or IOC_WS2 or 8;
{$EXTERNALSYM SIO_MULTIPOINT_LOOPBACK}
SIO_MULTIPOINT_LOOPBACK = IOC_IN or IOC_WS2 or 9;
{$EXTERNALSYM SIO_MULTICAST_SCOPE}
SIO_MULTICAST_SCOPE = IOC_IN or IOC_WS2 or 10;
{$EXTERNALSYM SIO_SET_QOS}
SIO_SET_QOS = IOC_IN or IOC_WS2 or 11;
{$EXTERNALSYM SIO_SET_GROUP_QOS}
SIO_SET_GROUP_QOS = IOC_IN or IOC_WS2 or 12;
{$EXTERNALSYM SIO_TRANSLATE_HANDLE}
SIO_TRANSLATE_HANDLE = IOC_INOUT or IOC_WS2 or 13;
{$EXTERNALSYM SIO_ROUTING_INTERFACE_QUERY}
SIO_ROUTING_INTERFACE_QUERY = IOC_INOUT or IOC_WS2 or 20;
{$EXTERNALSYM SIO_ROUTING_INTERFACE_CHANGE}
SIO_ROUTING_INTERFACE_CHANGE = IOC_IN or IOC_WS2 or 21;
{$EXTERNALSYM SIO_ADDRESS_LIST_QUERY}
SIO_ADDRESS_LIST_QUERY = IOC_OUT or IOC_WS2 or 22; // see below SOCKET_ADDRESS_LIST
{$EXTERNALSYM SIO_ADDRESS_LIST_CHANGE}
SIO_ADDRESS_LIST_CHANGE = IOC_VOID or IOC_WS2 or 23;
{$EXTERNALSYM SIO_QUERY_TARGET_PNP_HANDLE}
SIO_QUERY_TARGET_PNP_HANDLE = IOC_OUT or IOC_WS2 or 24;
{$EXTERNALSYM SIO_ADDRESS_LIST_SORT}
SIO_ADDRESS_LIST_SORT = IOC_INOUT or IOC_WS2 or 25;
type
// Manifest constants and type definitions related to name resolution and
// registration (RNR) API
{$EXTERNALSYM BLOB}
BLOB = packed record
cbSize : ULONG;
pBlobData : PBYTE;
end;
TBLOB = BLOB;
PBLOB = ^TBLOB;
{$EXTERNALSYM LPBLOB}
LPBLOB = PBLOB;
{ Resolution flags for WSAGetAddressByName().
Note these are also used by the 1.1 API GetAddressByName, so leave them around. }
{$EXTERNALSYM RES_UNUSED_1}
RES_UNUSED_1 = $00000001;
{$EXTERNALSYM RES_FLUSH_CACHE}
RES_FLUSH_CACHE = $00000002;
{$EXTERNALSYM RES_SERVICE}
RES_SERVICE = $00000004;
{ Well known value names for Service Types }
{$EXTERNALSYM SERVICE_TYPE_VALUE_IPXPORTA}
SERVICE_TYPE_VALUE_IPXPORTA = 'IpxSocket'; {Do not Localize}
{$EXTERNALSYM SERVICE_TYPE_VALUE_IPXPORTW}
SERVICE_TYPE_VALUE_IPXPORTW : PWideChar = 'IpxSocket'; {Do not Localize}
{$EXTERNALSYM SERVICE_TYPE_VALUE_SAPIDA}
SERVICE_TYPE_VALUE_SAPIDA = 'SapId'; {Do not Localize}
{$EXTERNALSYM SERVICE_TYPE_VALUE_SAPIDW}
SERVICE_TYPE_VALUE_SAPIDW : PWideChar = 'SapId'; {Do not Localize}
{$EXTERNALSYM SERVICE_TYPE_VALUE_TCPPORTA}
SERVICE_TYPE_VALUE_TCPPORTA = 'TcpPort'; {Do not Localize}
{$EXTERNALSYM SERVICE_TYPE_VALUE_TCPPORTW}
SERVICE_TYPE_VALUE_TCPPORTW : PWideChar = 'TcpPort'; {Do not Localize}
{$EXTERNALSYM SERVICE_TYPE_VALUE_UDPPORTA}
SERVICE_TYPE_VALUE_UDPPORTA = 'UdpPort'; {Do not Localize}
{$EXTERNALSYM SERVICE_TYPE_VALUE_UDPPORTW}
SERVICE_TYPE_VALUE_UDPPORTW : PWideChar = 'UdpPort'; {Do not Localize}
{$EXTERNALSYM SERVICE_TYPE_VALUE_OBJECTIDA}
SERVICE_TYPE_VALUE_OBJECTIDA = 'ObjectId'; {Do not Localize}
{$EXTERNALSYM SERVICE_TYPE_VALUE_OBJECTIDW}
SERVICE_TYPE_VALUE_OBJECTIDW : PWideChar = 'ObjectId'; {Do not Localize}
{
WS2TCPIP.H - WinSock2 Extension for TCP/IP protocols
This file contains TCP/IP specific information for use
by WinSock2 compatible applications.
Copyright (c) 1995-1999 Microsoft Corporation
To provide the backward compatibility, all the TCP/IP
specific definitions that were included in the WINSOCK.H
file are now included in WINSOCK2.H file. WS2TCPIP.H
file includes only the definitions introduced in the
"WinSock 2 Protocol-Specific Annex" document.
Rev 0.3 Nov 13, 1995
Rev 0.4 Dec 15, 1996
}
type
// Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP
{$EXTERNALSYM ip_mreq}
ip_mreq = packed record
imr_multiaddr : TInAddr; // IP multicast address of group
imr_interface : TInAddr; // local IP address of interface
end;
// Argument structure for IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP,
// IP_BLOCK_SOURCE, and IP_UNBLOCK_SOURCE
{$EXTERNALSYM ip_mreq_source}
ip_mreq_source = packed record
imr_multiaddr: TInAddr; // IP multicast address of group
imr_sourceaddr: TInAddr; // IP address of source
imr_interface: TInAddr; // local IP address of interface
end;
// Argument structure for SIO_{GET,SET}_MULTICAST_FILTER
{$EXTERNALSYM ip_msfilter}
ip_msfilter = packed record
imsf_multiaddr: TInAddr; // IP multicast address of group
imsf_interface: TInAddr; // local IP address of interface
imsf_fmode: u_long; // filter mode - INCLUDE or EXCLUDE
imsf_numsrc: u_long; // number of sources in src_list
imsf_slist: Array[0..0] of TInAddr;
end;
{$EXTERNALSYM IP_MSFILTER_SIZE}
function IP_MSFILTER_SIZE(numsrc: DWORD): DWORD;
{$EXTERNALSYM SIO_GET_INTERFACE_LIST}
SIO_GET_INTERFACE_LIST = IOC_OUT or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('t') shl 8) or 127; {Do not Localize}
// New IOCTL with address size independent address array
{$EXTERNALSYM SIO_GET_INTERFACE_LIST_EX}
SIO_GET_INTERFACE_LIST_EX = IOC_OUT or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('t') shl 8) or 126; {Do not Localize}
{$EXTERNALSYM SIO_SET_MULTICAST_FILTER}
SIO_SET_MULTICAST_FILTER = IOC_IN or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('t') shl 8) or 125; {Do not Localize}
{$EXTERNALSYM SIO_GET_MULTICAST_FILTER}
SIO_GET_MULTICAST_FILTER = IOC_IN or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('t') shl 8) or (124 or IOC_IN); {Do not Localize}
// Options for use with [gs]etsockopt at the IP level.
{$EXTERNALSYM IP_OPTIONS}
IP_OPTIONS = 1; // set/get IP options
{$EXTERNALSYM IP_HDRINCL}
IP_HDRINCL = 2; // header is included with data
{$EXTERNALSYM IP_TOS}
IP_TOS = 3; // IP type of service and preced
{$EXTERNALSYM IP_TTL}
IP_TTL = 4; // IP time to live
{$EXTERNALSYM IP_MULTICAST_IF}
IP_MULTICAST_IF = 9; // set/get IP multicast i/f
{$EXTERNALSYM IP_MULTICAST_TTL}
IP_MULTICAST_TTL = 10; // set/get IP multicast ttl
{$EXTERNALSYM IP_MULTICAST_LOOP}
IP_MULTICAST_LOOP = 11; // set/get IP multicast loopback
{$EXTERNALSYM IP_ADD_MEMBERSHIP}
IP_ADD_MEMBERSHIP = 12; // add an IP group membership
{$EXTERNALSYM IP_DROP_MEMBERSHIP}
IP_DROP_MEMBERSHIP = 13; // drop an IP group membership
{$EXTERNALSYM IP_DONTFRAGMENT}
IP_DONTFRAGMENT = 14; // don't fragment IP datagrams {Do not Localize}
{$EXTERNALSYM IP_ADD_SOURCE_MEMBERSHIP}
IP_ADD_SOURCE_MEMBERSHIP = 15; // join IP group/source
{$EXTERNALSYM IP_DROP_SOURCE_MEMBERSHIP}
IP_DROP_SOURCE_MEMBERSHIP = 16; // leave IP group/source
{$EXTERNALSYM IP_BLOCK_SOURCE}
IP_BLOCK_SOURCE = 17; // block IP group/source
{$EXTERNALSYM IP_UNBLOCK_SOURCE}
IP_UNBLOCK_SOURCE = 18; // unblock IP group/source
{$EXTERNALSYM IP_PKTINFO}
IP_PKTINFO = 19; // receive packet information for ipv4
{$EXTERNALSYM IP_DEFAULT_MULTICAST_TTL}
IP_DEFAULT_MULTICAST_TTL = 1; // normally limit m'casts to 1 hop {Do not Localize}
{$EXTERNALSYM IP_DEFAULT_MULTICAST_LOOP}
IP_DEFAULT_MULTICAST_LOOP = 1; // normally hear sends if a member
{$EXTERNALSYM IP_MAX_MEMBERSHIPS}
IP_MAX_MEMBERSHIPS = 20; // per socket; must fit in one mbuf
// Option to use with [gs]etsockopt at the IPPROTO_IPV6 level
{$EXTERNALSYM IPV6_HDRINCL}
IPV6_HDRINCL = 2; // Header is included with data
{$EXTERNALSYM IPV6_UNICAST_HOPS}
IPV6_UNICAST_HOPS = 4; // Set/get IP unicast hop limit
{$EXTERNALSYM IPV6_MULTICAST_IF}
IPV6_MULTICAST_IF = 9; // Set/get IP multicast interface
{$EXTERNALSYM IPV6_MULTICAST_HOPS}
IPV6_MULTICAST_HOPS = 10; // Set/get IP multicast ttl
{$EXTERNALSYM IPV6_MULTICAST_LOOP}
IPV6_MULTICAST_LOOP = 11; // Set/get IP multicast loopback
{$EXTERNALSYM IPV6_ADD_MEMBERSHIP}
IPV6_ADD_MEMBERSHIP = 12; // Add an IP group membership
{$EXTERNALSYM IPV6_DROP_MEMBERSHIP}
IPV6_DROP_MEMBERSHIP = 13; // Drop an IP group membership
{$EXTERNALSYM IPV6_JOIN_GROUP}
IPV6_JOIN_GROUP = IPV6_ADD_MEMBERSHIP;
{$EXTERNALSYM IPV6_LEAVE_GROUP}
IPV6_LEAVE_GROUP = IPV6_DROP_MEMBERSHIP;
{$EXTERNALSYM IPV6_PKTINFO}
IPV6_PKTINFO = 19; // Receive packet information for ipv6
// Option to use with [gs]etsockopt at the IPPROTO_UDP level
{$EXTERNALSYM UDP_NOCHECKSUM}
UDP_NOCHECKSUM = 1;
{$EXTERNALSYM UDP_CHECKSUM_COVERAGE}
UDP_CHECKSUM_COVERAGE = 20; // Set/get UDP-Lite checksum coverage
// Option to use with [gs]etsockopt at the IPPROTO_TCP level
{$EXTERNALSYM TCP_EXPEDITED_1122}
TCP_EXPEDITED_1122 = $0002;
// IPv6 definitions
type
{$EXTERNALSYM IN6_ADDR}
IN6_ADDR = packed record
case Integer of
0: (s6_addr: array[0..15] of u_char);
1: (word: array[0..7] of u_short);
end;
TIn6Addr = IN6_ADDR;
PIn6Addr = ^TIn6Addr;
{$EXTERNALSYM PIN6_ADDR}
PIN6_ADDR = ^PIn6Addr;
{$EXTERNALSYM LPIN6_ADDR}
LPIN6_ADDR = PIN6_ADDR;
// Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP
{$EXTERNALSYM ipv6_mreq}
ipv6_mreq = packed record
ipv6mr_multiaddr: TIn6Addr; // IPv6 multicast address
ipv6mr_interface: u_int; // Interface index
end;
// Old IPv6 socket address structure (retained for sockaddr_gen definition below)
{$EXTERNALSYM sockaddr_in6_old}
sockaddr_in6_old = packed record
sin6_family : Smallint; // AF_INET6
sin6_port : u_short; // Transport level port number
sin6_flowinfo : u_long; // IPv6 flow information
sin6_addr : TIn6Addr; // IPv6 address
end;
// IPv6 socket address structure, RFC 2553
{$EXTERNALSYM SOCKADDR_IN6}
SOCKADDR_IN6 = packed record
sin6_family : Smallint; // AF_INET6
sin6_port : u_short; // Transport level port number
sin6_flowinfo : u_long; // IPv6 flow information
sin6_addr : TIn6Addr; // IPv6 address
sin6_scope_id : u_long; // set of interfaces for a scope
end;
// DCR_FIX: EAI_NODATA remove or fix
//
// EAI_NODATA was removed from rfc2553bis
// need to find out from the authors why and
// determine the error for "no records of this type"
// temporarily, we'll keep #define to avoid changing
// code that could change back; use NONAME
{$EXTERNALSYM EAI_NODATA}
EAI_NODATA = EAI_NONAME;
// Structure used in getaddrinfo() call
type
PAddrInfo = ^TAddrInfo;
{$EXTERNALSYM ADDRINFO}
ADDRINFO = packed record
ai_flags : Integer; // AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST
ai_family : Integer; // PF_xxx
ai_socktype : Integer; // SOCK_xxx
ai_protocol : Integer; // 0 or IPPROTO_xxx for IPv4 and IPv6
ai_addrlen : ULONG; // Length of ai_addr
ai_canonname : PChar; // Canonical name for nodename
ai_addr : PSockAddr; // Binary address
ai_next : PAddrInfo; // Next structure in linked list
end;
TAddrInfo = ADDRINFO;
{$EXTERNALSYM LPADDRINFO}
LPADDRINFO = PAddrInfo;
// Flags used in "hints" argument to getaddrinfo()
const
{$EXTERNALSYM AI_PASSIVE}
AI_PASSIVE = $1; // Socket address will be used in bind() call
{$EXTERNALSYM AI_CANONNAME}
AI_CANONNAME = $2; // Return canonical name in first ai_canonname
{$EXTERNALSYM AI_NUMERICHOST}
AI_NUMERICHOST = $4; // Nodename must be a numeric address string
var
{$EXTERNALSYM in6addr_any}
in6addr_any: TIn6Addr;
{$EXTERNALSYM in6addr_loopback}
in6addr_loopback: TIn6Addr;
Microsoft Windows
Copyright (C) Microsoft Corporation, 1992-1999.
Windows Sockets include file for IPX/SPX. This file contains all
standardized IPX/SPX information. Include this header file after
winsock.h.
To open an IPX socket, call socket() with an address family of
AF_IPX, a socket type of SOCK_DGRAM, and protocol NSPROTO_IPX.
Note that the protocol value must be specified, it cannot be 0.
All IPX packets are sent with the packet type field of the IPX
header set to 0.
To open an SPX or SPXII socket, call socket() with an address
family of AF_IPX, socket type of SOCK_SEQPACKET or SOCK_STREAM,
and protocol of NSPROTO_SPX or NSPROTO_SPXII. If SOCK_SEQPACKET
is specified, then the end of message bit is respected, and
recv() calls are not completed until a packet is received with
the end of message bit set. If SOCK_STREAM is specified, then
the end of message bit is not respected, and recv() completes
as soon as any data is received, regardless of the setting of the
end of message bit. Send coalescing is never performed, and sends
smaller than a single packet are always sent with the end of
message bit set. Sends larger than a single packet are packetized
with the end of message bit set on only the last packet of the
send.
}
// This is the structure of the SOCKADDR structure for IPX and SPX.
type
{$EXTERNALSYM SOCKADDR_IPX}
SOCKADDR_IPX = packed record
sa_family : u_short;
sa_netnum : Array [0..3] of Char;
sa_nodenum : Array [0..5] of Char;
sa_socket : u_short;
end;
TSockAddr_IPX = SOCKADDR_IPX;
TSockAddrIPX = SOCKADDR_IPX;
PSockAddrIPX = ^TSockAddrIPX;
{$EXTERNALSYM PSOCKADDR_IPX}
PSOCKADDR_IPX = PSockAddrIPX;
{$EXTERNALSYM LPSOCKADDR_IPX}
LPSOCKADDR_IPX = PSOCKADDR_IPX;
// Protocol families used in the "protocol" parameter of the socket() API.
const
{$EXTERNALSYM NSPROTO_IPX}
NSPROTO_IPX = 1000;
{$EXTERNALSYM NSPROTO_SPX}
NSPROTO_SPX = 1256;
{$EXTERNALSYM NSPROTO_SPXII}
NSPROTO_SPXII = 1257;
Microsoft Windows
Copyright (C) Microsoft Corporation, 1992-1999.
Microsoft-specific extensions to the Windows NT IPX/SPX Windows
Sockets interface. These extensions are provided for use as
necessary for compatibility with existing applications. They are
otherwise not recommended for use, as they are only guaranteed to
work over the Microsoft IPX/SPX stack. An application which
uses these extensions may not work over other IPX/SPX
implementations. Include this header file after winsock.h and
wsipx.h.
To open an IPX socket where a particular packet type is sent in
the IPX header, specify NSPROTO_IPX + n as the protocol parameter
of the socket() API. For example, to open an IPX socket that
sets the packet type to 34, use the following socket() call:
s = socket(AF_IPX, SOCK_DGRAM, NSPROTO_IPX + 34);
}
// Below are socket option that may be set or retrieved by specifying
// the appropriate manifest in the "optname" parameter of getsockopt()
// or setsockopt(). Use NSPROTO_IPX as the "level" argument for the
// call.
const
// Set/get the IPX packet type. The value specified in the
// optval argument will be set as the packet type on every IPX
// packet sent from this socket. The optval parameter of
// getsockopt()/setsockopt() points to an int.
{$EXTERNALSYM IPX_PTYPE}
IPX_PTYPE = $4000;
// Set/get the receive filter packet type. Only IPX packets with
// a packet type equal to the value specified in the optval
// argument will be returned; packets with a packet type that
// does not match are discarded. optval points to an int.
{$EXTERNALSYM IPX_FILTERPTYPE}
IPX_FILTERPTYPE = $4001;
// Stop filtering on packet type set with IPX_FILTERPTYPE.
{$EXTERNALSYM IPX_STOPFILTERPTYPE}
IPX_STOPFILTERPTYPE = $4003;
// Set/get the value of the datastream field in the SPX header on
// every packet sent. optval points to an int.
{$EXTERNALSYM IPX_DSTYPE}
IPX_DSTYPE = $4002;
// Enable extended addressing. On sends, adds the element
// "unsigned char sa_ptype" to the SOCKADDR_IPX structure,
// making the total length 15 bytes. On receives, add both
// the sa_ptype and "unsigned char sa_flags" to the SOCKADDR_IPX
// structure, making the total length 16 bytes. The current
// bits defined in sa_flags are:
// 0x01 - the received frame was sent as a broadcast
// 0x02 - the received frame was sent from this machine
// optval points to a BOOL.
{$EXTERNALSYM IPX_EXTENDED_ADDRESS}
IPX_EXTENDED_ADDRESS = $4004;
// Send protocol header up on all receive packets. optval points
// to a BOOL.
{$EXTERNALSYM IPX_RECVHDR}
IPX_RECVHDR = $4005;
// Get the maximum data size that can be sent. Not valid with
// setsockopt(). optval points to an int where the value is
// returned.
{$EXTERNALSYM IPX_MAXSIZE}
IPX_MAXSIZE = $4006;
// Query information about a specific adapter that IPX is bound
// to. In a system with n adapters they are numbered 0 through n-1.
// Callers can issue the IPX_MAX_ADAPTER_NUM getsockopt() to find
// out the number of adapters present, or call IPX_ADDRESS with
// increasing values of adapternum until it fails. Not valid
// with setsockopt(). optval points to an instance of the
// IPX_ADDRESS_DATA structure with the adapternum filled in.
{$EXTERNALSYM IPX_ADDRESS}
IPX_ADDRESS = $4007;
type
{$EXTERNALSYM IPX_ADDRESS_DATA}
IPX_ADDRESS_DATA = packed record
adapternum : Integer; // input: 0-based adapter number
netnum : Array [0..3] of Byte; // output: IPX network number
nodenum : Array [0..5] of Byte; // output: IPX node address
wan : Boolean; // output: TRUE = adapter is on a wan link
status : Boolean; // output: TRUE = wan link is up (or adapter is not wan)
maxpkt : Integer; // output: max packet size, not including IPX header
linkspeed : ULONG; // output: link speed in 100 bytes/sec (i.e. 96 == 9600 bps)
end;
TIPXAddressData = IPX_ADDRESS_DATA;
PIPXAddressData = ^TIPXAddressData;
{$EXTERNALSYM PIPX_ADDRESS_DATA}
PIPX_ADDRESS_DATA = PIPXAddressData;
const
// Query information about a specific IPX network number. If the
// network is in IPX's cache it will return the information directly, {Do not Localize}
// otherwise it will issue RIP requests to find it. Not valid with
// setsockopt(). optval points to an instance of the IPX_NETNUM_DATA
// structure with the netnum filled in.
{$EXTERNALSYM IPX_GETNETINFO}
IPX_GETNETINFO = $4008;
type
{$EXTERNALSYM IPX_NETNUM_DATA}
IPX_NETNUM_DATA = packed record
netnum : Array [0..3] of Byte; // input: IPX network number
hopcount : Word; // output: hop count to this network, in machine order
netdelay : Word; // output: tick count to this network, in machine order
cardnum : Integer; // output: 0-based adapter number used to route to this net;
// can be used as adapternum input to IPX_ADDRESS
router : Array [0..5] of Byte; // output: MAC address of the next hop router, zeroed if
// the network is directly attached
end;
TIPXNetNumData = IPX_NETNUM_DATA;
PIPXNetNumData = ^TIPXNetNumData;
{$EXTERNALSYM PIPX_NETNUM_DATA}
PIPX_NETNUM_DATA = PIPXNetNumData;
const
// Like IPX_GETNETINFO except it does not issue RIP requests. If the
// network is in IPX's cache it will return the information, otherwise {Do not Localize}
// it will fail (see also IPX_RERIPNETNUMBER which always forces a
// re-RIP). Not valid with setsockopt(). optval points to an instance of
// the IPX_NETNUM_DATA structure with the netnum filled in.
{$EXTERNALSYM IPX_GETNETINFO_NORIP}
IPX_GETNETINFO_NORIP = $4009;
// Get information on a connected SPX socket. optval points
// to an instance of the IPX_SPXCONNSTATUS_DATA structure.
// *** All numbers are in Novell (high-low) order. ***
{$EXTERNALSYM IPX_SPXGETCONNECTIONSTATUS}
IPX_SPXGETCONNECTIONSTATUS = $400B;
const
// Get notification when the status of an adapter that IPX is
// bound to changes. Typically this will happen when a wan line
// goes up or down. Not valid with setsockopt(). optval points
// to a buffer which contains an IPX_ADDRESS_DATA structure
// followed immediately by a HANDLE to an unsignaled event.
//
// When the getsockopt() query is submitted, it will complete
// successfully. However, the IPX_ADDRESS_DATA pointed to by
// optval will not be updated at that point. Instead the
// request is queued internally inside the transport.
//
// When the status of an adapter changes, IPX will locate a
// queued getsockopt() query and fill in all the fields in the
// IPX_ADDRESS_DATA structure. It will then signal the event
// pointed to by the HANDLE in the optval buffer. This handle
// should be obtained before calling getsockopt() by calling
// CreateEvent(). If multiple getsockopts() are submitted at
// once, different events must be used.
//
// The event is used because the call needs to be asynchronous
// but currently getsockopt() does not support this.
//
// WARNING: In the current implementation, the transport will
// only signal one queued query for each status change. Therefore
// only one service which uses this query should be running at
// once.
{$EXTERNALSYM IPX_ADDRESS_NOTIFY}
IPX_ADDRESS_NOTIFY = $400C;
// Get the maximum number of adapters present. If this call returns
// n then the adapters are numbered 0 through n-1. Not valid
// with setsockopt(). optval points to an int where the value
// is returned.
{$EXTERNALSYM IPX_MAX_ADAPTER_NUM}
IPX_MAX_ADAPTER_NUM = $400D;
// Like IPX_GETNETINFO except it forces IPX to re-RIP even if the
// network is in its cache (but not if it is directly attached to).
// Not valid with setsockopt(). optval points to an instance of
// the IPX_NETNUM_DATA structure with the netnum filled in.
{$EXTERNALSYM IPX_RERIPNETNUMBER}
IPX_RERIPNETNUMBER = $400E;
// A hint that broadcast packets may be received. The default is
// TRUE. Applications that do not need to receive broadcast packets
// should set this sockopt to FALSE which may cause better system
// performance (note that it does not necessarily cause broadcasts
// to be filtered for the application). Not valid with getsockopt().
// optval points to a BOOL.
{$EXTERNALSYM IPX_RECEIVE_BROADCAST}
IPX_RECEIVE_BROADCAST = $400F;
// On SPX connections, don't delay before sending ack. Applications {Do not Localize}
// that do not tend to have back-and-forth traffic over SPX should
// set this; it will increase the number of acks sent but will remove
// delays in sending acks. optval points to a BOOL.
{$EXTERNALSYM IPX_IMMEDIATESPXACK}
IPX_IMMEDIATESPXACK = $4010;
// wsnetbs.h
// Copyright (c) 1994-1999, Microsoft Corp. All rights reserved.
//
// Windows Sockets include file for NETBIOS. This file contains all
// standardized NETBIOS information. Include this header file after
// winsock.h.
// To open a NetBIOS socket, call the socket() function as follows:
//
// s = socket( AF_NETBIOS, {SOCK_SEQPACKET|SOCK_DGRAM}, -Lana );
//
// where Lana is the NetBIOS Lana number of interest. For example, to
// open a socket for Lana 2, specify -2 as the "protocol" parameter
// to the socket() function.
// This is the structure of the SOCKADDR structure for NETBIOS.
type
{$EXTERNALSYM ATM_ADDRESS}
ATM_ADDRESS = packed record
AddressType : DWORD; // E.164 or NSAP-style ATM Endsystem Address
NumofDigits : DWORD; // number of digits;
Addr : Array[0..ATM_ADDR_SIZE-1] of Byte; // IA5 digits for E164, BCD encoding for NSAP
// format as defined in the ATM Forum UNI 3.1
end;
// values used for Layer2Protocol in B-LLI
const
{$EXTERNALSYM BLLI_L2_ISO_1745}
BLLI_L2_ISO_1745 = $01; // Basic mode ISO 1745
{$EXTERNALSYM BLLI_L2_Q921}
BLLI_L2_Q921 = $02; // CCITT Rec. Q.921
{$EXTERNALSYM BLLI_L2_X25L}
BLLI_L2_X25L = $06; // CCITT Rec. X.25, link layer
{$EXTERNALSYM BLLI_L2_X25M}
BLLI_L2_X25M = $07; // CCITT Rec. X.25, multilink
{$EXTERNALSYM BLLI_L2_ELAPB}
BLLI_L2_ELAPB = $08; // Extended LAPB; for half duplex operation
{$EXTERNALSYM BLLI_L2_HDLC_NRM}
BLLI_L2_HDLC_NRM = $09; // HDLC NRM (ISO 4335)
{$EXTERNALSYM BLLI_L2_HDLC_ABM}
BLLI_L2_HDLC_ABM = $0A; // HDLC ABM (ISO 4335)
{$EXTERNALSYM BLLI_L2_HDLC_ARM}
BLLI_L2_HDLC_ARM = $0B; // HDLC ARM (ISO 4335)
{$EXTERNALSYM BLLI_L2_LLC}
BLLI_L2_LLC = $0C; // LAN logical link control (ISO 8802/2)
{$EXTERNALSYM BLLI_L2_X75}
BLLI_L2_X75 = $0D; // CCITT Rec. X.75, single link procedure
{$EXTERNALSYM BLLI_L2_Q922}
BLLI_L2_Q922 = $0E; // CCITT Rec. Q.922
{$EXTERNALSYM BLLI_L2_USER_SPECIFIED}
BLLI_L2_USER_SPECIFIED = $10; // User Specified
{$EXTERNALSYM BLLI_L2_ISO_7776}
BLLI_L2_ISO_7776 = $11; // ISO 7776 DTE-DTE operation
// values used for Layer3IPI in B-LLI
{$EXTERNALSYM BLLI_L3_IPI_SNAP}
BLLI_L3_IPI_SNAP = $80; // IEEE 802.1 SNAP identifier
{$EXTERNALSYM BLLI_L3_IPI_IP}
BLLI_L3_IPI_IP = $CC; // Internet Protocol (IP) identifier
type
{$EXTERNALSYM ATM_BLLI}
ATM_BLLI = packed record
// Identifies the layer-two protocol.
// Corresponds to the User information layer 2 protocol field in the B-LLI information element.
// A value of SAP_FIELD_ABSENT indicates that this field is not used, and a value of SAP_FIELD_ANY means wildcard.
Layer2Protocol : DWORD; // User information layer 2 protocol
// Identifies the user-specified layer-two protocol.
// Only used if the Layer2Protocol parameter is set to BLLI_L2_USER_SPECIFIED.
// The valid values range from zero?27.
// Corresponds to the User specified layer 2 protocol information field in the B-LLI information element.
Layer2UserSpecifiedProtocol : DWORD; // User specified layer 2 protocol information
// Identifies the layer-three protocol.
// Corresponds to the User information layer 3 protocol field in the B-LLI information element.
// A value of SAP_FIELD_ABSENT indicates that this field is not used, and a value of SAP_FIELD_ANY means wildcard.
Layer3Protocol : DWORD; // User information layer 3 protocol
// Identifies the user-specified layer-three protocol.
// Only used if the Layer3Protocol parameter is set to BLLI_L3_USER_SPECIFIED.
// The valid values range from zero?27.
// Corresponds to the User specified layer 3 protocol information field in the B-LLI information element.
Layer3UserSpecifiedProtocol : DWORD; // User specified layer 3 protocol information
// Identifies the layer-three Initial Protocol Identifier.
// Only used if the Layer3Protocol parameter is set to BLLI_L3_ISO_TR9577.
// Corresponds to the ISO/IEC TR 9577 Initial Protocol Identifier field in the B-LLI information element.
Layer3IPI : DWORD; // ISO/IEC TR 9577 Initial Protocol Identifier
// Identifies the 802.1 SNAP identifier.
// Only used if the Layer3Protocol parameter is set to BLLI_L3_ISO_TR9577 and Layer3IPI is set to BLLI_L3_IPI_SNAP,
// indicating an IEEE 802.1 SNAP identifier. Corresponds to the OUI and PID fields in the B-LLI information element.
SnapID : Array[0..4] of Byte; // SNAP ID consisting of OUI and PID
end;
// values used for the HighLayerInfoType field in ATM_BHLI
const
{$EXTERNALSYM BHLI_ISO}
BHLI_ISO = $00; // ISO
{$EXTERNALSYM BHLI_UserSpecific}
BHLI_UserSpecific = $01; // User Specific
{$EXTERNALSYM BHLI_HighLayerProfile}
BHLI_HighLayerProfile = $02; // High layer profile (only in UNI3.0)
{$EXTERNALSYM BHLI_VendorSpecificAppId}
BHLI_VendorSpecificAppId = $03; // Vendor-Specific Application ID
type
{$EXTERNALSYM ATM_BHLI}
ATM_BHLI = packed record
// Identifies the high layer information type field in the B-LLI information element.
// Note that the type BHLI_HighLayerProfile has been eliminated in UNI 3.1.
// A value of SAP_FIELD_ABSENT indicates that B-HLI is not present, and a value of SAP_FIELD_ANY means wildcard.
HighLayerInfoType : DWORD; // High Layer Information Type
// Identifies the number of bytes from one to eight in the HighLayerInfo array.
// Valid values include eight for the cases of BHLI_ISO and BHLI_UserSpecific,
// four for BHLI_HighLayerProfile, and seven for BHLI_VendorSpecificAppId.
HighLayerInfoLength : DWORD; // number of bytes in HighLayerInfo
// Identifies the high layer information field in the B-LLI information element.
// In the case of HighLayerInfoType being BHLI_VendorSpecificAppId,
// the first 3 bytes consist of a globally-administered Organizationally Unique Identifier (OUI)
// (as per IEEE standard 802-1990), followed by a 4-byte application identifier,
// which is administered by the vendor identified by the OUI.
// Value for the case of BHLI_UserSpecific is user defined and requires bilateral agreement between two end users.
HighLayerInfo : Array[0..7] of Byte; // the value dependent on the HighLayerInfoType field
end;
// A new address family, AF_ATM, is introduced for native ATM services,
// and the corresponding SOCKADDR structure, sockaddr_atm, is defined in the following.
// To open a socket for native ATM services, parameters in socket should contain
// AF_ATM, SOCK_RAW, and ATMPROTO_AAL5 or ATMPROTO_AALUSER, respectively.
{$EXTERNALSYM SOCKADDR_ATM}
SOCKADDR_ATM = packed record
// Identifies the address family, which is AF_ATM in this case.
satm_family : u_short;
// Identifies the ATM address that could be either in E.164 or NSAP-style ATM End Systems Address format.
// This field will be mapped to the Called Party Number IE (Information Element)
// if it is specified in bind and WSPBind for a listening socket, or in connect, WSAConnect, WSPConnect,
// WSAJoinLeaf, or WSPJoinLeaf for a connecting socket.
// It will be mapped to the Calling Party Number IE if specified in bind and WSPBind for a connecting socket.
satm_number : ATM_ADDRESS;
// Identifies the fields in the B-LLI Information Element that are used along with satm_bhli to identify an application.
// Note that the B-LLI layer two information is treated as not present
// if its Layer2Protocol field contains SAP_FIELD_ABSENT, or as a wildcard if it contains SAP_FIELD_ANY.
// Similarly, the B-LLI layer three information is treated as not present
// if its Layer3Protocol field contains SAP_FIELD_ABSENT, or as a wildcard if it contains SAP_FIELD_ANY.
satm_blli : ATM_BLLI; // B-LLI
// Identifies the fields in the B-HLI Information Element that are used along with satm_blli to identify an application.
satm_bhli : ATM_BHLI; // B-HLI
end;
TSockAddrATM = SOCKADDR_ATM;
PSockAddrATM = ^TSockAddrATM;
LPSockAddrATM = PSockAddrATM;
{$EXTERNALSYM PSOCKADDR_ATM}
PSOCKADDR_ATM = ^SOCKADDR_ATM;
{$EXTERNALSYM LPSOCKADDR_ATM}
LPSOCKADDR_ATM = ^SOCKADDR_ATM;
// values used for the Mode field in struct AAL5_PARAMETERS
{$EXTERNALSYM AAL5_MODE_MESSAGE}
AAL5_MODE_MESSAGE = $01;
{$EXTERNALSYM AAL5_MODE_STREAMING}
AAL5_MODE_STREAMING = $02;
// values used for the SSCSType field in struct AAL5_PARAMETERS
{$EXTERNALSYM AAL5_SSCS_NULL}
AAL5_SSCS_NULL = $00;
{$EXTERNALSYM AAL5_SSCS_SSCOP_ASSURED}
AAL5_SSCS_SSCOP_ASSURED = $01;
{$EXTERNALSYM AAL5_SSCS_SSCOP_NON_ASSURED}
AAL5_SSCS_SSCOP_NON_ASSURED = $02;
{$EXTERNALSYM AAL5_SSCS_FRAME_RELAY}
AAL5_SSCS_FRAME_RELAY = $04;
type
{$EXTERNALSYM AAL5_PARAMETERS}
AAL5_PARAMETERS = packed record
ForwardMaxCPCSSDUSize : ULONG;
BackwardMaxCPCSSDUSize : ULONG;
Mode : Byte; // only available in UNI 3.0
SSCSType : Byte;
end;
{$EXTERNALSYM AALUSER_PARAMETERS}
AALUSER_PARAMETERS = packed record
UserDefined : ULONG;
end;
{$EXTERNALSYM AAL_PARAMETERS_IE}
AAL_PARAMETERS_IE = packed record
AALType : AAL_TYPE;
case Byte of
0: ( AAL5Parameters : AAL5_PARAMETERS );
1: ( AALUserParameters : AALUSER_PARAMETERS );
end;
// values used for the BearerClass field in struct ATM_BROADBAND_BEARER_CAPABILITY_IE
const
{$EXTERNALSYM BCOB_A}
BCOB_A = $01; // Bearer class A
{$EXTERNALSYM BCOB_C}
BCOB_C = $03; // Bearer class C
{$EXTERNALSYM BCOB_X}
BCOB_X = $10; // Bearer class X
// values used for the TrafficType field in struct ATM_BROADBAND_BEARER_CAPABILITY_IE
{$EXTERNALSYM TT_NOIND}
TT_NOIND = $00; // No indication of traffic type
{$EXTERNALSYM TT_CBR}
TT_CBR = $04; // Constant bit rate
{$EXTERNALSYM TT_VBR}
TT_VBR = $06; // Variable bit rate
// values used for the TimingRequirements field in struct ATM_BROADBAND_BEARER_CAPABILITY_IE
{$EXTERNALSYM TR_NOIND}
TR_NOIND = $00; // No timing requirement indication
{$EXTERNALSYM TR_END_TO_END}
TR_END_TO_END = $01; // End-to-end timing required
{$EXTERNALSYM TR_NO_END_TO_END}
TR_NO_END_TO_END = $02; // End-to-end timing not required
// values used for the ClippingSusceptability field in struct ATM_BROADBAND_BEARER_CAPABILITY_IE
{$EXTERNALSYM CLIP_NOT}
CLIP_NOT = $00; // Not susceptible to clipping
{$EXTERNALSYM CLIP_SUS}
CLIP_SUS = $20; // Susceptible to clipping
// values used for the UserPlaneConnectionConfig field in struct ATM_BROADBAND_BEARER_CAPABILITY_IE
{$EXTERNALSYM UP_P2P}
UP_P2P = $00; // Point-to-point connection
{$EXTERNALSYM UP_P2MP}
UP_P2MP = $01; // Point-to-multipoint connection
// values used for the Layer2Mode field in struct ATM_BLLI_IE
const
{$EXTERNALSYM BLLI_L2_MODE_NORMAL}
BLLI_L2_MODE_NORMAL = $40;
{$EXTERNALSYM BLLI_L2_MODE_EXT}
BLLI_L2_MODE_EXT = $80;
// values used for the Layer3Mode field in struct ATM_BLLI_IE
{$EXTERNALSYM BLLI_L3_MODE_NORMAL}
BLLI_L3_MODE_NORMAL = $40;
{$EXTERNALSYM BLLI_L3_MODE_EXT}
BLLI_L3_MODE_EXT = $80;
// values used for the Condition portion of the Diagnostics field
// in struct ATM_CAUSE_IE, for certain Cause values
{$EXTERNALSYM CAUSE_COND_UNKNOWN}
CAUSE_COND_UNKNOWN = $00;
{$EXTERNALSYM CAUSE_COND_PERMANENT}
CAUSE_COND_PERMANENT = $01;
{$EXTERNALSYM CAUSE_COND_TRANSIENT}
CAUSE_COND_TRANSIENT = $02;
// values used for the Rejection Reason portion of the Diagnostics field
// in struct ATM_CAUSE_IE, for certain Cause values
{$EXTERNALSYM CAUSE_REASON_USER}
CAUSE_REASON_USER = $00;
{$EXTERNALSYM CAUSE_REASON_IE_MISSING}
CAUSE_REASON_IE_MISSING = $04;
{$EXTERNALSYM CAUSE_REASON_IE_INSUFFICIENT}
CAUSE_REASON_IE_INSUFFICIENT = $08;
// values used for the P-U flag of the Diagnostics field
// in struct ATM_CAUSE_IE, for certain Cause values
{$EXTERNALSYM CAUSE_PU_PROVIDER}
CAUSE_PU_PROVIDER = $00;
{$EXTERNALSYM CAUSE_PU_USER}
CAUSE_PU_USER = $08;
// values used for the N-A flag of the Diagnostics field
// in struct ATM_CAUSE_IE, for certain Cause values
{$EXTERNALSYM CAUSE_NA_NORMAL}
CAUSE_NA_NORMAL = $00;
{$EXTERNALSYM CAUSE_NA_ABNORMAL}
CAUSE_NA_ABNORMAL = $04;
type
{$EXTERNALSYM ATM_CAUSE_IE}
ATM_CAUSE_IE = record
Location : Byte;
Cause : Byte;
DiagnosticsLength : Byte;
Diagnostics : Array[0..3] of Byte;
end;
// values used for the QOSClassForward and QOSClassBackward
// field in struct ATM_QOS_CLASS_IE
const
{$EXTERNALSYM QOS_CLASS0}
QOS_CLASS0 = $00;
{$EXTERNALSYM QOS_CLASS1}
QOS_CLASS1 = $01;
{$EXTERNALSYM QOS_CLASS2}
QOS_CLASS2 = $02;
{$EXTERNALSYM QOS_CLASS3}
QOS_CLASS3 = $03;
{$EXTERNALSYM QOS_CLASS4}
QOS_CLASS4 = $04;
type
{$EXTERNALSYM ATM_QOS_CLASS_IE}
ATM_QOS_CLASS_IE = packed record
QOSClassForward : Byte;
QOSClassBackward : Byte;
end;
// values used for the TypeOfNetworkId field in struct ATM_TRANSIT_NETWORK_SELECTION_IE
const
{$EXTERNALSYM TNS_TYPE_NATIONAL}
TNS_TYPE_NATIONAL = $40;
// values used for the NetworkIdPlan field in struct ATM_TRANSIT_NETWORK_SELECTION_IE
{$EXTERNALSYM TNS_PLAN_CARRIER_ID_CODE}
TNS_PLAN_CARRIER_ID_CODE = $01;
type
{$EXTERNALSYM ATM_TRANSIT_NETWORK_SELECTION_IE}
ATM_TRANSIT_NETWORK_SELECTION_IE = record
TypeOfNetworkId : Byte;
NetworkIdPlan : Byte;
NetworkIdLength : Byte;
NetworkId : Array[0..0] of Byte;
end;
function Winsock2Loaded : Boolean;
begin
Result := hWS2Dll <> 0;
end;
constructor EIdWS2StubError.Build( const ATitle : String; AWin32Error : DWORD );
begin
FTitle := ATitle;
FWin32Error := AWin32Error;
if AWin32Error = 0 then
begin
inherited Create( ATitle )
end
else
begin
FWin32ErrorMessage := SysUtils.SysErrorMessage(AWin32Error);
inherited Create( ATitle + ': ' + FWin32ErrorMessage ); {Do not Localize}
end;
end;
procedure WS2StubInit; forward;
procedure WS2Unload;
var h : THandle;
begin
h := InterlockedExchange(Integer(hWS2Dll), 0);
if h <> 0 then
begin
Windows.FreeLibrary(h);
WS2StubInit;
end;
end;
type
WS2StubEntry = record
StubProc : Pointer;
ProcVar : PPointer;
Name : PChar;
end;
function WS2Call( AStubEntryIndex : DWORD ) : Pointer; forward;
function WS2Call( AStubEntryIndex : DWORD ) : Pointer;
begin
with WS2StubTable[AStubEntryIndex] do
begin
if hWS2Dll = 0 then
begin
raise EIdWS2StubError.Build( Format(RSWS2CallError,[Name]), WSANOTINITIALISED );
end;
Result := Windows.GetProcAddress( hWS2Dll, Name );
ProcVar^ := Result;
end;
end;
procedure WS2StubInit;
var i : Integer;
begin
hWS2Dll := 0;
for i := 0 to WS2StubEntryCount-1 do
with WS2StubTable do
ProcVar^ := StubProc;
end;
function WSAStartup( const wVersionRequired: word; var WSData: TWSAData ): Integer;
begin
if hWS2Dll = 0 then
begin
hWS2Dll := LoadLibrary( WINSOCK2_DLL );
if hWS2Dll = 0 then
begin
raise EIdWS2StubError.Build( Format(RSWS2LoadError,[WINSOCK2_DLL]), Windows.GetLastError );
end;
WS2_WSAStartup := LPFN_WSASTARTUP( Windows.GetProcAddress( hWS2Dll, 'WSAStartup' ) ); {Do not Localize}
Result := WS2_WSAStartup( wVersionRequired, WSData );
end
else
begin
//actually, this not really be called if the lib is already loaded.
Result:= 0; ///<<<<<<<<< if loaded then all ok
end;
end;
function WSAMakeSyncReply;
begin
WSAMakeSyncReply:= MakeLong(Buflen, Error);
end;
function WSAMakeSelectReply;
begin
WSAMakeSelectReply:= MakeLong(Event, Error);
end;
function WSAGetAsyncBuflen;
begin
WSAGetAsyncBuflen:= LOWORD(Param);
end;
function WSAGetAsyncError;
begin
WSAGetAsyncError:= HIWORD(Param);
end;
function WSAGetSelectEvent;
begin
WSAGetSelectEvent:= LOWORD(Param);
end;
function WSAGetSelectError;
begin
WSAGetSelectError:= HIWORD(Param);
end;
procedure FD_CLR(Socket: TSocket; var FDSet: TFDSet);
//var i: DWord;
var
i: Integer;
begin
i := 0;
while i < FDSet.fd_count do
begin
if FDSet.fd_array = Socket then
begin
while i < FDSet.fd_count - 1 do
begin
FDSet.fd_array := FDSet.fd_array[i+1];
Inc(i);
end;
Dec(FDSet.fd_count);
Break;
end;
Inc(i);
end;
end;
function FD_ISSET(Socket: TSocket; var FDSet: TFDSet): Boolean;
begin
Result := __WSAFDIsSet(Socket, FDSet);
end;
procedure FD_SET(Socket: TSocket; var FDSet: TFDSet);
begin
if FDSet.fd_count < fd_setsize then
begin
FDSet.fd_array[FDSet.fd_count] := Socket;
Inc(FDSet.fd_count);
end;
end;
procedure FD_ZERO(var FDSet: TFDSet);
begin
FDSet.fd_count := 0;
end;
function IP_MSFILTER_SIZE(numsrc: DWORD): DWORD;
begin
Result := SizeOf(ip_msfilter) - SizeOf(TInAddr) + (numsrc*SizeOf(TInAddr));
end;
function SS_PORT(ssp: PSockAddrIn): u_short;
begin
Result := 0;
if ssp <> nil then Result := ssp^.sin_port;
end;
function IN6ADDR_ANY_INIT: TIn6Addr;
begin
with Result do
begin
System.FillChar( s6_addr, SizeOf(s6_addr), 0 ); {Do not Localize}
end;
end;
function IN6ADDR_LOOPBACK_INIT: TIn6Addr;
begin
with Result do
begin
System.FillChar( s6_addr, SizeOf(s6_addr), 0 ); {Do not Localize}
s6_addr[15] := 1;
end;
end;
procedure IN6ADDR_SETANY(sa: PSockAddrIn6);
begin
if sa <> nil then with sa^ do
begin
sin6_family := AF_INET6;
sin6_port := 0;
sin6_flowinfo := 0;
PULONG(@sin6_addr.s6_addr[0])^ := 0;
PULONG(@sin6_addr.s6_addr[4])^ := 0;
PULONG(@sin6_addr.s6_addr[8])^ := 0;
PULONG(@sin6_addr.s6_addr[12])^ := 0;
end;
end;
procedure IN6ADDR_SETLOOPBACK(sa: PSockAddrIn6);
begin
if sa <> nil then with sa^ do
begin
sin6_family := AF_INET6;
sin6_port := 0;
sin6_flowinfo := 0;
PULONG(@sin6_addr.s6_addr[0])^ := 0;
PULONG(@sin6_addr.s6_addr[4])^ := 0;
PULONG(@sin6_addr.s6_addr[8])^ := 0;
PULONG(@sin6_addr.s6_addr[12])^ := 1;
end;
end;
function IN6ADDR_ISANY(sa: PSockAddrIn6): Boolean;
begin
Result := False;
if sa <> nil then with sa^ do
begin
Result := (sin6_family = AF_INET6) and
(PULONG(@sin6_addr.s6_addr[0])^ = 0) and
(PULONG(@sin6_addr.s6_addr[4])^ = 0) and
(PULONG(@sin6_addr.s6_addr[8])^ = 0) and
(PULONG(@sin6_addr.s6_addr[12])^ = 0);
end;
end;
function IN6ADDR_ISLOOPBACK(sa: PSockAddrIn6): Boolean;
begin
Result := False;
if sa <> nil then with sa^ do
begin
Result := (sin6_family = AF_INET6) and
(PULONG(@sin6_addr.s6_addr[0])^ = 0) and
(PULONG(@sin6_addr.s6_addr[4])^ = 0) and
(PULONG(@sin6_addr.s6_addr[8])^ = 0) and
(PULONG(@sin6_addr.s6_addr[12])^ = 1);
end;
end;
function IN6_ADDR_EQUAL(const a: PIn6Addr; const b: PIn6Addr): Boolean;
begin
Result := SysUtils.CompareMem(a, b, SizeOf(TIn6Addr));
end;
function IN6_IS_ADDR_UNSPECIFIED(const a: PIn6Addr): Boolean;
begin
Result := IN6_ADDR_EQUAL(a, @in6addr_any);
end;
function IN6_IS_ADDR_LOOPBACK(const a: PIn6Addr): Boolean;
begin
Result := IN6_ADDR_EQUAL(a, @in6addr_loopback);
end;
function IN6_IS_ADDR_MULTICAST(const a: PIn6Addr): Boolean;
begin
Result := False;
if a <> nil then Result := (a^.s6_addr[0] = $FF);
end;
function IN6_IS_ADDR_LINKLOCAL(const a: PIn6Addr): Boolean;
begin
Result := False;
if a <> nil then with a^ do Result := (s6_addr[0] = $FE) and ((s6_addr[1] and $C0) = $80);
end;
function IN6_IS_ADDR_SITELOCAL(const a: PIn6Addr): Boolean;
begin
Result := False;
if a <> nil then with a^ do Result := (s6_addr[0] = $FE) and ((s6_addr[1] and $C0) = $C0);
end;
function IN6_IS_ADDR_V4MAPPED(const a: PIn6Addr): Boolean;
begin
Result := False;
if a <> nil then with a^ do
begin
Result := (word[0] = 0) and
(word[1] = 0) and
(word[2] = 0) and
(word[3] = 0) and
(word[4] = 0) and
(word[5] = $FFFF);
end;
end;
function IN6_IS_ADDR_V4COMPAT(const a: PIn6Addr): Boolean;
begin
Result := False;
if a <> nil then with a^ do
begin
Result := (word[0] = 0) and
(word[1] = 0) and
(word[2] = 0) and
(word[3] = 0) and
(word[4] = 0) and
(word[5] = 0) and
not ((word[6] = 0) and (s6_addr[14] = 0) and
((s6_addr[15] = 0) or (s6_addr[15] = 1)));
end;
end;
function IN6_IS_ADDR_MC_NODELOCAL(const a: PIn6Addr): Boolean;
begin
Result := False;
if a <> nil then Result := IN6_IS_ADDR_MULTICAST(a) and ((a^.s6_addr[1] and $F) = 1);
end;
function IN6_IS_ADDR_MC_LINKLOCAL(const a: PIn6Addr): Boolean;
begin
Result := False;
if a <> nil then Result := IN6_IS_ADDR_MULTICAST(a) and ((a^.s6_addr[1] and $F) = 2);
end;
function IN6_IS_ADDR_MC_SITELOCAL(const a: PIn6Addr): Boolean;
begin
Result := False;
if a <> nil then Result := IN6_IS_ADDR_MULTICAST(a) and ((a^.s6_addr[1] and $F) = 5);
end;
function IN6_IS_ADDR_MC_ORGLOCAL(const a: PIn6Addr): Boolean;
begin
Result := False;
if a <> nil then Result := IN6_IS_ADDR_MULTICAST(a) and ((a^.s6_addr[1] and $F) = 8);
end;
function IN6_IS_ADDR_MC_GLOBAL(const a: PIn6Addr): Boolean;
begin
Result := False;
if a <> nil then Result := IN6_IS_ADDR_MULTICAST(a) and ((a^.s6_addr[1] and $F) = $E);
end;
// A macro convenient for setting up NETBIOS SOCKADDRs.
procedure SET_NETBIOS_SOCKADDR( snb : PSockAddrNB; const SnbType : Word; const Name : PChar; const Port : Char );
var len : Integer;
begin
if snb <> nil then with snb^ do
begin
snb_family := AF_NETBIOS;
snb_type := SnbType;
len := StrLen(Name);
if len >= NETBIOS_NAME_LENGTH-1 then
begin
System.Move(Name^, snb_name, NETBIOS_NAME_LENGTH-1)
end
else
begin
if len > 0 then
begin
System.Move(Name^, snb_name, len);
end;
System.FillChar( (PChar(@snb_name)+len)^, NETBIOS_NAME_LENGTH-1-len, ' ' ); {Do not Localize}
end;
snb_name[NETBIOS_NAME_LENGTH-1] := Port;
end;
end;