| 1 | package Device::ZyXEL::IES::Port; | ||
| 2 | 21 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 21 | ▶ | use Net::SNMP qw/:asn1 ticks_to_time/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 21 | ▶ | use Net::SNMP::Util qw/snmpget/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 21 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 0 | ▶ | use Device::ZyXEL::IES::OID; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Device::ZyXEL::IES::Port - A model of a Port on a Slot on an IES. | ||
| 11 | |||
| 12 | =head1 VERSION | ||
| 13 | |||
| 14 | Version 0.10 | ||
| 15 | |||
| 16 | =cut | ||
| 17 | |||
| 18 | our $VERSION = '0.10'; | ||
| 19 | |||
| 20 | =head1 SYNOPSIS | ||
| 21 | |||
| 22 | Models a port on a ZyXEL IES Device. | ||
| 23 | |||
| 24 | Based on Moose. | ||
| 25 | |||
| 26 | # Must have a Device::Zyxel::IES::Slot object | ||
| 27 | |||
| 28 | my $p = Device::ZyXEL::IES::Port( | ||
| 29 | id => 301, slot => $s ); | ||
| 30 | |||
| 31 | my $adminstatus = $p->read_adminstatus(); | ||
| 32 | |||
| 33 | # $adminstatus is now the same as $p->adminstatus(); | ||
| 34 | |||
| 35 | # DOWN the port | ||
| 36 | |||
| 37 | $p->adminstatus(1); | ||
| 38 | |||
| 39 | =head1 MOOSE ATTRIBUTES | ||
| 40 | |||
| 41 | =head2 id | ||
| 42 | |||
| 43 | Required attribute that identifies the port. Matches ifIndex. | ||
| 44 | |||
| 45 | =cut | ||
| 46 | |||
| 47 | has 'id' => ( | ||
| 48 | isa => 'Int', | ||
| 49 | is => 'ro', | ||
| 50 | required => 1 | ||
| 51 | ); | ||
| 52 | |||
| 53 | =head2 slot | ||
| 54 | |||
| 55 | Required attribute that isa Device::ZyXEL::IES::Slot object. | ||
| 56 | |||
| 57 | =cut | ||
| 58 | has 'slot' => ( | ||
| 59 | isa => 'Device::ZyXEL::IES::Slot', | ||
| 60 | is => 'ro', | ||
| 61 | required => 1 | ||
| 62 | ); | ||
| 63 | |||
| 64 | =head2 adminstatus (rw) | ||
| 65 | |||
| 66 | ifAdminStatus on the port. Read from IES using read_adminstatus | ||
| 67 | |||
| 68 | =cut | ||
| 69 | has 'adminstatus' => ( | ||
| 70 | isa => 'Int', | ||
| 71 | is => 'rw', | ||
| 72 | ); | ||
| 73 | |||
| 74 | =head2 operstatus (ro) | ||
| 75 | |||
| 76 | ifOperStatus on the port. Read from IES using read_operstatus | ||
| 77 | |||
| 78 | =cut | ||
| 79 | has 'operstatus' => ( | ||
| 80 | isa => 'Int', | ||
| 81 | is => 'ro', | ||
| 82 | default => sub {0}, | ||
| 83 | writer => '_set_operstatus' | ||
| 84 | ); | ||
| 85 | |||
| 86 | =head2 uptime (ro) | ||
| 87 | |||
| 88 | uptime on the port. Read from IES using read_uptime | ||
| 89 | |||
| 90 | =cut | ||
| 91 | has 'uptime' => ( | ||
| 92 | isa => 'Str', | ||
| 93 | is => 'ro', | ||
| 94 | writer => '_set_uptime' | ||
| 95 | ); | ||
| 96 | |||
| 97 | =head2 profile (rw) | ||
| 98 | |||
| 99 | Configuration profile on the port. This attribute OID will depend on the | ||
| 100 | type of xDSL interface of the port. | ||
| 101 | |||
| 102 | =cut | ||
| 103 | has 'profile' => ( | ||
| 104 | isa => 'Str', | ||
| 105 | is => 'rw', | ||
| 106 | default => sub {''} | ||
| 107 | ); | ||
| 108 | |||
| 109 | =head2 ifInOctets (ro) | ||
| 110 | |||
| 111 | the ifInOctets on the port. Note that if this conglomorate of modules | ||
| 112 | is used to systematically read and record (say using RRD) values, you | ||
| 113 | might expience trouble with cpu load on the IES. (See Device::ZyXEL::IES) | ||
| 114 | |||
| 115 | Retrieve a value for this attribute from the IES using read_ifInOctets | ||
| 116 | =cut | ||
| 117 | has 'ifInOctets' => ( | ||
| 118 | isa => 'Int', | ||
| 119 | is => 'ro', | ||
| 120 | writer => '_set_ifInOctets' | ||
| 121 | ); | ||
| 122 | |||
| 123 | =head2 ifOutOctets (ro) | ||
| 124 | |||
| 125 | the ifOutOctets on the port. Note that if this conglomorate of modules | ||
| 126 | is used to systematically read and record (say using RRD) values, you | ||
| 127 | might expience trouble with cpu load on the IES. (See Device::ZyXEL::IES) | ||
| 128 | |||
| 129 | Retrieve a value for this attribute from the IES using read_ifOutOctets | ||
| 130 | =cut | ||
| 131 | has 'ifOutOctets' => ( | ||
| 132 | isa => 'Int', | ||
| 133 | is => 'ro', | ||
| 134 | writer => '_set_ifOutOctets' | ||
| 135 | ); | ||
| 136 | |||
| 137 | =head2 userinfo (ro) | ||
| 138 | |||
| 139 | Contains the userinfo OID value from the IES. | ||
| 140 | |||
| 141 | Retrieve userinfo from the IES Port using read_userinfo | ||
| 142 | =cut | ||
| 143 | has 'userinfo' => ( | ||
| 144 | isa => 'Str', | ||
| 145 | is => 'ro', | ||
| 146 | writer => '_set_userinfo' | ||
| 147 | ); | ||
| 148 | |||
| 149 | =head2 ifLastChange (ro) | ||
| 150 | |||
| 151 | Contains the ifLastChange OID value from the IES. | ||
| 152 | |||
| 153 | Retrieve a value from the IES Port using read_ifLastChange. | ||
| 154 | |||
| 155 | This attribute can be used to calculate the uptime of the port. | ||
| 156 | =cut | ||
| 157 | has 'ifLastChange' => ( | ||
| 158 | isa => 'Int', | ||
| 159 | is => 'ro', | ||
| 160 | writer => '_set_ifLastChange' | ||
| 161 | ); | ||
| 162 | |||
| 163 | =head2 maxmac (rw) | ||
| 164 | |||
| 165 | Contains the maxmac setting from the IES. | ||
| 166 | |||
| 167 | Retrieve the maxmac value from the IES Port using read_maxmac, | ||
| 168 | before that the value of this attribute will not reflect reality. | ||
| 169 | |||
| 170 | The maxmac setting is used by the IES in conjunction with the Snoop | ||
| 171 | feature to ensure a maximum number of MAC address pr port. | ||
| 172 | |||
| 173 | =cut | ||
| 174 | has 'maxmac' => ( | ||
| 175 | isa => 'Int', | ||
| 176 | is => 'rw', | ||
| 177 | lazy => 1, | ||
| 178 | default => sub { 2 } | ||
| 179 | ); | ||
| 180 | |||
| 181 | =head2 maxdown (ro) | ||
| 182 | |||
| 183 | Contains the maxAttainableDownstream setting from the IES. | ||
| 184 | |||
| 185 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 186 | object. | ||
| 187 | |||
| 188 | =cut | ||
| 189 | has 'maxdown' => ( | ||
| 190 | isa => 'Int', | ||
| 191 | is => 'ro', | ||
| 192 | writer => '_set_maxdown' | ||
| 193 | ); | ||
| 194 | |||
| 195 | =head2 maxup (ro) | ||
| 196 | |||
| 197 | Contains the maxAttainableUpstream setting from the IES. | ||
| 198 | |||
| 199 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 200 | object. | ||
| 201 | |||
| 202 | =cut | ||
| 203 | has 'maxup' => ( | ||
| 204 | isa => 'Int', | ||
| 205 | is => 'ro', | ||
| 206 | writer => '_set_maxup' | ||
| 207 | ); | ||
| 208 | |||
| 209 | =head2 downspeed (ro) | ||
| 210 | |||
| 211 | Contains the currAttainableDownstream setting from the IES. | ||
| 212 | |||
| 213 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 214 | object. | ||
| 215 | |||
| 216 | =cut | ||
| 217 | has 'downspeed' => ( | ||
| 218 | isa => 'Int', | ||
| 219 | is => 'ro', | ||
| 220 | writer => '_set_downspeed' | ||
| 221 | ); | ||
| 222 | |||
| 223 | =head2 upspeed (ro) | ||
| 224 | |||
| 225 | Contains the currAttainableUpstream setting from the IES. | ||
| 226 | |||
| 227 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 228 | object. | ||
| 229 | |||
| 230 | =cut | ||
| 231 | has 'upspeed' => ( | ||
| 232 | isa => 'Int', | ||
| 233 | is => 'ro', | ||
| 234 | writer => '_set_upspeed' | ||
| 235 | ); | ||
| 236 | |||
| 237 | =head2 snr_down (ro) | ||
| 238 | |||
| 239 | Contains the SNR on the Downstream channel from the IES. | ||
| 240 | |||
| 241 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 242 | object. | ||
| 243 | |||
| 244 | =cut | ||
| 245 | has 'snr_down' => ( | ||
| 246 | isa => 'Int', | ||
| 247 | is => 'ro', | ||
| 248 | writer => '_set_snrdown' | ||
| 249 | ); | ||
| 250 | |||
| 251 | =head2 snr_up (ro) | ||
| 252 | |||
| 253 | Contains the SNR on the Upstream channel from the IES. | ||
| 254 | |||
| 255 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 256 | object. | ||
| 257 | |||
| 258 | =cut | ||
| 259 | has 'snr_up' => ( | ||
| 260 | isa => 'Int', | ||
| 261 | is => 'ro', | ||
| 262 | writer => '_set_snrup' | ||
| 263 | ); | ||
| 264 | |||
| 265 | =head2 atn_down (ro) | ||
| 266 | |||
| 267 | Contains the current Attenautaion Downstream setting from the IES. | ||
| 268 | |||
| 269 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 270 | object. | ||
| 271 | |||
| 272 | =cut | ||
| 273 | has 'atn_down' => ( | ||
| 274 | isa => 'Int', | ||
| 275 | is => 'ro', | ||
| 276 | writer => '_set_atndown' | ||
| 277 | ); | ||
| 278 | |||
| 279 | =head2 atn_up (ro) | ||
| 280 | |||
| 281 | Contains the current Attenautaion Upstream setting from the IES. | ||
| 282 | |||
| 283 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 284 | object. | ||
| 285 | |||
| 286 | =cut | ||
| 287 | has 'atn_up' => ( | ||
| 288 | isa => 'Int', | ||
| 289 | is => 'ro', | ||
| 290 | writer => '_set_atnup' | ||
| 291 | ); | ||
| 292 | |||
| 293 | =head2 inp_down (rw) | ||
| 294 | |||
| 295 | Contains the current impulse noise protection level on the Downstream channel. | ||
| 296 | |||
| 297 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 298 | object. | ||
| 299 | |||
| 300 | =cut | ||
| 301 | has 'inp_down' => ( | ||
| 302 | isa => 'Int', | ||
| 303 | is => 'rw' | ||
| 304 | ); | ||
| 305 | |||
| 306 | =head2 inp_up (rw) | ||
| 307 | |||
| 308 | The upstream Impulse Noise Protection minimum setting in unit of DMT symbol. | ||
| 309 | |||
| 310 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 311 | object. | ||
| 312 | |||
| 313 | =cut | ||
| 314 | has 'inp_up' => ( | ||
| 315 | isa => 'Int', | ||
| 316 | is => 'rw' | ||
| 317 | ); | ||
| 318 | |||
| 319 | =head2 annexM (rw) | ||
| 320 | |||
| 321 | The ADSL Annex M setting. | ||
| 322 | |||
| 323 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 324 | object. | ||
| 325 | |||
| 326 | =cut | ||
| 327 | has 'annexM' => ( | ||
| 328 | isa => 'Int', | ||
| 329 | is => 'rw', | ||
| 330 | default => sub {0} | ||
| 331 | ); | ||
| 332 | |||
| 333 | =head2 annexL (rw) | ||
| 334 | |||
| 335 | The ADSL Annex L setting. | ||
| 336 | |||
| 337 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 338 | object. | ||
| 339 | |||
| 340 | =cut | ||
| 341 | has 'annexL' => ( | ||
| 342 | isa => 'Int', | ||
| 343 | is => 'rw', | ||
| 344 | default => sub {0} | ||
| 345 | ); | ||
| 346 | |||
| 347 | =head2 wirepairmode (ro) | ||
| 348 | |||
| 349 | The S.HDSL Wirepair Mode setting. | ||
| 350 | |||
| 351 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 352 | object. | ||
| 353 | |||
| 354 | =cut | ||
| 355 | has 'wirepairmode' => ( | ||
| 356 | isa => 'Int', | ||
| 357 | is => 'ro', | ||
| 358 | writer => '_set_wirepairmode' | ||
| 359 | ); | ||
| 360 | |||
| 361 | |||
| 362 | =head2 vdslprotocol (ro) | ||
| 363 | |||
| 364 | The VDSL Protocol Mode setting. | ||
| 365 | |||
| 366 | One of | ||
| 367 | |||
| 368 | none(1), | ||
| 369 | vdsl_8a(2), | ||
| 370 | vdsl_8b(3), | ||
| 371 | vdsl_8c(4), | ||
| 372 | vdsl_8d(5), | ||
| 373 | vdsl_12a(6), | ||
| 374 | vdsl_12b(7), | ||
| 375 | vdsl_17a(8), | ||
| 376 | vdsl_30a(9), | ||
| 377 | adsl2plus(10) | ||
| 378 | |||
| 379 | This attribute depends on the interface type, as determined by the assiciated Device::ZyXEL::IES::Slot | ||
| 380 | object. | ||
| 381 | |||
| 382 | =cut | ||
| 383 | has 'vdslprotocol' => ( | ||
| 384 | isa => 'Int', | ||
| 385 | is => 'ro', | ||
| 386 | writer => '_set_vdslprotocol' | ||
| 387 | ); | ||
| 388 | |||
| 389 | =head2 hlog_near (ro) | ||
| 390 | |||
| 391 | hlog data for the near end (dlsam) | ||
| 392 | |||
| 393 | This attribute depends on the interface type. | ||
| 394 | |||
| 395 | For ADSL it will contain an array of values between -32767 and 32768, with -32767 being | ||
| 396 | special, meaning "no measurement". | ||
| 397 | |||
| 398 | For VDSL the "no measurement" value is 1023. | ||
| 399 | |||
| 400 | Values for all interface types are dB. | ||
| 401 | |||
| 402 | =cut | ||
| 403 | has 'hlog_near' => ( | ||
| 404 | traits => ['Array'], | ||
| 405 | isa => 'ArrayRef[Num]', | ||
| 406 | is => 'ro', | ||
| 407 | writer => '_set_hlog_near' | ||
| 408 | ); | ||
| 409 | |||
| 410 | =head2 hlog_near_grpsize | ||
| 411 | |||
| 412 | In ADSL the group size (how many carriers are average over pr hlog value) is always | ||
| 413 | one. In VDSL this is set by the dslam firmware. | ||
| 414 | |||
| 415 | =cut | ||
| 416 | has 'hlog_near_grpsize' => ( | ||
| 417 | isa => 'Int', | ||
| 418 | is => 'ro', | ||
| 419 | default => sub { 1 }, | ||
| 420 | writer => '_set_hlog_near_grpsize' | ||
| 421 | ); | ||
| 422 | |||
| 423 | =head2 hlog_far (ro) | ||
| 424 | |||
| 425 | hlog data for the far end (cpe) | ||
| 426 | |||
| 427 | This attribute depends on the interface type. | ||
| 428 | |||
| 429 | For ADSL it will contain an array of values between -32767 and 32768, with -32767 being | ||
| 430 | special, meaning "no measurement". | ||
| 431 | |||
| 432 | For VDSL the "no measurement" value is 1023. | ||
| 433 | |||
| 434 | Values for all interface types are dB. | ||
| 435 | |||
| 436 | =cut | ||
| 437 | has 'hlog_far' => ( | ||
| 438 | traits => ['Array'], | ||
| 439 | isa => 'ArrayRef[Num]', | ||
| 440 | is => 'ro', | ||
| 441 | writer => '_set_hlog_far' | ||
| 442 | ); | ||
| 443 | |||
| 444 | =head2 hlog_far_grpsize | ||
| 445 | |||
| 446 | In ADSL the group size (how many carriers are average over pr hlog value) is always | ||
| 447 | one. In VDSL this is set by the dslam firmware. | ||
| 448 | |||
| 449 | =cut | ||
| 450 | has 'hlog_far_grpsize' => ( | ||
| 451 | isa => 'Int', | ||
| 452 | is => 'ro', | ||
| 453 | default => sub { 1 }, | ||
| 454 | writer => '_set_hlog_far_grpsize' | ||
| 455 | ); | ||
| 456 | |||
| 457 | =head2 qln_near (ro) | ||
| 458 | |||
| 459 | qln data for the near end (dlsam) | ||
| 460 | |||
| 461 | This attribute depends on the interface type. | ||
| 462 | |||
| 463 | For ADSL it will contain an array of values between -32767 and 32768, with -32767 being | ||
| 464 | special, meaning "no measurement". | ||
| 465 | |||
| 466 | For VDSL the "no measurement" value is 255. | ||
| 467 | |||
| 468 | Values for all interface types are dB. | ||
| 469 | |||
| 470 | =cut | ||
| 471 | has 'qln_near' => ( | ||
| 472 | traits => ['Array'], | ||
| 473 | isa => 'ArrayRef[Num]', | ||
| 474 | is => 'ro', | ||
| 475 | writer => '_set_qln_near' | ||
| 476 | ); | ||
| 477 | |||
| 478 | =head2 qln_near_grpsize | ||
| 479 | |||
| 480 | In ADSL the group size (how many carriers are average over pr qln value) is always | ||
| 481 | one. In VDSL this is set by the dslam firmware. | ||
| 482 | |||
| 483 | =cut | ||
| 484 | has 'qln_near_grpsize' => ( | ||
| 485 | isa => 'Int', | ||
| 486 | is => 'ro', | ||
| 487 | default => sub { 1 }, | ||
| 488 | writer => '_set_qln_near_grpsize' | ||
| 489 | ); | ||
| 490 | |||
| 491 | =head2 qln_far (ro) | ||
| 492 | |||
| 493 | qln data for the far end (cpe) | ||
| 494 | |||
| 495 | This attribute depends on the interface type. | ||
| 496 | |||
| 497 | For ADSL it will contain an array of values between -32767 and 32768, with -32767 being | ||
| 498 | special, meaning "no measurement". | ||
| 499 | |||
| 500 | For VDSL the "no measurement" value is 255. | ||
| 501 | |||
| 502 | Values for all interface types are dB. | ||
| 503 | |||
| 504 | =cut | ||
| 505 | has 'qln_far' => ( | ||
| 506 | traits => ['Array'], | ||
| 507 | isa => 'ArrayRef[Num]', | ||
| 508 | is => 'ro', | ||
| 509 | writer => '_set_qln_far' | ||
| 510 | ); | ||
| 511 | |||
| 512 | =head2 qln_far_grpsize | ||
| 513 | |||
| 514 | In ADSL the group size (how many carriers are average over pr qln value) is always | ||
| 515 | one. In VDSL this is set by the dslam firmware. | ||
| 516 | |||
| 517 | =cut | ||
| 518 | has 'qln_far_grpsize' => ( | ||
| 519 | isa => 'Int', | ||
| 520 | is => 'ro', | ||
| 521 | default => sub { 1 }, | ||
| 522 | writer => '_set_qln_far_grpsize' | ||
| 523 | ); | ||
| 524 | |||
| 525 | =head2 snr_near (ro) | ||
| 526 | |||
| 527 | snr data for the near end (dlsam) | ||
| 528 | |||
| 529 | This attribute depends on the interface type. | ||
| 530 | |||
| 531 | For ADSL it will contain nothing. | ||
| 532 | |||
| 533 | For VDSL the "no measurement" value is 255. | ||
| 534 | |||
| 535 | Values for all interface types are dB. | ||
| 536 | |||
| 537 | =cut | ||
| 538 | has 'snr_near' => ( | ||
| 539 | traits => ['Array'], | ||
| 540 | isa => 'ArrayRef[Num]', | ||
| 541 | is => 'ro', | ||
| 542 | writer => '_set_snr_near' | ||
| 543 | ); | ||
| 544 | |||
| 545 | =head2 snr_near_grpsize | ||
| 546 | |||
| 547 | The number of carriers grouped together for each snr value. | ||
| 548 | |||
| 549 | =cut | ||
| 550 | has 'snr_near_grpsize' => ( | ||
| 551 | isa => 'Int', | ||
| 552 | is => 'ro', | ||
| 553 | default => sub { 1 }, | ||
| 554 | writer => '_set_snr_near_grpsize' | ||
| 555 | ); | ||
| 556 | |||
| 557 | =head2 snr_far (ro) | ||
| 558 | |||
| 559 | snr data for the far end (cpe) | ||
| 560 | |||
| 561 | This attribute depends on the interface type. | ||
| 562 | |||
| 563 | For ADSL it will contain nothing. | ||
| 564 | |||
| 565 | For VDSL the "no measurement" value is 255. | ||
| 566 | |||
| 567 | Values for all interface types are dB. | ||
| 568 | |||
| 569 | =cut | ||
| 570 | has 'snr_far' => ( | ||
| 571 | traits => ['Array'], | ||
| 572 | isa => 'ArrayRef[Num]', | ||
| 573 | is => 'ro', | ||
| 574 | writer => '_set_snr_far' | ||
| 575 | ); | ||
| 576 | |||
| 577 | =head2 snr_far_grpsize | ||
| 578 | |||
| 579 | The number of carriers grouped together for each snr value. | ||
| 580 | |||
| 581 | =cut | ||
| 582 | has 'snr_far_grpsize' => ( | ||
| 583 | isa => 'Int', | ||
| 584 | is => 'ro', | ||
| 585 | default => sub { 1 }, | ||
| 586 | writer => '_set_snr_far_grpsize' | ||
| 587 | ); | ||
| 588 | |||
| 589 | =head2 seltStatus | ||
| 590 | |||
| 591 | Contains the status of a SELT operation on the port. | ||
| 592 | |||
| 593 | =cut | ||
| 594 | has 'seltStatus' => ( | ||
| 595 | isa => 'Str', | ||
| 596 | is => 'ro', | ||
| 597 | default => sub { 'NA' }, | ||
| 598 | writer => '_set_seltStatus' | ||
| 599 | ); | ||
| 600 | |||
| 601 | =head2 seltCableType | ||
| 602 | |||
| 603 | Contains the cable type reported by the IES as a result of a SELT operation. | ||
| 604 | |||
| 605 | 1 => 'awg24' | ||
| 606 | 2 => 'awg26' | ||
| 607 | |||
| 608 | =cut | ||
| 609 | has 'seltCableType' => ( | ||
| 610 | isa => 'Int', | ||
| 611 | is => 'ro', | ||
| 612 | default => sub { 0 }, | ||
| 613 | writer => '_set_seltCableType' | ||
| 614 | ); | ||
| 615 | |||
| 616 | =head2 seltLoopEstimateLengthFt | ||
| 617 | |||
| 618 | Contains the IES estimate of the loop length in Feet. | ||
| 619 | |||
| 620 | =cut | ||
| 621 | has 'seltLoopEstimateLengthFt' => ( | ||
| 622 | isa => 'Int', | ||
| 623 | is => 'ro', | ||
| 624 | default => sub { 0 }, | ||
| 625 | writer => '_set_seltLoopEstimateLengthFt' | ||
| 626 | ); | ||
| 627 | |||
| 628 | =head2 seltLoopEstimateLengthMeter | ||
| 629 | |||
| 630 | Contains the IES estimate of the loop length in Meters. | ||
| 631 | |||
| 632 | =cut | ||
| 633 | has 'seltLoopEstimateLengthMeter' => ( | ||
| 634 | isa => 'Int', | ||
| 635 | is => 'ro', | ||
| 636 | default => sub { 0 }, | ||
| 637 | writer => '_set_seltLoopEstimateLengthMeter' | ||
| 638 | ); | ||
| 639 | |||
| 640 | =head2 dhcpDiscovery | ||
| 641 | |||
| 642 | Contains the number of dhcp discoveries on the port. | ||
| 643 | |||
| 644 | =cut | ||
| 645 | has 'dhcpDiscovery' => ( | ||
| 646 | isa => 'Int', | ||
| 647 | is => 'ro', | ||
| 648 | default => sub { -1 }, | ||
| 649 | writer => '_set_dhcpDiscovery' | ||
| 650 | ); | ||
| 651 | |||
| 652 | =head2 dhcpOffer | ||
| 653 | |||
| 654 | Contains the number of dhcp offer on the port. | ||
| 655 | |||
| 656 | =cut | ||
| 657 | has 'dhcpOffer' => ( | ||
| 658 | isa => 'Int', | ||
| 659 | is => 'ro', | ||
| 660 | default => sub { -1 }, | ||
| 661 | writer => '_set_dhcpOffer' | ||
| 662 | ); | ||
| 663 | |||
| 664 | =head2 dhcpRequest | ||
| 665 | |||
| 666 | Contains the number of dhcp request on the port. | ||
| 667 | |||
| 668 | =cut | ||
| 669 | has 'dhcpRequest' => ( | ||
| 670 | isa => 'Int', | ||
| 671 | is => 'ro', | ||
| 672 | default => sub { -1 }, | ||
| 673 | writer => '_set_dhcpRequest' | ||
| 674 | ); | ||
| 675 | |||
| 676 | =head2 dhcpAck | ||
| 677 | |||
| 678 | Contains the number of dhcp ack on the port. | ||
| 679 | |||
| 680 | =cut | ||
| 681 | has 'dhcpAck' => ( | ||
| 682 | isa => 'Int', | ||
| 683 | is => 'ro', | ||
| 684 | default => sub { -1 }, | ||
| 685 | writer => '_set_dhcpAck' | ||
| 686 | ); | ||
| 687 | |||
| 688 | =head2 dhcpAckBySnoopFull | ||
| 689 | |||
| 690 | Contains the number of dhcp ack on the port. | ||
| 691 | |||
| 692 | =cut | ||
| 693 | has 'dhcpAckBySnoopFull' => ( | ||
| 694 | isa => 'Int', | ||
| 695 | is => 'ro', | ||
| 696 | default => sub { -1 }, | ||
| 697 | writer => '_set_dhcpAckBySnoopFull' | ||
| 698 | ); | ||
| 699 | |||
| 700 | =head1 METHODS | ||
| 701 | |||
| 702 | =head2 BUILD | ||
| 703 | |||
| 704 | When the object is created, we need to create an instance of the oid translater. | ||
| 705 | |||
| 706 | =cut | ||
| 707 | our $oid_tr; | ||
| 708 | sub BUILD { | ||
| 709 | $oid_tr = Device::ZyXEL::IES::OID->new; | ||
| 710 | } | ||
| 711 | |||
| 712 | =head2 write_oid | ||
| 713 | |||
| 714 | Used (mainly internally) to write a new value into the specified OID on the IES. | ||
| 715 | |||
| 716 | Params: | ||
| 717 | $oidname: Symbolic name of the OID, translated through mib files or statically through OID.pm | ||
| 718 | $type: An SNMP type, i.e. OCTET_STRING, INTEGER aso, imported by Net::SNMP asn1 | ||
| 719 | $value: <the value to set> | ||
| 720 | $actual: 1 => the oid indcated by oidname, and translated to an actual oid is the actual final one | ||
| 721 | 0 => Append port ID to the oid before setting | ||
| 722 | |||
| 723 | Returns: | ||
| 724 | a status string indicating the result. | ||
| 725 | |||
| 726 | =cut | ||
| 727 | sub write_oid { | ||
| 728 | my ($self, $oidname, $type, $value, $actual) = @_; | ||
| 729 | $actual = 0 unless defined $actual; | ||
| 730 | |||
| 731 | return "[ERROR] No set community" unless defined $self->slot->ies->set_community(); | ||
| 732 | |||
| 733 | my $oid = $oid_tr->translate( $oidname ); | ||
| 734 | |||
| 735 | return "[ERROR] Cant translate oidname: $oidname" unless defined( $oid ); | ||
| 736 | |||
| 737 | my ($s, $e) = Net::SNMP->session( | ||
| 738 | -hostname => $self->slot->ies->hostname, | ||
| 739 | -version => 1, | ||
| 740 | -community => $self->slot->ies->set_community() | ||
| 741 | ); | ||
| 742 | |||
| 743 | return "[ERROR] SNMP session creation failure: $e" unless defined( $s ); | ||
| 744 | my $actualoid; | ||
| 745 | if ( $actual == 0 ) { # $actual indicates whether or not the passed oid is the final one | ||
| 746 | $actualoid = $oid.'.'.$self->id; | ||
| 747 | if ( $oid =~ /%d/ ) { | ||
| 748 | $actualoid = sprintf( $oid, $self->id ); | ||
| 749 | } | ||
| 750 | } | ||
| 751 | else { | ||
| 752 | $actualoid = $oid; | ||
| 753 | } | ||
| 754 | |||
| 755 | my $r = $s->set_request( | ||
| 756 | varbindlist => [ $actualoid, $type, $value] | ||
| 757 | ); | ||
| 758 | |||
| 759 | return "[ERROR] SNMP set error: " . $s->error() unless defined( $r ); | ||
| 760 | return 'OK'; | ||
| 761 | } | ||
| 762 | |||
| 763 | =head2 read_oid | ||
| 764 | |||
| 765 | Uses Net::SNMP::Util to read the value of an oid | ||
| 766 | for a specific slot. | ||
| 767 | |||
| 768 | =cut | ||
| 769 | sub read_oid { | ||
| 770 | my ($self, $oidname,$postfix,$translate) = @_; | ||
| 771 | |||
| 772 | return "ERROR, invalid oid" unless defined( $oidname ); | ||
| 773 | |||
| 774 | my $oid = $oid_tr->translate( $oidname, $postfix ); | ||
| 775 | |||
| 776 | return "ERROR: cant translate $oidname" unless defined($oid); | ||
| 777 | |||
| 778 | my $actualoid = $oid.'.'.$self->id; | ||
| 779 | if ( $oid =~ /%d/ ) { | ||
| 780 | $actualoid = sprintf( $oid, $self->id ); | ||
| 781 | } | ||
| 782 | |||
| 783 | return $self->slot->ies->read_oid( $actualoid, $translate ); | ||
| 784 | } | ||
| 785 | |||
| 786 | |||
| 787 | =head2 read_operstatus | ||
| 788 | |||
| 789 | Asks the IES for OperStatus on the port. | ||
| 790 | |||
| 791 | =cut | ||
| 792 | sub read_operstatus { | ||
| 793 | my $self = shift; | ||
| 794 | |||
| 795 | my $operstatus = $self->read_oid( 'IF-MIB::ifOperStatus' ); | ||
| 796 | if ( $operstatus =~ /^[21]$/ ) { | ||
| 797 | $self->_set_operstatus($operstatus); | ||
| 798 | } | ||
| 799 | return $operstatus; | ||
| 800 | } | ||
| 801 | |||
| 802 | =head2 read_uptime | ||
| 803 | |||
| 804 | Asks the IES for uptime on the port. | ||
| 805 | |||
| 806 | =cut | ||
| 807 | sub read_uptime { | ||
| 808 | my $self = shift; | ||
| 809 | |||
| 810 | my $ifType = $self->readIfType; | ||
| 811 | my $uptime = ''; | ||
| 812 | |||
| 813 | if ( $ifType eq 'ADSL' ) { | ||
| 814 | $uptime = $self->read_oid( 'ZYXEL-IES5000-MIB::adslLineStatusUpTime' ); | ||
| 815 | } | ||
| 816 | else { | ||
| 817 | if ( $self->slot->ies->uptime() ne 'unknown' ) { | ||
| 818 | # use ifLastChange in combination with IES uptime to calculate | ||
| 819 | # the port uptime | ||
| 820 | if ( $self->ifLastChange eq 'default' ) { | ||
| 821 | $self->read_ifLastChange(); | ||
| 822 | } | ||
| 823 | if ( $self->slot->ies->uptime() eq 'default' ) { | ||
| 824 | $self->slot->ies->read_uptime(); | ||
| 825 | } | ||
| 826 | $uptime = ticks_to_time( $self->slot->ies->uptime() - $self->ifLastChange() ); | ||
| 827 | } | ||
| 828 | } | ||
| 829 | |||
| 830 | $self->_set_uptime( $uptime ) if $uptime !~ /ERROR/; | ||
| 831 | return $uptime; | ||
| 832 | } | ||
| 833 | |||
| 834 | =head2 read_profile | ||
| 835 | |||
| 836 | Asks the IES for profile on the port. | ||
| 837 | |||
| 838 | =cut | ||
| 839 | sub read_profile { | ||
| 840 | my $self = shift; | ||
| 841 | |||
| 842 | my $ifType = $self->readIfType; | ||
| 843 | my $oid = ''; | ||
| 844 | my $profile = ''; | ||
| 845 | |||
| 846 | if ( $ifType eq 'ADSL' ) { | ||
| 847 | $oid = 'ADSL-LINE-MIB::adslLineConfProfile'; | ||
| 848 | } | ||
| 849 | elsif ( $ifType eq 'VDSL' ) { | ||
| 850 | $oid = 'VDSL-LINE-MIB::vdslLineConfProfile'; | ||
| 851 | } | ||
| 852 | elsif ( $ifType eq 'SHDSL' ) { | ||
| 853 | $oid = 'HDSL2-SHDSL-LINE-MIB::hdsl2ShdslSpanConfProfile'; | ||
| 854 | } | ||
| 855 | |||
| 856 | if ( $oid ne '' ) { | ||
| 857 | $profile = $self->read_oid( $oid ); | ||
| 858 | $self->profile( $profile ) unless $profile =~ /ERROR/; | ||
| 859 | } | ||
| 860 | return $profile; | ||
| 861 | } | ||
| 862 | |||
| 863 | =head2 write_profile | ||
| 864 | =cut | ||
| 865 | sub write_profile { | ||
| 866 | my ($self, $new_value) = @_; | ||
| 867 | my $ifType = $self->readIfType; | ||
| 868 | |||
| 869 | my $oid; | ||
| 870 | if ( $ifType eq 'ADSL' ) { | ||
| 871 | $oid = 'ADSL-LINE-MIB::adslLineConfProfile'; | ||
| 872 | } | ||
| 873 | elsif ( $ifType eq 'VDSL' ) { | ||
| 874 | $oid = 'VDSL-LINE-MIB::vdslLineConfProfile'; | ||
| 875 | } | ||
| 876 | elsif ( $ifType eq 'SHDSL' ) { | ||
| 877 | $oid = 'HDSL2-SHDSL-LINE-MIB::hdsl2ShdslSpanConfProfile'; | ||
| 878 | } | ||
| 879 | my $res = $self->write_oid( $oid, OCTET_STRING, $new_value ); | ||
| 880 | $self->profile( $new_value ) if $res eq 'OK'; | ||
| 881 | return $res; | ||
| 882 | } | ||
| 883 | |||
| 884 | =head2 read_ifInOctets | ||
| 885 | |||
| 886 | Asks the IES for ifInOctets on the port. | ||
| 887 | |||
| 888 | =cut | ||
| 889 | sub read_ifInOctets { | ||
| 890 | my $self = shift; | ||
| 891 | |||
| 892 | my $octets = $self->read_oid( 'IF-MIB::ifHCInOctets' ); | ||
| 893 | if ( $octets =~ /^\d+$/ ) { | ||
| 894 | $self->_set_ifInOctets($octets); | ||
| 895 | } | ||
| 896 | return $octets; | ||
| 897 | } | ||
| 898 | |||
| 899 | =head2 read_ifOutOctets | ||
| 900 | |||
| 901 | Asks the IES for ifOutOctets on the port. | ||
| 902 | |||
| 903 | =cut | ||
| 904 | sub read_ifOutOctets { | ||
| 905 | my $self = shift; | ||
| 906 | |||
| 907 | my $octets = $self->read_oid( 'IF-MIB::ifHCOutOctets' ); | ||
| 908 | if ( $octets =~ /^\d+$/ ) { | ||
| 909 | $self->_set_ifOutOctets($octets); | ||
| 910 | } | ||
| 911 | return $octets; | ||
| 912 | } | ||
| 913 | |||
| 914 | =head2 read_ifLastChange | ||
| 915 | |||
| 916 | Asks the IES for ifLastChange on the port. | ||
| 917 | |||
| 918 | =cut | ||
| 919 | sub read_ifLastChange { | ||
| 920 | my $self = shift; | ||
| 921 | |||
| 922 | my $lastchange = $self->read_oid( 'IF-MIB::ifLastChange' ); | ||
| 923 | if ( $lastchange =~ /^\d+$/ ) { | ||
| 924 | $self->_set_ifLastChange($lastchange); | ||
| 925 | } | ||
| 926 | return $lastchange; | ||
| 927 | } | ||
| 928 | |||
| 929 | =head2 read_maxmac | ||
| 930 | |||
| 931 | Asks the IES for maxmac on the port. | ||
| 932 | |||
| 933 | =cut | ||
| 934 | sub read_maxmac { | ||
| 935 | my $self = shift; | ||
| 936 | |||
| 937 | my $maxmac = $self->read_oid( 'ZYXEL-IES5000-MIB::macFilterPortMacCount' ); | ||
| 938 | if ( $maxmac =~ /^\d+$/ ) { | ||
| 939 | $self->maxmac($maxmac); | ||
| 940 | } | ||
| 941 | return $maxmac; | ||
| 942 | } | ||
| 943 | |||
| 944 | =head2 write_maxmac | ||
| 945 | |||
| 946 | Sets the macFilterPortMacCount value in the dslam, and the value of the attribute | ||
| 947 | here. | ||
| 948 | |||
| 949 | =cut | ||
| 950 | sub write_maxmac { | ||
| 951 | my ($self, $new_value, $old_value) = @_; | ||
| 952 | my $res = $self->write_oid( 'ZYXEL-IES5000-MIB::macFilterPortMacCount', INTEGER, $new_value ); | ||
| 953 | if ( $res eq 'OK' ) { | ||
| 954 | $self->maxmac( $new_value ); | ||
| 955 | } | ||
| 956 | return $res; | ||
| 957 | } | ||
| 958 | |||
| 959 | =head2 read_adminstatus | ||
| 960 | |||
| 961 | Asks the IES for OperStatus on the port. | ||
| 962 | |||
| 963 | =cut | ||
| 964 | sub read_adminstatus { | ||
| 965 | my $self = shift; | ||
| 966 | |||
| 967 | my $adminstatus = $self->read_oid( 'IF-MIB::ifAdminStatus' ); | ||
| 968 | if ( $adminstatus =~ /^[21]$/ ) { | ||
| 969 | $self->adminstatus($adminstatus); | ||
| 970 | } | ||
| 971 | return $adminstatus; | ||
| 972 | } | ||
| 973 | |||
| 974 | =head2 write_adminstatus | ||
| 975 | |||
| 976 | Sets ifAdminStatus on the Port on the device. | ||
| 977 | |||
| 978 | =cut | ||
| 979 | sub write_adminstatus { | ||
| 980 | my ($self, $new_value) = @_; | ||
| 981 | my $res = $self->write_oid( 'IF-MIB::ifAdminStatus', INTEGER, $new_value ); | ||
| 982 | if ( $res eq 'OK' ) { | ||
| 983 | $self->adminstatus($new_value); | ||
| 984 | } | ||
| 985 | return $res; | ||
| 986 | } | ||
| 987 | |||
| 988 | =head2 read_userinfo | ||
| 989 | |||
| 990 | Asks the IES for userinfo on the port. | ||
| 991 | |||
| 992 | =cut | ||
| 993 | sub read_userinfo { | ||
| 994 | my $self = shift; | ||
| 995 | |||
| 996 | my $userinfo = $self->read_oid( 'ZYXEL-IES5000-MIB::subrPortName' ); | ||
| 997 | if ( $userinfo !~ /ERROR/ ) { | ||
| 998 | $self->_set_userinfo($userinfo); | ||
| 999 | } | ||
| 1000 | return $userinfo; | ||
| 1001 | } | ||
| 1002 | |||
| 1003 | =head2 readIfType | ||
| 1004 | |||
| 1005 | Retrieves the ifType [ADSL, VDSL, SHDSL] from the associated | ||
| 1006 | slot object. If cardtype (which determines the ifType) is not | ||
| 1007 | previosly read from the dslam, and present in the object, it start | ||
| 1008 | by reading the cardtype from the IES. | ||
| 1009 | |||
| 1010 | =cut | ||
| 1011 | sub readIfType { | ||
| 1012 | my $self = shift; | ||
| 1013 | if ( defined $self->slot->cardtype && $self->slot->cardtype ne '' ) { | ||
| 1014 | # trust ifType | ||
| 1015 | return $self->slot->iftype; | ||
| 1016 | } | ||
| 1017 | else { | ||
| 1018 | $self->slot->read_cardtype(); | ||
| 1019 | return $self->slot->iftype; | ||
| 1020 | } | ||
| 1021 | } | ||
| 1022 | |||
| 1023 | =head2 read_maxdown | ||
| 1024 | |||
| 1025 | Asks the IES for max attainable downstream speed on the port. | ||
| 1026 | |||
| 1027 | Different OID's for different slot types, determined | ||
| 1028 | by the slot cardtype. | ||
| 1029 | |||
| 1030 | =cut | ||
| 1031 | sub read_maxdown { | ||
| 1032 | my $self = shift; | ||
| 1033 | |||
| 1034 | my $ifType = $self->readIfType; | ||
| 1035 | my $maxdown = ''; | ||
| 1036 | |||
| 1037 | if ( $ifType eq 'ADSL' ) { | ||
| 1038 | $maxdown = $self->read_oid( 'ADSL-LINE-MIB::adslAtucCurrAttainableRate' ); | ||
| 1039 | } | ||
| 1040 | elsif ( $ifType eq 'VDSL' ) { | ||
| 1041 | $maxdown = $self->read_oid( 'VDSL-LINE-MIB::vdslPhysCurrAttainableRate', '%d.1' ); | ||
| 1042 | } | ||
| 1043 | elsif ( $ifType eq 'SHDSL' ) { | ||
| 1044 | $maxdown = $self->read_oid( 'HDSL2-SHDSL-LINE-MIB::hdsl2ShdslStatusActualLineRate' ); | ||
| 1045 | } | ||
| 1046 | $self->_set_maxdown($maxdown) if $maxdown =~ /^\d+$/; | ||
| 1047 | return $maxdown; | ||
| 1048 | } | ||
| 1049 | |||
| 1050 | =head2 read_maxup | ||
| 1051 | |||
| 1052 | Asks the IES for maximum attainable speed upstream on the port. | ||
| 1053 | |||
| 1054 | Different OID's for different slot types, determined | ||
| 1055 | by the slot cardtype. | ||
| 1056 | |||
| 1057 | =cut | ||
| 1058 | sub read_maxup { | ||
| 1059 | my $self = shift; | ||
| 1060 | |||
| 1061 | my $ifType = $self->readIfType; | ||
| 1062 | my $maxup = ''; | ||
| 1063 | |||
| 1064 | if ( $ifType eq 'ADSL' ) { | ||
| 1065 | $maxup = $self->read_oid( 'ADSL-LINE-MIB::adslAturCurrAttainableRate' ); | ||
| 1066 | } | ||
| 1067 | elsif ( $ifType eq 'VDSL' ) { | ||
| 1068 | $maxup = $self->read_oid( 'VDSL-LINE-MIB::vdslPhysCurrAttainableRate', '%d.2' ); | ||
| 1069 | } | ||
| 1070 | elsif ( $ifType eq 'SHDSL' ) { | ||
| 1071 | $maxup = $self->read_oid( 'HDSL2-SHDSL-LINE-MIB::hdsl2ShdslStatusActualLineRate' ); | ||
| 1072 | } | ||
| 1073 | $self->_set_maxup($maxup) if $maxup =~ /^\d+$/; | ||
| 1074 | return $maxup; | ||
| 1075 | } | ||
| 1076 | |||
| 1077 | =head2 read_downspeed | ||
| 1078 | |||
| 1079 | Asks the IES for the current downstream speed on the port. | ||
| 1080 | |||
| 1081 | Different OID's for different slot types, determined | ||
| 1082 | by the slot cardtype. | ||
| 1083 | |||
| 1084 | =cut | ||
| 1085 | sub read_downspeed { | ||
| 1086 | my $self = shift; | ||
| 1087 | |||
| 1088 | my $ifType = $self->readIfType; | ||
| 1089 | my $downspeed = ''; | ||
| 1090 | |||
| 1091 | if ( $ifType eq 'ADSL' ) { | ||
| 1092 | $downspeed = $self->read_oid( 'ADSL-LINE-MIB::adslAtucChanCurrTxRate' ); | ||
| 1093 | } | ||
| 1094 | elsif ( $ifType eq 'VDSL' ) { | ||
| 1095 | $downspeed = $self->read_oid( 'VDSL-LINE-MIB::vdslPhysCurrLineRate', '%d.1' ); | ||
| 1096 | } | ||
| 1097 | elsif ( $ifType eq 'SHDSL' ) { | ||
| 1098 | $downspeed = $self->read_oid( 'HDSL2-SHDSL-LINE-MIB::hdsl2ShdslStatusActualLineRate' ); | ||
| 1099 | } | ||
| 1100 | $self->_set_downspeed($downspeed) if $downspeed =~ /^\d+$/; | ||
| 1101 | return $downspeed; | ||
| 1102 | } | ||
| 1103 | |||
| 1104 | =head2 read_upspeed | ||
| 1105 | |||
| 1106 | Asks the IES for current upstream speed on the port. | ||
| 1107 | |||
| 1108 | Different OID's for different slot types, determined | ||
| 1109 | by the slot cardtype. | ||
| 1110 | |||
| 1111 | =cut | ||
| 1112 | sub read_upspeed { | ||
| 1113 | my $self = shift; | ||
| 1114 | |||
| 1115 | my $ifType = $self->readIfType; | ||
| 1116 | my $upspeed = ''; | ||
| 1117 | |||
| 1118 | if ( $ifType eq 'ADSL' ) { | ||
| 1119 | $upspeed = $self->read_oid( 'ADSL-LINE-MIB::adslAturChanCurrTxRate' ); | ||
| 1120 | } | ||
| 1121 | elsif ( $ifType eq 'VDSL' ) { | ||
| 1122 | $upspeed = $self->read_oid( 'VDSL-LINE-MIB::vdslPhysCurrLineRate', '%d.2' ); | ||
| 1123 | } | ||
| 1124 | elsif ( $ifType eq 'SHDSL' ) { | ||
| 1125 | $upspeed = $self->read_oid( 'HDSL2-SHDSL-LINE-MIB::hdsl2ShdslStatusActualLineRate' ); | ||
| 1126 | } | ||
| 1127 | $self->_set_upspeed($upspeed) if $upspeed =~ /^\d+$/; | ||
| 1128 | return $upspeed; | ||
| 1129 | } | ||
| 1130 | |||
| 1131 | =head2 read_snrdown | ||
| 1132 | |||
| 1133 | Asks the IES for the SNR for the downstream channel on the port. | ||
| 1134 | |||
| 1135 | Network side in case of SHDSL. | ||
| 1136 | |||
| 1137 | Different OID's for different slot types, determined | ||
| 1138 | by the slot cardtype. | ||
| 1139 | |||
| 1140 | =cut | ||
| 1141 | sub read_snrdown { | ||
| 1142 | my $self = shift; | ||
| 1143 | |||
| 1144 | my $ifType = $self->readIfType; | ||
| 1145 | my $snrdown = ''; | ||
| 1146 | |||
| 1147 | if ( $ifType eq 'ADSL' ) { | ||
| 1148 | $snrdown = $self->read_oid( 'ADSL-LINE-MIB::adslAturCurrSnrMgn' ); | ||
| 1149 | } | ||
| 1150 | elsif ( $ifType eq 'VDSL' ) { | ||
| 1151 | $snrdown = $self->read_oid( 'VDSL-LINE-MIB::vdslPhysCurrSnrMgn', '%d.1' ); | ||
| 1152 | } | ||
| 1153 | elsif ( $ifType eq 'SHDSL' ) { | ||
| 1154 | $snrdown = $self->read_oid( 'HDSL2-SHDSL-LINE-MIB::hdsl2ShdslEndpointCurrSnrMgn', '%d.2.1.1' ); | ||
| 1155 | } | ||
| 1156 | $self->_set_snrdown($snrdown) if $snrdown =~ /^\d+$/; | ||
| 1157 | return $snrdown; | ||
| 1158 | } | ||
| 1159 | |||
| 1160 | =head2 read_snrup | ||
| 1161 | |||
| 1162 | Asks the IES for SNR Margin on the upstream channel on the port. | ||
| 1163 | |||
| 1164 | Customer side in case of SHDSL. | ||
| 1165 | |||
| 1166 | Different OID's for different slot types, determined | ||
| 1167 | by the slot cardtype. | ||
| 1168 | |||
| 1169 | =cut | ||
| 1170 | sub read_snrup { | ||
| 1171 | my $self = shift; | ||
| 1172 | |||
| 1173 | my $ifType = $self->readIfType; | ||
| 1174 | my $snrup = ''; | ||
| 1175 | |||
| 1176 | if ( $ifType eq 'ADSL' ) { | ||
| 1177 | $snrup = $self->read_oid( 'ADSL-LINE-MIB::adslAtucCurrSnrMgn' ); | ||
| 1178 | } | ||
| 1179 | elsif ( $ifType eq 'VDSL' ) { | ||
| 1180 | $snrup = $self->read_oid( 'VDSL-LINE-MIB::vdslPhysCurrSnrMgn', '%d.2' ); | ||
| 1181 | } | ||
| 1182 | elsif ( $ifType eq 'SHDSL' ) { | ||
| 1183 | $snrup = $self->read_oid( 'HDSL2-SHDSL-LINE-MIB::hdsl2ShdslEndpointCurrSnrMgn', '%d.1.2.1' ); | ||
| 1184 | } | ||
| 1185 | $self->_set_snrup($snrup) if $snrup =~ /^\d+$/; | ||
| 1186 | return $snrup; | ||
| 1187 | } | ||
| 1188 | |||
| 1189 | =head2 read_atndown | ||
| 1190 | |||
| 1191 | Asks the IES for the Attenaution for the downstream channel on the port. | ||
| 1192 | |||
| 1193 | Network side in case of SHDSL. | ||
| 1194 | |||
| 1195 | Different OID's for different slot types, determined | ||
| 1196 | by the slot cardtype. | ||
| 1197 | |||
| 1198 | =cut | ||
| 1199 | sub read_atndown { | ||
| 1200 | my $self = shift; | ||
| 1201 | |||
| 1202 | my $ifType = $self->readIfType; | ||
| 1203 | my $atndown = ''; | ||
| 1204 | |||
| 1205 | if ( $ifType eq 'ADSL' ) { | ||
| 1206 | $atndown = $self->read_oid( 'ADSL-LINE-MIB::adslAturCurrAtn' ); | ||
| 1207 | } | ||
| 1208 | elsif ( $ifType eq 'VDSL' ) { | ||
| 1209 | $atndown = $self->read_oid( 'VDSL-LINE-MIB::vdslPhysCurrAtn', '%d.1' ); | ||
| 1210 | } | ||
| 1211 | elsif ( $ifType eq 'SHDSL' ) { | ||
| 1212 | $atndown = $self->read_oid( 'HDSL2-SHDSL-LINE-MIB::hdsl2ShdslEndpointCurrAtn', '%d.2.1.1' ); | ||
| 1213 | } | ||
| 1214 | $self->_set_atndown($atndown) if $atndown =~ /^\d+$/; | ||
| 1215 | return $atndown; | ||
| 1216 | } | ||
| 1217 | |||
| 1218 | =head2 read_atnup | ||
| 1219 | |||
| 1220 | Asks the IES for Attenaution on the upstream channel on the port. | ||
| 1221 | |||
| 1222 | Customer side in case of SHDSL. | ||
| 1223 | |||
| 1224 | Different OID's for different slot types, determined | ||
| 1225 | by the slot cardtype. | ||
| 1226 | |||
| 1227 | =cut | ||
| 1228 | sub read_atnup { | ||
| 1229 | my $self = shift; | ||
| 1230 | |||
| 1231 | my $ifType = $self->readIfType; | ||
| 1232 | my $atnup = ''; | ||
| 1233 | |||
| 1234 | if ( $ifType eq 'ADSL' ) { | ||
| 1235 | $atnup = $self->read_oid( 'ADSL-LINE-MIB::adslAtucCurrAtn' ); | ||
| 1236 | } | ||
| 1237 | elsif ( $ifType eq 'VDSL' ) { | ||
| 1238 | $atnup = $self->read_oid( 'VDSL-LINE-MIB::vdslPhysCurrAtn', '%d.2' ); | ||
| 1239 | } | ||
| 1240 | elsif ( $ifType eq 'SHDSL' ) { | ||
| 1241 | $atnup = $self->read_oid( 'HDSL2-SHDSL-LINE-MIB::hdsl2ShdslEndpointCurrAtn', '%d.1.2.1' ); | ||
| 1242 | } | ||
| 1243 | $self->_set_atnup($atnup) if $atnup =~ /^\d+$/; | ||
| 1244 | return $atnup; | ||
| 1245 | } | ||
| 1246 | |||
| 1247 | =head2 read_inpdown | ||
| 1248 | |||
| 1249 | Asks the IES for the Impulse Noice Protection level for the downstream channel on the port. | ||
| 1250 | |||
| 1251 | Different OID's for different slot types, determined | ||
| 1252 | by the slot cardtype. | ||
| 1253 | |||
| 1254 | =cut | ||
| 1255 | sub read_inpdown { | ||
| 1256 | my $self = shift; | ||
| 1257 | |||
| 1258 | my $ifType = $self->readIfType; | ||
| 1259 | my $inpdown = 0; | ||
| 1260 | |||
| 1261 | if ( $ifType eq 'ADSL' ) { | ||
| 1262 | $inpdown = $self->read_oid( 'ZYXEL-IES5000-MIB::adslLineConfAtucInp' ); | ||
| 1263 | } | ||
| 1264 | elsif ( $ifType eq 'VDSL' ) { | ||
| 1265 | $inpdown = $self->read_oid( 'ZYXEL-IES5000-MIB::vdslLineConfVturInp' ); | ||
| 1266 | } | ||
| 1267 | $self->inp_down($inpdown) if $inpdown =~ /^\d+$/;; | ||
| 1268 | return $inpdown; | ||
| 1269 | } | ||
| 1270 | |||
| 1271 | =head2 write_inpdown | ||
| 1272 | |||
| 1273 | Set the INP value in the device, and sets the attribute upon succes. | ||
| 1274 | |||
| 1275 | =cut | ||
| 1276 | sub write_inpdown { | ||
| 1277 | my ($self, $new_value) = @_; | ||
| 1278 | my $ifType = $self->readIfType; | ||
| 1279 | my $res = 'unknown'; | ||
| 1280 | |||
| 1281 | if ( $ifType eq 'ADSL' ) { | ||
| 1282 | # The INP value in ADSL must be [1..7] each unit | ||
| 1283 | # zero(1), | ||
| 1284 | # zero_point_five(2), | ||
| 1285 | # one(3), | ||
| 1286 | # two(4), | ||
| 1287 | # four(5), | ||
| 1288 | # eight(6), | ||
| 1289 | # sixteen(7) | ||
| 1290 | if ( $new_value > 0 && $new_value < 8 ) { | ||
| 1291 | $res = $self->write_oid( 'ZYXEL-IES5000-MIB::adslLineConfAtucInp', INTEGER, $new_value ); | ||
| 1292 | } | ||
| 1293 | } | ||
| 1294 | elsif ( $ifType eq 'VDSL' ) { | ||
| 1295 | # The INP value in VDSL must by [1..160] as is a .1 precision float | ||
| 1296 | if ( $new_value > 0 && $new_value <= 160 ) { | ||
| 1297 | $res = $self->write_oid( 'ZYXEL-IES5000-MIB::vdslLineConfVturInp', INTEGER, $new_value ); | ||
| 1298 | } | ||
| 1299 | } | ||
| 1300 | $self->inp_down( $new_value ) if $res eq 'OK'; | ||
| 1301 | return $res; | ||
| 1302 | } | ||
| 1303 | |||
| 1304 | =head2 read_inpup | ||
| 1305 | |||
| 1306 | Asks the IES for the Impulse Noice Protection level for the upstream channel on the port. | ||
| 1307 | |||
| 1308 | Different OID's for different slot types, determined | ||
| 1309 | by the slot cardtype. | ||
| 1310 | |||
| 1311 | =cut | ||
| 1312 | sub read_inpup { | ||
| 1313 | my $self = shift; | ||
| 1314 | |||
| 1315 | my $ifType = $self->readIfType; | ||
| 1316 | my $inpup = 0; | ||
| 1317 | |||
| 1318 | if ( $ifType eq 'ADSL' ) { | ||
| 1319 | $inpup = $self->read_oid( 'ZYXEL-IES5000-MIB::adslLineConfAturInp' ); | ||
| 1320 | } | ||
| 1321 | elsif ( $ifType eq 'VDSL' ) { | ||
| 1322 | $inpup = $self->read_oid( 'ZYXEL-IES5000-MIB::vdslLineConfVtucInp' ); | ||
| 1323 | } | ||
| 1324 | $self->inp_up($inpup) if $inpup =~ /^\d+$/; | ||
| 1325 | return $inpup; | ||
| 1326 | } | ||
| 1327 | |||
| 1328 | =head2 write_inpup | ||
| 1329 | =cut | ||
| 1330 | sub write_inpup { | ||
| 1331 | my ($self, $new_value) = @_; | ||
| 1332 | my $ifType = $self->readIfType; | ||
| 1333 | my $res = 'unknown'; | ||
| 1334 | |||
| 1335 | if ( $ifType eq 'ADSL' ) { | ||
| 1336 | # The INP value in ADSL must be [1..7] each unit | ||
| 1337 | # zero(1), | ||
| 1338 | # zero_point_five(2), | ||
| 1339 | # one(3), | ||
| 1340 | # two(4), | ||
| 1341 | # four(5), | ||
| 1342 | # eight(6), | ||
| 1343 | # sixteen(7) | ||
| 1344 | if ( $new_value > 0 && $new_value < 8 ) { | ||
| 1345 | $res = $self->write_oid( 'ZYXEL-IES5000-MIB::adslLineConfAturInp', INTEGER, $new_value ); | ||
| 1346 | } | ||
| 1347 | } | ||
| 1348 | elsif ( $ifType eq 'VDSL' ) { | ||
| 1349 | # The INP value in VDSL must by [1..160] as is a .1 precision float | ||
| 1350 | if ( $new_value > 0 && $new_value <= 160 ) { | ||
| 1351 | $res = $self->write_oid( 'ZYXEL-IES5000-MIB::vdslLineConfVtucInp', INTEGER, $new_value ); | ||
| 1352 | } | ||
| 1353 | } | ||
| 1354 | $self->inp_up( $new_value ) if $res eq 'OK'; | ||
| 1355 | return $res; | ||
| 1356 | } | ||
| 1357 | |||
| 1358 | =head2 read_annexM | ||
| 1359 | |||
| 1360 | Asks the IES for the Annex M setting for the ADSL port. | ||
| 1361 | |||
| 1362 | Different OID's for different slot types, determined | ||
| 1363 | by the slot cardtype. | ||
| 1364 | |||
| 1365 | =cut | ||
| 1366 | sub read_annexM { | ||
| 1367 | my $self = shift; | ||
| 1368 | |||
| 1369 | my $ifType = $self->readIfType; | ||
| 1370 | my $annexM = 0; | ||
| 1371 | |||
| 1372 | if ( $ifType eq 'ADSL' ) { | ||
| 1373 | $annexM = $self->read_oid( 'ZYXEL-IES5000-MIB::adslLineConfAnnexM' ); | ||
| 1374 | } | ||
| 1375 | $self->annexM($annexM) if $annexM =~ /^\d+$/; | ||
| 1376 | return $annexM; | ||
| 1377 | } | ||
| 1378 | |||
| 1379 | =head2 write_annexM | ||
| 1380 | |||
| 1381 | Sets the annexM value on the port on the IES. | ||
| 1382 | |||
| 1383 | =cut | ||
| 1384 | sub write_annexM { | ||
| 1385 | my ($self, $new_value, $old_value) = @_; | ||
| 1386 | my $ifType = $self->readIfType; | ||
| 1387 | my $res = 'unknown'; | ||
| 1388 | |||
| 1389 | if ( $ifType eq 'ADSL' ) { | ||
| 1390 | if ( $new_value =~ /^[12]$/ ) { | ||
| 1391 | $res = $self->write_oid( 'ZYXEL-IES5000-MIB::adslLineConfAnnexM', INTEGER, $new_value ); | ||
| 1392 | } | ||
| 1393 | } | ||
| 1394 | $self->annexM( $new_value ) if $res eq 'OK'; | ||
| 1395 | return $res; | ||
| 1396 | } | ||
| 1397 | |||
| 1398 | =head2 read_annexL | ||
| 1399 | |||
| 1400 | Asks the IES for the Annex L setting for the ADSL port. | ||
| 1401 | |||
| 1402 | Different OID's for different slot types, determined | ||
| 1403 | by the slot cardtype. | ||
| 1404 | |||
| 1405 | =cut | ||
| 1406 | sub read_annexL { | ||
| 1407 | my $self = shift; | ||
| 1408 | |||
| 1409 | my $ifType = $self->readIfType; | ||
| 1410 | my $annexL = 0; | ||
| 1411 | |||
| 1412 | if ( $ifType eq 'ADSL' ) { | ||
| 1413 | $annexL = $self->read_oid( 'ZYXEL-IES5000-MIB::adslLineConfAnnexL' ); | ||
| 1414 | } | ||
| 1415 | $self->annexL($annexL) if $annexL =~ /^\d+$/; | ||
| 1416 | return $annexL; | ||
| 1417 | } | ||
| 1418 | |||
| 1419 | =head2 write_annexL | ||
| 1420 | |||
| 1421 | Sets the annexL value on the port on the IES. | ||
| 1422 | |||
| 1423 | =cut | ||
| 1424 | sub write_annexL { | ||
| 1425 | my ($self, $new_value, $old_value) = @_; | ||
| 1426 | my $ifType = $self->readIfType; | ||
| 1427 | my $res = 'unknown'; | ||
| 1428 | |||
| 1429 | if ( $ifType eq 'ADSL' ) { | ||
| 1430 | if ( $new_value =~ /^[123]$/ ) { | ||
| 1431 | $res = $self->write_oid( 'ZYXEL-IES5000-MIB::adslLineConfAnnexL', INTEGER, $new_value ); | ||
| 1432 | } | ||
| 1433 | } | ||
| 1434 | $self->annexL( $new_value ) if $res eq 'OK'; | ||
| 1435 | return $res; | ||
| 1436 | } | ||
| 1437 | |||
| 1438 | =head2 read_wirepairmode | ||
| 1439 | |||
| 1440 | Asks the IES for the S.HDSL Wirepair mode of the port. | ||
| 1441 | |||
| 1442 | Different OID's for different slot types, determined | ||
| 1443 | by the slot cardtype. | ||
| 1444 | |||
| 1445 | =cut | ||
| 1446 | sub read_wirepairmode { | ||
| 1447 | my $self = shift; | ||
| 1448 | |||
| 1449 | my $ifType = $self->readIfType; | ||
| 1450 | my $wpm = 0; | ||
| 1451 | |||
| 1452 | if ( $ifType eq 'SHDSL' ) { | ||
| 1453 | $wpm = $self->read_oid( 'ZYXEL-IES5000-MIB::shdslLineStatusWirePair' ); | ||
| 1454 | } | ||
| 1455 | $self->_set_wirepairmode($wpm) if $wpm =~ /^\d+$/; | ||
| 1456 | return $wpm; | ||
| 1457 | } | ||
| 1458 | |||
| 1459 | =head2 read_vdslprotocol | ||
| 1460 | |||
| 1461 | Asks the IES for the actual VDSL protocol used on the port | ||
| 1462 | |||
| 1463 | Different OID's for different slot types, determined | ||
| 1464 | by the slot cardtype. | ||
| 1465 | |||
| 1466 | =cut | ||
| 1467 | sub read_vdslprotocol { | ||
| 1468 | my $self = shift; | ||
| 1469 | |||
| 1470 | my $ifType = $self->readIfType; | ||
| 1471 | my $protocol = 0; | ||
| 1472 | |||
| 1473 | if ( $ifType eq 'VDSL' ) { | ||
| 1474 | $protocol = $self->read_oid( 'ZYXEL-IES5000-MIB::vdslLineStatsProtocol' ); | ||
| 1475 | } | ||
| 1476 | $self->_set_vdslprotocol($protocol) if $protocol =~ /^\d+$/; | ||
| 1477 | return $protocol; | ||
| 1478 | } | ||
| 1479 | |||
| 1480 | =head2 read_hlog_near | ||
| 1481 | |||
| 1482 | Asks the dslam for the near end part (dslam side) of the hlog data. | ||
| 1483 | |||
| 1484 | Finds the correct oids to ask for, depending on the ifType | ||
| 1485 | =cut | ||
| 1486 | sub read_hlog_near { | ||
| 1487 | my $self = shift; | ||
| 1488 | |||
| 1489 | my @swords = (); | ||
| 1490 | my $ifType = $self->readIfType; | ||
| 1491 | if ( $ifType eq 'VDSL' ) { | ||
| 1492 | # hlog near for VDSL = hlog down | ||
| 1493 | my $hlog_down = $self->read_oid('ZYXEL-IES5000-MIB::vdslLineStatsVturHlog', '', {'-octetstring' => 0x0}); | ||
| 1494 | if ( $hlog_down !~ /^ERROR/ ) { | ||
| 1495 | my $hlog_down_grpsize = $self->read_oid('ZYXEL-IES5000-MIB::vdslLineStatsVturHlogGroupSize'); | ||
| 1496 | my @words = unpack("(n2)*", $hlog_down); | ||
| 1497 | # 1023 special => no measurement | ||
| 1498 | # Hlog(f) value is represented as (6-m(i)/10), with m(i) in the range 0 to 1022. | ||
| 1499 | foreach my $w ( @words ) { | ||
| 1500 | if ( $w != 1023 ) { | ||
| 1501 | $w = 6 - $w/10; | ||
| 1502 | } | ||
| 1503 | push @swords, $w; | ||
| 1504 | } | ||
| 1505 | if ( $hlog_down_grpsize =~ /^\d+$/ ) { | ||
| 1506 | $self->_set_hlog_near_grpsize( $hlog_down_grpsize ); | ||
| 1507 | } | ||
| 1508 | } | ||
| 1509 | } | ||
| 1510 | elsif ( $ifType eq 'ADSL' ) { | ||
| 1511 | my $hlog_dslam = $self->read_oid('ZYXEL-IES5000-MIB::adslLineStatsAturHlog', '', {'-octetstring' => 0x0}); | ||
| 1512 | if ( $hlog_dslam !~ /^ERROR/ ) { | ||
| 1513 | # 16 bit values. tenths of db | ||
| 1514 | my @words = unpack("(n)*", $hlog_dslam); | ||
| 1515 | foreach my $w ( @words ) { | ||
| 1516 | my $signed = to_signed16int( $w ); | ||
| 1517 | $signed /= 10 unless $signed == -32768; | ||
| 1518 | push @swords, $signed; | ||
| 1519 | } | ||
| 1520 | } | ||
| 1521 | $self->_set_hlog_near_grpsize( 1 ); | ||
| 1522 | } | ||
| 1523 | $self->_set_hlog_near(\@swords); | ||
| 1524 | return $self->hlog_near; | ||
| 1525 | } | ||
| 1526 | |||
| 1527 | =head2 read_hlog_far | ||
| 1528 | |||
| 1529 | Asks the dslam for the far end part (cpe side) of the hlog data. | ||
| 1530 | |||
| 1531 | Finds the correct oids to ask for, depending on the ifType | ||
| 1532 | =cut | ||
| 1533 | sub read_hlog_far { | ||
| 1534 | my $self = shift; | ||
| 1535 | |||
| 1536 | my @swords = (); | ||
| 1537 | my $ifType = $self->readIfType; | ||
| 1538 | if ( $ifType eq 'VDSL' ) { | ||
| 1539 | # hlog far for VDSL = hlog up | ||
| 1540 | my $hlog_up = $self->read_oid('ZYXEL-IES5000-MIB::vdslLineStatsVtucHlog', '', {'-octetstring' => 0x0}); | ||
| 1541 | if ( $hlog_up !~ /^ERROR/ ) { | ||
| 1542 | my $hlog_up_grpsize = $self->read_oid('ZYXEL-IES5000-MIB::vdslLineStatsVtucHlogGroupSize'); | ||
| 1543 | my @words = unpack("(n2)*", $hlog_up); | ||
| 1544 | # 1023 special => no measurement | ||
| 1545 | # Hlog(f) value is represented as (6-m(i)/10), with m(i) in the range 0 to 1022. | ||
| 1546 | foreach my $w ( @words ) { | ||
| 1547 | if ( $w != 1023 ) { | ||
| 1548 | $w = 6 - $w/10; | ||
| 1549 | } | ||
| 1550 | push @swords, $w; | ||
| 1551 | } | ||
| 1552 | if ( $hlog_up_grpsize =~ /^\d+$/ ) { | ||
| 1553 | $self->_set_hlog_far_grpsize( $hlog_up_grpsize ); | ||
| 1554 | } | ||
| 1555 | } | ||
| 1556 | } | ||
| 1557 | elsif ( $ifType eq 'ADSL' ) { | ||
| 1558 | my $hlog_cpe_first = $self->read_oid('ZYXEL-IES5000-MIB::adslLineStatsAtucHlog1', '', {'-octetstring' => 0x0}); | ||
| 1559 | if ( $hlog_cpe_first !~ /^ERROR/ ) { | ||
| 1560 | my $hlog_cpe_second = $self->read_oid('ZYXEL-IES5000-MIB::adslLineStatsAtucHlog2', '', {'-octetstring' => 0x0}); | ||
| 1561 | if ( $hlog_cpe_second !~ /^ERROR/ ) { | ||
| 1562 | # 16 bit values. tenths of db | ||
| 1563 | my @words = unpack("(n)*", $hlog_cpe_first.$hlog_cpe_second); | ||
| 1564 | foreach my $w ( @words ) { | ||
| 1565 | my $signed = to_signed16int( $w ); | ||
| 1566 | $signed /= 10 unless $signed == -32768; | ||
| 1567 | push @swords, $signed; | ||
| 1568 | } | ||
| 1569 | } | ||
| 1570 | } | ||
| 1571 | $self->_set_hlog_far_grpsize( 1 ); | ||
| 1572 | } | ||
| 1573 | |||
| 1574 | $self->_set_hlog_far(\@swords); | ||
| 1575 | return $self->hlog_far; | ||
| 1576 | } | ||
| 1577 | |||
| 1578 | =head2 read_qln_near | ||
| 1579 | |||
| 1580 | Asks the dslam for the near end part (dslam side) of the qln data. | ||
| 1581 | |||
| 1582 | Finds the correct oids to ask for, depending on the ifType | ||
| 1583 | =cut | ||
| 1584 | sub read_qln_near { | ||
| 1585 | my $self = shift; | ||
| 1586 | |||
| 1587 | my @swords = (); | ||
| 1588 | my $ifType = $self->readIfType; | ||
| 1589 | if ( $ifType eq 'VDSL' ) { | ||
| 1590 | # qln near for VDSL = qln down | ||
| 1591 | my $qln_down = $self->read_oid('ZYXEL-IES5000-MIB::vdslLineStatsVturQln', '', {'-octetstring' => 0x0}); | ||
| 1592 | if ( $qln_down !~ /^ERROR/ ) { | ||
| 1593 | my $qln_down_grpsize = $self->read_oid('ZYXEL-IES5000-MIB::vdslLineStatsVturQlnGroupSize'); | ||
| 1594 | my @bytes = unpack("(C)*", $qln_down); | ||
| 1595 | # 255 special => no measurement | ||
| 1596 | # The QLN(f) is represented as ( -23-n(i)/2), with n(i) in the range 0 to 254. | ||
| 1597 | foreach my $b ( @bytes ) { | ||
| 1598 | if ( $b != 255 ) { | ||
| 1599 | $b = - 23 - $b/2; | ||
| 1600 | } | ||
| 1601 | push @swords, $b; | ||
| 1602 | } | ||
| 1603 | if ( $qln_down_grpsize =~ /^\d+$/ ) { | ||
| 1604 | $self->_set_qln_near_grpsize( $qln_down_grpsize ); | ||
| 1605 | } | ||
| 1606 | } | ||
| 1607 | } | ||
| 1608 | elsif ( $ifType eq 'ADSL' ) { | ||
| 1609 | my $qln_dslam = $self->read_oid('ZYXEL-IES5000-MIB::adslLineStatsAturQln', '', {'-octetstring' => 0x0}); | ||
| 1610 | if ( $qln_dslam !~ /^ERROR/ ) { | ||
| 1611 | # 16 bit values. tenths of db | ||
| 1612 | my @words = unpack("(n)*", $qln_dslam); | ||
| 1613 | foreach my $w ( @words ) { | ||
| 1614 | my $signed = to_signed16int( $w ); | ||
| 1615 | $signed /= 10 unless $signed == -32768; | ||
| 1616 | push @swords, $signed; | ||
| 1617 | } | ||
| 1618 | } | ||
| 1619 | $self->_set_qln_near_grpsize( 1 ); | ||
| 1620 | } | ||
| 1621 | $self->_set_qln_near(\@swords); | ||
| 1622 | return $self->qln_near; | ||
| 1623 | } | ||
| 1624 | |||
| 1625 | =head2 read_qln_far | ||
| 1626 | |||
| 1627 | Asks the dslam for the far end part (cpe side) of the qln data. | ||
| 1628 | |||
| 1629 | Finds the correct oids to ask for, depending on the ifType | ||
| 1630 | =cut | ||
| 1631 | sub read_qln_far { | ||
| 1632 | my $self = shift; | ||
| 1633 | |||
| 1634 | my @swords = (); | ||
| 1635 | my $ifType = $self->readIfType; | ||
| 1636 | if ( $ifType eq 'VDSL' ) { | ||
| 1637 | # qln far for VDSL = qln up | ||
| 1638 | my $qln_up = $self->read_oid('ZYXEL-IES5000-MIB::vdslLineStatsVtucQln', '', {'-octetstring' => 0x0}); | ||
| 1639 | if ( $qln_up !~ /^ERROR/ ) { | ||
| 1640 | my $qln_up_grpsize = $self->read_oid('ZYXEL-IES5000-MIB::vdslLineStatsVtucQlnGroupSize'); | ||
| 1641 | my @bytes = unpack("(C)*", $qln_up); | ||
| 1642 | # 255 special => no measurement | ||
| 1643 | # The QLN(f) is represented as ( -23-n(i)/2), with n(i) in the range 0 to 254. | ||
| 1644 | foreach my $b ( @bytes ) { | ||
| 1645 | if ( $b != 255 ) { | ||
| 1646 | $b = - 23 - $b/2; | ||
| 1647 | } | ||
| 1648 | push @swords, $b; | ||
| 1649 | } | ||
| 1650 | if ( $qln_up_grpsize =~ /^\d+$/ ) { | ||
| 1651 | $self->_set_qln_far_grpsize( $qln_up_grpsize ); | ||
| 1652 | } | ||
| 1653 | } | ||
| 1654 | } | ||
| 1655 | elsif ( $ifType eq 'ADSL' ) { | ||
| 1656 | my $qln_cpe_first = $self->read_oid('ZYXEL-IES5000-MIB::adslLineStatsAtucQln1', '', {'-octetstring' => 0x0}); | ||
| 1657 | if ( $qln_cpe_first !~ /^ERROR/ ) { | ||
| 1658 | my $qln_cpe_second = $self->read_oid('ZYXEL-IES5000-MIB::adslLineStatsAtucQln2', '', {'-octetstring' => 0x0}); | ||
| 1659 | if ( $qln_cpe_second !~ /^ERROR/ ) { | ||
| 1660 | # 16 bit values. tenths of db | ||
| 1661 | my @words = unpack("(n)*", $qln_cpe_first.$qln_cpe_second); | ||
| 1662 | foreach my $w ( @words ) { | ||
| 1663 | my $signed = to_signed16int( $w ); | ||
| 1664 | $signed /= 10 unless $signed == -32768; | ||
| 1665 | push @swords, $signed; | ||
| 1666 | } | ||
| 1667 | } | ||
| 1668 | } | ||
| 1669 | $self->_set_qln_far_grpsize( 1 ); | ||
| 1670 | } | ||
| 1671 | $self->_set_qln_far(\@swords); | ||
| 1672 | return $self->qln_far; | ||
| 1673 | } | ||
| 1674 | |||
| 1675 | =head2 read_snr_near | ||
| 1676 | |||
| 1677 | Asks the dslam for the downstream part of the snr data. | ||
| 1678 | |||
| 1679 | =cut | ||
| 1680 | sub read_snr_near { | ||
| 1681 | my $self = shift; | ||
| 1682 | |||
| 1683 | my @swords = (); | ||
| 1684 | my $ifType = $self->readIfType; | ||
| 1685 | if ( $ifType eq 'VDSL' ) { | ||
| 1686 | # snr near for VDSL = snr down | ||
| 1687 | my $snr_down = $self->read_oid('ZYXEL-IES5000-MIB::vdslLineStatsVturSnr', '', {'-octetstring' => 0x0}); | ||
| 1688 | if ( $snr_down !~ /^ERROR/ ) { | ||
| 1689 | my $snr_down_grpsize = $self->read_oid('ZYXEL-IES5000-MIB::vdslLineStatsVturSnrGroupSize'); | ||
| 1690 | my @bytes = unpack("(C)*", $snr_down); | ||
| 1691 | # 255 special => no measurement | ||
| 1692 | # Octet i is set to a value in the range 0 to 254 (-32 + vdslLineStatsVtucSnr (i)/2) in dB | ||
| 1693 | foreach my $b ( @bytes ) { | ||
| 1694 | if ( $b != 255 ) { | ||
| 1695 | $b = - 32 + $b/2; | ||
| 1696 | } | ||
| 1697 | push @swords, $b; | ||
| 1698 | } | ||
| 1699 | if ( $snr_down_grpsize =~ /^\d+$/ ) { | ||
| 1700 | $self->_set_snr_near_grpsize( $snr_down_grpsize ); | ||
| 1701 | } | ||
| 1702 | } | ||
| 1703 | } | ||
| 1704 | $self->_set_snr_near(\@swords); | ||
| 1705 | return $self->snr_near; | ||
| 1706 | } | ||
| 1707 | |||
| 1708 | =head2 read_snr_far | ||
| 1709 | |||
| 1710 | Asks the dslam for the upstream part of the snr data. | ||
| 1711 | |||
| 1712 | =cut | ||
| 1713 | |||
| 1714 | sub read_snr_far { | ||
| 1715 | my $self = shift; | ||
| 1716 | |||
| 1717 | my @swords = (); | ||
| 1718 | my $ifType = $self->readIfType; | ||
| 1719 | if ( $ifType eq 'VDSL' ) { | ||
| 1720 | # snr far for VDSL = snr up | ||
| 1721 | my $snr_up = $self->read_oid('ZYXEL-IES5000-MIB::vdslLineStatsVtucSnr', '', {'-octetstring' => 0x0}); | ||
| 1722 | if ( $snr_up !~ /^ERROR/ ) { | ||
| 1723 | my $snr_up_grpsize = $self->read_oid('ZYXEL-IES5000-MIB::vdslLineStatsVtucSnrGroupSize'); | ||
| 1724 | my @bytes = unpack("(C)*", $snr_up); | ||
| 1725 | # 255 special => no measurement | ||
| 1726 | # Octet i is set to a value in the range 0 to 254 (-32 + vdslLineStatsVturSnr (i)/2) in dB | ||
| 1727 | foreach my $b ( @bytes ) { | ||
| 1728 | if ( $b != 255 ) { | ||
| 1729 | $b = - 32 + $b/2; | ||
| 1730 | } | ||
| 1731 | push @swords, $b; | ||
| 1732 | } | ||
| 1733 | if ( $snr_up_grpsize =~ /^\d+$/ ) { | ||
| 1734 | $self->_set_snr_far_grpsize( $snr_up_grpsize ); | ||
| 1735 | } | ||
| 1736 | } | ||
| 1737 | } | ||
| 1738 | $self->_set_snr_far(\@swords); | ||
| 1739 | return $self->snr_far; | ||
| 1740 | } | ||
| 1741 | |||
| 1742 | =head2 write_selt_begin | ||
| 1743 | |||
| 1744 | Sets the SeltOps thus initiating the SELT procedure on the port. | ||
| 1745 | |||
| 1746 | =cut | ||
| 1747 | sub write_selt_begin { | ||
| 1748 | my $self = shift; | ||
| 1749 | |||
| 1750 | my $res = 'ERROR: nothing done'; | ||
| 1751 | # Set the target port | ||
| 1752 | $res = $self->write_oid( 'ZYXEL-IES5000-MIB::seltTarget.0', INTEGER, $self->id, 1); | ||
| 1753 | if ( $res eq 'OK' ) { | ||
| 1754 | # Tell the DSLAM to start the test. | ||
| 1755 | $res = $self->write_oid( 'ZYXEL-IES5000-MIB::seltOps.0', INTEGER, 1, 1); | ||
| 1756 | } | ||
| 1757 | return $res; | ||
| 1758 | } | ||
| 1759 | |||
| 1760 | =head2 read_selt_results | ||
| 1761 | |||
| 1762 | Attempts to fetch the results of a SELT operation on the port. | ||
| 1763 | |||
| 1764 | Stores fetched values in the corresponding port attributes. | ||
| 1765 | |||
| 1766 | =cut | ||
| 1767 | sub read_selt_results { | ||
| 1768 | my $self = shift; | ||
| 1769 | |||
| 1770 | my $oidlist = {}; | ||
| 1771 | foreach my $oidname ( qw/seltStatus seltCableType seltLoopEstimateLengthFt seltLoopEstimateLengthMeter/ ) { | ||
| 1772 | $oidlist->{$oidname} = $oid_tr->translate( sprintf("ZYXEL-IES5000-MIB::%s.0",$oidname) ); | ||
| 1773 | } | ||
| 1774 | my $res = $self->slot->ies->read_oids( $oidlist ); | ||
| 1775 | return $res unless ref( $res ) eq 'HASH'; | ||
| 1776 | |||
| 1777 | foreach my $k ( keys %{$res} ) { | ||
| 1778 | my $setter = "_set_$k"; | ||
| 1779 | $self->$setter($res->{$k}); | ||
| 1780 | } | ||
| 1781 | return $res; | ||
| 1782 | } | ||
| 1783 | |||
| 1784 | =head2 read_dhcp_stats | ||
| 1785 | |||
| 1786 | Fetches the number of DHCPDISCOVER,-OFFER,-REQUEST and -ACK from the IES DHCP relay feature. | ||
| 1787 | |||
| 1788 | Params: | ||
| 1789 | None | ||
| 1790 | |||
| 1791 | Returns: | ||
| 1792 | Hash containing values for DISCOVER,OFFER,REQUEST,ACK and ACKBYSNOOPFULL | ||
| 1793 | |||
| 1794 | =cut | ||
| 1795 | sub read_dhcp_stats { | ||
| 1796 | my $self = shift; | ||
| 1797 | |||
| 1798 | my $oidlist = {}; | ||
| 1799 | foreach my $oidname ( qw/dhcpDiscovery dhcpOffer dhcpRequest dhcpAck dhcpAckBySnoopFull/ ) { | ||
| 1800 | $oidlist->{$oidname} = $oid_tr->translate( sprintf("ZYXEL-IES5000-MIB::%s",$oidname) ) .'.'.$self->id; | ||
| 1801 | } | ||
| 1802 | my $res = $self->slot->ies->read_oids( $oidlist ); | ||
| 1803 | return $res unless ref( $res ) eq 'HASH'; | ||
| 1804 | |||
| 1805 | foreach my $k ( keys %{$res} ) { | ||
| 1806 | my $setter = "_set_$k"; | ||
| 1807 | $self->$setter($res->{$k}); | ||
| 1808 | } | ||
| 1809 | return $res; | ||
| 1810 | |||
| 1811 | } | ||
| 1812 | |||
| 1813 | =head2 read_snoop_iplist | ||
| 1814 | |||
| 1815 | Retrieves the list of IP-Mac combination in the snoop table | ||
| 1816 | for a given port. | ||
| 1817 | |||
| 1818 | =cut | ||
| 1819 | sub read_snoop_iplist { | ||
| 1820 | my $self = shift; | ||
| 1821 | my $res = {}; | ||
| 1822 | |||
| 1823 | my $oidbase = $oid_tr->translate('ZYXEL-IES5000-MIB::dhcpSnoopMac'); | ||
| 1824 | my $oid = $oidbase.'.'.$self->id; | ||
| 1825 | |||
| 1826 | my $rawres = $self->slot->ies->walk_oid( $oid, { -octetstring => 0x0 } ); | ||
| 1827 | return $rawres if ( ref($rawres) eq 'SCALAR' && $rawres =~ /^ERROR/); | ||
| 1828 | foreach my $ip ( keys %{$rawres} ) { | ||
| 1829 | $ip =~ /^\d+\.\d+\.\d+.\d+$/ or next; | ||
| 1830 | $res->{$ip} = unpack('H*',$rawres->{$ip}); | ||
| 1831 | if ( $res->{$ip} =~ /^(..)(..)(..)(..)(..)(..)$/ ) { | ||
| 1832 | $res->{$ip} = sprintf("%s:%s:%s:%s:%s:%s",$1,$2,$3,$4,$5,$6); | ||
| 1833 | } | ||
| 1834 | } | ||
| 1835 | return $res; | ||
| 1836 | } | ||
| 1837 | |||
| 1838 | =head2 read_es_interval | ||
| 1839 | |||
| 1840 | Reads the ES Interval MIB, which returns a value for each 15 minute interval during the past 24 hours. | ||
| 1841 | |||
| 1842 | =cut | ||
| 1843 | sub read_es_interval { | ||
| 1844 | my $self = shift; | ||
| 1845 | my $res = {}; | ||
| 1846 | |||
| 1847 | my $ifType = $self->readIfType; | ||
| 1848 | if ( $ifType eq 'VDSL' ) { | ||
| 1849 | my $oidbase = $oid_tr->translate('VDSL-LINE-MIB::vdslPerfIntervalESs'); | ||
| 1850 | my $oid = $oidbase.'.'.$self->id; | ||
| 1851 | |||
| 1852 | my $rawres = $self->slot->ies->walk_oid( $oid ); | ||
| 1853 | return $rawres if ( ref($rawres) eq 'SCALAR' && $rawres =~ /^ERROR/); | ||
| 1854 | foreach my $interval ( keys %{$rawres} ) { | ||
| 1855 | $interval =~ /^([12])\.(\d+)$/ or next; | ||
| 1856 | my ($dir,$i) = ($1,$2); | ||
| 1857 | $dir = $dir == 1 ? 'near' : 'far'; | ||
| 1858 | $res->{$dir}{$i} = $rawres->{$interval}; | ||
| 1859 | } | ||
| 1860 | } | ||
| 1861 | elsif ( $ifType eq 'ADSL' ) { | ||
| 1862 | my %names = ( 'near' => 'ADSL-LINE-MIB::adslAtucIntervalESs', 'far' => 'ADSL-LINE-MIB::adslAturIntervalESs' ); | ||
| 1863 | foreach my $dir ( keys %names ) { | ||
| 1864 | my $oidbase = $oid_tr->translate($names{$dir}); | ||
| 1865 | my $oid = $oidbase.'.'.$self->id; | ||
| 1866 | |||
| 1867 | my $rawres = $self->slot->ies->walk_oid( $oid ); | ||
| 1868 | return $rawres if ( ref($rawres) eq 'SCALAR' && $rawres =~ /^ERROR/); | ||
| 1869 | foreach my $interval ( keys %{$rawres} ) { | ||
| 1870 | $interval =~ /^\d+$/ or next; | ||
| 1871 | $res->{$dir}{$interval} = $rawres->{$interval}; | ||
| 1872 | } | ||
| 1873 | } | ||
| 1874 | } | ||
| 1875 | else { | ||
| 1876 | return "ERROR: Not supported"; | ||
| 1877 | } | ||
| 1878 | return $res; | ||
| 1879 | } | ||
| 1880 | |||
| 1881 | =head2 read_crc_interval | ||
| 1882 | |||
| 1883 | Reads the ES Interval MIB, which returns a value for each 15 minute interval during the past 24 hours. | ||
| 1884 | |||
| 1885 | =cut | ||
| 1886 | sub read_crc_interval { | ||
| 1887 | my $self = shift; | ||
| 1888 | my $res = {}; | ||
| 1889 | |||
| 1890 | my $ifType = $self->readIfType; | ||
| 1891 | if ( $ifType eq 'VDSL' ) { | ||
| 1892 | my $oidbase = $oid_tr->translate('VDSL-LINE-MIB::vdslChanIntervalBadBlks'); | ||
| 1893 | my $oid = $oidbase.'.'.$self->id; | ||
| 1894 | |||
| 1895 | my $rawres = $self->slot->ies->walk_oid( $oid ); | ||
| 1896 | return $rawres if ( ref($rawres) eq 'SCALAR' && $rawres =~ /^ERROR/); | ||
| 1897 | foreach my $interval ( keys %{$rawres} ) { | ||
| 1898 | $interval =~ /^([12])\.(\d+)$/ or next; | ||
| 1899 | my ($dir,$i) = ($1,$2); | ||
| 1900 | $dir = $dir == 1 ? 'near' : 'far'; | ||
| 1901 | $res->{$dir}{$i} = $rawres->{$interval}; | ||
| 1902 | } | ||
| 1903 | } | ||
| 1904 | elsif ( $ifType eq 'ADSL' ) { | ||
| 1905 | my %names = ( 'near' => 'ADSL-LINE-MIB::adslAtucChanIntervalUncorrectBlks', 'far' => 'ADSL-LINE-MIB::adslAturChanIntervalUncorrectBlks' ); | ||
| 1906 | foreach my $dir ( keys %names ) { | ||
| 1907 | my $oidbase = $oid_tr->translate($names{$dir}); | ||
| 1908 | my $oid = $oidbase.'.'.$self->id; | ||
| 1909 | |||
| 1910 | my $rawres = $self->slot->ies->walk_oid( $oid ); | ||
| 1911 | return $rawres if ( ref($rawres) eq 'SCALAR' && $rawres =~ /^ERROR/); | ||
| 1912 | foreach my $interval ( keys %{$rawres} ) { | ||
| 1913 | $interval =~ /^\d+$/ or next; | ||
| 1914 | $res->{$dir}{$interval} = $rawres->{$interval}; | ||
| 1915 | } | ||
| 1916 | } | ||
| 1917 | } | ||
| 1918 | else { | ||
| 1919 | return "ERROR: Not supported"; | ||
| 1920 | } | ||
| 1921 | return $res; | ||
| 1922 | } | ||
| 1923 | |||
| 1924 | |||
| 1925 | =head2 fetchAllDetails | ||
| 1926 | |||
| 1927 | Retrieves the details of a port from the IES. | ||
| 1928 | |||
| 1929 | Fetches all relevant information from the port, and fills values into the appropriate attributes. | ||
| 1930 | |||
| 1931 | =cut | ||
| 1932 | |||
| 1933 | sub fetchAllDetails { | ||
| 1934 | my $self = shift; | ||
| 1935 | my $meta = $self->meta(); | ||
| 1936 | |||
| 1937 | foreach my $method ( $meta->get_method_list ) { | ||
| 1938 | if ( $method =~ /^read_/ && $method ne 'read_oid' ) { | ||
| 1939 | my $res = $self->$method; | ||
| 1940 | return $res if $res =~ /ERROR/i; | ||
| 1941 | } | ||
| 1942 | } | ||
| 1943 | return 'OK'; | ||
| 1944 | } | ||
| 1945 | |||
| 1946 | |||
| 1947 | =head2 fetchDetails | ||
| 1948 | |||
| 1949 | Retrieves the details of a port from the IES. | ||
| 1950 | |||
| 1951 | Fetches all relevant information from the port, and fills values into the appropriate attributes. | ||
| 1952 | |||
| 1953 | =cut | ||
| 1954 | |||
| 1955 | our %snmp_details = ( | ||
| 1956 | 'Common' => [ | ||
| 1957 | ['operStatus','IF-MIB::ifOperStatus',''], | ||
| 1958 | ['adminStatus','IF-MIB::ifAdminStatus',''], | ||
| 1959 | ['ifLastChange','IF-MIB::ifLastChange',''], | ||
| 1960 | ['macFilterCount','ZYXEL-IES5000-MIB::macFilterPortMacCount',''], | ||
| 1961 | ['inOctets','IF-MIB::ifHCInOctets',''], | ||
| 1962 | ['outOctets','IF-MIB::ifHCOutOctets',''], | ||
| 1963 | ], | ||
| 1964 | 'ADSL' => [ | ||
| 1965 | ['profile','ADSL-LINE-MIB::adslLineConfProfile',''], | ||
| 1966 | ['maxAttainableDown','ADSL-LINE-MIB::adslAtucCurrAttainableRate',''], | ||
| 1967 | ['maxAttainableUp','ADSL-LINE-MIB::adslAturCurrAttainableRate',''], | ||
| 1968 | ['currSpeedDown','ADSL-LINE-MIB::adslAtucChanCurrTxRate',''], | ||
| 1969 | ['currSpeedUp','ADSL-LINE-MIB::adslAturChanCurrTxRate',''], | ||
| 1970 | ['snrDown','ADSL-LINE-MIB::adslAtucCurrSnrMgn',''], | ||
| 1971 | ['snrUp','ADSL-LINE-MIB::adslAturCurrSnrMgn',''], | ||
| 1972 | ['atnDown','ADSL-LINE-MIB::adslAtucCurrAtn',''], | ||
| 1973 | ['atnUp','ADSL-LINE-MIB::adslAturCurrAtn',''], | ||
| 1974 | ['lineUptime','ZYXEL-IES5000-MIB::adslLineStatusUpTime',''], | ||
| 1975 | ['inpDown','ZYXEL-IES5000-MIB::adslLineConfAtucInp',''], | ||
| 1976 | ['inpUp','ZYXEL-IES5000-MIB::adslLineConfAturInp',''], | ||
| 1977 | ['annexM','ZYXEL-IES5000-MIB::adslLineConfAnnexM',''], | ||
| 1978 | ['annexL','ZYXEL-IES5000-MIB::adslLineConfAnnexL',''], | ||
| 1979 | ], | ||
| 1980 | 'VDSL' => [ | ||
| 1981 | ['profile','VDSL-LINE-MIB::vdslLineConfProfile',''], | ||
| 1982 | ['maxAttainableDown','VDSL-LINE-MIB::vdslPhysCurrAttainableRate','%d.1'], | ||
| 1983 | ['maxAttainableUp','VDSL-LINE-MIB::vdslPhysCurrAttainableRate','%d.2'], | ||
| 1984 | ['currSpeedDown','VDSL-LINE-MIB::vdslPhysCurrLineRate','%d.1'], | ||
| 1985 | ['currSpeedUp','VDSL-LINE-MIB::vdslPhysCurrLineRate','%d.2'], | ||
| 1986 | ['snrDown','VDSL-LINE-MIB::vdslPhysCurrSnrMgn','%d.1'], | ||
| 1987 | ['snrUp','VDSL-LINE-MIB::vdslPhysCurrSnrMgn','%d.2'], | ||
| 1988 | ['atnDown','VDSL-LINE-MIB::vdslPhysCurrAtn','%d.1'], | ||
| 1989 | ['atnUp','VDSL-LINE-MIB::vdslPhysCurrAtn','%d.2'], | ||
| 1990 | ['protocol','ZYXEL-IES5000-MIB::vdslLineStatsProtocol',''], | ||
| 1991 | ['inpDown','ZYXEL-IES5000-MIB::vdslLineConfVturInp',''], | ||
| 1992 | ['inpUp','ZYXEL-IES5000-MIB::vdslLineConfVtucInp',''], | ||
| 1993 | ], | ||
| 1994 | 'SHDSL' => [ | ||
| 1995 | ['profile','HDSL2-SHDSL-LINE-MIB::hdsl2ShdslSpanConfProfile',''], | ||
| 1996 | ['lineRate','HDSL2-SHDSL-LINE-MIB::hdsl2ShdslStatusActualLineRate',''], | ||
| 1997 | ['snrDown','HDSL2-SHDSL-LINE-MIB::hdsl2ShdslEndpointCurrSnrMgn','%d.2.1.1'], | ||
| 1998 | ['snrUp','HDSL2-SHDSL-LINE-MIB::hdsl2ShdslEndpointCurrSnrMgn','%d.1.2.1'], | ||
| 1999 | ['atnDown','HDSL2-SHDSL-LINE-MIB::hdsl2ShdslEndpointCurrAtn','%d.2.1.1'], | ||
| 2000 | ['atnUp','HDSL2-SHDSL-LINE-MIB::hdsl2ShdslEndpointCurrAtn','%d.1.2.1'], | ||
| 2001 | ['wirePairMode','ZYXEL-IES5000-MIB::shdslLineStatusWirePair',''], | ||
| 2002 | ], | ||
| 2003 | ); | ||
| 2004 | |||
| 2005 | my %set_map = ( | ||
| 2006 | 'profile' => 'profile', | ||
| 2007 | 'operStatus' => '_set_operstatus', | ||
| 2008 | 'adminStatus' => 'adminstatus', | ||
| 2009 | 'macFilterCount' => 'maxmac', | ||
| 2010 | 'maxAttainableDown' => '_set_maxdown', | ||
| 2011 | 'maxAttainableUp' => '_set_maxup', | ||
| 2012 | 'currSpeedDown' => '_set_downspeed', | ||
| 2013 | 'currSpeedUp' => '_set_upspeed', | ||
| 2014 | 'snrDown' => '_set_snrdown', | ||
| 2015 | 'snrUp' => '_set_snrup', | ||
| 2016 | 'atnDown' => '_set_atndown', | ||
| 2017 | 'atnUp' => '_set_atnup', | ||
| 2018 | 'inpDown' => 'inp_down', | ||
| 2019 | 'inpUp' => 'inp_up', | ||
| 2020 | 'annexM' => 'annexM', | ||
| 2021 | 'annexL' => 'annexL', | ||
| 2022 | 'protocol' => '_set_vdslprotocol', | ||
| 2023 | 'linerate' => ['_set_downspeed','_set_upspeed'], | ||
| 2024 | 'wirePairMode' => '_set_wirepairmode', | ||
| 2025 | 'inOctets' => '_set_ifInOctets', | ||
| 2026 | 'outOctets' => '_set_ifOutOctets', | ||
| 2027 | ); | ||
| 2028 | |||
| 2029 | sub fetchDetails { | ||
| 2030 | my $self = shift; | ||
| 2031 | |||
| 2032 | my $oidlist = {}; | ||
| 2033 | my $ifType = $self->readIfType; | ||
| 2034 | my @sections = ('Common',$ifType); | ||
| 2035 | foreach my $dk ( @sections ) { | ||
| 2036 | foreach my $dl ( @{$snmp_details{$dk}} ) { | ||
| 2037 | my $oid = $oid_tr->translate( $dl->[1], $dl->[2] ); | ||
| 2038 | my $actualoid = $oid.'.'.$self->id; | ||
| 2039 | if ( $oid =~ /%d/ ) { | ||
| 2040 | $actualoid = sprintf( $oid, $self->id ); | ||
| 2041 | } | ||
| 2042 | $oidlist->{$dl->[0]} = $actualoid; | ||
| 2043 | } | ||
| 2044 | } | ||
| 2045 | |||
| 2046 | my $res = $self->slot->ies->read_oids( $oidlist ); | ||
| 2047 | return $res unless ref( $res ) eq 'HASH'; | ||
| 2048 | |||
| 2049 | my $nofSet = 0; | ||
| 2050 | foreach my $key ( keys %set_map ) { | ||
| 2051 | if ( defined( $res->{$key} ) ) { | ||
| 2052 | $nofSet++; | ||
| 2053 | if ( ref( $set_map{$key} ) eq 'LIST' ) { | ||
| 2054 | foreach my $setter ( @{$set_map{$key}} ) { | ||
| 2055 | $self->$setter( $res->{$key} ); | ||
| 2056 | } | ||
| 2057 | } | ||
| 2058 | else { | ||
| 2059 | my $setter = $set_map{$key}; | ||
| 2060 | $self->$setter($res->{$key}); | ||
| 2061 | } | ||
| 2062 | } | ||
| 2063 | } | ||
| 2064 | return $nofSet>0?'OK':'ERROR: nothing set'; | ||
| 2065 | } | ||
| 2066 | |||
| 2067 | =head1 Private Methods | ||
| 2068 | |||
| 2069 | =head2 to_signed16int | ||
| 2070 | |||
| 2071 | Method that converts a 16 bit unsigned to a signed value | ||
| 2072 | |||
| 2073 | =cut | ||
| 2074 | sub to_signed16int { | ||
| 2075 | my ($num) = @_; | ||
| 2076 | return $num >> 15 ? $num - 2 ** 16 : $num; | ||
| 2077 | } | ||
| 2078 | |||
| 2079 | =head1 SUPPORT | ||
| 2080 | |||
| 2081 | You can find documentation for this module with the perldoc command. | ||
| 2082 | |||
| 2083 | perldoc Device::ZyXEL::IES::Port | ||
| 2084 | |||
| 2085 | |||
| 2086 | You can also look for information at: | ||
| 2087 | |||
| 2088 | =over 4 | ||
| 2089 | |||
| 2090 | =item * RT: CPAN's request tracker | ||
| 2091 | |||
| 2092 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Device-ZyXEL-IES> | ||
| 2093 | |||
| 2094 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 2095 | |||
| 2096 | L<http://annocpan.org/dist/Device-ZyXEL-IES> | ||
| 2097 | |||
| 2098 | =item * CPAN Ratings | ||
| 2099 | |||
| 2100 | L<http://cpanratings.perl.org/d/Device-ZyXEL-IES> | ||
| 2101 | |||
| 2102 | =item * Search CPAN | ||
| 2103 | |||
| 2104 | L<http://search.cpan.org/dist/Device-ZyXEL-IES/> | ||
| 2105 | |||
| 2106 | =back | ||
| 2107 | |||
| 2108 | |||
| 2109 | =head1 ACKNOWLEDGEMENTS | ||
| 2110 | |||
| 2111 | Fullrate (http://www.fullrate.dk) | ||
| 2112 | Thanks for allowing me to be introduced to the "wonderful" device ;) | ||
| 2113 | And thanks for donating some of my work time to create this module and | ||
| 2114 | sharing it with the world. | ||
| 2115 | |||
| 2116 | =head1 COPYRIGHT & LICENSE | ||
| 2117 | |||
| 2118 | Copyright 2012 Jesper Dalberg, all rights reserved. | ||
| 2119 | |||
| 2120 | This program is free software; you can redistribute it and/or modify it | ||
| 2121 | under the same terms as Perl itself. | ||
| 2122 | |||
| 2123 | |||
| 2124 | =cut | ||
| 2125 | |||
| 2126 | __PACKAGE__->meta->make_immutable; | ||
| 2127 | |||
| 2128 | 1; # End of Device::ZyXEL::IES::Port | ||