1Net::UPnP::GW::Gateway(U3s)er Contributed Perl DocumentatNieotn::UPnP::GW::Gateway(3)
2
3
4

NAME

6       Net::UPnP::GW::Gateway - Perl extension for UPnP.
7

SYNOPSIS

9               use Net::UPnP::ControlPoint;
10               use Net::UPnP::GW::Gateway;
11
12               my $obj = Net::UPnP::ControlPoint->new();
13
14               @dev_list = ();
15               while (@dev_list <= 0 || $retry_cnt > 5) {
16               #       @dev_list = $obj->search(st =>'urn:schemas-upnp-org:device:InternetGatewayDevice:1', mx => 10);
17                       @dev_list = $obj->search(st =>'upnp:rootdevice', mx => 3);
18                       $retry_cnt++;
19               }
20
21               $devNum= 0;
22               foreach $dev (@dev_list) {
23                       my $device_type = $dev->getdevicetype();
24                       if  ($device_type ne 'urn:schemas-upnp-org:device:InternetGatewayDevice:1') {
25                               next;
26                       }
27                       print "[$devNum] : " . $dev->getfriendlyname() . "\n";
28                       unless ($dev->getservicebyname('urn:schemas-upnp-org:service:WANIPConnection:1')) {
29                               next;
30                       }
31                       my $gwdev = Net::UPnP::GW::Gateway->new();
32                       $gwdev->setdevice($dev);
33                       print "\tExternalIPAddress = " . $gwdev->getexternalipaddress() . "\n";
34                       print "\tPortMappingNumberOfEntries = " . $gwdev->getportmappingnumberofentries() . "\n";
35                       @port_mapping = $gwdev->getportmappingentry();
36                       $port_num = 0;
37                       foreach $port_entry (@port_mapping) {
38                               if ($port_entry) {
39                                       $port_map_name = $port_entry->{'NewPortMappingDescription'};
40                                       if (length($port_map_name) <= 0) {
41                                               $port_map_name = "(No name)";
42                                       }
43                                       print "  [$port_num] : $port_map_name\n";
44                                       foreach $name ( keys %{$port_entry} ) {
45                                               print "    $name = $port_entry->{$name}\n";
46                                       }
47                               }
48                               else {
49                                       print "  [$port_num] : Unknown\n";
50                               }
51                               $port_num++;
52                       }
53               }
54

DESCRIPTION

56       The package is a extention UPnP/GW.
57

METHODS

59       new - create new Net::UPnP::GW::Gateway.
60               $mservier = Net::UPnP::GW::Gateway();
61
62           Creates a new object. Read `perldoc perlboot` if you don't
63           understand that.
64
65           The new object is not associated with any UPnP devices. Please use
66           setdevice() to set the device.
67
68       setdevice - set a UPnP devices
69               $gw->setdevice($dev);
70
71           Set a device to the object.
72
73       getexternalipaddress - External IP address
74               $gw->getexternalipaddress();
75
76           Get the external IP address.
77
78       getportmappingnumberofentries - PortMappingNumberOfEntries
79               $gw->getexternalipaddress();
80
81           Get the number of the port mapping entries.
82
83       getportmappingentry - PortMappingEntry
84               $gw->getexternalipaddress();
85
86           Get the port mapping entries.
87
88       addportmapping - add new port mapping.
89               $result = gw->addportmapping(
90                                         NewRemoteHost # '',
91                                         NewExternalPort # '',
92                                         NewProtocol # '',
93                                         NewInternalPort # '',
94                                         NewInternalClient # '',
95                                         NewEnabled #1,
96                                         NewPortMappingDescription # '',
97                                         NewLeaseDuration # 0);
98
99           Add a new specified port mapping.
100
101       deleteportmapping - delete a port mapping.
102               $result = gw->deleteportmapping(
103                                         NewRemoteHost # '',
104                                         NewExternalPort # '',
105                                         NewProtocol # '');
106
107           Delete the specified port mapping.
108
109       gettotalbytesrecieved - Total recieved bytes.
110               $gw->gettotalbytesrecieved();
111
112           Get the total recieved bytes.
113

AUTHOR

115       Satoshi Konno skonno@cybergarage.org
116
117       CyberGarage http://www.cybergarage.org
118
120       Copyright (C) 2005 by Satoshi Konno
121
122       It may be used, redistributed, and/or modified under the terms of BSD
123       License.
124
125
126
127perl v5.12.0                      2009-07-27         Net::UPnP::GW::Gateway(3)
Impressum