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

  1. /*++
  2.  
  3. Copyright (c) 1995  Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.  
  8. Abstract:
  9.     Router interface with IPX stack (to be replaced by WinSock 2.0)
  10.  
  11.  
  12. Author:
  13.  
  14.     Vadim Eydelman
  15.  
  16. Revision History:
  17.  
  18. --*/
  19. #ifndef _IPX_ADAPTER_
  20. #define _IPX_ADAPTER_
  21.  
  22. typedef struct _ADDRESS_RESERVED {
  23.     UCHAR            Reserved[28];
  24. } ADDRESS_RESERVED, *PADDRESS_RESERVED;
  25.  
  26. /*++
  27.  
  28.         C r e a t e S o c k e t P o r t
  29.  
  30. Routine Description:
  31.  
  32.     Creates port to communicate over IPX socket with direct access to NIC
  33.  
  34. Arguments:
  35.     Socket    - IPX socket number to use (network byte order)
  36.  
  37. Return Value:
  38.     Handle to communication port that provides NIC oriented interface
  39.     to IPX stack.  Returns INVALID_HANDLE_VALUE if port can not be opened
  40.  
  41. --*/
  42. HANDLE WINAPI
  43. CreateSocketPort (
  44.     IN USHORT    Socket
  45. ); 
  46.  
  47. /*++
  48.  
  49.         D e l e t e S o c k e t P o r t
  50.  
  51. Routine Description:
  52.  
  53.     Cancel all the outstandng requests and dispose of all the resources
  54.     allocated for communication port
  55.  
  56. Arguments:
  57.  
  58.     Handle    - Handle to communication port to be disposed of
  59.  
  60. Return Value:
  61.  
  62.     NO_ERROR - success
  63.     Windows error code - operation failed
  64. --*/
  65. DWORD WINAPI
  66. DeleteSocketPort (
  67.     IN HANDLE    Handle
  68. );
  69.  
  70. /*++
  71.  
  72.         I p x R e c v P a c k e t
  73.  
  74. Routine Description:
  75.  
  76.     Enqueue request to receive IPX packet.
  77.  
  78. Arguments:
  79.     Handle            - Handle to socket port to use
  80.     IpxPacket        - buffer for ipx packet (complete with header)
  81.     IpxPacketLength - length of the buffer
  82.     pReserved        - buffer to exchange NIC information with IPX stack
  83.                     (current implementation requires that memory allocated
  84.                     for this buffer is immediately followed by the
  85.                     IpxPacket buffer)
  86.     lpOverlapped    - structure to be used for async IO, fields are set
  87.                     as follows:
  88.                         Internal        - Reserved, must be 0
  89.                         InternalHigh    - Reserved, must be 0
  90.                         Offset            - Reserved, must be 0
  91.                         OffsetHigh        - Reserved, must be 0
  92.                         hEvent            - event to be signalled when IO
  93.                                         completes or NULL if CompletionRoutine
  94.                                         is to be called
  95.     CompletionRoutine -  to be called when IO operation is completes
  96.  
  97. Return Value:
  98.  
  99.     NO_ERROR        - if lpOverlapped->hEvent!=NULL, then receive has 
  100.                     successfully completed (do not need to wait on event,
  101.                     however it will be signalled anyway), otherwise,
  102.                     receive operation has started and completion routine will
  103.                     be called when done (possibly it has been called even
  104.                     before this routine returned)
  105.     ERROR_IO_PENDING - only returned if lpOverlapped->hEvent!=NULL and
  106.                     receive could not be completed immediately, event will
  107.                     be signalled when operation is done:
  108.                     call GetOverlapedResult to retrieve result of
  109.                     the operation
  110.     other (windows error code) - operation could not be started 
  111.                     (completion routine won't be called/event won't be 
  112.                     signalled)
  113. --*/
  114. DWORD WINAPI
  115. IpxRecvPacket (
  116.     IN HANDLE                             Handle,
  117.     OUT PUCHAR                             IpxPacket,
  118.     IN ULONG                            IpxPacketLength,
  119.     OUT PADDRESS_RESERVED                lpReserved,
  120.     IN LPOVERLAPPED                        lpOverlapped,
  121.     IN LPOVERLAPPED_COMPLETION_ROUTINE    CompletionRoutine
  122. );
  123.  
  124. /* Use this to retrieve NIC index once IO completes */
  125. #define  GetNicIdx(pReserved)    ((ULONG)*((USHORT *)(pReserved+2)))
  126.  
  127.  
  128. /*++
  129.  
  130.         I p x S e n d P a c k e t
  131.  
  132. Routine Description:
  133.  
  134.     Enqueue request to send IPX packet.
  135.  
  136. Arguments:
  137.  
  138.     Handle            - Handle to socket port to use
  139.     AdapterIdx        - NIC index on which to send
  140.     IpxPacket        - IPX packet complete with header
  141.     IpxPacketLength - length of the packet
  142.     pReserved        - buffer to exchange NIC info with IPX stack
  143.     lpOverlapped    - structure to be used for async IO, fields are set
  144.                     as follows:
  145.                         Internal        - Reserved, must be 0
  146.                         InternalHigh    - Reserved, must be 0
  147.                         Offset            - Reserved, must be 0
  148.                         OffsetHigh        - Reserved, must be 0
  149.                         hEvent            - event to be signalled when IO
  150.                                         completes or NULL if CompletionRoutine
  151.                                         is to be called
  152.     CompletionRoutine -  to be called when IO operation is completes
  153.  
  154. Return Value:
  155.  
  156.     NO_ERROR        - if lpOverlapped->hEvent!=NULL, then send has 
  157.                     successfully completed (do not need to wait on event,
  158.                     however it will be signalled anyway), otherwise,
  159.                     send operation has started and completion routine will
  160.                     be called when done (possibly it has been called even
  161.                     before this routine returned)
  162.     ERROR_IO_PENDING - only returned if lpOverlapped->hEvent!=NULL and
  163.                     send could not be completed immediately, event will
  164.                     be signalled when operation is done:
  165.                     call GetOverlapedResult to retrieve result of
  166.                     the operation
  167.     other (windows error code) - operation could not be started 
  168.                     (completion routine won't be called/event won't be 
  169.                     signalled)
  170.  
  171. --*/
  172. DWORD WINAPI
  173. IpxSendPacket (
  174.     IN HANDLE                            Handle,
  175.     IN ULONG                            AdapterIdx,
  176.     IN PUCHAR                            IpxPacket,
  177.     IN ULONG                            IpxPacketLength,
  178.     IN PADDRESS_RESERVED                lpReserved,
  179.     IN LPOVERLAPPED                        lpOverlapped,
  180.     IN LPOVERLAPPED_COMPLETION_ROUTINE    CompletionRoutine
  181. );
  182.  
  183. #endif // _IPX_ADAPTER_
  184.