1 karl 1.13 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.11 // 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 karl 1.9 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.11 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.12 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.13 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.2 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.5 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 mike 1.2 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
|
21 kumpf 1.5 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.2 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 kumpf 1.5 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 mike 1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
|
34 kumpf 1.3 #include "sr_conf.h"
35 #include <stdio.h>
36 #include <stdarg.h>
37 #include <unistd.h>
38 #include <fcntl.h>
39 #include <string.h>
40 #include <stdlib.h>
41
42 #include <sys/types.h>
43 #include <sys/sem.h>
44 #include <sys/stat.h>
45 #include <sys/param.h>
46
47 #include <signal.h>
48 #include <netinet/in.h>
49 #include <sys/socket.h>
50 #include <arpa/inet.h>
51 #include <netdb.h>
52 #include <errno.h>
53
54 #include "sr_snmp.h"
55 kumpf 1.3 #include "comunity.h"
56 #include "v2clssc.h"
57 #include "sr_trans.h"
58 #include "context.h"
59 #include "method.h"
60 #include "diag.h"
61 #include "subagent.h"
62 #include "agentsoc.h"
63 #include "evq.h"
64 #include "sig.h"
65
|
66 mike 1.2 #include <iostream>
67 #include <Pegasus/Common/Config.h>
68
69 #include "snmpDeliverTrap.h"
70
|
71 kumpf 1.6 PEGASUS_NAMESPACE_BEGIN
72
|
73 humberto 1.7 // l10n
74 // lots of hacking to make up these messages
|
75 kumpf 1.6
|
76 kumpf 1.15 static const char _MSG_INITSUBAGENT_FAILED[] =
77 "InitSubagent Failed to initialize";
78 static const char _MSG_INITSUBAGENT_FAILED_KEY[] =
79 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate."
80 "_MSG_INITSUBAGENT_FAILED";
81
82 static const char _MSG_INVALID_TRAPOID[] = "Invalid trapOid.";
83 static const char _MSG_INVALID_KEY[] =
84 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID";
85
86 static const char _MSG_DESTINATION_NOT_FOUND[] =
87 "Can not find trap destination.";
88 static const char _MSG_DESTINATION_NOT_FOUND_KEY[] =
89 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate."
90 "_MSG_DESTINATION_NOT_FOUND";
91
92 static const char _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED[] =
93 "Host Name and IPV4 Address are the only supported TargetHostFormat "
94 "values.";
95 static const char _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED_KEY[] =
96 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate."
97 kumpf 1.15 "_MSG_TARGETHOSTFORMAT_NOT_SUPPORTED";
98
99 static const char _MSG_INVALID_SECURITY_NAME[] = "Invalid SNMP SecurityName.";
100 static const char _MSG_INVALID_SECURITY_NAME_KEY[] =
101 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID";
|
102 kumpf 1.6
|
103 kumpf 1.15 static const char _MSG_INVALID_OCTET_VALUE[] =
|
104 kumpf 1.6 "Invalid octet value in trap destination.";
|
105 kumpf 1.15 static const char _MSG_INVALID_OCTET_VALUE_KEY[] =
106 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate."
107 "_MSG_INVALID_OCTET_VALUE";
|
108 kumpf 1.6
|
109 kumpf 1.15 static const char _MSG_CREATE_OCTET_FAILED[] =
|
110 humberto 1.8 "Creation of empty 4 length OctetString failed.";
|
111 kumpf 1.15 static const char _MSG_CREATE_OCTET_FAILED_KEY[] =
112 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate."
113 "_MSG_CREATE_OCTET_FAILED";
114
115 static const char _MSG_INVALID_ENTERPRISEOID[] = "Invalid enterpriseOid.";
116 static const char _MSG_INVALID_ENTERPRISEOID_KEY[] =
117 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID";
118
119 static const char _MSG_INVALID_PROPERTYOID[] = "Invalid OID of CIM Property.";
120 static const char _MSG_INVALID_PROPERTYOID_KEY[] =
121 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate."
122 "_MSG_INVALID_PROPERTYOID";
123
124 static const char _MSG_INVALID_PROPERTYVALUE[] =
125 "Invalid value of CIM Property.";
126 static const char _MSG_INVALID_PROPERTYVALUE_KEY[] =
127 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate."
128 "_MSG_INVALID_PROPERTY";
|
129 humberto 1.7
|
130 kumpf 1.15 static const char _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE[] =
|
131 humberto 1.8 "Failed to MakeVarBindWithValue for type OCTET_PRIM_TYPE.";
|
132 kumpf 1.15 static const char _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE_KEY[] =
133 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate."
134 "_MSG_MAKE_FAILED_FOR_OCTET_PRIM_TYPE";
|
135 humberto 1.8
|
136 kumpf 1.15 static const char _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE[] =
|
137 humberto 1.8 "Failed to MakeVarBindWithValue for type OBJECT_ID_TYPE.";
|
138 kumpf 1.15 static const char _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE_KEY[] =
139 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate."
140 "_MSG_MAKE_FAILED_FOR_OBJECT_ID_TYPE";
|
141 humberto 1.8
|
142 kumpf 1.15 static const char _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE[] =
|
143 humberto 1.8 "Failed to MakeVarBindWithValue for type INTEGER_TYPE.";
|
144 kumpf 1.15 static const char _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE_KEY[] =
145 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate."
146 "_MSG_MAKE_FAILED_FOR_INTEGER_TYPE";
|
147 kumpf 1.6
|
148 kumpf 1.15 static const char _MSG_VERSION_NOT_SUPPORTED[] =
|
149 humberto 1.8 "SNMPv1 Trap and SNMPv2C Trap are the only supported SNMPVersion values.";
|
150 kumpf 1.15 static const char _MSG_VERSION_NOT_SUPPORTED_KEY[] =
151 "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate."
152 "_MSG_VERSION_NOT_SUPPORTED";
|
153 mike 1.2
154 class snmpDeliverTrap_emanate : public snmpDeliverTrap
155 {
156 public:
|
157 kumpf 1.3
158 snmpDeliverTrap_emanate();
159
160 ~snmpDeliverTrap_emanate();
161
162 void initialize();
163
|
164 kumpf 1.14 void terminate();
165
|
166 kumpf 1.6 /**
|
167 kumpf 1.15 Send snmp trap to the target.
168 @param trapOid snmp trap OID
169 @param securityName either an SNMPv1 or SNMPv2c community
170 name or an SNMPv3 user name
171 @param targetHost address of the trap/infom destination
172 @param targetHostFormat targetHost format
173 @param otherTargetHostFormat other target format type
174 @param portNumber UDP port number to send the trap/inform
175 @param snmpVersion snmp version and format to use to send
176 the indication
177 @param engineID snmp engine ID used to create the SNMPv3
178 inform
179 @param vbOids VarBind OIDs
180 @param vbTypes VarBind types
181 @param vbValues VarBind values
|
182 kumpf 1.6 */
|
183 mike 1.2 void deliverTrap(
|
184 kumpf 1.6 const String& trapOid,
185 const String& securityName,
186 const String& targetHost,
187 const Uint16& targetHostFormat,
188 const String& otherTargetHostFormat,
189 const Uint32& portNumber,
190 const Uint16& snmpVersion,
191 const String& engineID,
|
192 kumpf 1.10 const Array<String>& vbOids,
193 const Array<String>& vbTypes,
194 const Array<String>& vbValues);
|
195 kumpf 1.6
196 private:
|
197 kumpf 1.15 char* _getIPAddress(const CString& hostName);
|
198 kumpf 1.6 Boolean _isValidOctet(const Uint32& octetValue);
199
200 /**
201 Values for the TargetHostFormat property of the
|
202 kumpf 1.15 PG_IndicationHandlerSNMPMapper class.
|
203 kumpf 1.6 */
|
204 kumpf 1.15 enum TargetHostFormat
205 {
206 _OTHER = 1,
207 _HOST_NAME = 2,
208 _IPV4_ADDRESS = 3,
209 _IPV6_ADDRESS = 4
210 };
211
212 enum SNMPVersion
213 {
214 _SNMPv1_TRAP = 2,
215 _SNMPv2C_TRAP = 3,
216 _SNMPv2C_INFORM = 4,
217 _SNMPv3_TRAP = 5,
218 _SNMPv3_INFORM = 6
219 };
|
220 mike 1.2 };
221
222 PEGASUS_NAMESPACE_END
|