-
Notifications
You must be signed in to change notification settings - Fork 17
/
types_lan_params.go
388 lines (342 loc) · 12.9 KB
/
types_lan_params.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
package ipmi
import (
"fmt"
"net"
"strings"
)
// Table 23-4, LAN Configuration Parameters
// Parameter selector
type LanParamSelector uint8
const (
LanParam_SetInProgress LanParamSelector = 0
LanParam_AuthTypeSupported LanParamSelector = 1
LanParam_AuthTypeEnables LanParamSelector = 2
LanParam_IP LanParamSelector = 3
LanParam_IPSource LanParamSelector = 4
LanParam_MAC LanParamSelector = 5 // read only
LanParam_SubnetMask LanParamSelector = 6
LanParam_IPv4HeaderParams LanParamSelector = 7
LanParam_PrimaryRMCPPort LanParamSelector = 8
LanParam_SecondaryRMCPPort LanParamSelector = 9
LanParam_ARPControl LanParamSelector = 10
LanParam_GratuituousARPInterval LanParamSelector = 11
LanParam_DefaultGatewayIP LanParamSelector = 12
LanParam_DefaultGatewayMAC LanParamSelector = 13
LanParam_BackupGatewayIP LanParamSelector = 14
LanParam_BackupGatewayMAC LanParamSelector = 15
LanParam_CommunityString LanParamSelector = 16
LanParam_AlertDestinationsNumber LanParamSelector = 17
LanParam_AlertDestinationType LanParamSelector = 18
LanParam_AlertDestinationAddress LanParamSelector = 19
LanParam_VLANID LanParamSelector = 20
LanParam_VLANPriority LanParamSelector = 21
LanParam_CipherSuiteEntrySupport LanParamSelector = 22
LanParam_CipherSuiteEntries LanParamSelector = 23
LanParam_CihperSuitePrivilegeLevels LanParamSelector = 24
LanParam_AlertDestinationVLAN LanParamSelector = 25 // read only
LanParam_BadPassordThreshold LanParamSelector = 26
LanParam_IP6Support LanParamSelector = 50
LanParam_IP6Enables LanParamSelector = 51
LanParam_IP6StaticTrafficClass LanParamSelector = 52
LanParam_IP6StaticHopLimit LanParamSelector = 53
LanParam_IP6FlowLabel LanParamSelector = 54
LanParam_IP6Status LanParamSelector = 55
LanParam_IP6StaticAddr LanParamSelector = 56
LanParam_IP6DHCP6StaticDUIDLength LanParamSelector = 57
LanParam_IP6DHCP6StaticDUIDs LanParamSelector = 58
LanParam_IP6DynamicAddr LanParamSelector = 59
LanParam_IP6DHCP6DynamicDUIDLenth LanParamSelector = 60
LanParam_IP6DHCP6DyanmicDUIDs LanParamSelector = 61
LanParam_IP6DHCP6TimingConfigSupport LanParamSelector = 62
LanParam_IP6DHCP6TimingConfig LanParamSelector = 63
LanParam_IP6RouterAddressConfigControl LanParamSelector = 64
LanParam_IP6StaticRouter1IP LanParamSelector = 65
LanParam_IP6StaticRouter1MAC LanParamSelector = 66
LanParam_IP6StaticRouter1PrefixLength LanParamSelector = 67
LanParam_IP6StaticRouter1PrefixValue LanParamSelector = 68
LanParam_IP6StaticRouter2IP LanParamSelector = 69
LanParam_IP6StaticRouter2MAC LanParamSelector = 70
LanParam_IP6StaticRouter2PrefixLength LanParamSelector = 71
LanParam_IP6StaticRouter2PrefixValue LanParamSelector = 72
LanParam_IP6DynamicRouterSetsNumber LanParamSelector = 73 // read only
LanParam_IP6DynamicRouterIP LanParamSelector = 74
LanParam_IP6DynamicRouterMAC LanParamSelector = 75
LanParam_IP6DynamicRouterPrefixLength LanParamSelector = 76
LanParam_IP6DynamicRouterPrefixValue LanParamSelector = 77
LanParam_IP6DynamicRouterReceivedHopLimit LanParamSelector = 78 // read only
LanParam_IP6NDSLAACTimingConfigSupport LanParamSelector = 79 // read only
LanParam_IP6NDSLAACTiming LanParamSelector = 80
// OEM Parameters 192:
// 255
// This range is available for special OEM configuration parameters. The OEM is identified
// according to the Manufacturer ID field returned by the Get Device ID command.
)
var LanParams = []LanParam{
{Selector: LanParam_SetInProgress, DataSize: 1, Name: "Set in Progress"},
{Selector: LanParam_AuthTypeSupported, DataSize: 1, Name: "Auth Type Support"},
{Selector: LanParam_AuthTypeEnables, DataSize: 5, Name: "Auth Type Enable"},
{Selector: LanParam_IP, DataSize: 4, Name: "IP Address"},
{Selector: LanParam_IPSource, DataSize: 1, Name: "IP Address Source"},
{Selector: LanParam_MAC, DataSize: 6, Name: "MAC Address"},
{Selector: LanParam_SubnetMask, DataSize: 4, Name: "Subnet Mask"},
{Selector: LanParam_IPv4HeaderParams, DataSize: 3, Name: "IP Header"},
{Selector: LanParam_PrimaryRMCPPort, DataSize: 2, Name: "Primary RMCP Port"},
{Selector: LanParam_SecondaryRMCPPort, DataSize: 2, Name: "Secondary RMCP Port"},
{Selector: LanParam_ARPControl, DataSize: 1, Name: "BMC ARP Control"},
{Selector: LanParam_GratuituousARPInterval, DataSize: 1, Name: "Gratituous ARP Intrvl"},
{Selector: LanParam_DefaultGatewayIP, DataSize: 4, Name: "Default Gateway IP"},
{Selector: LanParam_DefaultGatewayMAC, DataSize: 6, Name: "Default Gateway MAC"},
{Selector: LanParam_BackupGatewayIP, DataSize: 4, Name: "Backup Gateway IP"},
{Selector: LanParam_BackupGatewayMAC, DataSize: 6, Name: "Backup Gateway MAC"},
{Selector: LanParam_CommunityString, DataSize: 18, Name: "SNMP Community String"},
{Selector: LanParam_AlertDestinationsNumber, DataSize: 1, Name: "Number of Destinations"},
{Selector: LanParam_AlertDestinationType, DataSize: 4, Name: "Destination Type"},
{Selector: LanParam_AlertDestinationAddress, DataSize: 18, Name: "Destination Addresses"},
{Selector: LanParam_VLANID, DataSize: 2, Name: "802.1q VLAN ID"},
{Selector: LanParam_VLANPriority, DataSize: 1, Name: "802.1q VLAN Priority"},
{Selector: LanParam_CipherSuiteEntrySupport, DataSize: 1, Name: "RMCP+ Cipher Suite Count"},
{Selector: LanParam_CipherSuiteEntries, DataSize: 17, Name: "RMCP+ Cipher Suites"},
{Selector: LanParam_CihperSuitePrivilegeLevels, DataSize: 9, Name: "Cipher Suite Priv Max"},
{Selector: LanParam_BadPassordThreshold, DataSize: 4, Name: "Bad Password Threshold"},
}
func (lanParam LanParamSelector) String() string {
for _, v := range LanParams {
if v.Selector == lanParam {
return v.Name
}
}
return ""
}
type LanParam struct {
Selector LanParamSelector
DataSize uint8
Name string
}
type LanConfig struct {
SetInProgress SetInProgress
AuthTypeSupport AuthTypeSupport
AuthTypeEnables AuthTypeEnables
IP net.IP
IPSource IPAddressSource
MAC net.HardwareAddr
SubnetMask net.IP
IPHeaderParams IPHeaderParams
PrimaryRMCPPort uint16
SecondaryRMCPPort uint16
ARPControl ARPControl
GratuitousARPIntervalMilliSec int32
DefaultGatewayIP net.IP
DefaultGatewayMAC net.HardwareAddr
BackupGatewayIP net.IP
BackupGatewayMAC net.HardwareAddr
CommunityString CommunityString
AlertDestinationsNumber uint8
AlertDestinationType AlertDestinationType
AlertDestinationAddress AlertDestinationAddress
VLANEnabled bool
VLANID uint16
VLANPriority uint8
RMCPCipherSuitesCount uint8
RMCPCipherSuiteEntries []CipherSuiteID
RMCPCipherSuitesMaxPrivLevel []PrivilegeLevel
AlertDestinationVLAN AlertDestinationVLAN
BadPasswordThreshold BadPasswordThreshold
IP6Support IP6Support
}
func (lanConfig *LanConfig) Format() string {
cipherSuites := []string{}
for _, v := range lanConfig.RMCPCipherSuiteEntries {
cipherSuites = append(cipherSuites, fmt.Sprintf("%d", v))
}
cipherSuitesStr := strings.Join(cipherSuites, ",")
levels := []string{}
for _, v := range lanConfig.RMCPCipherSuitesMaxPrivLevel {
levels = append(levels, v.Short())
}
levelsStr := strings.Join(levels, "")
return fmt.Sprintf(`
Set in Progress : %s
IP Address Source : %s
IP Address : %s
Subnet Mask : %s
MAC Address : %s
SNMP Community String : %s
IP Header : TTL=%#02x Flags=%#02x Precedence=%#02x TOS=%#02x
Default Gateway IP : %s
802.1q VLAN ID : %d
RMCP+ Cipher Suites : %s
Cipher Suite Priv Max : %s
: X=Cipher Suite Unused
: c=CALLBACK
: u=USER
: o=OPERATOR
: a=ADMIN
: O=OEM
Bad Password Threshold : %d`,
lanConfig.SetInProgress,
lanConfig.IPSource,
lanConfig.IP,
lanConfig.SubnetMask,
lanConfig.MAC,
lanConfig.CommunityString,
lanConfig.IPHeaderParams.TTL, lanConfig.IPHeaderParams.Flags, lanConfig.IPHeaderParams.Precedence, lanConfig.IPHeaderParams.TOS,
lanConfig.DefaultGatewayIP,
lanConfig.VLANID,
cipherSuitesStr,
levelsStr,
lanConfig.BadPasswordThreshold.Threshold,
)
}
type SetInProgress uint8
func (p SetInProgress) String() string {
m := map[SetInProgress]string{
0x00: "set complete",
0x01: "set in progress",
0x02: "commit wirte",
0x03: "reserved",
}
s, ok := m[p]
if ok {
return s
}
return ""
}
type AuthTypeSupport struct {
OEM bool
Password bool
MD5 bool
MD2 bool
None bool
}
type AuthTypeEnabled struct {
OEM bool
Password bool
MD5 bool
MD2 bool
None bool
}
type AuthTypeEnables struct {
Callback AuthTypeEnabled
User AuthTypeEnabled
Operator AuthTypeEnabled
Admin AuthTypeEnabled
OEM AuthTypeEnabled
}
type IPAddressSource uint8
const (
IPAddressSourceUnspecified IPAddressSource = 0x00
IPAddressSourceStatic IPAddressSource = 0x01
IPAddressSourceDHCP IPAddressSource = 0x02
IPAddressSourceBIOS IPAddressSource = 0x03
IPAddressSourceOther IPAddressSource = 0x04
)
func (i IPAddressSource) String() string {
m := map[IPAddressSource]string{
0x00: "unspecified",
0x01: "static",
0x02: "dhcp",
0x03: "bios",
0x04: "other",
}
s, ok := m[i]
if ok {
return s
}
return ""
}
type IPHeaderParams struct {
TTL uint8
Flags uint8
Precedence uint8
TOS uint8
}
type ARPControl struct {
ARPResponseEnabled bool
GratuitousARPEnabled bool
}
type CommunityString [18]byte
func (c CommunityString) String() string {
s := []byte{}
for _, v := range c {
if v == 0x00 { // null
break
}
s = append(s, v)
}
return string(s)
}
func NewCommunityString(s string) CommunityString {
o := [18]byte{}
b := []byte(s)
for i := 0; i < 18; i++ {
if i < len(b) {
o[i] = b[i]
}
o[i] = 0x00
}
return CommunityString(o)
}
type AlertDestinationType struct {
SetSelector uint8 // Destination selector.
// 0b = Unacknowledged. Alert is assumed successful if transmission occurs
// without error. This value is also used with Callback numbers.
// 1b = Acknowledged. Alert is assumed successful only if acknowledged is
// returned. Note, some alert types, such as Dial Page, do not support an
// acknowledge
AlertSupportAcknowledge bool
// 000b = PET Trap destination
// 001b - 101b = reserved
// 110b = OEM 1
// 111b = OEM 2
DestinationType uint8
// Alert Acknowledge Timeout / Retry Interval, in seconds, 0-based (i.e. minimum
// timeout = 1 second)
AlertAcknowledgeTimeout uint8
// Number of times to retry alert to given destination.
Retries uint8
}
type AlertDestinationAddress struct {
SetSelector uint8
// 0h = IPv4 IP Address followed by DIX Ethernet/802.3 MAC Address
// 1h = IPv6 IP Address
AddressFormat uint8
IP4UseBackupGateway bool
IP4IP net.IP
IP4MAC net.HardwareAddr
IP6IP net.IP
}
type VLAN struct {
Enabled bool
ID uint16
Priority uint8
}
type AlertDestinationVLAN struct {
SetSelector uint8
// 0h = VLAN ID not used with this destination
// 1h = 802.1q VLAN TAG
AddressFormat uint8
VLANID uint16
// CFI (Canonical Format Indicator. Set to 0b)
CFI bool
Priority uint8
}
type BadPasswordThreshold struct {
// generate a Session Audit sensor "Invalid password disable" event message.
GenerateSessionAuditEvent bool
// Bad Password Threshold number
Threshold uint8
// Attempt Count Reset Interval.
// The raw data is 2 byte, and the unit is in tens of seconds, the program should convert to senconds.
AttemptCountResetIntevalSec uint32
// User Lockout Interval
// The raw data is 2 byte, and the unit is in tens of seconds, the program should convert to senconds.
UserLockoutIntervalSec uint32
}
type IP6Support struct {
// Implementation supports IPv6 Destination Addresses for LAN Alerting.
SupportIP6AlertDestination bool
// Implementation can be configured to use both IPv4 and IPv6 addresses simultaneously
CanUseBothIP4AndIP6 bool
// Implementation can be configured to use IPv6 addresses only.
CanUseIP6Only bool
}