From 5e43781680f9f55e0ae7c1b681465d64882e3b8c Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Wed, 27 Nov 2013 14:52:31 +0100 Subject: [PATCH] IPv6: add class support to regular IPv6 addresses --- interface-ip.c | 1 + interface-ip.h | 1 + proto.c | 5 +++++ scripts/netifd-proto.sh | 6 +++++- ubus.c | 3 +++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/interface-ip.c b/interface-ip.c index 084688c..4edae2e 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -578,6 +578,7 @@ interface_update_proto_addr(struct vlist_tree *tree, system_del_address(dev, a_old); } + free(a_old->pclass); free(a_old); } diff --git a/interface-ip.h b/interface-ip.h index b36c515..2559bcc 100644 --- a/interface-ip.h +++ b/interface-ip.h @@ -85,6 +85,7 @@ struct device_addr { /* ipv6 only */ time_t valid_until; time_t preferred_until; + char *pclass; /* must be last */ enum device_addr_flags flags; diff --git a/proto.c b/proto.c index d5e99bf..9121918 100644 --- a/proto.c +++ b/proto.c @@ -69,6 +69,7 @@ enum { ADDR_PREFERRED, ADDR_VALID, ADDR_OFFLINK, + ADDR_CLASS, __ADDR_MAX }; @@ -80,6 +81,7 @@ static const struct blobmsg_policy proto_ip_addr[__ADDR_MAX] = { [ADDR_PREFERRED] = { .name = "preferred", .type = BLOBMSG_TYPE_INT32 }, [ADDR_VALID] = { .name = "valid", .type = BLOBMSG_TYPE_INT32 }, [ADDR_OFFLINK] = { .name = "offlink", .type = BLOBMSG_TYPE_BOOL }, + [ADDR_CLASS] = { .name = "class", .type = BLOBMSG_TYPE_STRING }, }; static struct device_addr * @@ -208,6 +210,9 @@ parse_address_item(struct blob_attr *attr, bool v6, bool ext) else if (addr->preferred_until > addr->valid_until) goto error; } + + if ((cur = tb[ADDR_CLASS])) + addr->pclass = strdup(blobmsg_get_string(cur)); } return addr; diff --git a/scripts/netifd-proto.sh b/scripts/netifd-proto.sh index 9f062d8..7f08b1d 100644 --- a/scripts/netifd-proto.sh +++ b/scripts/netifd-proto.sh @@ -106,8 +106,9 @@ proto_add_ipv6_address() { local preferred="$3" local valid="$4" local offlink="$5" + local class="$6" - append PROTO_IP6ADDR "$address/$mask/$preferred/$valid/$offlink" + append PROTO_IP6ADDR "$address/$mask/$preferred/$valid/$offlink/$class" } proto_add_ipv4_route() { @@ -175,6 +176,8 @@ _proto_push_ipv6_addr() { valid="${str%%/*}" str="${str#*/}" offlink="${str%%/*}" + str="${str#*/}" + class="${str%%/*}" json_add_object "" json_add_string ipaddr "$address" @@ -182,6 +185,7 @@ _proto_push_ipv6_addr() { [ -n "$preferred" ] && json_add_int preferred "$preferred" [ -n "$valid" ] && json_add_int valid "$valid" [ -n "$offlink" ] && json_add_boolean offlink "$offlink" + [ -n "$class" ] && json_add_string class "$class" json_close_object } diff --git a/ubus.c b/ubus.c index 9063680..340a8e4 100644 --- a/ubus.c +++ b/ubus.c @@ -441,6 +441,9 @@ interface_ip_dump_address_list(struct interface_ip_settings *ip, bool v6, if (addr->valid_until) blobmsg_add_u32(&b, "valid", addr->valid_until - now); + if (addr->pclass) + blobmsg_add_string(&b, "class", addr->pclass); + blobmsg_close_table(&b, a); } } -- 2.25.1