diff options
author | Irfan Sheriff <isheriff@google.com> | 2012-05-23 11:51:34 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2012-05-23 11:52:51 -0700 |
commit | 48d5a1d50750ffa5d14b64841fc7e81dadafd1a4 (patch) | |
tree | 3d6ff613f9352a8dcc79c6c95a20ada11feb47d5 | |
parent | e4f0d1bd87c052c1b4af410599558de1e8875379 (diff) | |
download | external_dhcpcd-48d5a1d50750ffa5d14b64841fc7e81dadafd1a4.zip external_dhcpcd-48d5a1d50750ffa5d14b64841fc7e81dadafd1a4.tar.gz external_dhcpcd-48d5a1d50750ffa5d14b64841fc7e81dadafd1a4.tar.bz2 |
Reuse system properties for p2p
p2p interfaces keep increasing. Reuse a single "p2p" phrase to track all
p2p specific properties.
Longer term, we will remove the use of system properties for dhcp
Bug: 6522164
Change-Id: Ic9c54dc1904d2e1e8c33bbbc17234ed801f845dc
-rw-r--r-- | dhcpcd-hooks/20-dns.conf | 13 | ||||
-rw-r--r-- | dhcpcd-hooks/95-configured | 27 | ||||
-rw-r--r-- | dhcpcd.c | 18 |
3 files changed, 43 insertions, 15 deletions
diff --git a/dhcpcd-hooks/20-dns.conf b/dhcpcd-hooks/20-dns.conf index a92e91d..6165824 100644 --- a/dhcpcd-hooks/20-dns.conf +++ b/dhcpcd-hooks/20-dns.conf @@ -1,6 +1,13 @@ # Set net.<iface>.dnsN properties that contain the # DNS server addresses given by the DHCP server. +if [[ $interface == p2p* ]] + then + intf=p2p + else + intf=$interface +fi + set_dns_props() { case "${new_domain_name_servers}" in @@ -9,12 +16,12 @@ set_dns_props() count=1 for i in 1 2 3 4; do - setprop dhcp.${interface}.dns${i} "" + setprop dhcp.${intf}.dns${i} "" done count=1 for dnsaddr in ${new_domain_name_servers}; do - setprop dhcp.${interface}.dns${count} ${dnsaddr} + setprop dhcp.${intf}.dns${count} ${dnsaddr} count=$(($count + 1)) done } @@ -22,7 +29,7 @@ set_dns_props() unset_dns_props() { for i in 1 2 3 4; do - setprop dhcp.${interface}.dns${i} "" + setprop dhcp.${intf}.dns${i} "" done } diff --git a/dhcpcd-hooks/95-configured b/dhcpcd-hooks/95-configured index d67236a..7f1b0ab 100644 --- a/dhcpcd-hooks/95-configured +++ b/dhcpcd-hooks/95-configured @@ -3,25 +3,32 @@ # know that setting up the interface is complete. # For debugging: -setprop dhcp.${interface}.reason "${reason}" + +if [[ $interface == p2p* ]] + then + intf=p2p + else + intf=$interface +fi +setprop dhcp.${intf}.reason "${reason}" case "${reason}" in BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) - setprop dhcp.${interface}.ipaddress "${new_ip_address}" - setprop dhcp.${interface}.gateway "${new_routers%% *}" - setprop dhcp.${interface}.mask "${new_subnet_mask}" - setprop dhcp.${interface}.leasetime "${new_dhcp_lease_time}" - setprop dhcp.${interface}.server "${new_dhcp_server_identifier}" - setprop dhcp.${interface}.vendorInfo "${new_vendor_encapsulated_options}" + setprop dhcp.${intf}.ipaddress "${new_ip_address}" + setprop dhcp.${intf}.gateway "${new_routers%% *}" + setprop dhcp.${intf}.mask "${new_subnet_mask}" + setprop dhcp.${intf}.leasetime "${new_dhcp_lease_time}" + setprop dhcp.${intf}.server "${new_dhcp_server_identifier}" + setprop dhcp.${intf}.vendorInfo "${new_vendor_encapsulated_options}" - setprop dhcp.${interface}.result "ok" + setprop dhcp.${intf}.result "ok" ;; EXPIRE|FAIL|IPV4LL|STOP) - setprop dhcp.${interface}.result "failed" + setprop dhcp.${intf}.result "failed" ;; RELEASE) - setprop dhcp.${interface}.result "released" + setprop dhcp.${intf}.result "released" ;; esac @@ -1751,6 +1751,8 @@ main(int argc, char **argv) struct timespec ts; #ifdef ANDROID + /* Reuse system properties for a p2p interface */ + char p2p_interface[PROPERTY_KEY_MAX]; switchUser(); #endif closefrom(3); @@ -1915,9 +1917,15 @@ main(int argc, char **argv) exit(EXIT_FAILURE); } + if (strncmp(argv[optind], "p2p", 3) == 0) { + strncpy(p2p_interface, "p2p", sizeof(p2p_interface)); + } else { + strncpy(p2p_interface, argv[optind], sizeof(p2p_interface)); + } + if (snprintf(pidpropname, sizeof(pidpropname), - "dhcp.%s.pid", argv[optind]) >= PROPERTY_KEY_MAX) + "dhcp.%s.pid", p2p_interface) >= PROPERTY_KEY_MAX) exit(EXIT_FAILURE); property_get(pidpropname, pidpropval, NULL); if (strlen(pidpropval) == 0) @@ -2000,9 +2008,15 @@ main(int argc, char **argv) exit(EXIT_FAILURE); } + if (strncmp(argv[optind], "p2p", 3) == 0) { + strncpy(p2p_interface, "p2p", sizeof(p2p_interface)); + } else { + strncpy(p2p_interface, argv[optind], sizeof(p2p_interface)); + } + if (snprintf(pidpropname, sizeof(pidpropname), - "dhcp.%s.pid", argv[optind]) >= PROPERTY_KEY_MAX) + "dhcp.%s.pid", p2p_interface) >= PROPERTY_KEY_MAX) exit(EXIT_FAILURE); if (snprintf(pidpropval, sizeof(pidpropval), "%d", getpid()) >= PROPERTY_VALUE_MAX) exit(EXIT_FAILURE); |