Blobmsg for binary data?

Hello!

Is there any way to store binary data in blobmsg? Similar to string but allowing arbitrary binary data including zeros? As it's based on blob.h it should be possible, right? Is it already there? Am I missing something obvious?

I want to use UBUS as an interface to my daemon, but I need to be able to send/receive binary data.

Any hints? Thanks!

Well... wasn't too hard to add:

diff --git a/blobmsg.h b/blobmsg.h
index 7c6e9c6..f53f5fb 100644
--- a/blobmsg.h
+++ b/blobmsg.h
@@ -31,6 +31,7 @@ enum blobmsg_type {
        BLOBMSG_TYPE_ARRAY,
        BLOBMSG_TYPE_TABLE,
        BLOBMSG_TYPE_STRING,
+       BLOBMSG_TYPE_BINARY,
        BLOBMSG_TYPE_INT64,
        BLOBMSG_TYPE_INT32,
        BLOBMSG_TYPE_INT16,
@@ -226,6 +227,12 @@ blobmsg_add_string(struct blob_buf *buf, const char *name, const char *string)
        return blobmsg_add_field(buf, BLOBMSG_TYPE_STRING, name, string, strlen(string) + 1);
 }
 
+static inline int
+blobmsg_add_binary(struct blob_buf *buf, const char *name, const unsigned char *data, unsigned int len)
+{
+       return blobmsg_add_field(buf, BLOBMSG_TYPE_BINARY, name, data, len);
+}
+
 static inline int
 blobmsg_add_blob(struct blob_buf *buf, struct blob_attr *attr)
 {
@@ -310,6 +317,15 @@ static inline char *blobmsg_get_string(struct blob_attr *attr)
        return (char *) blobmsg_data(attr);
 }
 
+static inline unsigned char *blobmsg_get_binary(struct blob_attr *attr, unsigned int* len)
+{
+       if (!attr)
+               return NULL;
+
+       *len = blobmsg_data_len(attr);
+       return (unsigned char *) blobmsg_data(attr);
+}
+
 void *blobmsg_alloc_string_buffer(struct blob_buf *buf, const char *name, unsigned int maxlen);
 void *blobmsg_realloc_string_buffer(struct blob_buf *buf, unsigned int maxlen);
 void blobmsg_add_string_buffer(struct blob_buf *buf);