+static inline uint64_t blobmsg_cast_u64(struct blob_attr *attr)
+{
+ uint64_t tmp = 0;
+
+ if (blobmsg_type(attr) == BLOBMSG_TYPE_INT64)
+ tmp = blobmsg_get_u64(attr);
+ else if (blobmsg_type(attr) == BLOBMSG_TYPE_INT32)
+ tmp = blobmsg_get_u32(attr);
+ else if (blobmsg_type(attr) == BLOBMSG_TYPE_INT16)
+ tmp = blobmsg_get_u16(attr);
+ else if (blobmsg_type(attr) == BLOBMSG_TYPE_INT8)
+ tmp = blobmsg_get_u8(attr);
+
+ return tmp;
+}
+
+static inline int64_t blobmsg_cast_s64(struct blob_attr *attr)
+{
+ int64_t tmp = 0;
+
+ if (blobmsg_type(attr) == BLOBMSG_TYPE_INT64)
+ tmp = blobmsg_get_u64(attr);
+ else if (blobmsg_type(attr) == BLOBMSG_TYPE_INT32)
+ tmp = (int32_t)blobmsg_get_u32(attr);
+ else if (blobmsg_type(attr) == BLOBMSG_TYPE_INT16)
+ tmp = (int16_t)blobmsg_get_u16(attr);
+ else if (blobmsg_type(attr) == BLOBMSG_TYPE_INT8)
+ tmp = (int8_t)blobmsg_get_u8(attr);
+
+ return tmp;
+}
+
+static inline double blobmsg_get_double(struct blob_attr *attr)
+{
+ union {
+ double d;
+ uint64_t u64;
+ } v;
+ v.u64 = blobmsg_get_u64(attr);
+ return v.d;
+}
+