blobmsg: introduce BLOBMSG_CAST_INT64
[project/libubox.git] / blobmsg.c
index 7da41838029984bd94b367ceb320b016aaa9fd9c..93172abb8c63289884cc6cd09e010fb47600dd1f 100644 (file)
--- a/blobmsg.c
+++ b/blobmsg.c
@@ -195,9 +195,17 @@ int blobmsg_parse(const struct blobmsg_policy *policy, int policy_len,
                                continue;
 
                        if (policy[i].type != BLOBMSG_TYPE_UNSPEC &&
+                           policy[i].type != BLOBMSG_CAST_INT64 &&
                            blob_id(attr) != policy[i].type)
                                continue;
 
+                       if (policy[i].type == BLOBMSG_CAST_INT64 &&
+                           (blob_id(attr) != BLOBMSG_TYPE_INT64 &&
+                            blob_id(attr) != BLOBMSG_TYPE_INT32 &&
+                            blob_id(attr) != BLOBMSG_TYPE_INT16 &&
+                            blob_id(attr) != BLOBMSG_TYPE_INT8))
+                               continue;
+
                        if (blobmsg_namelen(hdr) != pslen[i])
                                continue;