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.

204 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. addrgen.h
  5. Abstract:
  6. This module provides the APIs for allocation and release of multicast addresses and ports.
  7. Author:
  8. B. Rajeev (rajeevb) 17-mar-1997
  9. Revision History:
  10. --*/
  11. #ifndef __ADDRESS_GENERATION__
  12. #define __ADDRESS_GENERATION__
  13. #ifndef __ADDRGEN_LIB__
  14. #define ADDRGEN_LIB_API //__declspec(dllimport)
  15. #else
  16. #define ADDRGEN_LIB_API // __declspec(dllexport)
  17. #endif
  18. #ifdef __cplusplus
  19. extern "C"
  20. {
  21. #endif // __cplusplus
  22. /*++
  23. These values are a short representation for well known port ranges (port type).
  24. ++*/
  25. #define OTHER_PORT 0 // none of the well-known ranges, uses MSA_PORT_GROUP to specify the range
  26. #define AUDIO_PORT 1 // port range [16384..32767) - note: 32767 is NOT included
  27. #define WHITEBOARD_PORT 2 // port range [32768..49152)
  28. #define VIDEO_PORT 3 // port range [49152.. 65535) - note: 65535 is NOT included
  29. /*++
  30. Type Description:
  31. Represents a multicast address scope.
  32. Multicast addresses may be allocated within such a scope
  33. Members:
  34. ScopeType - One of the well-known multicast scope types. In such a case, the value
  35. of other members is predefined and is not interpreted. If not, it takes
  36. the value OTHER_MULTICAST_SCOPE.
  37. BaseAddress - A 32 bit value, when ORed with the NetworkMask, provides the
  38. prefix of all multicast addresses allocated within the scope.
  39. NetworkMask - A 32 bit value that specifies which bits in the the BaseAddress remain on.
  40. NameString - Points to a human readable string.
  41. Infosize - Size of the Info field.
  42. Info - Points to more information about the address scope.
  43. Remarks:
  44. All values are in host byte order
  45. --*/
  46. typedef struct _MSA_MULTICAST_ADDRESS_SCOPE
  47. {
  48. DWORD ScopeType;
  49. DWORD BaseAddress;
  50. DWORD NetworkMask;
  51. BSTR NameString;
  52. DWORD Infosize;
  53. LPVOID Info;
  54. } MSA_MULTICAST_ADDRESS_SCOPE, *LPMSA_MULTICAST_ADDRESS_SCOPE;
  55. /*++
  56. Type Description:
  57. Represents a range of ports within which ([StartPort..EndPort]) a port must be allocated.
  58. Members:
  59. PortType - One of the well-known port types (audio, video etc.). In such a case, the value
  60. of other members is predefined and is not interpreted. If not, it takes the
  61. value OTHER_PORT.
  62. StartPort - First port of the range that may be allocated.
  63. EndPort - Last port of the range that may be allocated.
  64. Remarks:
  65. All values are in host byte order
  66. --*/
  67. typedef struct _MSA_PORT_GROUP
  68. {
  69. DWORD PortType;
  70. WORD StartPort;
  71. WORD EndPort;
  72. } MSA_PORT_GROUP, *LPMSA_PORT_GROUP;
  73. /*++
  74. Routine Description:
  75. This routine is used to reserve as well as renew local ports.
  76. Arguments:
  77. lpScope - Supplies a pointer to structure describing the port group.
  78. IsRenewal - Supplies a boolean value that describes whether the allocation call
  79. is a renewal attempt or a new allocation request.
  80. NumberOfPorts - Supplies the number of ports requested.
  81. lpFirstPort - Supplies the first port to be renewed in case of renewal
  82. (strictly an IN parameter).
  83. Returns the first port allocated otherwise
  84. (strictly an OUT parameter).
  85. Return Value:
  86. BOOL - TRUE if successful, FALSE otherwise. Further error information can be obtained by
  87. calling GetLastError(). These error codes are -
  88. NO_ERROR - The call was successful.
  89. MSA_INVALID_PORT_GROUP - The port group information is invalid (either if the PortType is
  90. invalid or the port range is unacceptable)
  91. MSA_RENEWAL_FAILED - System unable to renew the given ports.
  92. ERROR_INVALID_PARAMETER - One or more parameters is invalid.
  93. MSA_INVALID_DATA - One or more parameters has an invalid value.
  94. Remarks:
  95. All values are in host byte order
  96. --*/
  97. ADDRGEN_LIB_API BOOL WINAPI
  98. MSAAllocatePorts(
  99. IN LPMSA_PORT_GROUP lpPortGroup,
  100. IN BOOL IsRenewal,
  101. IN WORD NumberOfPorts,
  102. IN OUT LPWORD lpFirstPort
  103. );
  104. /*++
  105. Routine Description:
  106. This routine is used to release previously allocated multicast ports.
  107. Arguments:
  108. NumberOfPorts - Supplies the number of ports to be released.
  109. StartPort - Supplies the starting port of the port range to be released.
  110. Return Value:
  111. BOOL - TRUE if successful, FALSE otherwise. Further error information can be obtained by
  112. calling GetLastError(). These error codes are -
  113. NO_ERROR - The call was successful.
  114. MSA_NO_SUCH_RESERVATION - There is no such reservation.
  115. ERROR_INVALID_PARAMETER - One or more parameters is invalid.
  116. MSA_INVALID_DATA - One or more parameters has an invalid value.
  117. Remarks:
  118. if range [a..c] is reserved and the release is attempted on [a..d], the call fails with
  119. MSA_NO_SUCH_RESERVATION without releasing [a..c].
  120. All values are in host byte order
  121. ++*/
  122. ADDRGEN_LIB_API BOOL WINAPI
  123. MSAReleasePorts(
  124. IN WORD NumberOfPorts,
  125. IN WORD StartPort
  126. );
  127. // error codes
  128. #define MSA_INVALID_DATA 1 // value of one or more parameters is invalid
  129. #define MSA_NOT_AVAILABLE 2 // resources unavailable
  130. #define MSA_INVALID_PORT_GROUP 3 // the specified port group is invalid
  131. #ifdef __cplusplus
  132. }
  133. #endif // __cplusplus
  134. #endif // __ADDRESS_GENERATION__