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.

161 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. periodbc.c
  5. Abstract:
  6. Contains the work item handler periodic bcast
  7. Author:
  8. Stefan Solomon 07/20/1995
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. /*++
  14. Function: IfPeriodicBcast
  15. Descr: called to initiate or continue (complete) a bcast
  16. if EnumHandle is NULL it is a start, else a continuation
  17. Remark: called with the interface lock held
  18. --*/
  19. VOID
  20. IfPeriodicBcast(PWORK_ITEM wip)
  21. {
  22. UCHAR ripsocket[2];
  23. USHORT pktlen;
  24. ULONG delay;
  25. PICB icbp;
  26. icbp = wip->icbp;
  27. #define EnumHandle wip->WorkItemSpecific.WIS_EnumRoutes.RtmEnumerationHandle
  28. if(icbp->IfStats.RipIfOperState != OPER_STATE_UP) {
  29. if(EnumHandle) {
  30. CloseEnumHandle(EnumHandle);
  31. }
  32. FreeWorkItem(wip);
  33. return;
  34. }
  35. PUTUSHORT2SHORT(ripsocket, IPX_RIP_SOCKET);
  36. // check if this is the start or the continuation of a periodic bcast
  37. if(EnumHandle == NULL) {
  38. // *** This is the start of a new broadcast ***
  39. // create an RTM enumeration handle
  40. if((EnumHandle = CreateBestRoutesEnumHandle()) == NULL) {
  41. SS_ASSERT(FALSE);
  42. FreeWorkItem(wip);
  43. return;
  44. }
  45. }
  46. else
  47. {
  48. // *** This is the continuation of a started broadcast ***
  49. // check if this was the last packet in the response
  50. GETSHORT2USHORT(&pktlen, wip->Packet + IPXH_LENGTH);
  51. if(pktlen < FULL_PACKET) {
  52. // we are done
  53. goto ResetPeriodicBcast;
  54. }
  55. // check the time stamp to determine if an interpacket gap is needed
  56. delay = (wip->TimeStamp + 55) - GetTickCount();
  57. if(delay < MAXULONG/2) {
  58. // have to wait this delay
  59. IfRefStartWiTimer(wip, delay);
  60. return;
  61. }
  62. }
  63. // make the gen response packet
  64. pktlen = MakeRipGenResponsePacket(wip,
  65. bcastnode,
  66. ripsocket);
  67. if(pktlen == EMPTY_PACKET) {
  68. // we are done
  69. goto ResetPeriodicBcast;
  70. }
  71. // send the bcast and increment the ref counter
  72. if(IfRefSendSubmit(wip) != NO_ERROR) {
  73. // can't send on this interface now -> requeue in timer and retry
  74. goto ResetPeriodicBcast;
  75. }
  76. return;
  77. ResetPeriodicBcast:
  78. // no more routes to advertise for this general response
  79. CloseEnumHandle(EnumHandle);
  80. EnumHandle = NULL;
  81. // enqueue for the bcast time in the timer queue
  82. IfRefStartWiTimer(wip, PERIODIC_UPDATE_INTERVAL_MILISECS(icbp));
  83. }
  84. /*++
  85. Function: IfPeriodicSendGenRequest
  86. Descr: called to send periodically a gen request on a wan line for
  87. a remote or local workstation dial. This is mainly to remain
  88. compatible with NT 3.51 rip router which requires a gen request
  89. in order to send its internal node (if client) or routing table
  90. if server.
  91. Remark: called with the interface lock held
  92. --*/
  93. VOID
  94. IfPeriodicGenRequest(PWORK_ITEM wip)
  95. {
  96. PICB icbp;
  97. icbp = wip->icbp;
  98. if(icbp->IfStats.RipIfOperState != OPER_STATE_UP) {
  99. FreeWorkItem(wip);
  100. return;
  101. }
  102. SendRipGenRequest(icbp);
  103. // enqueue the periodic send bcast in the timer queue
  104. IfRefStartWiTimer(wip, 60000);
  105. }