More work on Solaris support for IPv6
authorJamie Cameron <jcameron@webmin.com>
Fri, 21 Jan 2011 06:00:11 +0000 (22:00 -0800)
committerJamie Cameron <jcameron@webmin.com>
Fri, 21 Jan 2011 06:00:11 +0000 (22:00 -0800)
net/edit_aifc.cgi
net/edit_bifc.cgi
net/lang/en
net/save_aifc.cgi
net/save_bifc.cgi
net/solaris-lib.pl

index 38e45ed..01bf95f 100755 (executable)
@@ -92,18 +92,33 @@ else {
 print &ui_table_row($text{'ifcs_broad'}, $broadfield);
 
 # Show the IPv6 field
-if (&supports_address6($a)) {
-       $table6 = &ui_columns_start([ $text{'ifcs_address6'},
-                                     $text{'ifcs_netmask6'} ], 50);
-       for($i=0; $i<=@{$a->{'address6'}}; $i++) {
-               $table6 .= &ui_columns_row([
-                   &ui_textbox("address6_$i",
-                               $a->{'address6'}->[$i], 40),
-                   &ui_textbox("netmask6_$i",
-                               $a->{'netmask6'}->[$i] || 64, 10) ]);
+$supp = &supports_address6($a);
+if ($supp) {
+       if ($supp == 1) {
+               # Multiple addresses supported
+               $table6 = &ui_columns_start([ $text{'ifcs_address6'},
+                                             $text{'ifcs_netmask6'} ], 50);
+               for($i=0; $i<=@{$a->{'address6'}}; $i++) {
+                       $table6 .= &ui_columns_row([
+                           &ui_textbox("address6_$i",
+                                       $a->{'address6'}->[$i], 40),
+                           &ui_textbox("netmask6_$i",
+                                       $a->{'netmask6'}->[$i] || 64, 10) ]);
+                       }
+               $table6 .= &ui_columns_end();
+               }
+       else {
+               # Just one address
+               $table6 = &ui_textbox("address6_0", $a->{'address6'}->[0], 40).
+                         " <b>".$text{'ifcs_netmask6'}."</b> ".
+                         &ui_textbox("netmask6_0",
+                                     $a->{'netmask6'}->[0] || 64, 10);
                }
-       $table6 .= &ui_columns_end();
-       print &ui_table_row($text{'ifcs_mode6a'}, $table6, 3);
+       print &ui_table_row($text{'ifcs_mode6a'},
+               &ui_radio_table("mode6",
+                       @{$a->{'address6'}} ? "address" : "none",
+                       [ [ "none", $text{'ifcs_none6'} ],
+                         [ "address", $text{'ifcs_static3'}, $table6 ] ]), 2);
        }
 
 # Show MTU
index 769291c..b4ab41e 100755 (executable)
@@ -143,17 +143,30 @@ else {
        }
 
 # Show the IPv6 field
-if (&supports_address6($b)) {
-       $table6 = &ui_columns_start([ $text{'ifcs_address6'},
-                                     $text{'ifcs_netmask6'} ], 50);
-       for($i=0; $i<=@{$b->{'address6'}}; $i++) {
-               $table6 .= &ui_columns_row([
-                   &ui_textbox("address6_$i",
-                               $b->{'address6'}->[$i], 40),
-                   &ui_textbox("netmask6_$i",
-                               $b->{'netmask6'}->[$i] || 64, 10) ]);
+$supp = &supports_address6($b);
+if ($supp) {
+       if ($supp == 1) {
+               # Multiple IPs allowed
+               $table6 = &ui_columns_start([ $text{'ifcs_address6'},
+                                             $text{'ifcs_netmask6'} ], 50);
+               for($i=0; $i<=@{$b->{'address6'}}; $i++) {
+                       $table6 .= &ui_columns_row([
+                           &ui_textbox("address6_$i",
+                                       $b->{'address6'}->[$i], 40),
+                           &ui_textbox("netmask6_$i",
+                                       $b->{'netmask6'}->[$i] || 64, 10) ]);
+                       }
+               $table6 .= &ui_columns_end();
+               }
+       else {
+               # Just one
+               @grid = ( $text{'ifcs_address6'},
+                         &ui_textbox("address6_0", $b->{'address6'}->[0], 40),
+                         $text{'ifcs_netmask6'},
+                         &ui_textbox("netmask6_0",
+                                     $b->{'netmask6'}->[0] || 64, 10) );
+               $table6 = &ui_grid_table(\@grid, 2);
                }
-       $table6 .= &ui_columns_end();
        print &ui_table_row($text{'ifcs_mode6'},
                &ui_radio_table("mode6",
                        $b->{'auto6'} ? "auto" :
index 5dfaaf0..f656a3d 100644 (file)
@@ -41,6 +41,7 @@ ifcs_ecannot=You are not allowed to edit network interfaces
 ifcs_ecannot_this=You are not allowed to edit this network interface
 ifcs_range=Range $1
 ifcs_static2=Static configuration
+ifcs_static3=IPv6 enabled
 ifcs_mode=IPv4 address
 ifcs_mode6=IPv6 addresses
 ifcs_address6=IPv6 address
@@ -71,6 +72,7 @@ aifc_eclash=The interface $1 is already using this IP address
 aifc_eaddress6=IPv6 address in row $1 is not valid
 aifc_enetmask6=IPv6 netmask in row $1 must be an integer between 1 and 128
 aifc_eclash6=IPv6 address in row $1 is already in use by interface $2
+aifc_eaddresses6=No IPv6 addresses entered
 
 bifc_create=Create Bootup Interface
 bifc_edit=Edit Bootup Interface
index 84f25aa..6986aa2 100755 (executable)
@@ -139,7 +139,8 @@ else {
                }
 
        # Save IPv6 addresses
-       if (&supports_address6($a) && defined($in{'address6_0'})) {
+       if (&supports_address6($a) && $in{'mode6'} eq 'address') {
+               # Has IPv6 addresses
                @address6 = ( );
                @netmask6 = ( );
                %clash6 = ( );
@@ -164,9 +165,15 @@ else {
                        push(@netmask6, $in{'netmask6_'.$i});
                        $clash6{$in{'address6_'.$i}} = $a;
                        }
+               @address6 || &error($text{'aifc_eaddresses6'});
                $a->{'address6'} = \@address6;
                $a->{'netmask6'} = \@netmask6;
                }
+       elsif (&supports_address6($a) && $in{'mode6'} eq 'none') {
+               # IPv6 addresses disabled
+               delete($a->{'address6'});
+               delete($a->{'netmask6'});
+               }
 
        if (!$in{'ether_def'} && $a->{'virtual'} eq "" &&
            &iface_hardware($a->{'name'})) {
index eab455e..f9a3578 100755 (executable)
@@ -229,6 +229,7 @@ else {
                        push(@netmask6, $in{'netmask6_'.$i});
                        $clash6{$in{'address6_'.$i}} = $b;
                        }
+               @address6 || &error($text{'aifc_eaddresses6'});
                delete($b->{'auto6'});
                $b->{'address6'} = \@address6;
                $b->{'netmask6'} = \@netmask6;
index 2ab89bd..80e01fe 100755 (executable)
@@ -19,7 +19,16 @@ foreach $l (@lines) {
        local %ifc;
        $l =~ /^([^:\s]+):/; $ifc{'name'} = $1;
        $l =~ /^(\S+):/; $ifc{'fullname'} = $1;
-       if ($l =~ /inet6\s+(\S+)/) { next; }    # skip IPv6 for now
+       if ($l =~ /inet6\s+(\S+)\/(\d+)/) {
+               # Find matching IPv6 interface, set address
+               my ($address6, $netmask6) = ($1, $2);
+               my ($ifc4) = grep { $_->{'fullname'} eq $ifc{'fullname'} } @rv;
+               if ($ifc4) {
+                       $ifc4->{'address6'} = [ $address6 ];
+                       $ifc4->{'netmask6'} = [ $netmask6 ];
+                       }
+               next;
+               }
        if ($l =~ /^(\S+):(\d+):\s/) { $ifc{'virtual'} = $2; }
        if ($l =~ /inet\s+(\S+)/) { $ifc{'address'} = $1; }
        if ($l =~ /netmask\s+(\S+)/) { $ifc{'netmask'} = &parse_hex($1); }
@@ -44,17 +53,24 @@ return @rv;
 sub activate_interface
 {
 local $a = $_[0];
+
+# Check if already up
 local @active = &active_interfaces();
 local ($already) = grep { $_->{'fullname'} eq $_[0]->{'fullname'} } @active;
 if (!$already) {
+       # Bring up for the first time
        if ($a->{'virtual'} eq "") {
-               local $out = &backquote_logged("ifconfig $a->{'name'} plumb 2>&1");
+               local $out = &backquote_logged(
+                "ifconfig $a->{'name'} plumb 2>&1");
                if ($out) { &error(&text('aifc_eexist', $a->{'name'})); }
                }
        elsif ($gconfig{'os_version'} >= 8) {
-               &system_logged("ifconfig $a->{'name'}:$a->{'virtual'} plumb >/dev/null 2>&1");
+               &system_logged(
+                "ifconfig $a->{'name'}:$a->{'virtual'} plumb >/dev/null 2>&1");
                }
        }
+
+# Set IP address and netmask
 local $cmd = "ifconfig $a->{'name'}";
 if ($a->{'virtual'} ne "") { $cmd .= ":$a->{'virtual'}"; }
 $cmd .= " $a->{'address'}";
@@ -68,6 +84,11 @@ if ($a->{'up'}) { $cmd .= " up"; }
 else { $cmd .= " down"; }
 local $out = &backquote_logged("$cmd 2>&1");
 if ($?) { &error("$cmd : $out"); }
+
+# Set IPv6 address
+# XXX
+
+# Set MAC address
 if ($a->{'ether'}) {
        $out = &backquote_logged(
                "ifconfig $a->{'name'} ether $a->{'ether'} 2>&1");
@@ -650,7 +671,7 @@ return $netmask;
 sub supports_address6
 {
 local ($iface) = @_;
-return 0;
+return !$iface || $iface->{'virtual'} eq '' ? 2 : 0;
 }
 
 1;