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.

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