1 //%2003////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 //==============================================================================
26 // Author: Paulo F. Borges (pfborges@wowmail.com)
28 // Modified By: Jair Francisco T. dos Santos (t.dos.santos.francisco@non.hp.com)
29 //==============================================================================
30 // Based on DNSService.h file
31 //%/////////////////////////////////////////////////////////////////////////////
35 //------------------------------------------------------------------------------
37 //------------------------------------------------------------------------------
39 #include <Pegasus/Common/Config.h>
40 #include <Pegasus/Common/String.h>
41 #include <Pegasus/Common/CIMDateTime.h>
42 #include <Pegasus/Common/OperationContext.h>
43 #include <Pegasus/Common/CIMName.h>
46 //------------------------------------------------------------------------------
47 PEGASUS_USING_PEGASUS;
51 static const String NTP_ROLE_CLIENT("server");
54 #define CLASS_NAME CIMName ("PG_NTPService")
55 #define SYSTEM_CREATION_CLASS_NAME CIMName ("CIM_UnitaryComputerSystem")
56 #define CREATION_CLASS_NAME CIMName ("PG_NTPService")
57 static const String NTP_CAPTION("NTP daemon");
58 static const String NTP_DESCRIPTION("Describes the Network Time Protocol (NTP) daemon");
60 // Insert MOF property definitions
61 static const int MAX_KEYS = 4;
62 static const String PROPERTY_SYSTEM_CREATION_CLASS_NAME("SystemCreationClassName");
63 static const String PROPERTY_SYSTEM_NAME("SystemName");
64 static const String PROPERTY_CREATION_CLASS_NAME("CreationClassName");
65 static const String PROPERTY_NAME("Name");
66 static const String PROPERTY_CAPTION("Caption");
67 static const String PROPERTY_DESCRIPTION("Description");
68 static const String PROPERTY_SERVER_ADDRESS("ServerAddress");
70 //------------------------------------------------------------------------------
71 // Class [NTPService] Definition
72 //------------------------------------------------------------------------------
76 //Constructor/Destructor
82 // Public Functions - Interface
85 // This function retrieve TRUE, if user have permissions, otherwise FALSE
86 Boolean AccessOk(const OperationContext & context);
88 // This function retrieves the system name
89 Boolean getSystemName(String & hostName);
91 // This function retrieves the local host name
92 Boolean getLocalHostName(String & hostName);
94 // This function returns TRUE if the Service Name is valid
95 // returns the Name property on the 'strValue' argument
96 Boolean getNTPName(String & strValue);
98 // This function returns TRUE if the Caption is valid
99 // returns the Caption property on the 'strValue' argument
100 Boolean getCaption(String & strValue);
102 // This function returns TRUE if the Description is valid
103 // returns the Description property on the 'strValue' argument
104 Boolean getDescription(String & strValue);
106 // This function returns TRUE if the ServerAddress is valid
107 // returns the ServerAddress property on the 'strValue' argument
108 Boolean getServerAddress(Array<String> & strValue);
116 // This function retrieves the NTP information from "/etc/ntp.conf" file
117 Boolean getNTPInfo(void);
119 // This function resolves host name servers
120 Boolean getHostName(String serverAddress, String & nameServer);
122 // This function verify if host is address
123 Boolean isHostAddress(String host);
125 // This function resolves address servers
126 Boolean getHostAddress(String nameServer, String & serverAddress);
128 // This function retrieves the key value from line buffer
129 Boolean getKeyValue(String strLine, String & strValue);
135 Array<String> ntpServerAddress;