r4675 bring in part of 0.19.7
[racktables] / wwwroot / inc / snmp.php
CommitLineData
2ffd5a2a
DO
1<?php
2
536e7323 3global $iftable_processors;
74aee2dc 4$iftable_processors = array();
6be06cbb 5
cbc30061 6$iftable_processors['catalyst-chassis-mgmt'] = array
6be06cbb 7(
cbc30061
DO
8 'pattern' => '@^FastEthernet([[:digit:]])$@',
9 'replacement' => 'fa\\1',
10 'dict_key' => '1-19',
6be06cbb
DO
11 'label' => 'mgmt',
12 'try_next_proc' => FALSE,
13);
14
15$iftable_processors['catalyst-chassis-any-100TX'] = array
74aee2dc 16(
6be06cbb
DO
17 'pattern' => '@^FastEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
18 'replacement' => 'fa\\1\\2',
74aee2dc 19 'dict_key' => 19,
6be06cbb 20 'label' => '\\2X',
56a797ef
DO
21 'try_next_proc' => FALSE,
22);
23
6be06cbb 24$iftable_processors['catalyst-chassis-25-to-26-100FX/MT-RJ'] = array
56a797ef 25(
6be06cbb
DO
26 'pattern' => '@^FastEthernet([[:digit:]]+/)?(25|26)$@',
27 'replacement' => 'fa\\1\\2',
8920f7f5 28 'dict_key' => 1195,
6be06cbb
DO
29 'label' => '\\2',
30 'try_next_proc' => FALSE,
31);
32
33$iftable_processors['catalyst-chassis-any-1000T'] = array
34(
f0255d01 35 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
6be06cbb
DO
36 'replacement' => 'gi\\1\\2',
37 'dict_key' => 24,
38 'label' => '\\2X',
56a797ef 39 'try_next_proc' => FALSE,
74aee2dc
DO
40);
41
6be06cbb 42$iftable_processors['catalyst-chassis-uplinks-1000T'] = array
74aee2dc 43(
6be06cbb
DO
44 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
45 'replacement' => 'gi\\1\\2',
74aee2dc 46 'dict_key' => 24,
6be06cbb 47 'label' => '\\2',
56a797ef
DO
48 'try_next_proc' => FALSE,
49);
50
8a4bee49
DO
51$iftable_processors['catalyst-chassis-uplinks-1000SX'] = array
52(
53 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
54 'replacement' => 'gi\\1\\2',
55 'dict_key' => '1-1202', // Gig-SX hardwired
56 'label' => '\\2',
57 'try_next_proc' => FALSE,
58);
59
6be06cbb 60$iftable_processors['catalyst-chassis-any-1000SFP'] = array
74aee2dc 61(
6be06cbb
DO
62 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
63 'replacement' => 'gi\\1\\2',
8536e20a 64 'dict_key' => '4-1077',
6be06cbb 65 'label' => '\\2',
56a797ef
DO
66 'try_next_proc' => FALSE,
67);
68
6be06cbb 69$iftable_processors['catalyst-chassis-any-1000GBIC'] = array
56a797ef 70(
6be06cbb
DO
71 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
72 'replacement' => 'gi\\1\\2',
8536e20a 73 'dict_key' => '3-1078',
6be06cbb 74 'label' => '\\2',
56a797ef
DO
75 'try_next_proc' => FALSE,
76);
77
7e87a291
DO
78$iftable_processors['catalyst-chassis-1-to-2-combo-1000SFP'] = array
79(
80 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(1|2)$@',
81 'replacement' => 'gi\\1\\2',
82 'dict_key' => '4-1077',
83 'label' => '\\2',
84 'try_next_proc' => TRUE,
85);
86
712010be
AA
87$iftable_processors['catalyst-chassis-1-to-2-1000SFP'] = array
88(
89 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(1|2)$@',
90 'replacement' => 'gi\\1\\2',
91 'dict_key' => '4-1077',
92 'label' => '\\2',
93 'try_next_proc' => FALSE,
94);
95
a048e8fc
DO
96$iftable_processors['catalyst-chassis-8-combo-1000SFP'] = array
97(
98 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(8)$@',
99 'replacement' => 'gi\\1\\2',
100 'dict_key' => '4-1077',
101 'label' => '\\2',
102 'try_next_proc' => TRUE,
103);
104
6be06cbb 105$iftable_processors['catalyst-chassis-21-to-24-combo-1000SFP'] = array
56a797ef 106(
6be06cbb
DO
107 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(21|22|23|24)$@',
108 'replacement' => 'gi\\1\\2',
8536e20a 109 'dict_key' => '4-1077',
6be06cbb 110 'label' => '\\2',
56a797ef
DO
111 'try_next_proc' => TRUE,
112);
113
6be06cbb 114$iftable_processors['catalyst-chassis-45-to-48-combo-1000SFP'] = array
56a797ef 115(
6be06cbb
DO
116 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(45|46|47|48)$@',
117 'replacement' => 'gi\\1\\2',
8536e20a 118 'dict_key' => '4-1077',
6be06cbb 119 'label' => '\\2',
56a797ef
DO
120 'try_next_proc' => TRUE,
121);
122
6be06cbb 123$iftable_processors['catalyst-chassis-uplinks-10000X2'] = array
56a797ef 124(
6be06cbb
DO
125 'pattern' => '@^TenGigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
126 'replacement' => 'te\\1\\2',
8536e20a 127 'dict_key' => '6-1080',
6be06cbb 128 'label' => '\\2',
56a797ef 129 'try_next_proc' => FALSE,
74aee2dc
DO
130);
131
6be06cbb 132$iftable_processors['catalyst-chassis-25-to-28-1000SFP'] = array
74aee2dc 133(
6be06cbb
DO
134 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(25|26|27|28)$@',
135 'replacement' => 'gi\\1\\2',
8536e20a 136 'dict_key' => '4-1077',
6be06cbb 137 'label' => '\\2',
56a797ef 138 'try_next_proc' => FALSE,
74aee2dc
DO
139);
140
6be06cbb 141$iftable_processors['catalyst-chassis-49-to-52-1000SFP'] = array
74aee2dc 142(
6be06cbb
DO
143 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(49|50|51|52)$@',
144 'replacement' => 'gi\\1\\2',
8536e20a 145 'dict_key' => '4-1077',
6be06cbb 146 'label' => '\\2',
56a797ef 147 'try_next_proc' => FALSE,
74aee2dc
DO
148);
149
71d6b313 150$iftable_processors['catalyst-blade-13-to-16-1000SFP'] = array
74aee2dc 151(
6be06cbb
DO
152 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(13|14|15|16)$@',
153 'replacement' => 'gi\\1\\2',
8536e20a 154 'dict_key' => '4-1077',
6be06cbb 155 'label' => '\\2',
56a797ef 156 'try_next_proc' => FALSE,
74aee2dc
DO
157);
158
71d6b313 159$iftable_processors['catalyst-blade-21-to-24-1000SFP'] = array
74aee2dc 160(
6be06cbb
DO
161 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(21|22|23|24)$@',
162 'replacement' => 'gi\\1\\2',
8536e20a 163 'dict_key' => '4-1077',
6be06cbb 164 'label' => '\\2',
56a797ef 165 'try_next_proc' => FALSE,
74aee2dc
DO
166);
167
71d6b313
DO
168$iftable_processors['catalyst-blade-11-to-12-1000T'] = array
169(
170 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(11|12)$@',
171 'replacement' => 'gi\\1\\2',
172 'dict_key' => '1-24',
173 'label' => '\\2',
174 'try_next_proc' => FALSE,
175);
176
177$iftable_processors['catalyst-blade-17-to-20-1000T'] = array
178(
179 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(17|18|19|20)$@',
180 'replacement' => 'gi\\1\\2',
181 'dict_key' => '1-24',
182 'label' => '\\2',
183 'try_next_proc' => FALSE,
184);
185
186$iftable_processors['catalyst-blade-any-bp/1000T'] = array
187(
188 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
189 'replacement' => 'gi\\1\\2',
190 'dict_key' => '1-1087',
191 'label' => '',
192 'try_next_proc' => FALSE,
193);
194
7e87a291
DO
195$iftable_processors['catalyst-1-to-10-1000T'] = array
196(
197 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(1|2|3|4|5|6|7|8|9|10)$@',
198 'replacement' => 'gi\\1\\2',
199 'dict_key' => '1-24',
200 'label' => '\\2',
201 'try_next_proc' => FALSE,
202);
203
204$iftable_processors['catalyst-11-to-12-GBIC'] = array
205(
206 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(11|12)$@',
207 'replacement' => 'gi\\1\\2',
208 'dict_key' => '3-1078',
209 'label' => '\\2',
210 'try_next_proc' => FALSE,
211);
212
74aee2dc
DO
213$iftable_processors['nexus-any-10000SFP+'] = array
214(
56a797ef 215 'pattern' => '@^Ethernet([[:digit:]]/[[:digit:]]+)$@',
74aee2dc 216 'replacement' => 'e\\1',
8536e20a 217 'dict_key' => '9-1084',
56a797ef
DO
218 'label' => '\\1',
219 'try_next_proc' => FALSE,
74aee2dc
DO
220);
221
8acd246d
DO
222$iftable_processors['ftos-any-1000T'] = array
223(
224 'pattern' => '@^GigabitEthernet 0/(\d+)$@',
225 'replacement' => 'gi0/\\1',
226 'dict_key' => '1-24',
227 'label' => '\\1',
228 'try_next_proc' => FALSE,
229);
230
231$iftable_processors['ftos-44-to-47-1000SFP'] = array
232(
233 'pattern' => '@^GigabitEthernet 0/(44|45|46|47)$@',
234 'replacement' => 'gi0/\\1',
235 'dict_key' => '4-1077',
236 'label' => '\\1',
237 'try_next_proc' => FALSE,
238);
239
240$iftable_processors['ftos-any-10000SFP+'] = array
241(
242 'pattern' => '@^TenGigabitEthernet 0/(\d+)$@',
243 'replacement' => 'te0/\\1',
244 'dict_key' => '9-1084',
245 'label' => '\\1',
246 'try_next_proc' => FALSE,
247);
248
e7662d90
DO
249$iftable_processors['nexus-mgmt'] = array
250(
251 'pattern' => '@^(mgmt[[:digit:]]+)$@',
252 'replacement' => '\\1',
253 'dict_key' => '1-24',
254 'label' => '\\1',
255 'try_next_proc' => FALSE,
256);
257
56a797ef 258$iftable_processors['procurve-chassis-100TX'] = array
74aee2dc 259(
56a797ef 260 'pattern' => '@^([[:digit:]]+)$@',
74aee2dc
DO
261 'replacement' => '\\1',
262 'dict_key' => 19,
56a797ef
DO
263 'label' => '\\1',
264 'try_next_proc' => FALSE,
265);
266
267$iftable_processors['procurve-chassis-1000T'] = array
268(
269 'pattern' => '@^([[:digit:]]+)$@',
270 'replacement' => '\\1',
271 'dict_key' => 24,
272 'label' => '\\1',
273 'try_next_proc' => FALSE,
274);
275
4b43f713
DO
276$iftable_processors['procurve-45-to-48-combo-1000SFP'] = array
277(
278 'pattern' => '@^(45|46|47|48)$@',
279 'replacement' => '\\1',
280 'dict_key' => '4-1077',
281 'label' => '\\1',
282 'try_next_proc' => TRUE,
283);
284
56a797ef
DO
285$iftable_processors['procurve-modular-100TX'] = array
286(
287 'pattern' => '@^([A-Z][[:digit:]]+)$@',
288 'replacement' => '\\1',
289 'dict_key' => 19,
290 'label' => '\\1',
291 'try_next_proc' => FALSE,
74aee2dc
DO
292);
293
294$iftable_processors['procurve-25-to-26-1000T'] = array
295(
56a797ef 296 'pattern' => '@^(25|26)$@',
74aee2dc
DO
297 'replacement' => '\\1',
298 'dict_key' => 24,
56a797ef
DO
299 'label' => '\\1',
300 'try_next_proc' => FALSE,
74aee2dc
DO
301);
302
303$iftable_processors['procurve-49-to-50-1000T'] = array
304(
56a797ef 305 'pattern' => '@^(49|50)$@',
74aee2dc
DO
306 'replacement' => '\\1',
307 'dict_key' => 24,
56a797ef
DO
308 'label' => '\\1',
309 'try_next_proc' => FALSE,
74aee2dc
DO
310);
311
6be06cbb 312$iftable_processors['netgear-chassis-any-1000T'] = array
74aee2dc 313(
56a797ef
DO
314 'pattern' => '@^Unit: 1 Slot: 0 Port: ([[:digit:]]+) Gigabit - Level$@',
315 'replacement' => '\\1',
316 'dict_key' => 24,
317 'label' => '\\1',
318 'try_next_proc' => FALSE,
319);
320
6be06cbb
DO
321$iftable_processors['netgear-chassis-21-to-24-1000Tcombo'] = array
322(
323 'pattern' => '@^Unit: 1 Slot: 0 Port: ([[:digit:]]+) Gigabit - Level$@',
324 'replacement' => '\\1',
325 'dict_key' => 24,
326 'label' => '\\1T',
327 'try_next_proc' => FALSE,
328);
329
330$iftable_processors['netgear-chassis-21-to-24-1000SFP'] = array
331(
332 'pattern' => '@^Unit: 1 Slot: 0 Port: ([[:digit:]]+) Gigabit - Level$@',
333 'replacement' => '\\1',
8536e20a 334 'dict_key' => '4-1077',
6be06cbb
DO
335 'label' => '\\1F',
336 'try_next_proc' => TRUE,
337);
338
56a797ef
DO
339$iftable_processors['nortel-any-1000T'] = array
340(
341 'pattern' => '@^Ethernet Port on unit 1, port ([[:digit:]]+)$@',
74aee2dc
DO
342 'replacement' => '\\1',
343 'dict_key' => 24,
56a797ef
DO
344 'label' => '\\1',
345 'try_next_proc' => FALSE,
74aee2dc
DO
346);
347
fb3e70de
DO
348$iftable_processors['smc-combo-45-to-48'] = array
349(
350 'pattern' => '@^Ethernet Port on unit 1, port (45|46|47|48)$@',
351 'replacement' => '\\1',
352 'dict_key' => '4-1077',
353 'label' => '\\1',
354 'try_next_proc' => TRUE,
355);
356
91389980
DO
357$iftable_processors['juniper-DPCE-R-4XGE-XFP'] = array
358(
7d69a266
DO
359 'pattern' => '@^xe-([[:digit:]]+)/([[:digit:]]+/[[:digit:]]+)$@',
360 'replacement' => '\\0',
91389980 361 'dict_key' => '8-1082', // XFP/empty
7d69a266
DO
362 'label' => 'slot \\1 port \\2',
363 'try_next_proc' => FALSE,
364);
365
1f54e1ba
DO
366$iftable_processors['juniper-ex-pic0-1000T'] = array
367(
368 'pattern' => '@^ge-([[:digit:]]+)/0/([[:digit:]]+)$@',
369 'replacement' => '\\0',
370 'dict_key' => '1-24',
371 'label' => 'unit \\1 port \\2',
372 'try_next_proc' => FALSE,
373);
374
375$iftable_processors['juniper-ex-mgmt'] = array
376(
377 'pattern' => '/^me0$/',
378 'replacement' => 'me0',
379 'dict_key' => '1-24',
380 'label' => 'MGMT',
381 'try_next_proc' => FALSE,
382);
383
7d69a266
DO
384$iftable_processors['quidway-21-to-24-comboT'] = array
385(
386 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+/)(21|22|23|24)$@',
387 'replacement' => 'gi\\1\\2',
388 'dict_key' => '1-24',
389 'label' => '\\2',
390 'try_next_proc' => TRUE,
391);
392
24c3e444
DO
393$iftable_processors['quidway-21-to-24-comboSFP'] = array
394(
395 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+/)(21|22|23|24)$@',
396 'replacement' => 'gi\\1\\2',
397 'dict_key' => '4-1077',
398 'label' => '\\2',
399 'try_next_proc' => TRUE,
400);
401
b55f8de3
DO
402$iftable_processors['quidway-slot1-SFP'] = array
403(
404 'pattern' => '@^GigabitEthernet0/1/([[:digit:]]+)$@',
405 'replacement' => 'gi0/1/\\1',
406 'dict_key' => '4-1077',
407 'label' => 'SFP\\1',
408 'try_next_proc' => FALSE,
409);
410
7d69a266
DO
411$iftable_processors['quidway-any-1000SFP'] = array
412(
413 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
414 'replacement' => 'gi\\1\\2',
415 'dict_key' => '4-1077', // empty SFP-1000
416 'label' => '\\2',
417 'try_next_proc' => FALSE,
418);
419
24c3e444
DO
420$iftable_processors['quidway-any-1000T'] = array
421(
422 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
423 'replacement' => 'gi\\1\\2',
424 'dict_key' => '1-24',
425 'label' => '\\2',
426 'try_next_proc' => FALSE,
427);
428
7d69a266
DO
429$iftable_processors['quidway-XFP'] = array
430(
431 'pattern' => '@^XGigabitEthernet([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
432 'replacement' => 'xg\\1\\2',
433 'dict_key' => '8-1082',
434 'label' => '\\2',
435 'try_next_proc' => FALSE,
436);
437
438$iftable_processors['quidway-mgmt'] = array
439(
440 'pattern' => '@^MEth([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
441 'replacement' => 'me\\1\\2',
442 'dict_key' => '1-19',
443 'label' => 'eth',
91389980
DO
444 'try_next_proc' => FALSE,
445);
446
661b3fdb
DO
447$iftable_processors['fgs-1-to-4-comboSFP'] = array
448(
449 # only 4 first copper ports of 1st unit of a stack
450 'pattern' => '@^GigabitEthernet1/1/(1|2|3|4)$@',
451 'replacement' => 'e1/1/\\1',
452 'dict_key' => '4-1077',
453 'label' => '\\1F',
454 'try_next_proc' => TRUE,
455);
456
457$iftable_processors['fgs-any-1000T'] = array
458(
6c32c3ff
AA
459 'pattern' => '@^GigabitEthernet(0|1)/1/([[:digit:]]+)$@',
460 'replacement' => 'e\\1/1/\\2',
661b3fdb 461 'dict_key' => '1-24',
6c32c3ff
AA
462 'label' => '\\2',
463 'try_next_proc' => FALSE,
464);
465
466$iftable_processors['fls624-combo'] = array
467(
468 'pattern' => '@^GigabitEthernet0/1/(21|22|23|24)$@',
469 'replacement' => 'e0/1/\\1',
470 'dict_key' => '4-1077',
661b3fdb 471 'label' => '\\1',
6c32c3ff
AA
472 'try_next_proc' => TRUE,
473);
474
475$iftable_processors['fls648-combo'] = array
476(
477 'pattern' => '@^GigabitEthernet0/1/(45|46|47|48)$@',
478 'replacement' => 'e0/1/\\1',
479 'dict_key' => '4-1077',
480 'label' => '\\1',
481 'try_next_proc' => TRUE,
482);
483
484# These can be CX4, but that is not handled here.
485$iftable_processors['fls-uplinks'] = array
486(
487 'pattern' => '@^10GigabitEthernet0/([234])/1$@',
488 'replacement' => 'e0/\\1/1',
489 'dict_key' => '8-1082',
490 'label' => 'Slot \\1',
661b3fdb
DO
491 'try_next_proc' => FALSE,
492);
493
494$iftable_processors['fgs-uplinks'] = array
495(
496 'pattern' => '@^10GigabitEthernet1/2/([[:digit:]]+)$@',
497 'replacement' => 'e1/2/\\1',
498 'dict_key' => '8-1082', // default is XFP, but may be overridden to CX4
499 'label' => 'Slot2 \\1',
500 'try_next_proc' => FALSE,
501);
502
ec523868
DO
503$iftable_processors['fcx-uplinks'] = array
504(
505 'pattern' => '@^10GigabitEthernet1/2/([[:digit:]]+)$@',
506 'replacement' => 'e1/2/\\1',
507 'dict_key' => '9-1084',
508 'label' => 'X\\1',
509 'try_next_proc' => FALSE,
510);
511
512$iftable_processors['fcx-management'] = array
513(
514 'pattern' => '@^Management$@',
515 'replacement' => 'management1',
516 'dict_key' => '1-24',
517 'label' => 'Management',
518 'try_next_proc' => FALSE,
519);
520
4eeadb79
DO
521$iftable_processors['summit-25-to-26-XFP-uplinks'] = array
522(
523 'pattern' => '@^.+ Port (25|26)$@',
524 'replacement' => '\\1',
525 'dict_key' => '8-1082',
526 'label' => '\\1',
527 'try_next_proc' => FALSE,
528);
529
dbcf1931
DO
530$iftable_processors['summit-27-to-30-XFP-uplinks'] = array
531(
532 'pattern' => '@^.+ Port (27|28|29|30)$@',
533 'replacement' => '\\1',
534 'dict_key' => '8-1082',
535 'label' => '\\1',
536 'try_next_proc' => FALSE,
537);
538
4eeadb79
DO
539$iftable_processors['summit-21-to-24-comboSFP'] = array
540(
541 'pattern' => '@^.+ Port (21|22|23|24)$@',
542 'replacement' => '\\1',
543 'dict_key' => '4-1077',
544 'label' => '\\1',
545 'try_next_proc' => TRUE,
546);
547
dbcf1931
DO
548$iftable_processors['summit-13-to-24-comboT'] = array
549(
550 'pattern' => '@^.+ Port (1[3456789]|2[01234])$@',
551 'replacement' => '\\1',
552 'dict_key' => '1-24',
553 'label' => '\\1',
554 'try_next_proc' => TRUE,
555);
556
4eeadb79
DO
557$iftable_processors['summit-any-1000T'] = array
558(
559 'pattern' => '@^.+ Port ([[:digit:]]+)$@',
560 'replacement' => '\\1',
561 'dict_key' => '1-24',
562 'label' => '\\1',
563 'try_next_proc' => FALSE,
564);
565
dbcf1931
DO
566$iftable_processors['summit-any-SFP'] = array
567(
568 'pattern' => '@^.+ Port ([[:digit:]]+)$@',
569 'replacement' => '\\1',
570 'dict_key' => '4-1077',
571 'label' => '\\1',
572 'try_next_proc' => FALSE,
573);
574
4eeadb79
DO
575$iftable_processors['summit-management'] = array
576(
577 'pattern' => '@^Management Port$@',
578 'replacement' => 'mgmt',
579 'dict_key' => '1-19',
21d38e6b 580 'label' => 'management',
4eeadb79
DO
581 'try_next_proc' => FALSE,
582);
583
536e7323 584global $known_switches;
74aee2dc
DO
585$known_switches = array // key is system OID w/o "enterprises" prefix
586(
d7466acb
DO
587 '9.1.248' => array
588 (
589 'dict_key' => 393,
590 'text' => 'WS-C3524-XL: 24 RJ-45/10-100TX + 2 GBIC/1000',
591 'processors' => array ('catalyst-chassis-any-1000GBIC', 'catalyst-chassis-any-100TX'),
592 ),
74aee2dc
DO
593 '9.1.324' => array
594 (
595 'dict_key' => 380,
596 'text' => 'WS-C2950-24: 24 RJ-45/10-100TX',
6be06cbb 597 'processors' => array ('catalyst-chassis-any-100TX'),
74aee2dc
DO
598 ),
599 '9.1.325' => array
600 (
601 'dict_key' => 382,
602 'text' => 'WS-C2950C-24: 24 RJ-45/10-100TX + 2 MT-RJ/100FX fiber',
6be06cbb 603 'processors' => array ('catalyst-chassis-25-to-26-100FX/MT-RJ', 'catalyst-chassis-any-100TX'),
74aee2dc 604 ),
7e87a291
DO
605 '9.1.695' => array
606 (
607 'dict_key' => 140,
608 'text' => 'WS-C2960-48TC-L: 48 RJ-45/10-100TX + 2 combo-gig',
609 'processors' => array ('catalyst-chassis-1-to-2-combo-1000SFP', 'catalyst-chassis-any-1000T', 'catalyst-chassis-any-100TX'),
610 ),
a048e8fc
DO
611 '9.1.799' => array
612 (
613 'dict_key' => 168,
614 'text' => 'WS-C2960G-8TC-L: 7 RJ-45/10-100-1000T(X) + 1 combo-gig',
615 'processors' => array ('catalyst-chassis-8-combo-1000SFP', 'catalyst-chassis-any-1000T'),
616 ),
74aee2dc
DO
617 '9.1.696' => array
618 (
619 'dict_key' => 167,
620 'text' => 'WS-C2960G-24TC-L: 20 RJ-45/10-100-1000T(X) + 4 combo-gig',
6be06cbb 621 'processors' => array ('catalyst-chassis-21-to-24-combo-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
622 ),
623 '9.1.697' => array
624 (
625 'dict_key' => 166,
626 'text' => 'WS-C2960G-48TC-L: 44 RJ-45/10-100-1000T(X) + 4 combo-gig',
6be06cbb 627 'processors' => array ('catalyst-chassis-45-to-48-combo-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
628 ),
629 '9.1.716' => array
630 (
631 'dict_key' => 164,
632 'text' => 'WS-C2960-24TT-L: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
6be06cbb 633 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
634 ),
635 '9.1.717' => array
636 (
637 'dict_key' => 162,
638 'text' => 'WS-C2960-48TT-L: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
6be06cbb 639 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000T'),
74aee2dc 640 ),
ec523868
DO
641 '9.1.950' => array
642 (
643 'dict_key' => 1347,
644 'text' => 'WS-C2960-24PC: 44 RJ-45/10-100TX + 2 combo-gig',
645 'processors' => array ('catalyst-chassis-1-to-2-combo-1000SFP', 'catalyst-chassis-any-1000T', 'catalyst-chassis-any-100TX'),
646 ),
4d043be1
AA
647 '9.1.927' => array
648 (
649 'dict_key' => 140,
650 'text' => 'WS-C2960-48TC: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
651 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000T'),
652 ),
74aee2dc
DO
653 '9.1.527' => array
654 (
655 'dict_key' => 210,
656 'text' => 'WS-C2970G-24T: 24 RJ-45/10-100-1000T(X)',
6be06cbb 657 'processors' => array ('catalyst-chassis-any-1000T'),
74aee2dc
DO
658 ),
659 '9.1.561' => array
660 (
661 'dict_key' => 115,
662 'text' => 'WS-C2970G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 663 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
664 ),
665 '9.1.633' => array
666 (
667 'dict_key' => 169,
668 'text' => 'WS-C3560-24TS: 24 RJ-45/10-100TX + 2 SFP/1000',
6be06cbb 669 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
670 ),
671 '9.1.634' => array
672 (
673 'dict_key' => 170,
674 'text' => 'WS-C3560-48TS: 48 RJ-45/10-100TX + 4 SFP/1000',
6be06cbb 675 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
676 ),
677 '9.1.563' => array
678 (
679 'dict_key' => 171,
680 'text' => 'WS-C3560-24PS: 24 RJ-45/10-100TX + 2 SFP/1000',
6be06cbb 681 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
682 ),
683 '9.1.564' => array
684 (
685 'dict_key' => 172,
686 'text' => 'WS-C3560-48PS: 48 RJ-45/10-100TX + 4 SFP/1000',
6be06cbb 687 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
688 ),
689 '9.1.614' => array
690 (
691 'dict_key' => 175,
692 'text' => 'WS-C3560G-24PS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 693 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
694 ),
695 '9.1.615' => array
696 (
697 'dict_key' => 173,
698 'text' => 'WS-C3560G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 699 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
700 ),
701 '9.1.616' => array
702 (
703 'dict_key' => 176,
704 'text' => 'WS-C3560G-48PS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 705 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
706 ),
707 '9.1.617' => array
708 (
709 'dict_key' => 174,
710 'text' => 'WS-C3560G-48TS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 711 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
712 ),
713 '9.1.626' => array
714 (
715 'dict_key' => 147,
56a797ef 716 'text' => 'WS-C4948: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000 + 1 RJ-45/100TX (OOB mgmt)',
cbc30061 717 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-uplinks-1000T', 'catalyst-chassis-mgmt'),
74aee2dc
DO
718 ),
719 '9.1.659' => array
720 (
721 'dict_key' => 377,
56a797ef 722 'text' => 'WS-C4948-10GE: 48 RJ-45/10-100-1000T(X) + 2 X2/10000 + 1 RJ-45/100TX (OOB mgmt)',
cbc30061 723 'processors' => array ('catalyst-chassis-uplinks-10000X2', 'catalyst-chassis-uplinks-1000T', 'catalyst-chassis-mgmt'),
74aee2dc
DO
724 ),
725 '9.1.428' => array
726 (
727 'dict_key' => 389,
728 'text' => 'WS-C2950G-24: 24 RJ-45/10-100TX + 2 GBIC/1000',
6be06cbb 729 'processors' => array ('catalyst-chassis-any-1000GBIC', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
730 ),
731 '9.1.429' => array
732 (
733 'dict_key' => 390,
734 'text' => 'WS-C2950G-48: 48 RJ-45/10-100TX + 2 GBIC/1000',
6be06cbb 735 'processors' => array ('catalyst-chassis-any-1000GBIC', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
736 ),
737 '9.1.559' => array
738 (
739 'dict_key' => 387,
740 'text' => 'WS-C2950T-48: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
6be06cbb 741 'processors' => array ('catalyst-chassis-uplinks-1000T', 'catalyst-chassis-any-100TX'),
74aee2dc 742 ),
8a4bee49
DO
743 '9.1.560' => array
744 (
745 'dict_key' => 384,
746 'text' => 'WS-C2950SX-48: 48 RJ-45/10-100TX + 2 1000Base-SX',
747 'processors' => array ('catalyst-chassis-uplinks-1000SX', 'catalyst-chassis-any-100TX'),
748 ),
74aee2dc
DO
749 '9.1.749' => array
750 (
751 'dict_key' => 989,
752 'text' => 'WS-CBS3030-DEL: 10 internal/10-100-1000T(X) + 2 RJ-45/10-100-1000T(X) + 4 SFP/1000',
71d6b313 753 'processors' => array ('catalyst-blade-11-to-12-1000T', 'catalyst-blade-13-to-16-1000SFP', 'catalyst-blade-any-bp/1000T'),
74aee2dc
DO
754 ),
755 '9.1.920' => array
756 (
757 'dict_key' => 795,
758 'text' => 'WS-CBS3032-DEL: 16 internal/10-100-1000T(X) + 4 RJ-45/10-100-1000T(X) + 4 SFP/1000',
71d6b313 759 'processors' => array ('catalyst-blade-17-to-20-1000T', 'catalyst-blade-21-to-24-1000SFP', 'catalyst-blade-any-bp/1000T'),
74aee2dc 760 ),
2217e284
DO
761 '9.1.367' => array
762 (
763 'dict_key' => 404,
764 'text' => 'WS-C3550-48: 48 RJ-45/10-100TX + 2 GBIC/1000',
765 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000GBIC'),
766 ),
7e87a291
DO
767 '9.1.368' => array
768 (
769 'dict_key' => 398,
770 'text' => 'WS-C3550-12T: 10 RJ-45/10-100-1000T(X) + 2 GBIC/1000',
771 'processors' => array ('catalyst-1-to-10-1000T', 'catalyst-11-to-12-GBIC'),
772 ),
a9bd9e98
DO
773 '9.1.282' => array
774 (
775 'dict_key' => 154,
776 'text' => 'WS-C6506: modular device (INCOMPLETE!)',
777 'processors' => array ('catalyst-chassis-any-1000T'),
778 ),
65b4b21a
DO
779 '9.1.1104' => array
780 (
781 'dict_key' => 1348,
782 'text' => 'WS-C2350-48TD: 48 RJ-45/10-100-1000T(X) + 2 X2/10000 w/TwinGig option',
783 'processors' => array
784 (
785 'catalyst-chassis-49-to-52-1000SFP', // TwinGig actually
786 'catalyst-chassis-any-1000T',
787 'catalyst-chassis-uplinks-10000X2',
788 'catalyst-chassis-mgmt',
789 ),
790 ),
712010be
AA
791 '9.1.1016' => array
792 (
793 'dict_key' => 1370,
794 'text' => 'WS-C2960-48PST-L: 48 RJ-45/10-100TX PoE + 2 SFP/1000 + 2 RJ-45/10-100-1000T(X)',
795 'processors' => array
796 (
797 'catalyst-chassis-any-100TX',
798 'catalyst-chassis-1-to-2-1000SFP',
799 'catalyst-chassis-uplinks-1000T',
800 ),
801 ),
74aee2dc
DO
802 '9.12.3.1.3.719' => array
803 (
804 'dict_key' => 960,
805 'text' => 'N5K-C5020: 40 SFP+/10000',
e7662d90 806 'processors' => array ('nexus-any-10000SFP+', 'nexus-mgmt'),
74aee2dc 807 ),
bc45a3a4
DO
808 '9.12.3.1.3.798' => array
809 (
810 'dict_key' => 959,
811 'text' => 'N5K-C5010: 20 SFP+/10000',
812 'processors' => array ('nexus-any-10000SFP+', 'nexus-mgmt'),
813 ),
56a797ef
DO
814 '11.2.3.7.11.32' => array
815 (
816 'dict_key' => 871,
817 'text' => 'J4904A: 48 RJ-45/10-100-1000T(X)',
818 'processors' => array ('procurve-chassis-1000T'),
819 ),
74aee2dc
DO
820 '11.2.3.7.11.36' => array
821 (
822 'dict_key' => 865,
823 'text' => 'J8164A: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
56a797ef 824 'processors' => array ('procurve-25-to-26-1000T', 'procurve-chassis-100TX'),
74aee2dc
DO
825 ),
826 '11.2.3.7.11.35' => array
827 (
828 'dict_key' => 867,
829 'text' => 'J8165A: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
56a797ef
DO
830 'processors' => array ('procurve-49-to-50-1000T', 'procurve-chassis-100TX'),
831 ),
832 '11.2.3.7.11.9' => array
833 (
834 'dict_key' => 1086,
835 'text' => 'J4121A: modular system',
836 'processors' => array ('procurve-modular-100TX'),
74aee2dc 837 ),
4b43f713
DO
838 '11.2.3.7.11.87' => array
839 (
840 'dict_key' => 1349,
841 'text' => 'J9147A: 44 RJ-45/10-100-1000T(X) + 4 combo-gig)',
842 'processors' => array ('procurve-45-to-48-combo-1000SFP', 'procurve-chassis-1000T'),
843 ),
74aee2dc
DO
844 '4526.100.2.2' => array
845 (
846 'dict_key' => 562,
6be06cbb
DO
847 'text' => 'GSM7224: 20 RJ-45/10-100-1000T(X) + 4 combo-gig',
848 'processors' => array ('netgear-chassis-21-to-24-1000SFP', 'netgear-chassis-21-to-24-1000Tcombo', 'netgear-chassis-any-1000T'),
74aee2dc 849 ),
56a797ef
DO
850 '45.3.68.5' => array
851 (
852 'dict_key' => 1085,
853 'text' => 'BES50GE-12T PWR: 12 RJ-45/10-100-1000T(X)',
854 'processors' => array ('nortel-any-1000T'),
855 ),
91389980
DO
856 '2636.1.1.1.2.29' => array
857 (
858 'dict_key' => 925,
859 'text' => 'MX240 modular router',
860 'processors' => array ('juniper-DPCE-R-4XGE-XFP'),
861 ),
1f54e1ba
DO
862 // Juniper Networks assigns single SNMP OID per series:
863 // EX2200 2636.1.1.1.1.43
864 // EX3200 2636.1.1.1.2.30
865 // EX4200 2636.1.1.1.2.31
866 // EX4500 2636.1.1.1.1.44
867 // There is a special workaround in code below to derive specific
868 // product number from sysDescr string.
869 '2636.1.1.1.2.31' => array
870 (
871 'dict_key' => 905,
872 'text' => 'Juniper EX4200 series',
873 'processors' => array ('juniper-ex-pic0-1000T', 'juniper-ex-mgmt'),
874 ),
7d69a266
DO
875 '2011.2.23.96' => array
876 (
877 'dict_key' => 1321,
24c3e444 878 'text' => 'S5328C-EI-24S: 20 SFP-1000 + 4 combo-gig + 2 XFP slots',
7d69a266
DO
879 'processors' => array ('quidway-21-to-24-comboT', 'quidway-any-1000SFP', 'quidway-XFP', 'quidway-mgmt'),
880 ),
b55f8de3
DO
881 '2011.2.23.103' => array
882 (
883 'dict_key' => 1341,
884 'text' => 'S5352C-SI: 48 RJ-45/10-100-1000T(X) + optional 2xXFP/4xSFP slots',
885 'processors' => array ('quidway-slot1-SFP', 'quidway-any-1000T', 'quidway-XFP', 'quidway-mgmt'),
886 ),
24c3e444
DO
887 '2011.2.23.102' => array
888 (
889 'dict_key' => 1339,
890 'text' => 'S5328C-SI: 20 RJ-45/10-100-1000T(X) + 4 combo-gig + 2 XFP slots',
891 'processors' => array ('quidway-21-to-24-comboSFP', 'quidway-any-1000T', 'quidway-XFP', 'quidway-mgmt'),
892 ),
661b3fdb
DO
893 '1991.1.3.45.2.1.1.1' => array
894 (
895 'dict_key' => 127,
896 'text' => 'FGS648P: 48 RJ-45/10-100-1000T(X) + 4 combo-gig + uplink slot',
897 'processors' => array ('fgs-1-to-4-comboSFP', 'fgs-any-1000T', 'fgs-uplinks'),
898 ),
899 '1991.1.3.45.2.2.1.1' => array
900 (
901 'dict_key' => 131,
902 'text' => 'FGS648P-POE: 48 RJ-45/10-100-1000T(X) + 4 combo-gig + uplink slot',
903 'processors' => array ('fgs-1-to-4-comboSFP', 'fgs-any-1000T', 'fgs-uplinks'),
904 ),
ec523868
DO
905 '1991.1.3.54.2.4.1.1' => array
906 (
907 'dict_key' => 1362,
908 'text' => 'FCX 648: 48 RJ-45/10-100-1000T(X) + uplink slot with 4 SFP+',
909 'processors' => array ('fgs-any-1000T', 'fcx-uplinks', 'fcx-management'),
910 ),
6c32c3ff
AA
911 '1991.1.3.46.1.1.1.1' => array
912 (
913 'dict_key' => 413,
914 'text' => 'FLS 624: 20 RJ-45/10-100-1000T(X) + 4 combo-gig + 3 optional 10G modules',
915 'processors' => array ('fls624-combo', 'fgs-any-1000T', 'fls-uplinks'),
916 ),
917 '1991.1.3.46.2.1.1.1' => array
918 (
919 'dict_key' => 414,
920 'text' => 'FLS 648: 44 RJ-45/10-100-1000T(X) + 4 combo-gig + 2 optional 10G modules',
921 'processors' => array ('fls648-combo', 'fgs-any-1000T', 'fls-uplinks'),
922 ),
4eeadb79
DO
923 '1916.2.71' => array
924 (
925 'dict_key' => 694,
926 'text' => 'X450a-24t: 20 RJ-45/10-100-1000T(X) + 4 combo-gig + XFP uplinks slot',
927 'processors' => array ('summit-25-to-26-XFP-uplinks', 'summit-21-to-24-comboSFP', 'summit-any-1000T', 'summit-management'),
928 ),
dbcf1931
DO
929 '1916.2.139' => array
930 (
931 'dict_key' => 1353,
932 'text' => 'X480-24x: 12 SFP-1000 + 12 combo-gig + 2 XFP + VIM slot',
933 'processors' => array
934 (
935 'summit-27-to-30-XFP-uplinks',
936 'summit-25-to-26-XFP-uplinks',
937 'summit-13-to-24-comboT',
938 'summit-any-SFP',
939 'summit-management'
940 ),
941 ),
fb3e70de
DO
942 '202.20.68' => array
943 (
944 'dict_key' => 1374,
945 'text' => 'SMC8150L2: 46 RJ-45/10-100-1000T(X) + 4 combo ports',
946 'processors' => array ('smc-combo-45-to-48', 'nortel-any-1000T'),
947 ),
8acd246d
DO
948 '6027.1.3.12' => array
949 (
950 'dict_key' => 1471,
951 'text' => 'Force10 S60: 44 RJ-45/10-100-1000T(X) + 4 SFP-1000 ports + 0/2/4 SFP+ ports',
952 'processors' => array ('ftos-44-to-47-1000SFP', 'ftos-any-1000T', 'ftos-any-10000SFP+'),
953 ),
74aee2dc
DO
954);
955
536e7323 956global $swtype_pcre;
1f54e1ba
DO
957$swtype_pcre = array
958(
959 '/Huawei Versatile Routing Platform Software.+VRP.+Software, Version 5.30 /s' => 1360,
960 '/Huawei Versatile Routing Platform Software.+VRP.+Software, Version 5.50 /s' => 1361,
8732faac 961 '/Huawei Versatile Routing Platform Software.+VRP.+Software,\s*Version 5.70 /is' => 1369,
1f54e1ba
DO
962 // FIXME: get sysDescr for IronWare 5 and add a pattern
963 '/^Brocade Communications Systems.+, IronWare Version 07\./' => 1364,
964 '/^Juniper Networks,.+JUNOS 9\./' => 1366,
965 '/^Juniper Networks,.+JUNOS 10\./' => 1367,
966);
967
74aee2dc
DO
968function updateStickerForCell ($cell, $attr_id, $new_value)
969{
970 if (!strlen ($cell['attrs'][$attr_id]['value']) && strlen ($new_value))
971 commitUpdateAttrValue ($cell['id'], $attr_id, $new_value);
972}
973
bdc91a5c
DO
974// Accept "X-Y" on input and make sure, that PortInterfaceCompat contains
975// a record with IIF id = X and OIF id = Y.
976function checkPIC ($port_type_id)
977{
978 $matches = array();
979 switch (1)
980 {
981 case preg_match ('/^([[:digit:]]+)-([[:digit:]]+)$/', $port_type_id, $matches):
982 $iif_id = $matches[1];
983 $oif_id = $matches[2];
984 break;
985 case preg_match ('/^([[:digit:]]+)$/', $port_type_id, $matches):
986 $iif_id = 1;
987 $oif_id = $matches[1];
988 break;
989 default:
990 return;
991 }
992 foreach (getPortInterfaceCompat() as $record)
993 if ($record['iif_id'] == $iif_id and $record['oif_id'] == $oif_id)
994 return;
995 commitSupplementPIC ($iif_id, $oif_id);
996}
997
8536e20a
DO
998$msgcode['doSNMPmining']['ERR1'] = 161;
999$msgcode['doSNMPmining']['ERR2'] = 162;
8536e20a 1000$msgcode['doSNMPmining']['OK'] = 81;
8228bdb4 1001function doSNMPmining ($object_id, $snmpsetup)
74aee2dc 1002{
74aee2dc
DO
1003 $objectInfo = spotEntity ('object', $object_id);
1004 $objectInfo['attrs'] = getAttrValues ($object_id);
1005 $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
1006 if (count ($endpoints) == 0)
8ab645cf 1007 return showFuncMessage (__FUNCTION__, 'ERR1'); // endpoint not found
74aee2dc 1008 if (count ($endpoints) > 1)
8ab645cf 1009 return showFuncMessage (__FUNCTION__, 'ERR2'); // can't pick an address
4848a7e3 1010
8228bdb4
DO
1011 $device = new SNMPDevice($endpoints[0], $snmpsetup);
1012
4848a7e3
DO
1013 switch ($objectInfo['objtype_id'])
1014 {
24a6e3a2 1015 case 7:
4848a7e3 1016 case 8:
8228bdb4 1017 return doSwitchSNMPmining ($objectInfo, $device);
4848a7e3 1018 case 2:
8228bdb4 1019 return doPDUSNMPmining ($objectInfo, $device);
4848a7e3
DO
1020 }
1021}
1022
24a6e3a2 1023$msgcode['doSwitchSNMPmining']['ERR3'] = 188;
e22f9600 1024$msgcode['doSwitchSNMPmining']['ERR4'] = 189;
8228bdb4 1025function doSwitchSNMPmining ($objectInfo, $device)
4848a7e3 1026{
4848a7e3 1027 global $known_switches, $iftable_processors;
74aee2dc 1028
8228bdb4 1029 if (FALSE === ($sysObjectID = $device->snmpget ('sysObjectID.0')))
8ab645cf 1030 return showFuncMessage (__FUNCTION__, 'ERR3'); // // fatal SNMP failure
84986395 1031 $sysObjectID = preg_replace ('/^.*(enterprises\.)([\.[:digit:]]+)$/', '\\2', $sysObjectID);
8228bdb4
DO
1032 $sysName = substr ($device->snmpget ('sysName.0'), strlen ('STRING: '));
1033 $sysDescr = substr ($device->snmpget ('sysDescr.0'), strlen ('STRING: '));
74aee2dc
DO
1034 $sysDescr = str_replace (array ("\n", "\r"), " ", $sysDescr); // Make it one line
1035 if (!isset ($known_switches[$sysObjectID]))
8ab645cf 1036 return showFuncMessage (__FUNCTION__, 'ERR4', array ($sysObjectID)); // unknown OID
5e193b67
DO
1037 foreach (array_keys ($known_switches[$sysObjectID]['processors']) as $pkey)
1038 if (!array_key_exists ($known_switches[$sysObjectID]['processors'][$pkey], $iftable_processors))
1039 {
8ab645cf 1040 showWarning ('processor "' . $known_switches[$sysObjectID]['processors'][$pkey] . '" not found');
5e193b67
DO
1041 unset ($known_switches[$sysObjectID]['processors'][$pkey]);
1042 }
56a797ef 1043 updateStickerForCell ($objectInfo, 2, $known_switches[$sysObjectID]['dict_key']);
74aee2dc 1044 updateStickerForCell ($objectInfo, 3, $sysName);
8ab645cf 1045 showOneLiner (81, array ('generic'));
74aee2dc
DO
1046 switch (1)
1047 {
56a797ef 1048 case preg_match ('/^9\.1\./', $sysObjectID): // Catalyst
84986395
DO
1049 $exact_release = preg_replace ('/^.*, Version ([^ ]+), .*$/', '\\1', $sysDescr);
1050 $major_line = preg_replace ('/^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*/', '\\1', $exact_release);
74aee2dc
DO
1051 $ios_codes = array
1052 (
1053 '12.0' => 244,
1054 '12.1' => 251,
1055 '12.2' => 252,
1056 );
1057 updateStickerForCell ($objectInfo, 5, $exact_release);
6be06cbb
DO
1058 if (array_key_exists ($major_line, $ios_codes))
1059 updateStickerForCell ($objectInfo, 4, $ios_codes[$major_line]);
8228bdb4 1060 $sysChassi = $device->snmpget ('1.3.6.1.4.1.9.3.6.3.0');
74aee2dc
DO
1061 if ($sysChassi !== FALSE or $sysChassi !== NULL)
1062 updateStickerForCell ($objectInfo, 1, str_replace ('"', '', substr ($sysChassi, strlen ('STRING: '))));
bdc91a5c
DO
1063 checkPIC ('1-29');
1064 commitAddPort ($objectInfo['id'], 'con0', '1-29', 'console', ''); // RJ-45 RS-232 console
facd0235
DO
1065 // blade devices are powered through internal circuitry of chassis
1066 if ($sysObjectID != '9.1.749' and $sysObjectID != '9.1.920')
1067 {
1068 checkPIC ('1-16'); // AC input
1069 commitAddPort ($objectInfo['id'], 'AC-in', '1-16', '', '');
1070 }
8ab645cf 1071 showOneLiner (81, array ('catalyst-generic'));
74aee2dc 1072 break;
56a797ef 1073 case preg_match ('/^9\.12\.3\.1\.3\./', $sysObjectID): // Nexus
84986395
DO
1074 $exact_release = preg_replace ('/^.*, Version ([^ ]+), .*$/', '\\1', $sysDescr);
1075 $major_line = preg_replace ('/^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*/', '\\1', $exact_release);
74aee2dc
DO
1076 $nxos_codes = array
1077 (
1078 '4.0' => 963,
1079 '4.1' => 964,
1080 );
6be06cbb
DO
1081 if (array_key_exists ($major_line, $nxos_codes))
1082 updateStickerForCell ($objectInfo, 4, $nxos_codes[$major_line]);
74aee2dc 1083 updateStickerForCell ($objectInfo, 5, $exact_release);
bdc91a5c 1084 checkPIC ('1-29');
24a6e3a2 1085 commitAddPort ($objectInfo['id'], 'con0', '1-29', 'console', ''); // RJ-45 RS-232 console
dcfa87d7
DO
1086 checkPIC ('1-16'); // AC input
1087 commitAddPort ($objectInfo['id'], 'AC-in-1', '1-16', 'AC1', '');
1088 commitAddPort ($objectInfo['id'], 'AC-in-2', '1-16', 'AC2', '');
8ab645cf 1089 showOneLiner (81, array ('nexus-generic'));
74aee2dc 1090 break;
56a797ef 1091 case preg_match ('/^11\.2\.3\.7\.11\./', $sysObjectID): // ProCurve
84986395 1092 $exact_release = preg_replace ('/^.* revision ([^ ]+), .*$/', '\\1', $sysDescr);
74aee2dc 1093 updateStickerForCell ($objectInfo, 5, $exact_release);
8ab645cf 1094 showOneLiner (81, array ('procurve-generic'));
74aee2dc 1095 break;
6be06cbb 1096 case preg_match ('/^4526\.100\.2\./', $sysObjectID): // NETGEAR
bdc91a5c
DO
1097 checkPIC ('1-681');
1098 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
8ab645cf 1099 showOneLiner (81, array ('netgear-generic'));
6be06cbb 1100 break;
7d69a266 1101 case preg_match ('/^2011\.2\.23\./', $sysObjectID): // Huawei
1f54e1ba 1102 detectSoftwareType ($objectInfo, $sysDescr);
bdc91a5c 1103 checkPIC ('1-681');
b55f8de3 1104 commitAddPort ($objectInfo['id'], 'con0', '1-681', 'console', ''); // DB-9 RS-232 console
8ab645cf 1105 showOneLiner (81, array ('huawei-generic'));
7d69a266 1106 break;
1f54e1ba
DO
1107 case '2636.1.1.1.2.31' == $sysObjectID: // Juniper EX4200
1108 detectSoftwareType ($objectInfo, $sysDescr);
1109 checkPIC ('1-29');
1110 commitAddPort ($objectInfo['id'], 'con', '1-29', 'CON', ''); // RJ-45 RS-232 console
1111 // EX4200-24T is already in DB
1112 if (preg_match ('/^Juniper Networks, Inc. ex4200-48t internet router/', $sysDescr))
1113 updateStickerForCell ($objectInfo, 2, 907);
8ab645cf 1114 showOneLiner (81, array ('juniper-ex'));
1f54e1ba 1115 break;
7d69a266 1116 case preg_match ('/^2636\.1\.1\.1\.2\./', $sysObjectID): // Juniper
1f54e1ba 1117 detectSoftwareType ($objectInfo, $sysDescr);
bdc91a5c
DO
1118 checkPIC ('1-681');
1119 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
8ab645cf 1120 showOneLiner (81, array ('juniper-generic'));
661b3fdb
DO
1121 break;
1122 case preg_match ('/^1991\.1\.3\.45\./', $sysObjectID): // snFGSFamily
6c32c3ff 1123 case preg_match ('/^1991\.1\.3\.46\./', $sysObjectID): // snFLSFamily
ec523868 1124 case preg_match ('/^1991\.1\.3\.54\.2\.4\.1\.1$/', $sysObjectID): // FCX 648
1f54e1ba 1125 detectSoftwareType ($objectInfo, $sysDescr);
84986395 1126 $exact_release = preg_replace ('/^.*, IronWare Version ([^ ]+) .*$/', '\\1', $sysDescr);
661b3fdb
DO
1127 updateStickerForCell ($objectInfo, 5, $exact_release);
1128 # FOUNDRY-SN-AGENT-MIB::snChasSerNum.0
8228bdb4 1129 $sysChassi = $device->snmpget ('enterprises.1991.1.1.1.1.2.0');
661b3fdb
DO
1130 if ($sysChassi !== FALSE or $sysChassi !== NULL)
1131 updateStickerForCell ($objectInfo, 1, str_replace ('"', '', substr ($sysChassi, strlen ('STRING: '))));
1132
1133 # Type of uplink module installed.
1134 # table: FOUNDRY-SN-AGENT-MIB::snAgentBrdMainBrdDescription
1135 # Possible part numbers are:
1136 # FGS-1XG1XGC (one fixed CX4 port)
1137 # FGS-2XGC (two fixed CX4 ports)
1138 # FGS-2XG (two XFP slots)
6c32c3ff
AA
1139 # And for FLS result (which is not handled here) would be:
1140 # 1991.1.1.2.2.1.1.2.1 = STRING: "FLS-24G 24-port Management Module"
1141 # 1991.1.1.2.2.1.1.2.3 = STRING: "FLS-1XG 1-port 10G Module (1-XFP)"
1142 # 1991.1.1.2.2.1.1.2.4 = STRING: "FLS-1XG 1-port 10G Module (1-XFP)"
1143 # (assuming, that the device has 2 XFP modules in slots 3 and 4).
1144
8228bdb4 1145 foreach ($device->snmpwalkoid ('enterprises.1991.1.1.2.2.1.1.2') as $module_raw)
661b3fdb
DO
1146 if (preg_match ('/^STRING: "(FGS-1XG1XGC|FGS-2XGC) /i', $module_raw))
1147 {
1148 $iftable_processors['fgs-uplinks']['dict_key'] = '1-40'; // CX4
1149 break;
1150 }
1151
1152 # AC inputs
1153 # table: FOUNDRY-SN-AGENT-MIB::snChasPwrSupplyDescription
1154 # "Power supply 1 "
1155 # "Power supply 2 "
8228bdb4 1156 foreach ($device->snmpwalkoid ('enterprises.1991.1.1.1.2.1.1.2') as $PSU_raw)
661b3fdb
DO
1157 {
1158 $count = 0;
1159 $PSU_cooked = trim (preg_replace ('/^string: "(.+)"$/i', '\\1', $PSU_raw, 1, $count));
1160 if ($count)
1161 {
1162 checkPIC ('1-16');
1163 commitAddPort ($objectInfo['id'], $PSU_cooked, '1-16', '', '');
1164 }
1165 }
1166 # fixed console port
1167 checkPIC ('1-681');
1168 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
8ab645cf 1169 showOneLiner (81, array ('brocade-generic'));
661b3fdb 1170 break;
4eeadb79
DO
1171 case preg_match ('/^1916\.2\./', $sysObjectID): // Extreme Networks Summit
1172 $xos_release = preg_replace ('/^ExtremeXOS version ([[:digit:]]+)\..*$/', '\\1', $sysDescr);
1173 $xos_codes = array
1174 (
1175 '10' => 1350,
1176 '11' => 1351,
1177 '12' => 1352,
1178 );
1179 if (array_key_exists ($xos_release, $xos_codes))
1180 updateStickerForCell ($objectInfo, 4, $xos_codes[$xos_release]);
1181 checkPIC ('1-681');
1182 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232
1183 checkPIC ('1-16');
1184 commitAddPort ($objectInfo['id'], 'AC-in', '1-16', '', '');
8ab645cf 1185 showOneLiner (81, array ('summit-generic'));
4eeadb79 1186 break;
8acd246d
DO
1187 case preg_match ('/^6027\.1\./', $sysObjectID): # Force10
1188 commitAddPort ($objectInfo['id'], 'aux', '1-29', 'RS-232', ''); // RJ-45 RS-232 console
1189 commitAddPort ($objectInfo['id'], 'ma0/0', '1-19', 'ETHERNET', '');
1190 $m = array();
1191 if (preg_match ('/Force10 Application Software Version: ([\d\.]+)/', $sysDescr, $m))
1192 updateStickerForCell ($objectInfo, 5, $m[1]);
1193 # F10-S-SERIES-CHASSIS-MIB::chStackUnitSerialNumber.1
1194 $serialNo = $device->snmpget ('enterprises.6027.3.10.1.2.2.1.12.1');
1195 if (strlen ($serialNo))
1196 updateStickerForCell ($objectInfo, 1, str_replace ('"', '', substr ($serialNo, strlen ('STRING: '))));
1197 break;
7d69a266 1198 default: // Nortel...
74aee2dc
DO
1199 break;
1200 }
56a797ef
DO
1201 $ifInfo = array();
1202 $tablename = 'ifDescr';
8228bdb4 1203 foreach ($device->snmpwalkoid ($tablename) as $oid => $value)
56a797ef 1204 {
84986395
DO
1205 $randomindex = preg_replace ("/^.*${tablename}\.(.+)\$/", '\\1', $oid);
1206 $value = trim (preg_replace ('/^.+: (.+)$/', '\\1', $value), '"');
56a797ef
DO
1207 $ifInfo[$randomindex][$tablename] = $value;
1208 }
1209 $tablename = 'ifPhysAddress';
8228bdb4 1210 foreach ($device->snmpwalkoid ($tablename) as $oid => $value)
56a797ef 1211 {
84986395 1212 $randomindex = preg_replace ("/^.*${tablename}\.(.+)\$/", '\\1', $oid);
56a797ef
DO
1213 $value = trim ($value);
1214 // NET-SNMP may return MAC addresses in one of two (?) formats depending on
1215 // DISPLAY-HINT internal database. The best we can do about it is to accept both.
1216 // Bug originally reported by Walery Wysotsky against openSUSE 11.0.
6a845dce 1217 if (preg_match ('/^string: [0-9a-f]{1,2}(:[0-9a-f]{1,2}){5}/i', $value)) // STRING: x:yy:z:xx:y:zz
56a797ef
DO
1218 {
1219 list ($dummy, $value) = explode (' ', $value);
1220 $addrbytes = explode (':', $value);
1221 foreach ($addrbytes as $bidx => $bytestr)
1222 if (strlen ($bytestr) == 1)
1223 $addrbytes[$bidx] = '0' . $bytestr;
1224 }
6a845dce 1225 elseif (preg_match ('/^hex-string:( [0-9a-f]{2}){6}/i', $value)) // Hex-STRING: xx yy zz xx yy zz
56a797ef 1226 $addrbytes = explode (' ', substr ($value, -17));
6a845dce
DO
1227 elseif (preg_match ('/22[0-9a-f]{12}22$/', bin2hex ($value))) // STRING: "??????"
1228 $addrbytes = array (substr (bin2hex ($value), -14, 12));
56a797ef
DO
1229 else
1230 continue; // martian format
1231 $ifInfo[$randomindex][$tablename] = implode ('', $addrbytes);
1232 }
1233 // process each interface only once regardless of how many processors we have to run
1234 foreach ($ifInfo as $iface)
1235 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
1236 {
56a797ef 1237 $newname = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['replacement'], $iface['ifDescr'], 1, $count);
1f54e1ba
DO
1238 if ($newname === NULL)
1239 {
8ab645cf 1240 showError ('PCRE pattern error, terminating');
1f54e1ba
DO
1241 break 2;
1242 }
56a797ef
DO
1243 if (!$count)
1244 continue; // try next processor on current port
1245 $newlabel = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['label'], $iface['ifDescr'], 1, $count);
bdc91a5c 1246 checkPIC ($iftable_processors[$processor_name]['dict_key']);
73a9a0a0 1247 commitAddPort ($objectInfo['id'], $newname, $iftable_processors[$processor_name]['dict_key'], $newlabel, $iface['ifPhysAddress']);
56a797ef
DO
1248 if (!$iftable_processors[$processor_name]['try_next_proc']) // done with this port
1249 continue 2;
1250 }
1251 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
8ab645cf 1252 showOneLiner (81, array ($processor_name));
8536e20a 1253 // No failure up to this point, thus leave current tab for the "Ports" one.
8ab645cf 1254 return buildRedirectURL (NULL, 'ports');
74aee2dc
DO
1255}
1256
8228bdb4 1257function doPDUSNMPmining ($objectInfo, $hostname, $snmpsetup)
38e05b77 1258{
29de85b6 1259 global $known_APC_SKUs;
8228bdb4 1260 $switch = new APCPowerSwitch ($hostname, $snmpsetup);
29de85b6
DO
1261 if (FALSE !== ($dict_key = array_search ($switch->getHWModel(), $known_APC_SKUs)))
1262 updateStickerForCell ($objectInfo, 2, $dict_key);
1263 updateStickerForCell ($objectInfo, 1, $switch->getHWSerial());
4848a7e3 1264 updateStickerForCell ($objectInfo, 3, $switch->getName());
29de85b6 1265 updateStickerForCell ($objectInfo, 5, $switch->getFWRev());
bdc91a5c 1266 checkPIC ('1-16');
29de85b6 1267 commitAddPort ($objectInfo['id'], 'input', '1-16', 'input', '');
4848a7e3
DO
1268 $portno = 1;
1269 foreach ($switch->getPorts() as $name => $port)
29de85b6
DO
1270 {
1271 $label = mb_strlen ($port[0]) ? $port[0] : $portno;
bdc91a5c 1272 checkPIC ('1-1322');
29de85b6
DO
1273 commitAddPort ($objectInfo['id'], $portno, '1-1322', $port[0], '');
1274 $portno++;
1275 }
8ab645cf
AA
1276 showSuccess ("Added ${portno} port(s)");
1277 return buildRedirectURL (NULL, 'ports');
38e05b77
DO
1278}
1279
4848a7e3 1280// APC SNMP code by Russ Garrett
38e05b77
DO
1281define('APC_STATUS_ON', 1);
1282define('APC_STATUS_OFF', 2);
1283define('APC_STATUS_REBOOT', 3);
1284
1285class SNMPDevice {
8228bdb4
DO
1286 protected $snmp;
1287
1288 function __construct($hostname, $snmpsetup) {
1289 if( isset($snmpsetup['community']) ) {
1290 $this->snmp = new SNMPv2($hostname, $snmpsetup);
1291 }
1292 else {
1293 $this->snmp = new SNMPv3($hostname, $snmpsetup);
1294 }
38e05b77 1295
38e05b77
DO
1296 }
1297
1298 function getName() {
1299 return $this->getString('sysName.0');
1300 }
1301
1302 function getDescription() {
1303 return $this->getString('sysDescr.0');
1304 }
8228bdb4
DO
1305
1306 function snmpget($oid) {
1307 return $this->snmp->snmpget($oid);
1308 }
1309
1310 function snmpwalkoid($oid) {
1311 return $this->snmp->snmpwalkoid($oid);
1312 }
38e05b77
DO
1313
1314 protected function snmpSet($oid, $type, $value) {
8228bdb4 1315 return $this->snmp->snmpset($oid, $type, $value);
38e05b77
DO
1316 }
1317
1318 protected function getString($oid) {
8228bdb4
DO
1319 return trim(str_replace('STRING: ', '', $this->snmp->snmpget($oid)), '"');
1320 }
1321}
1322
1323abstract class SNMP {
1324 protected $hostname;
1325 protected $snmpsetup;
1326
1327 function __construct($hostname, $snmpsetup) {
1328 $this->hostname = $hostname;
1329 $this->snmpsetup = $snmpsetup;
1330 }
1331
1332 abstract function snmpget($oid);
1333 abstract function snmpset($oid, $type, $value);
1334 abstract function snmpwalkoid($oid);
1335}
1336
1337class SNMPv2 extends SNMP {
1338 function snmpget($oid) {
1339 return snmpget($this->hostname, $this->snmpsetup['community'], $oid);
1340 }
1341
1342 function snmpset($oid, $type, $value) {
1343 return snmpset($this->hostname, $this->snmpsetup['community'], $oid, $type, $value);
1344 }
1345
1346 function snmpwalkoid($oid) {
1347 return snmpwalkoid($this->hostname, $this->snmpsetup['community'], $oid);
1348 }
1349}
1350
1351class SNMPv3 extends SNMP {
1352 function snmpget($oid) {
1353 return snmp3_get($this->hostname, $this->snmpsetup['sec_name'], $this->snmpsetup['sec_level'], $this->snmpsetup['auth_protocol'], $this->snmpsetup['auth_passphrase'], $this->snmpsetup['priv_protocol'], $this->snmpsetup['priv_passphrase'], $oid);
1354 }
1355
1356 function snmpset($oid, $type, $value) {
1357 return snmp3_set($this->hostname, $this->snmpsetup['sec_name'], $this->snmpsetup['sec_level'], $this->snmpsetup['auth_protocol'], $this->snmpsetup['auth_passphrase'], $this->snmpsetup['priv_protocol'], $this->snmpsetup['priv_passphrase'], $oid, $type, $value);
1358 }
1359
1360 function snmpwalkoid($oid) {
1361 return snmp3_real_walk($this->hostname, $this->snmpsetup['sec_name'], $this->snmpsetup['sec_level'], $this->snmpsetup['auth_protocol'], $this->snmpsetup['auth_passphrase'], $this->snmpsetup['priv_protocol'], $this->snmpsetup['priv_passphrase'], $oid);
38e05b77
DO
1362 }
1363}
1364
1365class APCPowerSwitch extends SNMPDevice {
1366 protected $snmpMib = 'SNMPv2-SMI::enterprises.318';
1367
1368 function getPorts() {
8228bdb4
DO
1369 $data = $this->snmpwalk("{$this->snmpMib}.1.1.12.3.3.1.1.2");
1370 $status = $this->snmpwalk("{$this->snmpMib}.1.1.12.3.3.1.1.4");
38e05b77
DO
1371 $out = array();
1372 foreach ($data as $id => $d) {
1373 $out[$id + 1] = array(trim(str_replace('STRING: ', '', $d), '"'), str_replace('INTEGER: ', '', $status[$id]));
1374 }
1375 return $out;
1376 }
1377
1378 function getPortStatus($id) {
8228bdb4 1379 return trim($this->snmpget("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id"), 'INTEGER: ');
38e05b77
DO
1380 }
1381
1382 function getPortName($id) {
8228bdb4 1383 return trim(str_replace('STRING: ', '', $this->snmpget("{$this->snmpMib}.1.1.12.3.3.1.1.2.$id")), '"');
38e05b77
DO
1384 }
1385
1386 function setPortName($id, $name) {
8228bdb4 1387 return $this->snmpset("{$this->snmpMib}.1.1.4.5.2.1.3.$id", 's', $name);
38e05b77
DO
1388 }
1389
1390 function portOff($id) {
1391 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_OFF);
1392 }
1393
1394 function portOn($id) {
1395 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_ON);
1396 }
1397
1398 function portReboot($id) {
1399 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_REBOOT);
1400 }
30ad8bc4
DO
1401 // rPDUIdentFirmwareRev.0 == .1.3.6.1.4.1.318.1.1.12.1.3.0 = STRING: "vN.N.N"
1402 function getFWRev()
1403 {
8228bdb4 1404 return preg_replace ('/^STRING: "(.+)"$/', '\\1', $this->snmpget ("{$this->snmpMib}.1.1.12.1.3.0"));
30ad8bc4
DO
1405 }
1406 // rPDUIdentSerialNumber.0 == .1.3.6.1.4.1.318.1.1.12.1.6.0 = STRING: "XXXXXXXXXXX"
1407 function getHWSerial()
1408 {
8228bdb4 1409 return preg_replace ('/^STRING: "(.+)"$/', '\\1', $this->snmpget ("{$this->snmpMib}.1.1.12.1.6.0"));
30ad8bc4
DO
1410 }
1411 // rPDUIdentModelNumber.0 == .1.3.6.1.4.1.318.1.1.12.1.5.0 = STRING: "APnnnn"
1412 function getHWModel()
1413 {
8228bdb4 1414 return preg_replace ('/^STRING: "(.*)"$/', '\\1', $this->snmpget ("{$this->snmpMib}.1.1.12.1.5.0"));
30ad8bc4 1415 }
38e05b77
DO
1416}
1417
2d511052
DO
1418// Take address in the form XX:XX:XX:XX:XX:XX and return the next
1419// address in the same form.
1420function nextMACAddress ($addr)
1421{
cc000fab
DO
1422 if ($addr == '')
1423 return '';
2d511052
DO
1424 $bytes = array();
1425 foreach (explode (':', $addr) as $hex)
1426 $bytes[] = hexdec ($hex);
1427 for ($i = 5; $i >= 0; $i--)
1428 {
1429 $bytes[$i] += 1;
1430 if ($bytes[$i] <= 255) // FF
1431 break; // no roll over
1432 $bytes[$i] = 0;
1433 }
1434 foreach (array_keys ($bytes) as $key)
1435 $bytes[$key] = sprintf ('%02X', $bytes[$key]);
1436 return implode (':', $bytes);
1437}
1438
1439function generatePortsForCatModule ($object_id, $slotno = 1, $mtype = 'X6748', $mac_address = '')
1440{
1441 global $dbxlink;
1442 $mac_address = l2addressFromDatabase (l2addressForDatabase ($mac_address));
1443 switch ($mtype)
1444 {
cc000fab 1445 case 'WS-X6748-GE-TX':
2d511052
DO
1446 $dbxlink->beginTransaction();
1447 for ($i = 1; $i <= 48; $i++)
1448 {
73a9a0a0 1449 commitAddPort ($object_id, "gi${slotno}/${i}", '1-24', "slot ${slotno} port ${i}", $mac_address);
cc000fab 1450 $mac_address = nextMACAddress ($mac_address);
2d511052
DO
1451 }
1452 $dbxlink->commit();
1453 break;
cc000fab
DO
1454 case 'WS-X6708-10GE':
1455 for ($i = 1; $i <= 8; $i++)
1456 {
1457 commitAddPort ($object_id, "te${slotno}/${i}", '6-1080', "slot ${slotno} port ${i}", $mac_address);
1458 $mac_address = nextMACAddress ($mac_address);
1459 }
1460 break;
8fe2d6f0
DO
1461 case 'WS-X6704-10GE':
1462 for ($i = 1; $i <= 4; $i++)
1463 {
1464 commitAddPort ($object_id, "te${slotno}/${i}", '5-1079', "slot ${slotno} port ${i}", $mac_address);
1465 $mac_address = nextMACAddress ($mac_address);
1466 }
1467 break;
cc000fab
DO
1468 case 'VS-S720-10G':
1469 commitAddPort ($object_id, "gi${slotno}/1", '4-1077', "slot ${slotno} port 1", $mac_address);
1470 $mac_address = nextMACAddress ($mac_address);
1471 commitAddPort ($object_id, "gi${slotno}/2", '4-1077', "slot ${slotno} port 2", $mac_address);
1472 $mac_address = nextMACAddress ($mac_address);
1473 commitAddPort ($object_id, "gi${slotno}/3", '1-24', "slot ${slotno} port 3", $mac_address);
1474 $mac_address = nextMACAddress ($mac_address);
1475 commitAddPort ($object_id, "te${slotno}/4", '6-1080', "slot ${slotno} port 4", $mac_address);
1476 $mac_address = nextMACAddress ($mac_address);
1477 commitAddPort ($object_id, "te${slotno}/5", '6-1080', "slot ${slotno} port 5", $mac_address);
1478 break;
3e34adae
DO
1479 case '3750G-24TS':
1480 // MAC address of 1st port is the next one after switch's address
cc000fab 1481 $mac_address = nextMACAddress ($mac_address);
3e34adae
DO
1482 for ($i = 1; $i <= 24; $i++)
1483 {
1484 commitAddPort ($object_id, "gi${slotno}/0/${i}", '1-24', "unit ${slotno} port ${i}", $mac_address);
cc000fab 1485 $mac_address = nextMACAddress ($mac_address);
3e34adae
DO
1486 }
1487 for ($i = 25; $i <= 28; $i++)
1488 {
1489 commitAddPort ($object_id, "gi${slotno}/0/${i}", '4-1077', "unit ${slotno} port ${i}", $mac_address);
abd1e9ac
DO
1490 $mac_address = nextMACAddress ($mac_address);
1491 }
1492 break;
1493 case '3750G-24T':
1494 $mac_address = nextMACAddress ($mac_address);
1495 for ($i = 1; $i <= 24; $i++)
1496 {
1497 commitAddPort ($object_id, "gi${slotno}/0/${i}", '1-24', "unit ${slotno} port ${i}", $mac_address);
cc000fab 1498 $mac_address = nextMACAddress ($mac_address);
3e34adae
DO
1499 }
1500 break;
d423bb7d
DO
1501 case '3750G-16TD':
1502 $mac_address = nextMACAddress ($mac_address);
1503 for ($i = 1; $i <= 16; $i++)
1504 {
1505 commitAddPort ($object_id, "gi${slotno}/0/${i}", '1-24', "unit ${slotno} port ${i}", $mac_address);
1506 $mac_address = nextMACAddress ($mac_address);
1507 }
1508 commitAddPort ($object_id, "te${slotno}/0/1", '5-1079', "unit ${slotno} port ${i}", $mac_address);
1509 break;
c5553818
DO
1510 case 'LE02G48TA':
1511 for ($i = 0; $i <= 47; $i++)
1512 commitAddPort ($object_id, "gi${slotno}/0/${i}", '1-24', "slot ${slotno} port ${i}", $mac_address);
1513 break;
1514 case 'LE02X12SA':
1515 for ($i = 0; $i <= 11; $i++)
1516 commitAddPort ($object_id, "gi${slotno}/0/${i}", '9-1084', "slot ${slotno} port ${i}", $mac_address);
1517 break;
2d511052
DO
1518 }
1519}
1520
1f54e1ba
DO
1521function detectSoftwareType ($objectInfo, $sysDescr)
1522{
1523 global $swtype_pcre;
1524 foreach ($swtype_pcre as $pattern => $dict_key)
1525 if (preg_match ($pattern, $sysDescr))
1526 {
1527 updateStickerForCell ($objectInfo, 4, $dict_key);
1528 return;
1529 }
1530}
2ffd5a2a 1531?>