PEP 55 Update license on source files to current license text and date
[tpot/pegasus/.git] / src / Providers / ManagedSystem / IP / IP_HPUX.h
1 //%2003////////////////////////////////////////////////////////////////////////
2 //
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.
7 //
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:
14 // 
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.
23 //
24 //==============================================================================
25 //
26 // Author: Christopher Neufeld <neufeld@linuxcare.com>
27 //         David Kennedy       <dkennedy@linuxcare.com>
28 //
29 // Modified By:
30 //         David Kennedy       <dkennedy@linuxcare.com>
31 //         Christopher Neufeld <neufeld@linuxcare.com>
32 //         Al Stone, Hewlett-Packard Company <ahs3@fc.hp.com>
33 //         Jim Metcalfe, Hewlett-Packard Company
34 //         Carlos Bonilla, Hewlett-Packard Company
35 //         Mike Glantz, Hewlett-Packard Company <michael_glantz@hp.com>
36 //         Lyle Wilkinson, Hewlett-Packard Company <lyle_wilkinson@hp.com>
37 //
38 //%////////////////////////////////////////////////////////////////////////////
39
40 #ifndef PG_IP_HPUX_H
41 #define PG_IP_HPUX_H
42
43 // =============================================================================
44 // Includes.
45 // =============================================================================
46
47 #include <Pegasus/Provider/CIMInstanceProvider.h>
48 #include <unistd.h>       // gethostname
49 #include <sys/socket.h>   // gethostbyname
50 #include <netinet/in.h>   // gethostbyname
51 #include <netdb.h>        // gethostbyname
52 extern "C" {
53 #define __STDC__
54 #include <sys/mib.h>      // open_mib, close_mib, get_mib_info
55 }
56 #include <arpa/inet.h>    // ioctl
57 #include <net/if.h>       // ioctl
58 #include <string.h>       // strerror
59 #include <errno.h>        // errno
60 #include <vector>         // vector container
61
62 PEGASUS_USING_STD;
63 PEGASUS_USING_PEGASUS;
64
65 // =============================================================================
66 // Defines.
67 // =============================================================================
68
69 // Support IP PROTOCOL TYPES
70
71 #define PROTOCOL_IPV4  "IPv4"
72 #define PROTOCOL_IPV6  "IPv6"
73
74
75 // =============================================================================
76 // Type Definitions.
77 // =============================================================================
78
79 class IPInterface
80 {
81
82   public:
83
84     IPInterface();
85     ~IPInterface();
86
87     // Property Accessor Methods
88
89     Boolean getCaption(String&) const;
90     Boolean getDescription(String&) const;
91     Boolean getInstallDate(CIMDateTime&) const;
92     Boolean getName(String&) const;
93     Boolean getStatus(String&) const;
94     Boolean getNameFormat(String&) const;
95     Boolean getProtocolType(Uint16&) const;
96     Boolean getOtherTypeDescription(String&) const;
97     Boolean getAddress(String&) const;
98     Boolean getSubnetMask(String&) const;
99     Boolean getAddressType(Uint16&) const;
100     Boolean getIPVersionSupport(Uint16&) const;
101     Boolean getFrameType(Uint16&) const;
102
103     // System name is the same for all instances
104     static Boolean getSystemName(String&);
105
106     // Method to Get the Simple Interface Name before the colon (":")
107     String get_LANInterfaceName(void) const;
108
109     // Method to determine if this IP interface ties to a LAN Interface
110     Boolean bindsToLANInterface(void) const;
111
112     // Method to obtain/save the fully qualified host name
113     static void initSystemName(void);
114
115     // Methods to Load Instances
116
117     void set_address(const String& addr);
118     void set_subnetMask(const String& snm);
119     void set_protocol(const String& proto);
120     void set_simpleIfName(const String& name);
121
122   private:
123
124     String _address;           // dot (IPv4) or colon (IPv6) notation
125     String _subnetMask;        // dot (IPv4) or colon (IPv6) notation
126     String _protocol;          // e.g. IPv4, IPv6
127     String _simpleIfName;      // e.g. lan0, lan0:1, lan1, lo0
128     static String _hostname;   // fully qualified hostname
129
130 };
131
132 class InterfaceList
133 {
134
135   public:
136
137     InterfaceList();    // Constructor - should load list of interfaces
138
139     ~InterfaceList();
140
141     // Method to get a particular element based on an Interface Name
142     // Returns false if one is not found.
143     Boolean findInterface(const String &ifName,
144                           IPInterface &ipIfInst ) const;
145
146     // Method to get a particular element based on an index
147     IPInterface getInterface(const int index) const;
148  
149     // Number of Elements in the InterfaceList
150     int size(void) const;
151
152   private:
153
154     vector<IPInterface> _ifl;
155
156 };
157
158 class IPRoute
159 {
160
161   public:
162
163     IPRoute();
164     ~IPRoute();
165
166     // Property Accessor Methods
167
168     Boolean getCaption(String&) const;
169     Boolean getDescription(String&) const;
170     Boolean getInstallDate(CIMDateTime&) const;
171     Boolean getName(String&) const;
172     Boolean getStatus(String&) const;
173     Boolean getDestinationAddress(String&) const;
174     Boolean getDestinationMask(String&) const;
175     Boolean getNextHop(String&) const;
176     Boolean getIsStatic(Boolean&) const;
177     Boolean getAddressType(Uint16&) const;
178
179     // Methods to Load Instances
180
181     void set_destAddr(const String& addr);
182     void set_destMask(const String& mask);
183     void set_nextHop(const String& nhop);
184     void set_protocolType(const String& pt);
185
186   private:
187
188     String _destAddr;          // dot (IPv4) or colon (IPv6) notation
189     String _destMask;          // dot (IPv4) or colon (IPv6) notation
190     String _nextHop;           // dot (IPv4) or colon (IPv6) notation
191     String _protocolType;      // IPv4 or IPv6
192     static String _hostname;   // fully qualified hostname
193
194 };
195
196 class RouteList
197 {
198
199   public:
200
201     RouteList();        // Constructor - should load list of interfaces
202
203     ~RouteList();
204
205     // Method to find a particular IP Route based on a Destination
206     // Address, Destination Mask, and Address Type (e.g. IPv4):
207     // Returns false if a match is not found.
208     Boolean findRoute(const String &destAddr,
209                       const String &destMask,
210                       const Uint16 &addrType,
211                            IPRoute &ipRInst ) const;
212
213     // Method to get a particular element based on an index
214     IPRoute getRoute(const int index) const;
215  
216     // Number of Elements in the IP Route
217     int size(void) const;
218
219   private:
220
221     vector<IPRoute> _iprl;
222
223 };
224
225 #endif  /* #ifndef PG_IP_HPUX_H */