Net::U...ateway(3pm)

πŸ“¦
version 1.4.6 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Net::UPnP::GW::Gateway πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation for the module Net::UPnP::GW::Gateway (that's the 3pm situation β€” a Perl module manual, iykyk). It's a Perl extension for UPnP, and it's giving gateway energy, and we're gonna go through it together, no cap. πŸ¦‹


✨ NAME ✨

Net::UPnP::GW::Gateway β€” Perl extension for UPnP. that's it, that's the name, she's simple and she's iconic. πŸ’…


🌈 SYNOPSIS 🌈

here's the whole vibe, copied exactly so you can steal it:

use Net::UPnP::ControlPoint;
use Net::UPnP::GW::Gateway;

my $obj = Net::UPnP::ControlPoint->new();

@dev_list = ();
while (@dev_list <= 0 || $retry_cnt > 5) {
#       @dev_list = $obj->search(st =>'urn:schemas-upnp-org:device:InternetGatewayDevice:1', mx => 10);
        @dev_list = $obj->search(st =>'upnp:rootdevice', mx => 3);
        $retry_cnt++;
}

$devNum= 0;
foreach $dev (@dev_list) {
        my $device_type = $dev->getdevicetype();
        if  ($device_type ne 'urn:schemas-upnp-org:device:InternetGatewayDevice:1') {
                next;
        }
        print "[$devNum] : " . $dev->getfriendlyname() . "\n";
        unless ($dev->getservicebyname('urn:schemas-upnp-org:service:WANIPConnection:1')) {
                next;
        }
        my $gwdev = Net::UPnP::GW::Gateway->new();
        $gwdev->setdevice($dev);
        print "\tExternalIPAddress = " . $gwdev->getexternalipaddress() . "\n";
        print "\tPortMappingNumberOfEntries = " . $gwdev->getportmappingnumberofentries() . "\n";
        @port_mapping = $gwdev->getportmappingentries();
        $port_num = 0;
        foreach $port_entry (@port_mapping) {
                $port_map_name = $port_entry->{'NewPortMappingDescription'};
                if (length($port_map_name) <= 0) {
                        $port_map_name = "(No name)";
                }
                print "  [$port_num] : $port_map_name\n";
                foreach $name ( keys %{$port_entry} ) {
                        print "    $name = $port_entry->{$name}\n";
                }
                $port_num++;
        }
}

like… she's thorough. she searches, she loops, she prints. main character behavior fr fr. πŸ”₯


πŸ’œ DESCRIPTION πŸ’œ

The package is a extension UPnP/GW. yep, that's the whole description, short and sweet, a little lowercase moment, we respect it. πŸŽ€


🌸 METHODS 🌸

new β€” create new Net::UPnP::GW::Gateway.

$mservier = Net::UPnP::GW::Gateway();

Creates a new object. Read perldoc perlboot if you don't understand that. (not me telling you to go read the docs, but like, respectfully, go read the docs bestie πŸ™ˆ)

The new object is not associated with any UPnP devices. Please use setdevice() to set the device. so she's brand new and unbothered, no device attached yet, you gotta introduce her. ✨

setdevice β€” set a UPnP devices

$gw->setdevice($dev);

Set a device to the object. matchmaker behavior, honestly. 🫢

getexternalipaddress β€” External IP address

$gw->getexternalipaddress();

Get the external IP address. that's your outside-the-house address, the one the internet knows you by. πŸ‘‘

getportmappingnumberofentries β€” PortMappingNumberOfEntries

$gw->getportmappingnumberofentries();

Get the number of the port mapping entries. just a lil count, a census of your mappings. πŸ“

getportmappingentries β€” PortMappingEntry

$gw->getportmappingentries();

Get the port mapping entries. all of them. the whole lineup. πŸ’…

addportmapping β€” add new port mapping.

$result = gw->addportmapping(
                          NewRemoteHost # '',
                          NewExternalPort # '',
                          NewProtocol # '',
                          NewInternalPort # '',
                          NewInternalClient # '',
                          NewEnabled #1,
                          NewPortMappingDescription # '',
                          NewLeaseDuration # 0);

Add a new specified port mapping. eight whole arguments, she does NOT do things by halves. notice NewEnabled defaults to 1 and NewLeaseDuration defaults to 0, the rest are empty strings. periodt. ⭐

deleteportmapping β€” delete a port mapping.

$result = gw->deleteportmapping(
                          NewRemoteHost # '',
                          NewExternalPort # '',
                          NewProtocol # '');

Delete the specified port mapping. three arguments only, she's efficient when she wants to be. bye bye mapping πŸ¦‹

gettotalbytesreceived β€” Total received bytes.

$gw->gettotalbytesreceived();

Get the total received bytes. the big number. the receipts, literally. 😭


🧚 AUTHOR 🧚

Satoshi Konno skonno@cybergarage.org

CyberGarage http://www.cybergarage.org


Copyright (C) 2005 by Satoshi Konno

It may be used, redistributed, and/or modified under the terms of BSD License.

so basically: use it, share it, remix it β€” just respect the BSD License terms, bestie. that's the whole deal. 🫢

and that's the page!! this whole thing is from perl v5.36.0, dated 2022-12-06, and it's the Net::UPnP::GW::Gateway(3pm) manual from the User Contributed Perl Documentation. slay, go map some ports responsibly πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from