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.

258 lines
5.7 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. svcinfo.hxx
  5. Abstract:
  6. contains class definitions for service location classes.
  7. Author:
  8. Madan Appiah (madana) 15-May-1995
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. Sean Woodward (t-seanwo) 26-October-1997 ADSI Update
  13. --*/
  14. #ifndef _SVCINFO_
  15. #define _SVCINFO_
  16. /*++
  17. Class Description:
  18. Class definition for internet service info.
  19. Private Member functions:
  20. ComputeServiceInfoSize : computes the size of embedded service info
  21. buffer.
  22. CopyServiceInfo : copies the service info structure to emdedded
  23. service info buffer.
  24. Public Member functions:
  25. EMBED_SERVICE_INFO : constructs a service info object.
  26. ~EMBED_SERVICE_INFO : destructs a service info object.
  27. GetStatus : returns status of the object.
  28. SetServiceInfo : updates the service info object.
  29. SetServiceState :updates service state in the service info object.
  30. GetServiceMask : retrieves service mask.
  31. GetServiceInfoLength : retrieves the size of the embedded service
  32. info.
  33. GetServiceInfoBuffer : retrieves the buffer pointer of the embedded
  34. service info.
  35. GetServiceInfo : unmarshells the embedded buffer and retrieves service
  36. info structure.
  37. --*/
  38. class EMBED_SERVICE_INFO {
  39. private:
  40. DWORD _Status;
  41. DWORD _ServiceInfoLength;
  42. LPBYTE _ServiceInfoBuffer;
  43. DWORD _AllottedBufferSize;
  44. INET_SERVICE_STATE *_ServiceState;
  45. LPSTR _ServiceComment;
  46. ULONGLONG UNALIGNED *_ServiceMask;
  47. CRITICAL_SECTION _ServiceObjCritSect;
  48. DWORD ComputeServiceInfoSize( LPINET_SERVICE_INFO ServiceInfo );
  49. VOID CopyServiceInfo( LPINET_SERVICE_INFO ServiceInfo );
  50. VOID LockServiceObj( VOID ) {
  51. EnterCriticalSection( &_ServiceObjCritSect );
  52. }
  53. VOID UnlockServiceObj( VOID ) {
  54. LeaveCriticalSection( &_ServiceObjCritSect );
  55. }
  56. public:
  57. EMBED_SERVICE_INFO( LPINET_SERVICE_INFO ServiceInfo );
  58. EMBED_SERVICE_INFO( LPBYTE InfoBuffer, DWORD InfoBufferLength );
  59. ~EMBED_SERVICE_INFO( VOID );
  60. DWORD GetStatus( VOID ) {
  61. return( _Status );
  62. }
  63. DWORD SetServiceInfo( LPINET_SERVICE_INFO ServiceInfo );
  64. VOID SetServiceState( INET_SERVICE_STATE SvcState ) {
  65. *_ServiceState = SvcState;
  66. return;
  67. }
  68. ULONGLONG GetServiceMask( VOID ) {
  69. return( *_ServiceMask );
  70. }
  71. DWORD GetServiceInfoLength( VOID ) {
  72. return( _ServiceInfoLength );
  73. }
  74. DWORD GetServiceInfoBuffer(
  75. LPBYTE Buffer,
  76. DWORD BufferLength,
  77. DWORD *ReturnBufferLength ) {
  78. LockServiceObj();
  79. if( BufferLength < _ServiceInfoLength ) {
  80. UnlockServiceObj();
  81. return( ERROR_INSUFFICIENT_BUFFER );
  82. }
  83. memcpy(Buffer, _ServiceInfoBuffer, _ServiceInfoLength );
  84. *ReturnBufferLength = _ServiceInfoLength;
  85. UnlockServiceObj();
  86. return( ERROR_SUCCESS );
  87. }
  88. DWORD GetServiceInfo( LPINET_SERVICE_INFO *ServiceInfo );
  89. }
  90. typedef EMBED_SERVICE_INFO, *LPSERVICE_OBJECT;
  91. //
  92. // service object list entry.
  93. //
  94. typedef struct _EMBED_SERVICE_ENTRY {
  95. LIST_ENTRY NextEntry ;
  96. LPSERVICE_OBJECT ServiceObject;
  97. } EMBED_SERVICE_ENTRY, *LPEMBED_SERVICE_ENTRY;
  98. /*++
  99. Class Description:
  100. Class definition for internet server info.
  101. Private Member functions:
  102. IsServiceEntryExist : finds a service is in the server services list.
  103. Public Member functions:
  104. EMBED_SERVER_INFO : constructs a server info object.
  105. ~EMBED_SERVER_INFO : destructs a server info object.
  106. GetStatus : returns status of the object.
  107. SetServerLoad : sets server load value in the server info object.
  108. AddService : adds a new service or updates the info existing server in
  109. the server info object.
  110. RemoveService :removes a service from the server info object.
  111. SetServiceState : sets the state of the existing service in the server
  112. info object.
  113. ComputeResponseLength : computes the length of the response message
  114. (containing server info and all services info in the embeded
  115. formatted) sent to a client.
  116. MakeResponseMessage : makes a response message sent to a client.
  117. --*/
  118. class EMBED_SERVER_INFO {
  119. private:
  120. DWORD _Status;
  121. DWORD _ServerInfoLength;
  122. LPBYTE _ServerInfoBuffer;
  123. DWORD _AllottedBufferSize;
  124. INET_VERSION_NUM *_VersionNum;
  125. DWORD *_ServerLoad;
  126. ULONGLONG UNALIGNED *_ServicesMask;
  127. LPSTR _ServerName;
  128. DWORD *_NumServices;
  129. LIST_ENTRY _ServicesList;
  130. CRITICAL_SECTION _ServerObjCritSect;
  131. BOOL IsServiceEntryExist(
  132. ULONGLONG ServiceMask,
  133. LPEMBED_SERVICE_ENTRY *ServiceEntry
  134. );
  135. VOID LockServerObj( VOID ) {
  136. EnterCriticalSection( &_ServerObjCritSect );
  137. }
  138. VOID UnlockServerObj( VOID ) {
  139. LeaveCriticalSection( &_ServerObjCritSect );
  140. }
  141. public:
  142. EMBED_SERVER_INFO(
  143. WORD MajorVersion,
  144. WORD MinorVersion,
  145. LPSTR ServerName );
  146. EMBED_SERVER_INFO(
  147. LPBYTE ResponseBuffer,
  148. DWORD ResponseBufferLength );
  149. ~EMBED_SERVER_INFO( VOID );
  150. DWORD GetStatus( VOID ) {
  151. return( _Status );
  152. }
  153. VOID SetServerLoad ( DWORD SrvLoad ) {
  154. *_ServerLoad = SrvLoad;
  155. return;
  156. }
  157. ULONGLONG GetServicesMask( VOID ) {
  158. return(*_ServicesMask);
  159. }
  160. DWORD AddService ( LPINET_SERVICE_INFO ServiceInfo );
  161. DWORD RemoveService( ULONGLONG ServiceMask );
  162. DWORD SetServiceState(
  163. ULONGLONG ServiceMask,
  164. INET_SERVICE_STATE ServiceState );
  165. DWORD ComputeResponseLength( VOID );
  166. DWORD MakeResponseMessage( LPBYTE MessageBuffer, DWORD BufferLength );
  167. DWORD GetServerInfo( LPINET_SERVER_INFO *ServerInfo );
  168. };
  169. #endif // _SVCINFO_
  170.