From 7654ad59f97c23c0eedc6ba85785dd6d7d633f72 Mon Sep 17 00:00:00 2001 From: maniacikarus Date: Thu, 29 Mar 2007 19:50:28 +0000 Subject: [PATCH] Upnp fast fertig gestellt zumindest was Web und Ctrl Datei angeht git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@472 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- config/upnp/gatedesc.xml | 81 +++++++++++ html/cgi-bin/upnp.cgi | 284 ++++++++++++++------------------------ lfs/linux-igd | 1 + src/misc-progs/upnpctrl.c | 19 ++- 4 files changed, 195 insertions(+), 190 deletions(-) create mode 100755 config/upnp/gatedesc.xml diff --git a/config/upnp/gatedesc.xml b/config/upnp/gatedesc.xml new file mode 100755 index 0000000000..49d2406b4d --- /dev/null +++ b/config/upnp/gatedesc.xml @@ -0,0 +1,81 @@ + + + + 1 + 0 + + + urn:schemas-upnp-org:device:InternetGatewayDevice:1 + IpFire Upnp Device + IpFire Project + http://www.ipfire.org + IGD Version 0.92 + uuid:75802409-bccb-40e7-8e6c-fa095ecce13e + + + image/gif + 118 + 119 + 8 + /ligd.gif + + + + + urn:schemas-dummy-com:service:Dummy:1 + urn:dummy-com:serviceId:dummy1 + /dummy + /dummy + /dummy.xml + + + + + urn:schemas-upnp-org:device:WANDevice:1 + WANDevice + IpFire Project + http://www.ipfire.org + WAN Device on Linux IGD + Linux IGD + 0.92 + http://linux-igd.sourceforge.net + 0.92 + uuid:75802409-bccb-40e7-8e6c-fa095ecce13e + Linux IGD + + + urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1 + urn:upnp-org:serviceId:WANCommonIFC1 + /upnp/control/WANCommonIFC1 + /upnp/control/WANCommonIFC1 + /gateicfgSCPD.xml + + + + + urn:schemas-upnp-org:device:WANConnectionDevice:1 + WANConnectionDevice + IpFire Project + http://www.ipfire.org + WanConnectionDevice on Linux IGD + Linux IGD + 0.92 + http://www.ipfire.org + 0.92 + uuid:75802409-bccb-40e7-8e6c-fa095ecce13e + Linux IGD + + + urn:schemas-upnp-org:service:WANIPConnection:1 + urn:upnp-org:serviceId:WANIPConn1 + /upnp/control/WANIPConn1 + /upnp/control/WANIPConn1 + /gateconnSCPD.xml + + + + + + + + diff --git a/html/cgi-bin/upnp.cgi b/html/cgi-bin/upnp.cgi index 3970cc8d92..3d8495501c 100644 --- a/html/cgi-bin/upnp.cgi +++ b/html/cgi-bin/upnp.cgi @@ -17,17 +17,12 @@ require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; my %upnpsettings = (); -my %checked = (); my %netsettings = (); my $message = ""; my $errormessage = ""; my %selected= () ; -&General::readhash("${General::swroot}/ethernet/settings", \%netsettings); -my %servicenames = -( - 'UPnP Daemon' => 'upnpd', -); +my %servicenames =('UPnP Daemon' => 'upnpd',); &Header::showhttpheaders(); ############################################################################################################################ @@ -35,25 +30,17 @@ my %servicenames = $upnpsettings{'DEBUGMODE'} = '3'; $upnpsettings{'FORWARDRULES'} = 'yes'; -$upnpsettings{'FORWARDCHAIN'} = 'FORWARD'; -$upnpsettings{'PREROUTINGCHAIN'} = 'PORTFW'; $upnpsettings{'DOWNSTREAM'} = '900000'; $upnpsettings{'UPSTREAM'} = '16000000'; $upnpsettings{'DESCRIPTION'} = 'gatedesc.xml'; $upnpsettings{'XML'} = '/etc/linuxigd'; $upnpsettings{'ENABLED'} = 'off'; -$upnpsettings{'GREENi'} = 'on'; -$upnpsettings{'BLUEi'} = 'off'; -$upnpsettings{'REDi'} = 'off'; -$upnpsettings{'ORANGEi'} = 'off'; -$upnpsettings{'GREENe'} = 'off'; -$upnpsettings{'BLUEe'} = 'off'; -$upnpsettings{'REDe'} = 'on'; -$upnpsettings{'ORANGEe'} = 'off'; +$upnpsettings{'friendlyName'} = 'IpFire Upnp Device'; ### Values that have to be initialized $upnpsettings{'ACTION'} = ''; &General::readhash("${General::swroot}/upnp/settings", \%upnpsettings); +&General::readhash("${General::swroot}/ethernet/settings", \%netsettings); &Header::getcgihash(\%upnpsettings); &Header::openpage('UPnP', 1, ''); @@ -63,20 +50,22 @@ $upnpsettings{'ACTION'} = ''; ################################################### Speichern der Config ################################################### if ($upnpsettings{'ACTION'} eq $Lang::tr{'save'}) -{ -&General::writehash("${General::swroot}/upnp/settings", \%upnpsettings); + { + $upnpsettings{'DOWNSTREAM'} = $upnpsettings{'DOWNSTREAM'} * 8; + $upnpsettings{'UPSTREAM'} = $upnpsettings{'UPSTREAM'} * 8; + &General::writehash("${General::swroot}/upnp/settings", \%upnpsettings); open (FILE, ">${General::swroot}/upnp/upnpd.conf") or die "Can't save the upnp config: $!"; flock (FILE, 2); - -print FILE <$errormessage\n"; - print " \n"; - &Header::closebox(); -} - -$checked{'GREENi'}{'on'} = ''; -$checked{'GREENi'}{'off'} = ''; -$checked{'GREENi'}{"$upnpsettings{'GREENi'}"} = 'checked'; -$checked{'BLUEi'}{'on'} = ''; -$checked{'BLUEi'}{'off'} = ''; -$checked{'BLUEi'}{"$upnpsettings{'BLUEi'}"} = 'checked'; -$checked{'REDi'}{'on'} = ''; -$checked{'REDi'}{'off'} = ''; -$checked{'REDi'}{"$upnpsettings{'REDi'}"} = 'checked'; -$checked{'ORANGEi'}{'on'} = ''; -$checked{'ORANGEi'}{'off'} = ''; -$checked{'ORANGEi'}{"$upnpsettings{'ORANGEi'}"} = 'checked'; -$checked{'GREENe'}{'on'} = ''; -$checked{'GREENe'}{'off'} = ''; -$checked{'GREENe'}{"$upnpsettings{'GREENe'}"} = 'checked'; -$checked{'BLUEe'}{'on'} = ''; -$checked{'BLUEe'}{'off'} = ''; -$checked{'BLUEe'}{"$upnpsettings{'BLUEe'}"} = 'checked'; -$checked{'REDe'}{'on'} = ''; -$checked{'REDe'}{'off'} = ''; -$checked{'REDe'}{"$upnpsettings{'REDe'}"} = 'checked'; -$checked{'ORANGEe'}{'on'} = ''; -$checked{'ORANGEe'}{'off'} = ''; -$checked{'ORANGEe'}{"$upnpsettings{'ORANGEe'}"} = 'checked'; +if ($errormessage) + { + &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); + print "$errormessage\n"; + print " \n"; + &Header::closebox(); + } ############################################################################################################################ ############################################################################################################################ &Header::openbox('100%', 'center', 'UPnP'); print < - + +
END ; - if ( $message ne "" ) { - print "\n";} + else + {print "\n"; } + + print "\n"; } - else { - print "\n"; } - print "
$message"; - } +if ( $message ne "" ) {print "
$message";} + +my $lines = 0; +my $key = ''; +foreach $key (sort keys %servicenames) +{ + if ($lines % 2) + {print "
$key\n"; + my $shortname = $servicenames{$key}; + my $status = &isrunning($shortname); + print "$status\n"; + $lines++; +} - my $lines = 0; - my $key = ''; - foreach $key (sort keys %servicenames) - { - if ($lines % 2) { - print "
$key\n"; - my $shortname = $servicenames{$key}; - my $status = &isrunning($shortname); - print "$status\n"; - $lines++; - } - print <Alle Dienste: - - - -
-END -; -#print <
-#
-#

-# -# -# -# -# -# -#
External Interface
 RED - $netsettings{'RED_DEV'}

-# $Lang::tr{'green'} - $netsettings{'GREEN_DEV'}

-#END -#; -# if (&Header::blue_used()){ -# print <$Lang::tr{'wireless'} - $netsettings{'BLUE_DEV'}

-#END -#; -# } -# if (&Header::orange_used()){ -# print <$Lang::tr{'dmz'} - $netsettings{'ORANGE_DEV'}

-#END -#; -# } -# print <


Internal Interface
 RED - $netsettings{'RED_DEV'}

-# $Lang::tr{'green'} - $netsettings{'GREEN_DEV'}

-#END -#; -# if (&Header::blue_used()){ -# print <$Lang::tr{'wireless'} - $netsettings{'BLUE_DEV'}

-#END -#; -# } -# if (&Header::orange_used()){ -# print <$Lang::tr{'dmz'} - $netsettings{'ORANGE_DEV'}

-#END -#; -# } -# print <
print <Alle Dienste: + + + + -

+
- - - - - - - - + + + + + + + + +
$Lang::tr{'options'}


Debug Mode:
Forward Rules:
Forward Chain:
Prerouting Chain:
Down Stream:
Up Strean:
Description Document:
XML Document:
Debug Mode:
Forward Rules:

Down Stream in KB:
Up Strean in KB:

XML Document:
Description Document:
Upnp Device Name:


-

-
+
+
END ; &Header::closebox(); @@ -250,34 +171,29 @@ END ############################################################################################################################ sub isrunning -{ - my $cmd = $_[0]; - my $status = "$Lang::tr{'stopped'}"; - my $pid = ''; - my $testcmd = ''; - my $exename; - - $cmd =~ /(^[a-z]+)/; - $exename = $1; - - if (open(FILE, "/var/run/${cmd}.pid")) - { - $pid = ; chomp $pid; - close FILE; - if (open(FILE, "/proc/${pid}/status")) - { - while () - { - if (/^Name:\W+(.*)/) { - $testcmd = $1; } - } - close FILE; - if ($testcmd =~ /$exename/) - { - $status = "$Lang::tr{'running'}"; - } - } - } - - return $status; -} + { + my $cmd = $_[0]; + my $status = "$Lang::tr{'stopped'}"; + my $pid = ''; + my $testcmd = ''; + my $exename; + + $cmd =~ /(^[a-z]+)/; + $exename = $1; + + if (open(FILE, "/var/run/${cmd}.pid")) + { + $pid = ; chomp $pid; + close FILE; + if (open(FILE, "/proc/${pid}/status")) + { + while () + {if (/^Name:\W+(.*)/) {$testcmd = $1; }} + close FILE; + if ($testcmd =~ /$exename/) + {$status = "$Lang::tr{'running'}";} + } + } + + return $status; + } \ No newline at end of file diff --git a/lfs/linux-igd b/lfs/linux-igd index 704fa1b4ee..ff5dbce425 100644 --- a/lfs/linux-igd +++ b/lfs/linux-igd @@ -74,5 +74,6 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) cd $(DIR_APP) && make $(MAKETUNING) #HAVE_LIBIPTC=1 cd $(DIR_APP) && make install + cp -vf $(DIR_SRC)/config/upnp/* /etc/linuigd/ @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/src/misc-progs/upnpctrl.c b/src/misc-progs/upnpctrl.c index d133c163ce..bb6c43b3ec 100644 --- a/src/misc-progs/upnpctrl.c +++ b/src/misc-progs/upnpctrl.c @@ -19,13 +19,13 @@ int main(int argc, char *argv[]) // Check what command is asked if (argc==1) { - fprintf (stderr, "Missing upnpctrl command!\n"); + fprintf (stderr, "Missing smbctrl command!\n"); return 1; } - if (strcmp(argv[1], "start")==0) + if (strcmp(argv[1], "upnpstart")==0) { - snprintf(command, BUFFER_SIZE-1, "route add -net 239.0.0.0 netmask 255.0.0.0 %s", argv[2]); + snprintf(command, BUFFER_SIZE-1, "route add -net 239.0.0.0 netmask 255.0.0.0 %s", argv[3]); safe_system(command); printf(command); snprintf(command, BUFFER_SIZE-1, "/usr/sbin/upnpd %s %s", argv[2], argv[3] ); @@ -34,14 +34,21 @@ int main(int argc, char *argv[]) return 0; } - if (strcmp(argv[1], "stop")==0) + if (strcmp(argv[1], "upnpstop")==0) { snprintf(command, BUFFER_SIZE-1, "killall upnpd"); safe_system(command); printf(command); - snprintf(command, BUFFER_SIZE-1, "route del -net 239.0.0.0 netmask 255.0.0.0 %s", argv[2]); + snprintf(command, BUFFER_SIZE-1, "route del -net 239.0.0.0 netmask 255.0.0.0 %s", argv[3]); safe_system(command); printf(command); return 0; } -} + if (strcmp(argv[1], "upnpxml")==0) + { + snprintf(command, BUFFER_SIZE-1, "sed 's/.*<\/friendlyName>/%s<\/friendlyName>/gi' %s/%s > tmp && mv tmp %s/%s", argv[2], argv[3], argv[4], argv[3], argv[4]); + safe_system(command); + printf(command); + return 0; + } +} \ No newline at end of file -- 2.39.2