Net::ASN(3)

πŸ“¦
version 1.08 Β· 2 versions
, in fedora 43

πŸ’– 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 (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>

perl(1)


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