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.

144 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. D:\nt\private\ntos\tdi\rawwan\core\vc.c
  5. Abstract:
  6. Routines that manage NDIS VC objects.
  7. Revision History:
  8. Who When What
  9. -------- -------- ----------------------------------------------
  10. arvindm 05-05-97 Created
  11. Notes:
  12. --*/
  13. #include <precomp.h>
  14. #define _FILENUMBER ' CV'
  15. PRWAN_NDIS_VC
  16. RWanAllocateVc(
  17. IN PRWAN_NDIS_AF pAf,
  18. IN BOOLEAN IsOutgoing
  19. )
  20. /*++
  21. Routine Description:
  22. Allocate and initialize an NDIS VC endpoint on the specified
  23. Address Family. If it is an "outgoing" VC, we also request
  24. NDIS to allocate a handle for it.
  25. Arguments:
  26. pAf - Points to NDIS AF block
  27. IsOutgoing - This VC is for an outgoing call
  28. Return Value:
  29. Pointer to VC if successful, NULL otherwise.
  30. --*/
  31. {
  32. PRWAN_NDIS_VC pVc;
  33. NDIS_STATUS Status;
  34. RWAN_ALLOC_MEM(pVc, RWAN_NDIS_VC, sizeof(RWAN_NDIS_VC));
  35. if (pVc != NULL)
  36. {
  37. RWAN_ZERO_MEM(pVc, sizeof(RWAN_NDIS_VC));
  38. RWAN_SET_SIGNATURE(pVc, nvc);
  39. pVc->pNdisAf = pAf;
  40. pVc->MaxSendSize = 0; // Initialize.
  41. RWAN_INIT_LIST(&(pVc->NdisPartyList));
  42. if (IsOutgoing)
  43. {
  44. //
  45. // Request the Call manager and Miniport to create a VC.
  46. //
  47. Status = NdisCoCreateVc(
  48. pAf->pAdapter->NdisAdapterHandle,
  49. pAf->NdisAfHandle,
  50. (NDIS_HANDLE)pVc,
  51. &(pVc->NdisVcHandle)
  52. );
  53. if (Status == NDIS_STATUS_SUCCESS)
  54. {
  55. //
  56. // Add this VC to the list on the AF Block.
  57. //
  58. RWAN_ACQUIRE_AF_LOCK(pAf);
  59. RWAN_INSERT_TAIL_LIST(&(pAf->NdisVcList),
  60. &(pVc->VcLink));
  61. RWanReferenceAf(pAf); // New outgoing VC ref
  62. RWAN_RELEASE_AF_LOCK(pAf);
  63. }
  64. else
  65. {
  66. RWAN_FREE_MEM(pVc);
  67. pVc = NULL;
  68. }
  69. }
  70. else
  71. {
  72. //
  73. // Add this VC to the list on the AF Block.
  74. //
  75. RWAN_ACQUIRE_AF_LOCK(pAf);
  76. RWAN_INSERT_TAIL_LIST(&(pAf->NdisVcList),
  77. &(pVc->VcLink));
  78. RWanReferenceAf(pAf); // New incoming VC ref
  79. RWAN_RELEASE_AF_LOCK(pAf);
  80. }
  81. }
  82. return (pVc);
  83. }
  84. VOID
  85. RWanFreeVc(
  86. IN PRWAN_NDIS_VC pVc
  87. )
  88. /*++
  89. Routine Description:
  90. Free a VC structure.
  91. Arguments:
  92. pVc - Pointer to VC to be freed.
  93. Return Value:
  94. None
  95. --*/
  96. {
  97. RWAN_FREE_MEM(pVc);
  98. }