ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-BER-XS/XS.pm
(Generate patch)

Comparing Convert-BER-XS/XS.pm (file contents):
Revision 1.57 by root, Thu Apr 25 22:30:21 2019 UTC vs.
Revision 1.62 by root, Thu Feb 6 23:15:44 2020 UTC

69 69
70 my $buf = ber_encode $ber, $Convert::BER::XS::SNMP_PROFILE; 70 my $buf = ber_encode $ber, $Convert::BER::XS::SNMP_PROFILE;
71 71
72=head1 DESCRIPTION 72=head1 DESCRIPTION
73 73
74WARNING: Before release 1.0, the API is not considered stable in any way.
75
76This module implements a I<very> low level BER/DER en-/decoder. 74This module implements a I<very> low level BER/DER en-/decoder.
77 75
78It is tuned for low memory and high speed, while still maintaining some 76It is tuned for low memory and high speed, while still maintaining some
79level of user-friendlyness. 77level of user-friendlyness.
80 78
414use Carp (); 412use Carp ();
415 413
416our $VERSION; 414our $VERSION;
417 415
418BEGIN { 416BEGIN {
419 $VERSION = 1.2; 417 $VERSION = 1.21;
420 XSLoader::load __PACKAGE__, $VERSION; 418 XSLoader::load __PACKAGE__, $VERSION;
421} 419}
422 420
423our %EXPORT_TAGS = ( 421our %EXPORT_TAGS = (
424 const_index => [qw( 422 const_index => [qw(
473$SNMP_PROFILE->set (ASN_APPLICATION, SNMP_UNSIGNED32, BER_TYPE_INT); 471$SNMP_PROFILE->set (ASN_APPLICATION, SNMP_UNSIGNED32, BER_TYPE_INT);
474$SNMP_PROFILE->set (ASN_APPLICATION, SNMP_TIMETICKS , BER_TYPE_INT); 472$SNMP_PROFILE->set (ASN_APPLICATION, SNMP_TIMETICKS , BER_TYPE_INT);
475 473
476# decodes REAL values according to ECMA-63 474# decodes REAL values according to ECMA-63
477# this is pretty strict, except it doesn't catch -0. 475# this is pretty strict, except it doesn't catch -0.
476# I don't have access to ISO 6093 (or BS 6727, or ANSI X.3-42)), so this is all guesswork.
478sub _decode_real_decimal { 477sub _decode_real_decimal {
479 my ($format, $val) = @_; 478 my ($format, $val) = @_;
480 479
481 $val =~ y/,/./; 480 $val =~ y/,/./; # probably not in ISO-6093
482 481
483 if ($format == 1) { 482 if ($format == 1) {
484 $val =~ /^ \ * [+-]? [0-9]+ \z/x 483 $val =~ /^ \ * [+-]? [0-9]+ \z/x
485 or Carp::croak "BER_TYPE_REAL NR1 value not in NR1 format ($val) (X.690 8.5.8, ECMA-63)"; 484 or Carp::croak "BER_TYPE_REAL NR1 value not in NR1 format ($val) (X.690 8.5.8)";
486 } elsif ($format == 2) { 485 } elsif ($format == 2) {
487 $val =~ /^ \ * [+-]? (?: [0-9]+\.[0-9]* | [0-9]*\.[0-9]+ ) \z/x 486 $val =~ /^ \ * [+-]? (?: [0-9]+\.[0-9]* | [0-9]*\.[0-9]+ ) \z/x
488 or Carp::croak "BER_TYPE_REAL NR2 value not in NR2 format ($val) (X.690 8.5.8, ECMA-63)"; 487 or Carp::croak "BER_TYPE_REAL NR2 value not in NR2 format ($val) (X.690 8.5.8)";
489 } elsif ($format == 3) { 488 } elsif ($format == 3) {
490 $val =~ /^ \ * [+-] (?: [0-9]+\.[0-9]* | [0-9]*\.[0-9]+ ) E [+-][0-9]+ \z/x 489 $val =~ /^ \ * [+-] (?: [0-9]+\.[0-9]* | [0-9]*\.[0-9]+ ) [eE] [+-]? [0-9]+ \z/x
491 or Carp::croak "BER_TYPE_REAL NR3 value not in NR3 format ($val) (X.690 8.5.8, ECMA-63)"; 490 or Carp::croak "BER_TYPE_REAL NR3 value not in NR3 format ($val) (X.690 8.5.8)";
492 } else { 491 } else {
493 Carp::croak "BER_TYPE_REAL illegal decimal numerical representation format $format"; 492 Carp::croak "BER_TYPE_REAL invalid decimal numerical representation format $format";
494 } 493 }
495 494
496 $val 495 $val
497} 496}
498 497
728dot, e.g. C<1.3.6.1.213>. 727dot, e.g. C<1.3.6.1.213>.
729 728
730=item C<BER_TYPE_RELOID> 729=item C<BER_TYPE_RELOID>
731 730
732Same as C<BER_TYPE_OID> but uses relative object identifier 731Same as C<BER_TYPE_OID> but uses relative object identifier
733encoding: ASN.1 has this hack of encoding the first two OID components 732encoding: ASN.1 uses some hack encoding of the first two OID components
734into a single integer in a weird attempt to save an insignificant amount 733into a single integer in a weird attempt to save an insignificant amount
735of space in an otherwise wasteful encoding, and relative OIDs are 734of space in an otherwise wasteful encoding, and relative OIDs are
736basically OIDs without this hack. The practical difference is that the 735basically OIDs without this hack. The practical difference is that the
737second component of an OID can only have the values 1..40, while relative 736second component of an OID can only have the values 1..40, while relative
738OIDs do not have this restriction. 737OIDs do not have this restriction.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines