0

我正在尝试使用“ubus call uci add_list ..”向 network.lan.ifname 添加一个新接口

用于直接运行它的语法是(正在工作):

uci add_list network.lan.ifname="new_iface_name"

我尝试使用以下 shell 命令通过 ubus 调用将接口添加到列表中:

  1. 选项单独定义
ubus call uci add_list '{"config" : "network", "section" : "lan", "option" : "ifname", "values" : "new_iface_name"}}'

这导致以下错误消息:

Command failed: Method not found
  1. 没有选项(部分,然后是值)
ubus call uci add_list '{"config" : "network", "section" : "lan", "values" : {"ifname"="new_iface_name"}}'

这导致相同的错误消息:

Command failed: Method not found
  1. 即兴创作
ubus call uci add_list '{"config" : "network", "section" : "lan", "valures" : {"ifname"="adam"}}

这导致无法解析消息:

Failed to parse message data

提前感谢任何可以阐明所需正确语法的人

4

1 回答 1

0

You need to make sure that there is "add_list" on the ubus.

ubus -v list uci
'uci' @387e9297
        "configs":{}
        "get":{"config":"String","section":"String","option":"String","type":"String","match":"Table","ubus_rpc_session":"String"}
        "state":{"config":"String","section":"String","option":"String","type":"String","match":"Table","ubus_rpc_session":"String"}
        "add":{"config":"String","type":"String","name":"String","values":"Table","ubus_rpc_session":"String"}
        "set":{"config":"String","section":"String","type":"String","match":"Table","values":"Table","ubus_rpc_session":"String"}
        "delete":{"config":"String","section":"String","type":"String","match":"Table","option":"String","options":"Array","ubus_rpc_session":"String"}
        "rename":{"config":"String","section":"String","option":"String","name":"String","ubus_rpc_session":"String"}
        "order":{"config":"String","sections":"Array","ubus_rpc_session":"String"}
        "changes":{"config":"String","ubus_rpc_session":"String"}
        "revert":{"config":"String","ubus_rpc_session":"String"}
        "commit":{"config":"String","ubus_rpc_session":"String"}
        "apply":{"rollback":"Boolean","timeout":"Integer","ubus_rpc_session":"String"}
        "confirm":{"ubus_rpc_session":"String"}
        "rollback":{"ubus_rpc_session":"String"}
        "reload_config":{}

Here is the code in rpcd.

static const struct ubus_method uci_methods[] = {
        { .name = "configs", .handler = rpc_uci_configs },
        UBUS_METHOD("get",      rpc_uci_get,      rpc_uci_get_policy),
        UBUS_METHOD("state",    rpc_uci_state,    rpc_uci_get_policy),
        UBUS_METHOD("add",      rpc_uci_add,      rpc_uci_add_policy),
        UBUS_METHOD("set",      rpc_uci_set,      rpc_uci_set_policy),
        UBUS_METHOD("delete",   rpc_uci_delete,   rpc_uci_delete_policy),
        UBUS_METHOD("rename",   rpc_uci_rename,   rpc_uci_rename_policy),
        UBUS_METHOD("order",    rpc_uci_order,    rpc_uci_order_policy),
        UBUS_METHOD("changes",  rpc_uci_changes,  rpc_uci_config_policy),
        UBUS_METHOD("revert",   rpc_uci_revert,   rpc_uci_config_policy),
        UBUS_METHOD("commit",   rpc_uci_commit,   rpc_uci_config_policy),
        UBUS_METHOD("apply",    rpc_uci_apply,    rpc_uci_apply_policy),
        UBUS_METHOD("confirm",  rpc_uci_confirm,  rpc_uci_rollback_policy),
        UBUS_METHOD("rollback", rpc_uci_rollback, rpc_uci_rollback_policy),
        UBUS_METHOD_NOARG("reload_config", rpc_uci_reload),
    };
于 2020-09-01T08:44:32.653 回答