}
}
- 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) {
.params = vxlan_data_attrs,
};
+static const struct blobmsg_policy gre_data_attrs[__GRE_DATA_ATTR_MAX] = {
+ [GRE_DATA_IKEY] = { .name = "ikey", .type = BLOBMSG_TYPE_INT32 },
+ [GRE_DATA_OKEY] = { .name = "okey", .type = BLOBMSG_TYPE_INT32 },
+ [GRE_DATA_ICSUM] = { .name = "icsum", .type = BLOBMSG_TYPE_BOOL },
+ [GRE_DATA_OCSUM] = { .name = "ocsum", .type = BLOBMSG_TYPE_BOOL },
+ [GRE_DATA_ISEQNO] = { .name = "iseqno", .type = BLOBMSG_TYPE_BOOL },
+ [GRE_DATA_OSEQNO] = { .name = "oseqno", .type = BLOBMSG_TYPE_BOOL },
+};
+
+const struct uci_blob_param_list gre_data_attr_list = {
+ .n_params = __GRE_DATA_ATTR_MAX,
+ .params = gre_data_attrs,
+};
+
void system_fd_set_cloexec(int fd)
{
#ifdef FD_CLOEXEC