+static void
+netifd_init_extdev_handler(const char *config_file, json_object *obj,
+ create_extdev_handler_cb cb)
+{
+ json_object *tmp, *cfg, *info, *stats;
+ const char *name, *ubus_name, *br_prefix = NULL;
+ bool bridge_support = true;
+ char *err_missing;
+
+ if (!json_check_type(obj, json_type_object))
+ return;
+
+ tmp = json_get_field(obj, "name", json_type_string);
+ if (!tmp) {
+ err_missing = "name";
+ goto field_missing;
+ }
+
+ name = json_object_get_string(tmp);
+
+ tmp = json_get_field(obj, "ubus_name", json_type_string);
+ if (!tmp) {
+ err_missing = "ubus_name";
+ goto field_missing;
+ }
+
+ ubus_name = json_object_get_string(tmp);
+
+ tmp = json_get_field(obj, "bridge", json_type_string);
+ if (!tmp || !strcmp(json_object_get_string(tmp), "0"))
+ bridge_support = false;
+
+ if (bridge_support) {
+ tmp = json_get_field(obj, "br-prefix", json_type_string);
+ if (!tmp)
+ br_prefix = name;
+ else
+ br_prefix = json_object_get_string(tmp);
+ }
+
+ tmp = json_get_field(obj, "config", json_type_array);
+ if (!tmp) {
+ err_missing = "config";
+ goto field_missing;
+ }
+
+ cfg = tmp;
+
+ info = json_get_field(obj, "info", json_type_array);
+ stats = json_get_field(obj, "stats", json_type_array);
+
+ cb(config_file, name, ubus_name, bridge_support, br_prefix, cfg, info, stats);
+ return;
+
+field_missing:
+ netifd_log_message(L_WARNING, "external device handler description '%s' is"
+ "missing field '%s'\n", config_file, err_missing);
+}
+