Net::ASN(3)
π NAME π
Net::ASN β a Perl extension for manipulating autonomous system numbers, bestie π¦
β¨ SYNOPSIS β¨
Okay so here's the whole vibe in one go, two flavours, pick your fighter:
##OO implementation (methods)
use Net::ASN;
my $asn = Net::ASN->new($ARGV[0]);
print "type : " . $asn->gettype . "\n";
print "asplain16: " . $asn->toasplain16 . "\n";
print "asplain32: " . $asn->toasplain . "\n";
print "asdot : " . $asn->toasdot . "\n";
print "asdotplus: " . $asn->toasdotplus . "\n";
print "\n";
##Non OO implementation (functions)
use Net::ASN qw(:all);
my $asplain = 12345;
print "ASN in asdotplus format is " . plaintodotplus($asplain) . "\n";
my $asdotplus = '1.1';
print "ASN in asplain format is " . dotplustoplain($asdotplus) . "\n";
πΈ DESCRIPTION πΈ
Net::ASN hands you functions for parsing autonomous system numbers (ASNs) as defined in RFC 1771 and extended by RFC4893, plus converting between the formats talked about in RFC5396. Periodt. π
And because she's generous, she gives you both an OO implementation (method based) and a non-OO one (function based), just for convenience. Pick whichever one matches your main character energy. π«Ά
π METHODS π
new
my $asn = Net::ASN->new(1234); #Automatic parsing
or
my $asn = Net::ASN->new(1234,1); #Parse as ASDOT
Makes you a brand new Net::ASN object, which prompts parsing of the parameter you handed over, an ASN. Heads up tho: right now only ASPLAIN and ASDOT+ get auto-recognised as input formats. So if you wanna force the input as ASDOT, you have to pass a second argument to the constructor. That's the rule, no cap. π
gettype
my $type = $asn->gettype;
Returns the type of ASN the parser assumes it's dealing with. It's giving "what even are you" but politely. π
toasplain
my $asplain = $asn->toasplain;
Returns the ASPLAIN representation of the parsed ASN. β¨
toasplain16
my $asplain = $asn->toasplain16;
Returns the ASPLAIN representation of the parsed ASN if the ASPLAIN representation is less than or equal to 65535, else returns AS_TRANS. π¨
Use this for compatibility with 16 bit ASN systems, bestie, they're doing their best. π§
toasdot
my $asdot = $asn->toasdot;
Returns the ASDOT representation of the parsed ASN. But plot twist: if the parsed ASN is ASPLAIN and less than or equal to 65535, then it just returns the ASPLAIN. π
toasdotplus
my $asdotplus = $asn->toasdotplus;
Returns the ASDOT+ representation of the parsed ASN. Clean, simple, iconic. π
isprivate
my $isprivate = $asn->isprivate;
Returns 1 if the number falls within the private reserved ranges according to RFC6996, 0 otherwise. She's flexible too β will accept any format that Net::ASN can convert to ASPLAIN. π
π₯ FUNCTIONS π₯
plaintodot
my $asdot = plaintodot($asn);
Returns the ASDOT representation of the ASN ($asn). If $asn is ASPLAIN and less than or equal to 65535 then it returns the ASPLAIN. (Assumes your ASN is in ASPLAIN format β she's not psychic, okay π)
plaintodotplus
my $asdotplus = plaintodotplus($asn);
Returns the ASDOT+ representation of the ASN ($asn). (Assumes your ASN is in ASPLAIN format)
dottodotplus
my $asplain = dottodotplus($asn);
Returns the ASDOT+ representation of the ASN ($asn). (Assumes your ASN is in ASDOT format)
dottoplain
my $asplain = dottoplain($asn);
Returns the ASPLAIN representation of the ASN ($asn). (Assumes your ASN is in ASDOT format)
dottoplain16
my $asplain = dottoplain16($asn);
Returns the ASPLAIN representation of the ASN ($asn) if the ASPLAIN representation is less than or equal to 65535, else returns AS_TRANS. (Assumes your ASN is in ASDOT format)
dotplustodot
my $asdot = dotplustodot($asn);
Returns the ASDOT representation of the ASN ($asn). (Assumes your ASN is in ASDOT+ format)
dotplustoplain
my $asplain = dotplustoplain($asn);
Returns the ASPLAIN representation of the ASN ($asn). (Assumes your ASN is in ASDOT+ format)
dotplustoplain16
my $asplain = dotplustoplain16($asn);
Returns the ASPLAIN representation of the ASN ($asn) if the ASPLAIN representation is less than or equal to 65535, else returns AS_TRANS. (Assumes your ASN is in ASDOT+ format)
isprivateasn
my $isprivateasn = isprivateasn($asn);
Returns 1 if the number falls within the private reserved ranges according to RFC6996, 0 otherwise. Will accept any format that Net::ASN can convert to ASPLAIN. Same energy as the method, just without the ->. π
π AUTHOR π
David J. Freedman <lochii AT convergence DOT cx> β shoutout, legend behaviour fr fr π
π COPYRIGHT π
Copyright (c) 2008 Convergence Inc. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms as perl itself. Slay. π
π¦ SEE ALSO π¦
REPOSITORY
<https://github.com/lochiiconnectivity/netasn.git>
Go read those RFCs, bestie, they're lowkey important. π
Okay that's the whole page!! This was perl v5.42.0, dated 2025-07-25, and yes it's the Net::ASN(3) manpage from User Contributed Perl Documentation. Byeeee πβ¨π«Ά
π¦ where this page comes from
- fedora 43: perl-Net-ASN 1.08-3.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms