Hallo zusammen,
ich möchte mit Perl via Soap alle WLAN Geräte über meine Fritzbox auslesen.
Die Anzahl kann ich leicht über GetTotalAssociations() auslesen.
Nun muss ich die einzelnen Geräte MAC, IP Adresse und AUTHState auslesen.
Das bekomme ich nur via PHP hin:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$client = new SoapClient(
null,
array(
'location' => "http://".$fritzboxIP.":".$fritzboxPort."/upnp/control/wlanconfig2",
'uri' => "urn:dslforum-org:service:WLANConfiguration:2",
'noroot' => True,
'login' => $login,
'password' => $password
)
);
//print_r($client);
$NumberOfHosts = $client->GetTotalAssociations();
//print_r($NumberOfHosts);
for ($i=0;$i<$NumberOfHosts;$i++)
{
$Host = $client->GetGenericAssociatedDeviceInfo(new SoapParam($i,'NewAssociatedDeviceIndex'));
//print_r($Host);
$Hosts[] = $Host;
}
Bei Perl sieht es so aus:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use strict;
use warnings;
use SOAP::Lite;
use Data::Dumper;
use constant {
FRITZ_USER => "dslf-config",
FRITZ_PASS => "***********",
BASIC_URI => "urn:dslforum-org:service:",
BASIC_PROXY => "http://fritz.box:49000/upnp/control/deviceinfo",
HTTPS_PROXY => "https://fritz.box:",
};
my $s = SOAP::Lite
-> uri('urn:dslforum-org:service:DeviceInfo:1')
-> proxy('http://fritz.box:49000/upnp/control/deviceinfo')
-> getSecurityPort();
my $port = $s->result;
print "Using TCP port $port for Fritzbox access.\n";
BEGIN {
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
}
undef $s;
$s = SOAP::Lite
-> uri(BASIC_URI . "WLANConfiguration:2")
-> proxy(HTTPS_PROXY . $port . "/upnp/control/wlanconfig2", ssl_opts => [ SSL_verify_mode => 0 ] )
-> GetGenericAssociatedDeviceInfo( INDEX 1 - ???????? );
open FH, ">erg_dumper.txt" or die ("Fehler beim schreiben $!");
print FH Dumper $s;
close FH;
print "result: " . $s->result . "\n";
sub SOAP::Transport::HTTP::Client::get_basic_credentials {
return FRITZ_USER => FRITZ_PASS;
}
Genau bei INDEX 1 - ???????? ist mein Problem, hier benötige ich wohl ein Objekt ähnlich wie in php:
new SoapParam(1,'NewAssociatedDeviceIndex')
.
Kann mir wer weiter helfen?
Hintergrund: Ich habe einen FritzDECT Steckdose, und wenn bestimmte MAC Adressen nicht im WLaN online sind, soll er diese ausschalten.
Vielen Dank im Voraus.
Gruß