From 00a630fd346fd3694f8479949e31883e0dab729d Mon Sep 17 00:00:00 2001
From: Philippe PITTOLI
Date: Sun, 13 Oct 2019 18:54:04 +0200
Subject: [PATCH] dhcpv6
---
src/main.cr | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/src/main.cr b/src/main.cr
index 544478d..66741cd 100644
--- a/src/main.cr
+++ b/src/main.cr
@@ -183,6 +183,13 @@ class NetworkCommands
raise "(udhcpc) dhcp failed on #{ifname}"
end
end
+
+ def self.dhcp6(ifname : String)
+ # we suppose udhcpc6 installed along with udhcpc
+ unless Do.run("udhcpc6", [ ifname ]).success?
+ raise "(udhcpc6) dhcp failed on #{ifname}"
+ end
+ end
end
class DHClientCommand
@@ -191,6 +198,12 @@ class NetworkCommands
raise "(dhclient) dhcp failed on #{ifname}"
end
end
+
+ def self.dhcp6(ifname : String)
+ unless Do.run("dhclient", [ "-6", ifname ]).success?
+ raise "(dhclient) dhcp6 failed on #{ifname}"
+ end
+ end
end
class IfconfigCommand
@@ -367,6 +380,13 @@ class NetworkCommands
def self.autoconfiguration(ifname : String)
puts "TODO: IPv6 autoconfiguration setup"
+ puts "sysctl -w net.ipv6.conf.#{ifname}.autoconf=1"
+ puts "sysctl -w net.ipv6.conf.#{ifname}.accept_ra=1"
+ end
+
+ def self.dhcp6(ifname : String)
+ puts "TODO: dhcpv6"
+ @@cmd_dhcp_client.dhcp6 ifname
end
def self.wireless_connect_wpa_psk(ifname : String, ssid : String, passwd : String)
@@ -613,20 +633,15 @@ class InterfaceConfiguration
# ipv6 configuration
main_ip_v6.tap do |ip|
- puts "CONFIGURATION IPV6"
-
case ip
when IPAddress
NetworkCommands.set_ip name, ip
- # TODO
when Autoconfiguration
- puts "CONFIGURATION IPV6 : autoconfiguration !!!"
NetworkCommands.autoconfiguration name
- #when DHCP
- # NetworkCommands.dhcp6 name
+ when DHCP
+ NetworkCommands.dhcp6 name
when NotSetup
# do nothing
- puts "CONFIGURATION IPV6 : not setup !!!"
else
raise "ipv6 configuration: neither static nor dynamic"
end
@@ -780,10 +795,7 @@ class NetworkConfigurationParser
next
end
- # TODO
ipaddr = IPAddress.parse ipstr
-
- # TODO
access_point = wireless_networks[ssid].not_nil!
if ipaddr.ipv4?