X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=ubus.c;h=ebf9891d0d95e57304a60e6ba1375e7dc611b774;hp=0123b17e62a5bad6cc69f0e5f9a999355a0d6dd4;hb=ead9789e75824854c2ffab0c68bc0dd4269afc81;hpb=650758b16e5185505a3fbc1307949340af70b611 diff --git a/ubus.c b/ubus.c index 0123b17..ebf9891 100644 --- a/ubus.c +++ b/ubus.c @@ -44,8 +44,10 @@ netifd_handle_reload(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) { - netifd_reload(); - return 0; + if (netifd_reload()) + return UBUS_STATUS_NOT_FOUND; + + return UBUS_STATUS_OK; } enum { @@ -127,7 +129,6 @@ netifd_add_dynamic(struct ubus_context *ctx, struct ubus_object *obj, struct blob_attr *tb[__DI_MAX]; struct interface *iface; struct blob_attr *config; - struct device *dev; blobmsg_parse(dynamic_policy, __DI_MAX, tb, blob_data(msg), blob_len(msg)); @@ -155,10 +156,6 @@ netifd_add_dynamic(struct ubus_context *ctx, struct ubus_object *obj, // Set interface as dynamic interface_set_dynamic(iface); - dev = iface->main_dev.dev; - if (!dev || !dev->default_config) - return UBUS_STATUS_UNKNOWN_ERROR; - return UBUS_STATUS_OK; error: @@ -376,6 +373,19 @@ netifd_handle_down(struct ubus_context *ctx, struct ubus_object *obj, return 0; } +static int +netifd_handle_renew(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + struct interface *iface; + + iface = container_of(obj, struct interface, ubus); + interface_renew(iface); + + return 0; +} + static void netifd_add_interface_errors(struct blob_buf *b, struct interface *iface) { @@ -402,8 +412,7 @@ netifd_add_interface_errors(struct blob_buf *b, struct interface *iface) } static void -interface_ip_dump_address_list(struct interface_ip_settings *ip, bool v6, - bool enabled) +interface_ip_dump_address_list(struct interface_ip_settings *ip, bool v6, bool enabled) { struct device_addr *addr; char *buf; @@ -619,8 +628,7 @@ interface_ip_dump_prefix_assignment_list(struct interface *iface) } static void -interface_ip_dump_dns_server_list(struct interface_ip_settings *ip, - bool enabled) +interface_ip_dump_dns_server_list(struct interface_ip_settings *ip, bool enabled) { struct dns_server *dns; int buflen = 128; @@ -637,8 +645,7 @@ interface_ip_dump_dns_server_list(struct interface_ip_settings *ip, } static void -interface_ip_dump_dns_search_list(struct interface_ip_settings *ip, - bool enabled) +interface_ip_dump_dns_search_list(struct interface_ip_settings *ip, bool enabled) { struct dns_search_domain *dns; @@ -701,6 +708,8 @@ netifd_dump_status(struct interface *iface) blobmsg_add_u32(&b, "metric", iface->metric); blobmsg_add_u32(&b, "dns_metric", iface->dns_metric); blobmsg_add_u8(&b, "delegation", !iface->proto_ip.no_delegation); + if (iface->assignment_weight) + blobmsg_add_u32(&b, "ip6weight", iface->assignment_weight); a = blobmsg_open_array(&b, "ipv4-address"); interface_ip_dump_address_list(&iface->config_ip, false, true); interface_ip_dump_address_list(&iface->proto_ip, false, true); @@ -913,6 +922,7 @@ netifd_handle_set_data(struct ubus_context *ctx, struct ubus_object *obj, static struct ubus_method iface_object_methods[] = { { .name = "up", .handler = netifd_handle_up }, { .name = "down", .handler = netifd_handle_down }, + { .name = "renew", .handler = netifd_handle_renew }, { .name = "status", .handler = netifd_handle_status }, { .name = "prepare", .handler = netifd_handle_iface_prepare }, { .name = "dump", .handler = netifd_handle_dump },