luci2: add 'eap_support' ubus method
authorJo-Philipp Wich <jow@openwrt.org>
Fri, 13 Feb 2015 23:51:54 +0000 (00:51 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Fri, 13 Feb 2015 23:54:34 +0000 (00:54 +0100)
This method is used to query whether hostapd and wpa_supplicent support
802.1x authnetication.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
luci2/src/rpcd/luci2.c

index 179a055cae069254a3f612e755f20db47c4f1f20..c8ef9bf370d22be3b65ddd406cf5fed6d8a75ef3 100644 (file)
@@ -2283,6 +2283,18 @@ rpc_luci2_network_dev_list(struct ubus_context *ctx, struct ubus_object *obj,
        return 0;
 }
 
+static int
+rpc_luci2_network_eap_support(struct ubus_context *ctx, struct ubus_object *obj,
+                              struct ubus_request_data *req, const char *method,
+                              struct blob_attr *msg)
+{
+       blob_buf_init(&buf, 0);
+       blobmsg_add_u8(&buf, "master", !system("/usr/sbin/hostapd -veap"));
+       blobmsg_add_u8(&buf, "client", !system("/usr/sbin/wpa_supplicant -veap"));
+       ubus_send_reply(ctx, req, buf.head);
+       return 0;
+}
+
 
 struct opkg_state {
        int cur_offset;
@@ -2814,7 +2826,8 @@ rpc_luci2_api_init(const struct rpc_daemon_ops *o, struct ubus_context *ctx)
                                                     rpc_data_policy),
                UBUS_METHOD("ifdown",                rpc_luci2_network_ifdown,
                                                     rpc_data_policy),
-               UBUS_METHOD_NOARG("device_list",     rpc_luci2_network_dev_list)
+               UBUS_METHOD_NOARG("device_list",     rpc_luci2_network_dev_list),
+               UBUS_METHOD_NOARG("eap_support",     rpc_luci2_network_eap_support)
        };
 
        static struct ubus_object_type luci2_network_type =