ipconfig: Save IPv6 privacy setting
[platform/upstream/connman.git] / test / set-ipv6-method
1 #!/usr/bin/python
2
3 import sys
4 import dbus
5
6 def print_usage():
7         print "Usage: %s <service> off|manual|auto [<address> [prefixlen] [gateway]] [<privacy>]" % (sys.argv[0])
8
9 if (len(sys.argv) < 3):
10         print_usage()
11         sys.exit(1)
12
13 bus = dbus.SystemBus()
14 path = "/profile/default/" + sys.argv[1]
15 service = dbus.Interface(bus.get_object('net.connman', path),
16                                         'net.connman.Service')
17
18 properties = service.GetProperties()
19
20 print "Setting method %s for %s" % (sys.argv[2], sys.argv[1])
21
22 ipv6_configuration = { "Method": sys.argv[2] }
23 if sys.argv[2] == "auto":
24         if (len(sys.argv) > 3):
25                 ipv6_configuration["Privacy"] = sys.argv[3]
26 else:
27         if (len(sys.argv) > 3):
28                 ipv6_configuration["Address"] = sys.argv[3]
29         if (len(sys.argv) > 4):
30                 ipv6_configuration["PrefixLength"] = sys.argv[4]
31         if (len(sys.argv) > 5):
32                 ipv6_configuration["Gateway"] = sys.argv[5]
33
34 service.SetProperty("IPv6.Configuration", ipv6_configuration)
35 print "New IPv6.Configuration: ", ipv6_configuration
36
37 print