You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/01/19 22:50:57 UTC

[1/4] incubator-mynewt-larva git commit: Go json parser does not like stray commas in the end.

Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master 933c75320 -> 4d28af268


Go json parser does not like stray commas in the end.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/5f444432
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/5f444432
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/5f444432

Branch: refs/heads/master
Commit: 5f444432281a6812ff1ecb6fb2cb22627166deb9
Parents: 933c753
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Jan 19 13:48:00 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Jan 19 13:48:00 2016 -0800

----------------------------------------------------------------------
 libs/json/src/json_encode.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/5f444432/libs/json/src/json_encode.c
----------------------------------------------------------------------
diff --git a/libs/json/src/json_encode.c b/libs/json/src/json_encode.c
index d1229ef..ed44402 100644
--- a/libs/json/src/json_encode.c
+++ b/libs/json/src/json_encode.c
@@ -37,6 +37,7 @@ int
 json_encode_object_start(struct json_encoder *encoder)
 {
     JSON_ENCODE_OBJECT_START(encoder);
+    encoder->je_has_objects = 0;
 
     return (0);
 }
@@ -112,7 +113,9 @@ json_encode_value(struct json_encoder *encoder, struct json_value *jv)
                 if (rc != 0) {
                     goto err;
                 }
-                encoder->je_write(encoder->je_arg, ",", sizeof(",")-1);
+                if (i != jv->jv_len - 1) {
+                    encoder->je_write(encoder->je_arg, ",", sizeof(",")-1);
+                }
             }
             JSON_ENCODE_ARRAY_END(encoder);
             break;
@@ -146,6 +149,9 @@ json_encode_object_entry(struct json_encoder *encoder, char *key,
 {
     int rc;
 
+    if (encoder->je_has_objects) {
+        encoder->je_write(encoder->je_arg, ",", sizeof(",")-1);
+    }
     /* Write the key entry */
     encoder->je_write(encoder->je_arg, "\"", sizeof("\"")-1);
     encoder->je_write(encoder->je_arg, key, strlen(key));
@@ -155,7 +161,7 @@ json_encode_object_entry(struct json_encoder *encoder, char *key,
     if (rc != 0) {
         goto err;
     }
-    encoder->je_write(encoder->je_arg, ",", sizeof(",")-1);
+    encoder->je_has_objects = 1;
 
     return (0);
 err:


[3/4] incubator-mynewt-larva git commit: Go json parser does not like stray commas in the end.

Posted by ma...@apache.org.
Go json parser does not like stray commas in the end.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/90030f84
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/90030f84
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/90030f84

Branch: refs/heads/master
Commit: 90030f84b568e8bc88c824e6892a8ad8e15934e6
Parents: bd10285
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Jan 19 13:50:19 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Jan 19 13:50:19 2016 -0800

----------------------------------------------------------------------
 libs/json/include/json/json.h | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/90030f84/libs/json/include/json/json.h
----------------------------------------------------------------------
diff --git a/libs/json/include/json/json.h b/libs/json/include/json/json.h
index 1d41100..4eee6d3 100644
--- a/libs/json/include/json/json.h
+++ b/libs/json/include/json/json.h
@@ -91,6 +91,7 @@ typedef int (*json_write_func_t)(void *buf, char *data,
 struct json_encoder {
     json_write_func_t je_write;
     void *je_arg;
+    int je_has_objects:1;
     char je_encode_buf[64];
 };
 


[2/4] incubator-mynewt-larva git commit: Use updated json library API.

Posted by ma...@apache.org.
Use updated json library API.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/bd10285d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/bd10285d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/bd10285d

Branch: refs/heads/master
Commit: bd10285d4f3b2fcc74189f1280a61e9ad575648f
Parents: 5f44443
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Jan 19 13:49:46 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Jan 19 13:49:46 2016 -0800

----------------------------------------------------------------------
 libs/imgmgr/include/imgmgr/imgmgr.h |  10 +++
 libs/imgmgr/src/imgmgr.c            | 138 +++++++++----------------------
 libs/imgmgr/src/imgmgr_fs.c         |  59 ++++++-------
 libs/imgmgr/src/imgmgr_priv.h       |   2 -
 libs/imgmgr/src/imgmgr_util.c       |  87 +++++++++++++++++++
 5 files changed, 161 insertions(+), 135 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/bd10285d/libs/imgmgr/include/imgmgr/imgmgr.h
----------------------------------------------------------------------
diff --git a/libs/imgmgr/include/imgmgr/imgmgr.h b/libs/imgmgr/include/imgmgr/imgmgr.h
index 7fa580f..78f4c5e 100644
--- a/libs/imgmgr/include/imgmgr/imgmgr.h
+++ b/libs/imgmgr/include/imgmgr/imgmgr.h
@@ -22,10 +22,20 @@
 #define IMGMGR_NMGR_OP_BOOT	2
 
 #define IMGMGR_NMGR_MAX_MSG	120
+#define IMGMGR_NMGR_MAX_VER	25	/* 255.255.65535.4294967295\0 */
 
 int imgmgr_module_init(void);
 
 struct image_version;
+
+/*
+ * Parse version string in src, and fill in ver.
+ */
 int imgr_ver_parse(char *src, struct image_version *ver);
 
+/*
+ * Take version and convert it to string in dst.
+ */
+int imgr_ver_str(struct image_version *ver, char *dst);
+
 #endif /* _IMGMGR_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/bd10285d/libs/imgmgr/src/imgmgr.c
----------------------------------------------------------------------
diff --git a/libs/imgmgr/src/imgmgr.c b/libs/imgmgr/src/imgmgr.c
index 1a77382..4df9389 100644
--- a/libs/imgmgr/src/imgmgr.c
+++ b/libs/imgmgr/src/imgmgr.c
@@ -19,7 +19,6 @@
 #include <limits.h>
 #include <assert.h>
 #include <string.h>
-#include <stdio.h>
 #include <hal/flash_map.h>
 #include <newtmgr/newtmgr.h>
 #include <json/json.h>
@@ -52,8 +51,6 @@ static const struct nmgr_handler imgr_nmgr_handlers[] = {
         .nh_read = imgr_boot_read,
         .nh_write = imgr_boot_write
     }
-#else
-    goob
 #endif
 };
 
@@ -103,102 +100,43 @@ imgr_read_ver(int area_id, struct image_version *ver)
     return rc;
 }
 
-int
-imgr_ver_parse(char *src, struct image_version *ver)
-{
-    unsigned long ul;
-    char *tok;
-    char *nxt;
-    char *ep;
-
-    memset(ver, 0, sizeof(*ver));
-
-    nxt = src;
-    tok = strsep(&nxt, ".");
-    ul = strtoul(tok, &ep, 10);
-    if (tok[0] == '\0' || ep[0] != '\0' || ul > UINT8_MAX) {
-        return -1;
-    }
-    ver->iv_major = ul;
-    if (nxt == NULL) {
-        return 0;
-    }
-    tok = strsep(&nxt, ".");
-    ul = strtoul(tok, &ep, 10);
-    if (tok[0] == '\0' || ep[0] != '\0' || ul > UINT8_MAX) {
-        return -1;
-    }
-    ver->iv_minor = ul;
-    if (nxt == NULL) {
-        return 0;
-    }
-
-    tok = strsep(&nxt, ".");
-    ul = strtoul(tok, &ep, 10);
-    if (tok[0] == '\0' || ep[0] != '\0' || ul > UINT16_MAX) {
-        return -1;
-    }
-    ver->iv_revision = ul;
-    if (nxt == NULL) {
-        return 0;
-    }
-
-    tok = nxt;
-    ul = strtoul(tok, &ep, 10);
-    if (tok[0] == '\0' || ep[0] != '\0' || ul > UINT32_MAX) {
-        return -1;
-    }
-    ver->iv_build_num = ul;
-
-    return 0;
-}
-
-int
-imgr_ver_jsonstr(char *dst, int dstlen, char *key, struct image_version *ver)
-{
-    int off = 0;
-
-    if (key) {
-        off = snprintf(dst, dstlen, "\"%s\":", key);
-    }
-    if (ver->iv_build_num) {
-        off += snprintf(dst + off, dstlen - off, "\"%u.%u.%u.%lu\"",
-          ver->iv_major, ver->iv_minor, ver->iv_revision,
-          (unsigned long)ver->iv_build_num);
-    } else {
-        off += snprintf(dst + off, dstlen - off, "\"%u.%u.%u\"",
-          ver->iv_major, ver->iv_minor, ver->iv_revision);
-    }
-    return off;
-}
-
 static int
 imgr_list(struct nmgr_hdr *nmr, struct os_mbuf *req, uint16_t srcoff,
   struct nmgr_hdr *rsp_hdr, struct os_mbuf *rsp)
 {
     struct image_version ver;
-    char str[128];
-    int off;
-    int rc;
     int i;
-    int put_comma = 0;
+    int rc;
+    struct json_encoder *enc;
+    struct json_value array;
+    struct json_value versions[4];
+    struct json_value *version_ptrs[4];
+    char vers_str[4][IMGMGR_NMGR_MAX_VER];
+    int ver_len;
+    int cnt = 0;
 
-    off = snprintf(str, sizeof(str), "{\"images\":[");
     for (i = FLASH_AREA_IMAGE_0; i <= FLASH_AREA_IMAGE_1; i++) {
         rc = imgr_read_ver(i, &ver);
         if (rc < 0) {
             continue;
         }
-        if (put_comma) {
-            off += snprintf(str + off, sizeof(str) - off, ",");
-        }
-        put_comma = 1;
-        off += imgr_ver_jsonstr(str + off, sizeof(str) - off, NULL, &ver);
+        ver_len = imgr_ver_str(&ver, vers_str[cnt]);
+        JSON_VALUE_STRINGN(&versions[cnt], vers_str[cnt], ver_len);
+        version_ptrs[cnt] = &versions[cnt];
+        cnt++;
     }
-    off += snprintf(str + off, sizeof(str) - off, "]}");
+    array.jv_type = JSON_VALUE_TYPE_ARRAY;
+    array.jv_len = cnt;
+    array.jv_val.composite.values = version_ptrs;
 
-    rc = nmgr_rsp_extend(rsp_hdr, rsp, str, off);
-    return rc;
+    enc = &nmgr_task_jbuf.njb_enc;
+    nmgr_jbuf_setobuf(&nmgr_task_jbuf, rsp_hdr, rsp);
+
+    json_encode_object_start(enc);
+    json_encode_object_entry(enc, "images", &array);
+    json_encode_object_finish(enc);
+
+    return 0;
 }
 
 static int
@@ -213,7 +151,6 @@ imgr_upload(struct nmgr_hdr *nmr, struct os_mbuf *req, uint16_t srcoff,
   struct nmgr_hdr *rsp_hdr, struct os_mbuf *rsp)
 {
     char img_data[BASE64_ENCODE_SIZE(IMGMGR_NMGR_MAX_MSG)];
-    char json_data[32 + sizeof(img_data)];
     unsigned int off = UINT_MAX;
     const struct json_attr_t off_attr[3] = {
         [0] = {
@@ -230,20 +167,18 @@ imgr_upload(struct nmgr_hdr *nmr, struct os_mbuf *req, uint16_t srcoff,
         }
     };
     struct image_version ver;
+    struct json_encoder *enc;
+    struct json_value jv;
     int active;
     int best;
     int rc;
     int len;
     int i;
 
-    len = min(nmr->nh_len, sizeof(json_data));
-
-    rc = os_mbuf_copydata(req, srcoff + sizeof(*nmr), len, json_data);
-    if (rc) {
-        return OS_EINVAL;
-    }
+    nmgr_jbuf_setibuf(&nmgr_task_jbuf, req, srcoff + sizeof(*nmr),
+      nmr->nh_len);
 
-    rc = json_read_object(json_data, off_attr, NULL);
+    rc = json_read_object(&nmgr_task_jbuf.njb_buf, off_attr);
     if (rc || off == UINT_MAX) {
         return OS_EINVAL;
     }
@@ -326,13 +261,16 @@ imgr_upload(struct nmgr_hdr *nmr, struct os_mbuf *req, uint16_t srcoff,
         img_state.upload.off += len;
     }
 out:
-    off = snprintf(json_data, sizeof(json_data),
-      "{\"off\":%u}", img_state.upload.off);
-    rc = nmgr_rsp_extend(rsp_hdr, rsp, json_data, off);
-    if (rc != 0) {
-        return OS_ENOMEM;
-    }
-    return rc;
+    enc = &nmgr_task_jbuf.njb_enc;
+    nmgr_jbuf_setobuf(&nmgr_task_jbuf, rsp_hdr, rsp);
+
+    json_encode_object_start(enc);
+
+    JSON_VALUE_UINT(&jv, img_state.upload.off);
+    json_encode_object_entry(enc, "off", &jv);
+    json_encode_object_finish(enc);
+
+    return 0;
 }
 
 int

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/bd10285d/libs/imgmgr/src/imgmgr_fs.c
----------------------------------------------------------------------
diff --git a/libs/imgmgr/src/imgmgr_fs.c b/libs/imgmgr/src/imgmgr_fs.c
index a1794cf..ddcbc09 100644
--- a/libs/imgmgr/src/imgmgr_fs.c
+++ b/libs/imgmgr/src/imgmgr_fs.c
@@ -67,57 +67,56 @@ imgr_write_file(const char *path, struct image_version *ver)
     return fsutil_write_file(path, ver, sizeof(*ver));
 }
 
+static void
+imgr_ver_jsonstr(struct json_encoder *enc, char *key,
+  struct image_version *ver)
+{
+    struct json_value jv;
+    char ver_str[IMGMGR_NMGR_MAX_VER];
+    int ver_len;
+
+    ver_len = imgr_ver_str(ver, ver_str);
+    JSON_VALUE_STRINGN(&jv, ver_str, ver_len);
+    json_encode_object_entry(enc, key, &jv);
+}
+
 int
 imgr_boot_read(struct nmgr_hdr *nmr, struct os_mbuf *req,
   uint16_t srcoff, struct nmgr_hdr *rsp_hdr, struct os_mbuf *rsp)
 {
     int rc;
-    int prev_set = 0;
+    struct json_encoder *enc;
     struct image_version ver;
-    char str[128];
-    int off;
 
-    off = snprintf(str, sizeof(str), "{");
+    enc = &nmgr_task_jbuf.njb_enc;
+    nmgr_jbuf_setobuf(&nmgr_task_jbuf, rsp_hdr, rsp);
+
+    json_encode_object_start(enc);
+
     rc = imgr_read_test(&ver);
     if (!rc) {
-        off += imgr_ver_jsonstr(str + off, sizeof(str) - off, "test", &ver);
-        prev_set = 1;
+        imgr_ver_jsonstr(enc, "test", &ver);
     }
 
     rc = imgr_read_main(&ver);
     if (!rc) {
-        if (prev_set) {
-            off += snprintf(str + off, sizeof(str) - off, ",");
-        }
-        off += imgr_ver_jsonstr(str + off, sizeof(str) - off, "main", &ver);
-        prev_set = 1;
+        imgr_ver_jsonstr(enc, "main", &ver);
     }
 
     rc = imgr_read_ver(bsp_imgr_current_slot(), &ver);
     if (!rc) {
-        if (prev_set) {
-            off += snprintf(str + off, sizeof(str) - off, ",");
-        }
-        off += imgr_ver_jsonstr(str + off, sizeof(str) - off, "active", &ver);
+        imgr_ver_jsonstr(enc, "active", &ver);
     }
 
-    off += snprintf(str + off, sizeof(str) - off, "}");
-
-    rc = nmgr_rsp_extend(rsp_hdr, rsp, str, off);
-    if (rc) {
-        goto err;
-    }
+    json_encode_object_finish(enc);
 
     return 0;
-err:
-    return rc;
 }
 
 int
 imgr_boot_write(struct nmgr_hdr *nmr, struct os_mbuf *req,
   uint16_t srcoff, struct nmgr_hdr *rsp_hdr, struct os_mbuf *rsp)
 {
-    char incoming[64];
     char test_ver_str[28];
     const struct json_attr_t boot_write_attr[2] = {
         [0] = {
@@ -131,18 +130,12 @@ imgr_boot_write(struct nmgr_hdr *nmr, struct os_mbuf *req,
         }
     };
     int rc;
-    const char *end;
     struct image_version ver;
 
-    if (nmr->nh_len > sizeof(incoming)) {
-        return OS_EINVAL;
-    }
-    rc = os_mbuf_copydata(req, srcoff + sizeof(*nmr), nmr->nh_len, incoming);
-    if (rc) {
-        return OS_EINVAL;
-    }
+    nmgr_jbuf_setibuf(&nmgr_task_jbuf, req, srcoff + sizeof(*nmr),
+      nmr->nh_len);
 
-    rc = json_read_object(incoming, boot_write_attr, &end);
+    rc = json_read_object(&nmgr_task_jbuf.njb_buf, boot_write_attr);
     if (rc) {
         return OS_EINVAL;
     }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/bd10285d/libs/imgmgr/src/imgmgr_priv.h
----------------------------------------------------------------------
diff --git a/libs/imgmgr/src/imgmgr_priv.h b/libs/imgmgr/src/imgmgr_priv.h
index 7375cd7..aa9950f 100644
--- a/libs/imgmgr/src/imgmgr_priv.h
+++ b/libs/imgmgr/src/imgmgr_priv.h
@@ -67,7 +67,5 @@ int imgr_boot_write(struct nmgr_hdr *nmr, struct os_mbuf *req,
   uint16_t srcoff, struct nmgr_hdr *rsp_hdr, struct os_mbuf *rsp);
 
 int imgr_read_ver(int area_id, struct image_version *ver);
-int imgr_ver_jsonstr(char *dst, int dstlen, char *key,
-  struct image_version *ver);
 
 #endif /* __IMGMGR_PRIV_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/bd10285d/libs/imgmgr/src/imgmgr_util.c
----------------------------------------------------------------------
diff --git a/libs/imgmgr/src/imgmgr_util.c b/libs/imgmgr/src/imgmgr_util.c
new file mode 100644
index 0000000..7a04f57
--- /dev/null
+++ b/libs/imgmgr/src/imgmgr_util.c
@@ -0,0 +1,87 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <bootutil/image.h>
+#include <imgmgr/imgmgr.h>
+
+int
+imgr_ver_parse(char *src, struct image_version *ver)
+{
+    unsigned long ul;
+    char *tok;
+    char *nxt;
+    char *ep;
+
+    memset(ver, 0, sizeof(*ver));
+
+    nxt = src;
+    tok = strsep(&nxt, ".");
+    ul = strtoul(tok, &ep, 10);
+    if (tok[0] == '\0' || ep[0] != '\0' || ul > UINT8_MAX) {
+        return -1;
+    }
+    ver->iv_major = ul;
+    if (nxt == NULL) {
+        return 0;
+    }
+    tok = strsep(&nxt, ".");
+    ul = strtoul(tok, &ep, 10);
+    if (tok[0] == '\0' || ep[0] != '\0' || ul > UINT8_MAX) {
+        return -1;
+    }
+    ver->iv_minor = ul;
+    if (nxt == NULL) {
+        return 0;
+    }
+
+    tok = strsep(&nxt, ".");
+    ul = strtoul(tok, &ep, 10);
+    if (tok[0] == '\0' || ep[0] != '\0' || ul > UINT16_MAX) {
+        return -1;
+    }
+    ver->iv_revision = ul;
+    if (nxt == NULL) {
+        return 0;
+    }
+
+    tok = nxt;
+    ul = strtoul(tok, &ep, 10);
+    if (tok[0] == '\0' || ep[0] != '\0' || ul > UINT32_MAX) {
+        return -1;
+    }
+    ver->iv_build_num = ul;
+
+    return 0;
+}
+
+int
+imgr_ver_str(struct image_version *ver, char *dst)
+{
+    if (ver->iv_build_num) {
+        return sprintf(dst, "%u.%u.%u.%lu",
+          ver->iv_major, ver->iv_minor, ver->iv_revision,
+          (unsigned long)ver->iv_build_num);
+    } else {
+        return sprintf(dst, "%u.%u.%u",
+          ver->iv_major, ver->iv_minor, ver->iv_revision);
+    }
+}
+


[4/4] incubator-mynewt-larva git commit: Export nmgr_task_jbuf for now.

Posted by ma...@apache.org.
Export nmgr_task_jbuf for now.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/4d28af26
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/4d28af26
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/4d28af26

Branch: refs/heads/master
Commit: 4d28af2682656b31d23b8af6b68ce8a4f757d4de
Parents: 90030f8
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Jan 19 13:50:30 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Jan 19 13:50:30 2016 -0800

----------------------------------------------------------------------
 libs/newtmgr/include/newtmgr/newtmgr.h | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/4d28af26/libs/newtmgr/include/newtmgr/newtmgr.h
----------------------------------------------------------------------
diff --git a/libs/newtmgr/include/newtmgr/newtmgr.h b/libs/newtmgr/include/newtmgr/newtmgr.h
index b00a47f..7840b0a 100644
--- a/libs/newtmgr/include/newtmgr/newtmgr.h
+++ b/libs/newtmgr/include/newtmgr/newtmgr.h
@@ -61,6 +61,7 @@ int nmgr_jbuf_setibuf(struct nmgr_jbuf *njb, struct os_mbuf *m, uint16_t off,
         uint16_t len);
 int nmgr_jbuf_setobuf(struct nmgr_jbuf *njb, struct nmgr_hdr *hdr, 
         struct os_mbuf *m);
+extern struct nmgr_jbuf nmgr_task_jbuf;
 
 typedef int (*nmgr_handler_func_t)(struct nmgr_hdr *nmr, struct os_mbuf *req, 
         uint16_t srcoff, struct nmgr_hdr *rsp_hdr, struct os_mbuf *rsp);