# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Here's a routine that generates the "magic" field in the SNMP MIB table. A # # symbolic name is accepted, and a two-item list is returned. The first item # # is the constant name, which is upper-case and starts with 'X'. Some # # canonicalization is done, too. The second item is the numeric value, which # # starts at $cmagic. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # sub cmagic { local($n) = @_; local($s,$x); return ('0', 0) if $type{$n} eq 'GRP'; # No magic code for group items. if (!(($s = $cmagicname{$n}) && ($x = $cmagiccode{$s}))) { ($s = "X$n") =~ tr/a-z/A-Z/; # Capitalize the name. $s =~ s/-CLP0+//; # GTE kludge. $s =~ s/ADDRESS/ADR/; $s =~ s/ADMINSTATUS/ADSTAT/; $s =~ s/CALLED/CLD/; $s =~ s/CALLING/CLG/; $s =~ s/CONNECTION/CONN/; $s =~ s/ENTRY$/ENT/; $s =~ s/INDEX$/NDX/; $s =~ s/OBJECTID$/OID/; $s =~ s/OPERSTATUS/OPSTAT/; $s =~ s/PARTY/PTY/; $s =~ s/TABLE$/TBL/; $s =~ s/THRESHOLD$/TH/; $s =~ s/THOLD$/TH/; $s =~ s/TOLERANCE/TOL/; $s =~ s/TRUNK$/TRK/; $s =~ s/[-+]+/_/g; $cmagicname{$n} = $s; $cmagiccode{$s} = $x = (++$cmagic || 1); } ($s, $x); # Return symbol and its numeric value. } 1; # Gotta return a value to satisfy the require command.