SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
SET(UBUS_UNIX_SOCKET "/var/run/ubus.sock")
+SET(UBUS_MAX_MSGLEN 1048576)
ADD_DEFINITIONS( -DUBUS_UNIX_SOCKET="${UBUS_UNIX_SOCKET}")
+ADD_DEFINITIONS( -DUBUS_MAX_MSGLEN=${UBUS_MAX_MSGLEN})
IF(APPLE)
INCLUDE_DIRECTORIES(/opt/local/include)
struct blob_attr data;
} hdrbuf;
struct iovec iov = STATIC_IOV(hdrbuf);
+ int len;
int r;
/* receive header + start attribute */
if (!ubus_validate_hdr(&hdrbuf.hdr))
return false;
+ len = blob_raw_len(&hdrbuf.data);
+ if (len > ctx->msgbuf_data_len) {
+ ctx->msgbuf.data = realloc(ctx->msgbuf.data, len * sizeof(char));
+ if (ctx->msgbuf.data)
+ ctx->msgbuf_data_len = len;
+ }
+ if (!ctx->msgbuf.data)
+ return false;
+
memcpy(&ctx->msgbuf.hdr, &hdrbuf.hdr, sizeof(hdrbuf.hdr));
memcpy(ctx->msgbuf.data, &hdrbuf.data, sizeof(hdrbuf.data));
ctx->connection_lost = ubus_default_connection_lost;
ctx->pending_timer.cb = ubus_process_pending_msg;
- ctx->msgbuf.data = calloc(UBUS_MAX_MSGLEN, sizeof(char));
+ ctx->msgbuf.data = calloc(UBUS_MSG_CHUNK_SIZE, sizeof(char));
if (!ctx->msgbuf.data)
return -1;
+ ctx->msgbuf_data_len = UBUS_MSG_CHUNK_SIZE;
INIT_LIST_HEAD(&ctx->requests);
INIT_LIST_HEAD(&ctx->pending);
void (*connection_lost)(struct ubus_context *ctx);
struct ubus_msghdr_buf msgbuf;
+ uint32_t msgbuf_data_len;
};
struct ubus_object_data {
#define __packetdata __attribute__((packed)) __attribute__((__aligned__(4)))
-#define UBUS_MAX_MSGLEN 65536
+#define UBUS_MSG_CHUNK_SIZE 65536
#define UBUS_SYSTEM_OBJECT_EVENT 1
#define UBUS_SYSTEM_OBJECT_MAX 1024