diff options
author | Jan Huwald <jh@sotun.de> | 2012-03-30 11:35:31 (GMT) |
---|---|---|
committer | Jan Huwald <jh@sotun.de> | 2012-03-30 11:35:31 (GMT) |
commit | 0f638b572f70ef6461fdc6fb2e8865c0454d6867 (patch) | |
tree | 07f375b922f8f41b3c2a42836a1ee49abbb65472 | |
parent | fa535dfab3d554c12e41678cd4600719ab57fa8e (diff) |
webif: add client network reflection api
-rwxr-xr-x | files/common/www/service/cgi-bin/client_net.json | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/files/common/www/service/cgi-bin/client_net.json b/files/common/www/service/cgi-bin/client_net.json new file mode 100755 index 0000000..21c5767 --- /dev/null +++ b/files/common/www/service/cgi-bin/client_net.json @@ -0,0 +1,19 @@ +#!/bin/sh -e + +[ -n "$REMOTE_HOST" ] +{ + grep ^$REMOTE_HOST </proc/net/arp \ + | awk 'BEGIN { FS = " " } ; { print $4, $6 }' +} | { + read client_mac iface + if [ "$iface" == br-lan ]; then wired=true; else wired=false; fi + router_name="$(uci get 'system.@system[0].hostname')" + echo -e "Status: 200 OK\r +Content-Type: application/json\r +\r +{\"client_mac\": \"$client_mac\", + \"router_name\": \"$router_name\", + \"iface\": \"$iface\", + \"wired\": $wired +}" +} |