summaryrefslogtreecommitdiffhomepage
path: root/system-linux.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2017-03-14 21:36:38 +0100
committerHans Dedecker <dedeckeh@gmail.com>2017-03-21 22:39:14 +0100
commit7e3b89a4d4c0b55a9b2376b88cbe72a1edc5cd82 (patch)
tree2de7c40b6c3ce35aef4bf2297094ea9f63a0e000 /system-linux.c
parent91810ecc13239f3b18c8299de265b4f3531c0017 (diff)
system-linux: parse gre specific settings as nested json data object
Parse gre specific settings ikey, okey, icsum, ocsum, iseqno and oseqno as nested json data object Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/system-linux.c b/system-linux.c
index 8888047..b7297fd 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -2316,31 +2316,41 @@ static int system_add_gre_tunnel(const char *name, const char *kind,
}
}
- if ((cur = tb[TUNNEL_ATTR_INFO]) && (blobmsg_type(cur) == BLOBMSG_TYPE_STRING)) {
- uint8_t icsum, ocsum, iseqno, oseqno;
- if (sscanf(blobmsg_get_string(cur), "%u,%u,%hhu,%hhu,%hhu,%hhu",
- &ikey, &okey, &icsum, &ocsum, &iseqno, &oseqno) < 6) {
- ret = -EINVAL;
- goto failure;
- }
+ if ((cur = tb[TUNNEL_ATTR_DATA])) {
+ struct blob_attr *tb_data[__GRE_DATA_ATTR_MAX];
+
+ blobmsg_parse(gre_data_attr_list.params, __GRE_DATA_ATTR_MAX, tb_data,
+ blobmsg_data(cur), blobmsg_len(cur));
- if (ikey)
- iflags |= GRE_KEY;
+ if ((cur = tb_data[GRE_DATA_IKEY])) {
+ if ((ikey = blobmsg_get_u32(cur)))
+ iflags |= GRE_KEY;
+ }
- if (okey)
- oflags |= GRE_KEY;
+ if ((cur = tb_data[GRE_DATA_OKEY])) {
+ if ((okey = blobmsg_get_u32(cur)))
+ oflags |= GRE_KEY;
+ }
- if (icsum)
- iflags |= GRE_CSUM;
+ if ((cur = tb_data[GRE_DATA_ICSUM])) {
+ if (blobmsg_get_bool(cur))
+ iflags |= GRE_CSUM;
+ }
- if (ocsum)
- oflags |= GRE_CSUM;
+ if ((cur = tb_data[GRE_DATA_OCSUM])) {
+ if (blobmsg_get_bool(cur))
+ oflags |= GRE_CSUM;
+ }
- if (iseqno)
- iflags |= GRE_SEQ;
+ if ((cur = tb_data[GRE_DATA_ISEQNO])) {
+ if (blobmsg_get_bool(cur))
+ iflags |= GRE_SEQ;
+ }
- if (oseqno)
- oflags |= GRE_SEQ;
+ if ((cur = tb[GRE_DATA_OSEQNO])) {
+ if (blobmsg_get_bool(cur))
+ oflags |= GRE_SEQ;
+ }
}
if (v6) {