summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-05-13 22:16:48 +0200
committerFelix Fietkau <nbd@openwrt.org>2012-05-14 21:38:20 +0200
commit2dc0f134aa7ec68ea7892a0d5e18d2e70b59a40e (patch)
treef5492e95be582b088e293ad34e675d783b9caaae
parent139b16ed4c7511f076ec4f5735c76954e4d3ea33 (diff)
parse point to point ip addresses
-rwxr-xr-xdummy/netifd-proto.sh10
-rw-r--r--interface-ip.h1
-rw-r--r--proto.c10
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;
}