Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
2.0 KiB

  1. /*
  2. * TPKT_Send_Setup
  3. * TPKT_Send_Setup should be called before a TPKT message is sent. It fills in the TPKT
  4. * header in the message. The caller passes TPKT_Send_Setup the wsabuf array before it is
  5. * passed to Winsock to be sent. The caller must allocate an extra TPKT_HEADER_SIZE bytes
  6. * at the beginning of the first buffer in the wsabuf, which TPKT_Send_Setup can fill in.
  7. * The length of the buffer specified in wsabuf must include these bytes. TPKT_Send_Setup
  8. * adds the len fields in the wsabuf array to compute the length of the message.
  9. *
  10. * TPKT_Receive_Init
  11. * TPKT_Receive_Init is called to begin receiving TPKT (RFC 1006) formatted data on a
  12. * connected socket. The socket must have been created as an overlapped socket, and must
  13. * have been connected before TPKT_Init is called.
  14. *
  15. * TPKT_RECEIVE_CALLBACK
  16. * Each complete TPKT message received on the socket is passed to the callback function
  17. * (which was passed to the TPKT_Receive_Init call). The TPKT header is not included. The
  18. * same callback function is called if there is an error in Winsock or an internal error in
  19. * the TPKT module. In this case, the buffer pointer will be NULL and the byte count
  20. * will be 0. When the socket is closed normally, the callback will be called with the
  21. * buffer pointer equal to NULL, the byte count equal to 0, and the error code equal to
  22. * NOERROR.
  23. *
  24. * TPKT_Receive_Close
  25. * TPKT_Receive_Close must be called *after* the socket has been closed, so that the TPKT
  26. * module can free its resources. The following procedure should be used to close a socket:
  27. * shutdown(s, SD_SEND);
  28. * (wait for TPKT receive callback with 0 bytes)
  29. * closesocket(s);
  30. * TPKT_Receive_Close(s);
  31. */
  32. #ifndef TPKT_H
  33. #define TPKT_H
  34. #include <winsock2.h>
  35. #define TPKT_HEADER_SIZE 4
  36. typedef long HRESULT;
  37. typedef void (*TPKT_RECEIVE_CALLBACK)(SOCKET s, void *buf, unsigned long nbytes, HRESULT error);
  38. void TPKT_Send_Setup(WSABUF *wsabuf, DWORD BufferCount);
  39. HRESULT TPKT_Receive_Init(SOCKET s, TPKT_RECEIVE_CALLBACK callback);
  40. HRESULT TPKT_Receive_Close(SOCKET s);
  41. #endif /* TPKT_H */