Leaked source code of windows server 2003
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.

124 lines
3.7 KiB

  1. //////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // send.cpp
  7. //
  8. // Abstract:
  9. // This module contains code which implements send
  10. // commands from the dll
  11. //
  12. //////////////////////////////////////////////////////////
  13. #include "stdafx.h"
  14. ///////////////////////////////////////////////////////////////////////
  15. // Public functions
  16. ///////////////////////////////////////////////////////////////////////
  17. // --------------------------------------------------------------------
  18. //
  19. // Function: DoSendDatagram
  20. //
  21. // Arguments: TdiHandle -- handle of address object
  22. // pTransportAddress -- TA to send data to
  23. // pucBuffer -- data buffer to send
  24. // ulBufferLength -- length of data buffer
  25. //
  26. // Returns: none
  27. //
  28. // Descript: This function causes the driver to send a datagram
  29. //
  30. //---------------------------------------------------------------------
  31. VOID
  32. DoSendDatagram(ULONG ulTdiHandle,
  33. PTRANSPORT_ADDRESS pTransportAddress,
  34. PUCHAR pucBuffer,
  35. ULONG ulBufferLength)
  36. {
  37. RECEIVE_BUFFER ReceiveBuffer; // return info from command
  38. SEND_BUFFER SendBuffer; // arguments for command
  39. //
  40. // set up arguments
  41. //
  42. SendBuffer.TdiHandle = ulTdiHandle;
  43. memcpy(&SendBuffer.COMMAND_ARGS.SendArgs.TransAddr,
  44. pTransportAddress,
  45. (FIELD_OFFSET(TRANSPORT_ADDRESS, Address)
  46. + FIELD_OFFSET(TA_ADDRESS, Address)
  47. + pTransportAddress->Address[0].AddressLength));
  48. SendBuffer.COMMAND_ARGS.SendArgs.ulBufferLength = ulBufferLength;
  49. SendBuffer.COMMAND_ARGS.SendArgs.pucUserModeBuffer = pucBuffer;
  50. //
  51. // call the driver
  52. //
  53. NTSTATUS lStatus = TdiLibDeviceIO(ulSENDDATAGRAM,
  54. &SendBuffer,
  55. &ReceiveBuffer);
  56. if (lStatus != STATUS_SUCCESS)
  57. {
  58. _tprintf(TEXT("DoSendDatagram: failure, status = %s\n"), TdiLibStatusMessage(lStatus));
  59. }
  60. }
  61. // --------------------------------------------------------------------
  62. //
  63. // Function: DoSend
  64. //
  65. // Arguments: TdiHandle -- handle of endpoint
  66. // pucBuffer -- data buffer to send
  67. // ulBufferLength -- length of data buffer
  68. // ulSendFlags -- send options
  69. //
  70. // Returns: none
  71. //
  72. // Descript: This function causes the driver to send data over
  73. // a connection
  74. //
  75. //---------------------------------------------------------------------
  76. VOID
  77. DoSend(ULONG ulTdiHandle,
  78. PUCHAR pucBuffer,
  79. ULONG ulBufferLength,
  80. ULONG ulSendFlags)
  81. {
  82. RECEIVE_BUFFER ReceiveBuffer; // return info from command
  83. SEND_BUFFER SendBuffer; // arguments for command
  84. //
  85. // set up arguments
  86. //
  87. SendBuffer.TdiHandle = ulTdiHandle;
  88. SendBuffer.COMMAND_ARGS.SendArgs.ulFlags = ulSendFlags;
  89. SendBuffer.COMMAND_ARGS.SendArgs.ulBufferLength = ulBufferLength;
  90. SendBuffer.COMMAND_ARGS.SendArgs.pucUserModeBuffer = pucBuffer;
  91. //
  92. // call the driver
  93. //
  94. NTSTATUS lStatus = TdiLibDeviceIO(ulSEND,
  95. &SendBuffer,
  96. &ReceiveBuffer);
  97. if (lStatus != STATUS_SUCCESS)
  98. {
  99. _tprintf(TEXT("DoSend: failure, status = %s\n"), TdiLibStatusMessage(lStatus));
  100. }
  101. }
  102. ////////////////////////////////////////////////////////////////////
  103. // end of file send.cpp
  104. ////////////////////////////////////////////////////////////////////