From a3f8fdaa59c36d97ac4086c600bd7df6139d2294 Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Wed, 4 Jul 2012 15:58:21 +0200 Subject: [PATCH] split proxy uri to multiple options when exceeding 270 bytes --- examples/client.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/examples/client.c b/examples/client.c index 06d25577..796a66f2 100644 --- a/examples/client.c +++ b/examples/client.c @@ -634,12 +634,20 @@ cmdline_uri(char *arg) { int res; if (proxy.length) { /* create Proxy-Uri from argument */ + size_t len = strlen(arg); + while (len > 270) { + coap_insert(&optlist, + new_option_node(COAP_OPTION_PROXY_URI, + 270, (unsigned char *)arg), + order_opts); + len -= 270; + arg += 270; + } - coap_insert( &optlist, - new_option_node(COAP_OPTION_PROXY_URI, - strlen(arg), (unsigned char *)arg), - order_opts); - + coap_insert(&optlist, + new_option_node(COAP_OPTION_PROXY_URI, + len, (unsigned char *)arg), + order_opts); } else { /* split arg into Uri-* options */ coap_split_uri((unsigned char *)arg, strlen(arg), &uri );