NAME
Net::IANA::PortNumbers - translate ports to services and vice versa
SYNOPSIS
use Net::IANA::PortNumbers;
my $iana = Net::IANA::PortNumbers->new(); # or: ->new(MyRegistry->new());
($iana->port(22, 'tcp'))[0]->svc; # returns 'ssh'
($iana->port(22, 'tcp'))[0]->port; # returns 22
($iana->port(22, 'tcp'))[0]->desc; # returns 'SSH Remote Login Protocol'
($iana->port(22, 'tcp'))[0]->proto; # returns 'tcp'
($iana->port(22, 'tcp'))[0]->range; # returns 'Well known'
($iana->svc('ssh', 'tcp'))[0]->svc; # returns 'ssh'
($iana->svc('ssh', 'tcp'))[0]->port; # returns 22
($iana->svc('ssh', 'tcp'))[0]->desc; # returns 'SSH Remote Login Protocol'
($iana->svc('ssh', 'tcp'))[0]->proto; # returns 'tcp'
($iana->svc('ssh', 'tcp'))[0]->range; # returns 'Well known'
# prints: ident auth
for my $port ($iana->port(113, 'tcp')) {
print $port->svc(), " ";
}
# prints: 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012
# 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026
# 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040
# 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054
# 6055 6056 6057 6058 6059 6060 6061
for my $service ($iana->svc('x11', 'tcp')) {
print $service->port(), " ";
}
# prints: ISO Transport Class 2 Non-Control over TCP, ISO Transport Class
# 2 Non-Control over UDP
print join ', ', map {$_->desc} $iana->port(399);
# prints: Management Utility, Compression Process
print join ', ', map {$_->desc} $iana->svc('compressnet', 'udp');
DESCRIPTION
Net::IANA::PortNumbers translates port numbers and services to ports, services, descriptions, protocols, and ranges.
METHODS
new
This constructor returns a Net::IANA::PortNumbers object. It accepts an optional parameter of a registry object, otherwise it defaults to using Net::IANA::Registry.
svc
Takes one mandatory argument of a service, i.e., 'ssh', and one optional argument of a protocol, i.e., 'tcp'. It will returns a list of port objects that match.
port
Takes one mandatory argument of a port, i.e., 22, and one optional argument of a protocol, i.e., 'tcp'. It will returns a list of port objects that match.
COPYRIGHT
Copyright (c) 2003 Adam J. Foxson. All rights reserved.
LICENSE
See COPYING
SEE ALSO
AUTHOR
Adam J. Foxson <afoxson@pobox.com>, with special thanks to Kurt Starsinic <kstar@cpan.org> for many suggestions.