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.

168 lines
8.5 KiB

  1. #ifndef H__pktz
  2. #define H__pktz
  3. #define NDDESignature 0x4E444445L
  4. /* states of packetizer */
  5. #define PKTZ_CONNECTED 1
  6. #define PKTZ_WAIT_PHYSICAL_CONNECT 2
  7. #define PKTZ_WAIT_NEG_CMD 3
  8. #define PKTZ_WAIT_NEG_RSP 4
  9. #define PKTZ_PAUSE_FOR_MEMORY 5
  10. #define PKTZ_CLOSE 6
  11. /* Timer IDs */
  12. #define TID_NO_RCV_CONN_CMD 1
  13. #define TID_NO_RCV_CONN_RSP 2
  14. #define TID_MEMORY_PAUSE 3
  15. #define TID_NO_RESPONSE 4
  16. #define TID_KEEPALIVE 5
  17. #define TID_XMT_STUCK 6
  18. #define TID_CLOSE_PKTZ 7
  19. /*
  20. PKTZ_NEG_CMD: negotiate pktsize, etc.
  21. */
  22. typedef struct {
  23. WORD nc_type; /* PKTZ_NEG_CMD */
  24. WORD nc_pktSize; /* proposed size of packets */
  25. WORD nc_maxUnackPkts; /* proposed maximum unacknowledged packets */
  26. WORD nc_offsSrcNodeName; /* offset (from nc_strings[0]) of source node name */
  27. WORD nc_offsDstNodeName; /* offset (from nc_strings[0]) of destination node name */
  28. WORD nc_offsProtocols; /* offset (from nc_strings[0]) of start of protocol strings */
  29. WORD nc_protocolBytes; /* number of bytes of protocol strings */
  30. BYTE nc_strings[1]; /* start of NULL-terminated strings
  31. srcNodeName
  32. dstNodeName
  33. protocols
  34. */
  35. } NEGCMD, FAR *LPNEGCMD;
  36. #define NEGRSP_ERRCLASS_NONE (0x0000)
  37. #define NEGRSP_ERRCLASS_NAME (0x0001)
  38. #define NEGRSP_ERRNAME_MISMATCH (0x0001)
  39. #define NEGRSP_ERRNAME_DUPLICATE (0x0002)
  40. #define NEGRSP_PROTOCOL_NONE (0xFFFF)
  41. typedef struct {
  42. WORD nr_type; /* one of PKTZ_NEG_CMD or PKTZ_NEG_RSP or PKTZ_KEEPALIVE */
  43. WORD nr_pktSize; /* size of packets agreed upon */
  44. WORD nr_maxUnackPkts; /* maximum unacknowledged packets agreed on */
  45. WORD nr_protocolIndex; /* protocol index. NEGRSP_PROTOCOL_NONE indicates error */
  46. WORD nr_errorClass; /* errors */
  47. WORD nr_errorNum;
  48. } NEGRSP, FAR *LPNEGRSP;
  49. typedef struct {
  50. WORD pc_type; /* PKTZ_NEG_... */
  51. } PKTZCMD;
  52. typedef PKTZCMD FAR *LPPKTZCMD;
  53. /* types of PKTZ messages */
  54. #define PKTZ_NEG_CMD (1)
  55. #define PKTZ_NEG_RSP (2)
  56. #define PKTZ_KEEPALIVE (3)
  57. /*
  58. N E T H D R
  59. NETHDR is the data in front of each network packet that the
  60. PKTZ uses to keep track of various information
  61. */
  62. typedef struct nethdr {
  63. struct nethdr FAR *nh_prev; /* previous link */
  64. struct nethdr FAR *nh_next; /* next link */
  65. WORD nh_noRsp; /* count of consecutive no response errors */
  66. WORD nh_xmtErr; /* count of consecutive transmission errors */
  67. WORD nh_memErr; /* count of consecutive out-of-memory errors */
  68. WORD nh_filler; /* filler for byte-alignment problems */
  69. DWORD nh_timeSent; /* timestamp of when sent (in msec) */
  70. HTIMER nh_hTimerRspTO; /* hTimer for send response timeout */
  71. } NETHDR, FAR *LPNETHDR;
  72. /*
  73. PKTZ is the data associated with each instance of PKTZ
  74. */
  75. typedef struct {
  76. CONNID pk_connId; /* connId: connection id for the associated network interface */
  77. WORD pk_state; /* PKTZ_... */
  78. BOOL pk_fControlPktNeeded; /* fControlPktNeeded: do we need to send a control packet */
  79. PKTID pk_pktidNextToSend; /* pktidNextToSend: pktId of the next packet that we should send. If we get a NACK regarding a packet, we should set pktidNextToSend to that pktid and retransmit it next chance we have */
  80. PKTID pk_pktidNextToBuild; /* pktidNextToBuild: pktId of the next packet that we build. */
  81. BYTE pk_lastPktStatus; /* lastPktStatus: status of last packet that we received from the other side. This gets put into the next packet that we send out (put in np_lastPktStatus field) */
  82. PKTID pk_lastPktRcvd; /* lastPktRcvd: last packet that we received. This gets put into np_lastPktRcvd on next pkt we xmit. */
  83. PKTID pk_lastPktOk; /* lastPktOk: last packet that we received OK. This gets put into np_lastPktOK on the next pkt we xmit. */
  84. PKTID pk_lastPktOkOther; /* lastPktOkOther: last packet that the other side has received OK. */
  85. PKTID pk_pktidNextToRecv; /* pktidNextToRecv: next packet number that we're expecting. We ignore any packets except this packet number */
  86. DWORD pk_pktOffsInXmtMsg; /* pktOffsInMsg: where we should start in the next DDE Packet to xmit. If this is non-zero, it means that part of the DDE Packet at the head of the DDE Packet list (pk_ddePktListHead) is in the unacked packet list */
  87. LPDDEPKT pk_lpDdePktSave; /* lpDdePktSave: if we are in the middle of a DDE packet, this is a pointer to the beginning of the packet */
  88. char pk_szDestName[ MAX_NODE_NAME+1 ];/* szDestName: name of destination node */
  89. char pk_szAliasName[ MAX_NODE_NAME+1 ]; /* szAliasName: alias of destination node, e.g. 15.8.0.244 w/ destName of sidloan */
  90. WORD pk_pktSize; /* pktSize: how big are the packets for this netintf */
  91. WORD pk_maxUnackPkts; /* maxUnackPkts: how many unacknowledged packets should we xmit? */
  92. DWORD pk_timeoutRcvNegCmd; /* configuration parameters for timeouts and retry limits */
  93. DWORD pk_timeoutRcvNegRsp;
  94. DWORD pk_timeoutMemoryPause;
  95. DWORD pk_timeoutKeepAlive;
  96. DWORD pk_timeoutXmtStuck;
  97. DWORD pk_timeoutSendRsp;
  98. WORD pk_wMaxNoResponse;
  99. WORD pk_wMaxXmtErr;
  100. WORD pk_wMaxMemErr;
  101. BOOL pk_fDisconnect; /* disconnect information */
  102. int pk_nDelay;
  103. LPNIPTRS pk_lpNiPtrs;/* lpNiPtrs: pointer to list of functions for associated netintf */
  104. /* statistics */
  105. DWORD pk_sent;
  106. DWORD pk_rcvd;
  107. HTIMER pk_hTimerKeepalive;
  108. HTIMER pk_hTimerXmtStuck; /* hTimerRcvNegCmd: timer for timeout waiting for client to send us the connect cmd */
  109. HTIMER pk_hTimerRcvNegCmd; /* hTimerRcvNegRsp: timer for timeout waiting for server to send us the connect cmd rsp */
  110. HTIMER pk_hTimerRcvNegRsp; /* hTimerMemoyrPause: timer for waiting before retransmitting a packet that was NACKed because of memory errors */
  111. HTIMER pk_hTimerMemoryPause;
  112. HTIMER pk_hTimerCloseConnection; /* rt_hTimerClose: timer for closing this route */
  113. /* list of saved packets that have been transmitted and are not acked. */
  114. LPNETHDR pk_pktUnackHead; /* Head is lowest numbered (least recent) packet */
  115. LPNETHDR pk_pktUnackTail; /* tail is highest numbered (most recent) packet */
  116. LPVOID pk_rcvBuf; /* receive buffer for getting info from netintf */
  117. LPNETPKT pk_controlPkt; /* buffer for control packet. Must always have memory available to send a control packet */
  118. LPNETHDR pk_pktFreeHead; /* list of packet buffers available for transmission */
  119. LPNETHDR pk_pktFreeTail;
  120. /* list of DDE packets that have yet to be xmitted */
  121. LPVOID pk_ddePktHead; /* earliest (least recent) */
  122. LPVOID pk_ddePktTail; /* latest (most recent) */
  123. LPVOID pk_prevPktz; /* list of packetizers in the system */
  124. LPVOID pk_nextPktz;
  125. LPVOID pk_prevPktzForNetintf; /* list of packetizers associated with this netintf */
  126. LPVOID pk_nextPktzForNetintf;
  127. HROUTER pk_hRouterHead; /* head of list of routers associated with PKTZ */
  128. WORD pk_hRouterExtraHead; /* extra info for list of hRouters */
  129. } PKTZ;
  130. typedef PKTZ FAR *LPPKTZ;
  131. VOID PktzSlice( void );
  132. BOOL PktzGetPktzForRouter( LPNIPTRS lpNiPtrs, LPSTR lpszNodeName,
  133. LPSTR lpszNodeInfo, HROUTER hRouter, WORD hRouterExtra,
  134. WORD FAR *lpwHopErr, BOOL bDisconnect, int nDelay,
  135. HPKTZ hPktzDisallowed );
  136. HPKTZ PktzNew( LPNIPTRS lpNiPtrs, BOOL bClient,
  137. LPSTR lpszNodeName, LPSTR lpszNodeInfo, CONNID connId,
  138. BOOL bDisconnect, int nDelay );
  139. VOID PktzAssociateRouter( HPKTZ hPktz, HROUTER hRouter,
  140. WORD hRouterExtra );
  141. VOID PktzDisassociateRouter( HPKTZ hPktz, HROUTER hRouter,
  142. WORD hRouterExtra );
  143. HPKTZ PktzGetNext( HPKTZ hPktz );
  144. HPKTZ PktzGetPrev( HPKTZ hPktz );
  145. VOID PktzSetNext( HPKTZ hPktz, HPKTZ hPktzNext );
  146. VOID PktzSetPrev( HPKTZ hPktz, HPKTZ hPktzPrev );
  147. VOID PktzLinkDdePktToXmit( HPKTZ hPktz, LPDDEPKT lpDdePkt );
  148. #endif