From 2dc0f134aa7ec68ea7892a0d5e18d2e70b59a40e Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 13 May 2012 22:16:48 +0200 Subject: [PATCH] parse point to point ip addresses --- dummy/netifd-proto.sh | 10 +++++++--- interface-ip.h | 1 + proto.c | 10 ++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/dummy/netifd-proto.sh b/dummy/netifd-proto.sh index 99ad11e..a38f9d9 100755 --- a/dummy/netifd-proto.sh +++ b/dummy/netifd-proto.sh @@ -105,8 +105,9 @@ proto_add_ipv4_address() { local address="$1" local mask="$2" local broadcast="$3" + local ptp="$4" - jshn_append PROTO_IPADDR "$address/$mask/$broadcast" + jshn_append PROTO_IPADDR "$address/$mask/$broadcast/$ptp" } proto_add_ipv6_address() { @@ -134,18 +135,21 @@ proto_add_ipv6_route() { _proto_push_ipv4_addr() { local str="$1" - local address mask broadcast + local address mask broadcast ptp address="${str%%/*}" str="${str#*/}" mask="${str%%/*}" str="${str#*/}" - broadcast="$str" + broadcast="${str%%/*}" + str="${str#*/}" + ptp="$str" json_add_object "" json_add_string ipaddr "$address" [ -n "$mask" ] && json_add_string mask "$mask" [ -n "$broadcast" ] && json_add_string broadcast "$broadcast" + [ -n "$ptp" ] && json_add_string ptp "$ptp" json_close_object } diff --git a/interface-ip.h b/interface-ip.h index cbfcb49..ae5a63e 100644 --- a/interface-ip.h +++ b/interface-ip.h @@ -40,6 +40,7 @@ struct device_addr { /* ipv4 only */ uint32_t broadcast; + uint32_t point_to_point; /* must be last */ enum device_addr_flags flags; diff --git a/proto.c b/proto.c index ed0a008..8266e81 100644 --- a/proto.c +++ b/proto.c @@ -64,6 +64,7 @@ enum { ADDR_IPADDR, ADDR_MASK, ADDR_BROADCAST, + ADDR_PTP, __ADDR_MAX }; @@ -71,6 +72,7 @@ static const struct blobmsg_policy proto_ip_addr[__ADDR_MAX] = { [ADDR_IPADDR] = { .name = "ipaddr", .type = BLOBMSG_TYPE_STRING }, [ADDR_MASK] = { .name = "mask", .type = BLOBMSG_TYPE_STRING }, [ADDR_BROADCAST] = { .name = "broadcast", .type = BLOBMSG_TYPE_STRING }, + [ADDR_PTP] = { .name = "ptp", .type = BLOBMSG_TYPE_STRING }, }; unsigned int @@ -226,8 +228,12 @@ parse_address_item(struct blob_attr *attr, bool v6, bool ext) if (!inet_pton(v6 ? AF_INET6 : AF_INET, blobmsg_data(cur), &addr->addr)) goto error; - if (!v6 && (cur = tb[ADDR_BROADCAST])) { - if (!inet_pton(AF_INET, blobmsg_data(cur), &addr->broadcast)) + if (!v6) { + if ((cur = tb[ADDR_BROADCAST]) && + !inet_pton(AF_INET, blobmsg_data(cur), &addr->broadcast)) + goto error; + if ((cur = tb[ADDR_PTP]) && + !inet_pton(AF_INET, blobmsg_data(cur), &addr->point_to_point)) goto error; } -- 2.25.1