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.

135 lines
5.0 KiB

  1. /********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990-2000 **/
  4. /********************************************************************/
  5. /* :ts=4 */
  6. //** DGRAM.H - Common datagram protocol definitions.
  7. //
  8. // This file contains definitions for the functions common to
  9. // both UDP and Raw IP.
  10. //
  11. #ifndef _DGRAM_INCLUDED_
  12. #define _DGRAM_INCLUDED_ 1
  13. //* Structure used for maintaining DG send requests.
  14. #define dsr_signature 0x20525338
  15. typedef struct DGSendReq {
  16. #if DBG
  17. ulong dsr_sig;
  18. #endif
  19. Queue dsr_q; // Queue linkage when pending.
  20. PNDIS_BUFFER dsr_buffer; // Buffer of data to send.
  21. PNDIS_BUFFER dsr_header; // Pointer to header buffer.
  22. CTEReqCmpltRtn dsr_rtn; // Completion routine.
  23. PVOID dsr_context; // User context.
  24. IPAddr dsr_addr; // Remote IPAddr.
  25. IPAddr dsr_srcaddr; // Local IPAddr.
  26. ulong dsr_pid;
  27. ushort dsr_port; // Remote port.
  28. ushort dsr_size; // Size of buffer.
  29. ushort dsr_srcport; // Local Port.
  30. } DGSendReq;
  31. //* Structure used for maintaining DG receive requests.
  32. #define drr_signature 0x20525238
  33. typedef struct DGRcvReq {
  34. #if DBG
  35. ulong drr_sig;
  36. #endif
  37. Queue drr_q; // Queue linkage on AddrObj.
  38. PNDIS_BUFFER drr_buffer; // Buffer to be filled in.
  39. PTDI_CONNECTION_INFORMATION drr_conninfo; // Pointer to conn. info.
  40. CTEReqCmpltRtn drr_rtn; // Completion routine.
  41. PVOID drr_context; // User context.
  42. IPAddr drr_addr; // Remote IPAddr acceptable.
  43. ushort drr_port; // Remote port acceptable.
  44. ushort drr_size; // Size of buffer.
  45. } DGRcvReq;
  46. //* External definition of exported variables.
  47. extern CACHE_LINE_KSPIN_LOCK DGQueueLock;
  48. extern CTEEvent DGDelayedEvent;
  49. //* External definition of exported functions.
  50. extern void DGSendComplete(void *Context, PNDIS_BUFFER BufferChain,
  51. IP_STATUS SendStatus);
  52. extern TDI_STATUS TdiSendDatagram(PTDI_REQUEST Request,
  53. PTDI_CONNECTION_INFORMATION ConnInfo,
  54. uint DataSize, uint *BytesSent,
  55. PNDIS_BUFFER Buffer);
  56. extern TDI_STATUS TdiReceiveDatagram(PTDI_REQUEST Request,
  57. PTDI_CONNECTION_INFORMATION ConnInfo,
  58. PTDI_CONNECTION_INFORMATION ReturnInfo,
  59. uint RcvSize, uint *BytesRcvd,
  60. PNDIS_BUFFER Buffer);
  61. extern VOID TdiCancelSendDatagram(AddrObj * SrcAO, PVOID Context,
  62. KIRQL inHandle);
  63. extern VOID TdiCancelReceiveDatagram(AddrObj * SrcAO, PVOID Context,
  64. KIRQL inHandle);
  65. extern IP_STATUS DGRcv(void *IPContext, IPAddr Dest, IPAddr Src,
  66. IPAddr LocalAddr, IPRcvBuf *RcvBuf, uint Size,
  67. uchar IsBCast, uchar Protocol, IPOptInfo *OptInfo);
  68. extern void FreeDGRcvReq(DGRcvReq *RcvReq);
  69. extern void FreeDGSendReq(DGSendReq *SendReq);
  70. extern int InitDG(uint MaxHeaderSize);
  71. extern PNDIS_BUFFER GetDGHeader(struct UDPHeader **Header);
  72. extern void FreeDGHeader(PNDIS_BUFFER FreedBuffer);
  73. extern void PutPendingQ(AddrObj *QueueingAO);
  74. //* The following is needed for the IP_PKTINFO option and echos what is found
  75. // in ws2tcpip.h and winsock.h
  76. #define IP_PKTINFO 19 // receive packet information
  77. typedef struct in_pktinfo {
  78. IPAddr ipi_addr; // destination IPv4 address
  79. uint ipi_ifindex; // received interface index
  80. } IN_PKTINFO;
  81. //* Make sure the size of IN_PKTINFO is still what we think it is.
  82. // If it is changed, the corresponding definition in ws2tcpip.h must be
  83. // changed as well.
  84. C_ASSERT(sizeof(IN_PKTINFO) == 8);
  85. #define IPPROTO_IP 0
  86. //* Function to allocate and populate an IN_PKTINFO ancillary object.
  87. PTDI_CMSGHDR
  88. DGFillIpPktInfo(IPAddr DestAddr, IPAddr LocalAddr, int *Size);
  89. //* Structure sent to XxxDeliver function.
  90. typedef struct DGDeliverInfo {
  91. IPAddr DestAddr; // Destination address in IP Header.
  92. IPAddr LocalAddr; // Address of interface packet was delivered on.
  93. #if TRACE_EVENT
  94. ushort DestPort;
  95. #endif
  96. uint Flags; // Flags describing aspects of this delivery.
  97. } DGDeliverInfo;
  98. //* Values for Flags member of DGDeliverInfo.
  99. #define NEED_CHECKSUM 0x1
  100. #define IS_BCAST 0x2
  101. #define SRC_LOCAL 0x4
  102. #endif // ifndef _DGRAM_INCLUDED_