home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / wsnwlink.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  9KB  |  280 lines

  1. /*
  2.  *   wsnwlink.h
  3.  *
  4.  *
  5.  *  Microsoft Windows
  6.  *  Copyright (C) Microsoft Corporation, 1992-1997.
  7.  *   Microsoft-specific extensions to the Windows NT IPX/SPX Windows
  8.  *   Sockets interface.  These extensions are provided for use as
  9.  *   necessary for compatibility with existing applications.  They are
  10.  *   otherwise not recommended for use, as they are only guaranteed to
  11.  *   work *   over the Microsoft IPX/SPX stack.  An application which
  12.  *   uses these *   extensions may not work over other IPX/SPX
  13.  *   implementations.  Include this header file after winsock.h and
  14.  *   wsipx.h.
  15.  *
  16.  *   To open an IPX socket where a particular packet type is sent in
  17.  *   the IPX header, specify NSPROTO_IPX + n as the protocol parameter
  18.  *   of the socket() API.  For example, to open an IPX socket that
  19.  *   sets the packet type to 34, use the following socket() call:
  20.  *
  21.  *       s = socket(AF_IPX, SOCK_DGRAM, NSPROTO_IPX + 34);
  22.  *
  23.  *   Below are socket option that may be set or retrieved by specifying
  24.  *   the appropriate manifest in the "optname" parameter of getsockopt()
  25.  *   or setsockopt().  Use NSPROTO_IPX as the "level" argument for the
  26.  *   call.
  27.  *
  28.  */
  29.  
  30. #ifndef _WSNWLINK_
  31. #define _WSNWLINK_
  32.  
  33.  
  34. /*
  35.  *   Set/get the IPX packet type.  The value specified in the
  36.  *   optval argument will be set as the packet type on every IPX
  37.  *   packet sent from this socket.  The optval parameter of
  38.  *   getsockopt()/setsockopt() points to an int.
  39.  *
  40.  */
  41.  
  42. #define IPX_PTYPE               0x4000
  43.  
  44.  
  45. /*
  46.  *   Set/get the receive filter packet type.  Only IPX packets with
  47.  *   a packet type equal to the value specified in the optval
  48.  *   argument will be returned; packets with a packet type that
  49.  *   does not match are discarded.  optval points to an int.
  50.  *
  51.  */
  52.  
  53. #define IPX_FILTERPTYPE         0x4001
  54.  
  55.  
  56. /*
  57.  *   Stop filtering on packet type set with IPX_FILTERPTYPE.
  58.  *
  59.  */
  60.  
  61. #define IPX_STOPFILTERPTYPE     0x4003
  62.  
  63.  
  64. /*
  65.  *   Set/get the value of the datastream field in the SPX header on
  66.  *   every packet sent.  optval points to an int.
  67.  *
  68.  */
  69.  
  70. #define IPX_DSTYPE              0x4002
  71.  
  72.  
  73. /*
  74.  *   Enable extended addressing.  On sends, adds the element
  75.  *   "unsigned char sa_ptype" to the SOCKADDR_IPX structure,
  76.  *   making the total length 15 bytes.  On receives, add both
  77.  *   the sa_ptype and "unsigned char sa_flags" to the SOCKADDR_IPX
  78.  *   structure, making the total length 16 bytes.  The current
  79.  *   bits defined in sa_flags are:
  80.  *
  81.  *   0x01 - the received frame was sent as a broadcast
  82.  *   0x02 - the received frame was sent from this machine
  83.  *
  84.  *   optval points to a BOOL.
  85.  *
  86.  */
  87.  
  88. #define IPX_EXTENDED_ADDRESS    0x4004
  89.  
  90.  
  91. /*
  92.  *   Send protocol header up on all receive packets.  optval points
  93.  *   to a BOOL.
  94.  *
  95.  */
  96.  
  97. #define IPX_RECVHDR             0x4005
  98.  
  99.  
  100. /*
  101.  *   Get the maximum data size that can be sent.  Not valid with
  102.  *   setsockopt().  optval points to an int where the value is
  103.  *   returned.
  104.  *
  105.  */
  106.  
  107. #define IPX_MAXSIZE             0x4006
  108.  
  109.  
  110. /*
  111.  *   Query information about a specific adapter that IPX is bound
  112.  *   to.  In a system with n adapters they are numbered 0 through n-1.
  113.  *   Callers can issue the IPX_MAX_ADAPTER_NUM getsockopt() to find
  114.  *   out the number of adapters present, or call IPX_ADDRESS with
  115.  *   increasing values of adapternum until it fails.  Not valid
  116.  *   with setsockopt().  optval points to an instance of the
  117.  *   IPX_ADDRESS_DATA structure with the adapternum filled in.
  118.  *
  119.  */
  120.  
  121. #define IPX_ADDRESS             0x4007
  122.  
  123. typedef struct _IPX_ADDRESS_DATA {
  124.     INT   adapternum;  /* input: 0-based adapter number */
  125.     UCHAR netnum[4];   /* output: IPX network number */
  126.     UCHAR nodenum[6];  /* output: IPX node address */
  127.     BOOLEAN wan;       /* output: TRUE = adapter is on a wan link */
  128.     BOOLEAN status;    /* output: TRUE = wan link is up (or adapter is not wan) */
  129.     INT   maxpkt;      /* output: max packet size, not including IPX header */
  130.     ULONG linkspeed;   /* output: link speed in 100 bytes/sec (i.e. 96 == 9600 bps) */
  131. } IPX_ADDRESS_DATA, *PIPX_ADDRESS_DATA;
  132.  
  133.  
  134. /*
  135.  *   Query information about a specific IPX network number.  If the
  136.  *   network is in IPX's cache it will return the information directly,
  137.  *   otherwise it will issue RIP requests to find it.  Not valid with
  138.  *   setsockopt().  optval points to an instance of the IPX_NETNUM_DATA
  139.  *   structure with the netnum filled in.
  140.  *
  141.  */
  142.  
  143. #define IPX_GETNETINFO          0x4008
  144.  
  145. typedef struct _IPX_NETNUM_DATA {
  146.     UCHAR  netnum[4];  /* input: IPX network number */
  147.     USHORT hopcount;   /* output: hop count to this network, in machine order */
  148.     USHORT netdelay;   /* output: tick count to this network, in machine order */
  149.     INT    cardnum;    /* output: 0-based adapter number used to route to this net;
  150.                        /*         can be used as adapternum input to IPX_ADDRESS */
  151.     UCHAR  router[6];  /* output: MAC address of the next hop router, zeroed if
  152.                        /*         the network is directly attached */
  153. } IPX_NETNUM_DATA, *PIPX_NETNUM_DATA;
  154.  
  155.  
  156. /*
  157.  *   Like IPX_GETNETINFO except it *does not* issue RIP requests. If the
  158.  *   network is in IPX's cache it will return the information, otherwise
  159.  *   it will fail (see also IPX_RERIPNETNUMBER which *always* forces a
  160.  *   re-RIP). Not valid with setsockopt().  optval points to an instance of
  161.  *   the IPX_NETNUM_DATA structure with the netnum filled in.
  162.  *
  163.  */
  164.  
  165. #define IPX_GETNETINFO_NORIP    0x4009
  166.  
  167.  
  168. /*
  169.  *   Get information on a connected SPX socket.  optval points
  170.  *   to an instance of the IPX_SPXCONNSTATUS_DATA structure.
  171.  *
  172.  *   All numbers are in Novell (high-low) order.
  173.  *
  174.  */
  175.  
  176. #define IPX_SPXGETCONNECTIONSTATUS 0x400B
  177.  
  178. typedef struct _IPX_SPXCONNSTATUS_DATA {
  179.     UCHAR  ConnectionState;
  180.     UCHAR  WatchDogActive;
  181.     USHORT LocalConnectionId;
  182.     USHORT RemoteConnectionId;
  183.     USHORT LocalSequenceNumber;
  184.     USHORT LocalAckNumber;
  185.     USHORT LocalAllocNumber;
  186.     USHORT RemoteAckNumber;
  187.     USHORT RemoteAllocNumber;
  188.     USHORT LocalSocket;
  189.     UCHAR  ImmediateAddress[6];
  190.     UCHAR  RemoteNetwork[4];
  191.     UCHAR  RemoteNode[6];
  192.     USHORT RemoteSocket;
  193.     USHORT RetransmissionCount;
  194.     USHORT EstimatedRoundTripDelay; /* In milliseconds */
  195.     USHORT RetransmittedPackets;
  196.     USHORT SuppressedPacket;
  197. } IPX_SPXCONNSTATUS_DATA, *PIPX_SPXCONNSTATUS_DATA;
  198.  
  199.  
  200. /*
  201.  *   Get notification when the status of an adapter that IPX is
  202.  *   bound to changes.  Typically this will happen when a wan line
  203.  *   goes up or down.  Not valid with setsockopt().  optval points
  204.  *   to a buffer which contains an IPX_ADDRESS_DATA structure
  205.  *   followed immediately by a HANDLE to an unsignaled event.
  206.  *
  207.  *   When the getsockopt() query is submitted, it will complete
  208.  *   successfully.  However, the IPX_ADDRESS_DATA pointed to by
  209.  *   optval will not be updated at that point.  Instead the
  210.  *   request is queued internally inside the transport.
  211.  *
  212.  *   When the status of an adapter changes, IPX will locate a
  213.  *   queued getsockopt() query and fill in all the fields in the
  214.  *   IPX_ADDRESS_DATA structure.  It will then signal the event
  215.  *   pointed to by the HANDLE in the optval buffer.  This handle
  216.  *   should be obtained before calling getsockopt() by calling
  217.  *   CreateEvent().  If multiple getsockopts() are submitted at
  218.  *   once, different events must be used.
  219.  *
  220.  *   The event is used because the call needs to be asynchronous
  221.  *   but currently getsockopt() does not support this.
  222.  *
  223.  *   WARNING: In the current implementation, the transport will
  224.  *   only signal one queued query for each status change.  Therefore
  225.  *   only one service which uses this query should be running at
  226.  *   once.
  227.  *
  228.  */
  229.  
  230. #define IPX_ADDRESS_NOTIFY      0x400C
  231.  
  232.  
  233. /*
  234.  *   Get the maximum number of adapters present.  If this call returns
  235.  *   n then the adapters are numbered 0 through n-1.  Not valid
  236.  *   with setsockopt().  optval points to an int where the value
  237.  *   is returned.
  238.  *
  239.  */
  240.  
  241. #define IPX_MAX_ADAPTER_NUM     0x400D
  242.  
  243.  
  244. /*
  245.  *   Like IPX_GETNETINFO except it forces IPX to re-RIP even if the
  246.  *   network is in its cache (but not if it is directly attached to).
  247.  *   Not valid with setsockopt().  optval points to an instance of
  248.  *   the IPX_NETNUM_DATA structure with the netnum filled in.
  249.  *
  250.  */
  251.  
  252. #define IPX_RERIPNETNUMBER      0x400E
  253.  
  254.  
  255. /*
  256.  *   A hint that broadcast packets may be received.  The default is
  257.  *   TRUE.  Applications that do not need to receive broadcast packets
  258.  *   should set this sockopt to FALSE which may cause better system
  259.  *   performance (note that it does not necessarily cause broadcasts
  260.  *   to be filtered for the application).  Not valid with getsockopt().
  261.  *   optval points to a BOOL.
  262.  *
  263.  */
  264.  
  265. #define IPX_RECEIVE_BROADCAST   0x400F
  266.  
  267.  
  268. /*
  269.  *   On SPX connections, don't delay before sending ack.  Applications
  270.  *   that do not tend to have back-and-forth traffic over SPX should
  271.  *   set this; it will increase the number of acks sent but will remove
  272.  *   delays in sending acks.  optval points to a BOOL.
  273.  *
  274.  */
  275.  
  276. #define IPX_IMMEDIATESPXACK     0x4010
  277.  
  278. #endif
  279.  
  280.