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