6 def make_variant(string):
7 return dbus.String(string, variant_level=1)
9 def make_byte_variant(string):
10 return dbus.Byte(int(string), variant_level=1)
13 print "Usage: %s <service> off|manual|auto [<address> [prefixlen] [gateway]] [<privacy>]" % (sys.argv[0])
15 if (len(sys.argv) < 3):
19 bus = dbus.SystemBus()
20 path = "/net/connman/service/" + sys.argv[1]
21 service = dbus.Interface(bus.get_object('net.connman', path),
22 'net.connman.Service')
24 properties = service.GetProperties()
26 print "Setting method %s for %s" % (sys.argv[2], sys.argv[1])
28 ipv6_configuration = { "Method": make_variant(sys.argv[2])}
29 if sys.argv[2] == "auto":
30 if (len(sys.argv) > 3):
31 ipv6_configuration["Privacy"] = make_variant(sys.argv[3])
33 if (len(sys.argv) > 3):
34 ipv6_configuration["Address"] = make_variant(sys.argv[3])
35 if (len(sys.argv) > 4):
36 ipv6_configuration["PrefixLength"] = make_byte_variant(sys.argv[4])
37 if (len(sys.argv) > 5):
38 ipv6_configuration["Gateway"] = make_variant(sys.argv[5])
40 service.SetProperty("IPv6.Configuration", ipv6_configuration)
41 print "New IPv6.Configuration: ", ipv6_configuration