diff options
author | Irfan Sheriff <isheriff@google.com> | 2012-05-23 14:21:56 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-05-23 14:21:56 -0700 |
commit | 7f3cf96c06ae2d927ec71f717f1f8a9bac0541f9 (patch) | |
tree | f0573d0a8a1431ca7ccc1ef64468575121bdfeec | |
parent | da9c16b7e0c079c1f5d2340037b8968cde6de7ef (diff) | |
parent | 48d5a1d50750ffa5d14b64841fc7e81dadafd1a4 (diff) | |
download | external_dhcpcd-7f3cf96c06ae2d927ec71f717f1f8a9bac0541f9.zip external_dhcpcd-7f3cf96c06ae2d927ec71f717f1f8a9bac0541f9.tar.gz external_dhcpcd-7f3cf96c06ae2d927ec71f717f1f8a9bac0541f9.tar.bz2 |
am 48d5a1d5: Reuse system properties for p2p
* commit '48d5a1d50750ffa5d14b64841fc7e81dadafd1a4':
Reuse system properties for p2p
-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); |