Fixes the observe option size to the legal max value of 3.
authorStephane Lejeune <stlejeun@cisco.com>
Wed, 2 Sep 2015 11:45:55 +0000 (13:45 +0200)
committerJon A. Cruz <jonc@osg.samsung.com>
Fri, 4 Sep 2015 18:29:23 +0000 (18:29 +0000)
commit07db265dabfa18d18ba87c334aa15f9e25a253c8
tree52bd136fd291647a4be739aaf0284f61a18276a0
parente29b60bbbf330693c75ef2a3ab18b7da3835fd4e
Fixes the observe option size to the legal max value of 3.

The options that have variable byte length are now being
encoded to their minimal value. This patch also truncates the
option data to their maximum value allowed per the spec. One specific
example is the observer data option which receives 4 bytes of data from
the OC stack. When encoding in CoAP, the maximum value is 3 bytes.
Consequently, the CA layer which is aware of the CoAP encoding truncates
the value back to 3 bytes. Also when registering an observe, the data
length is now set to 0 using the CoAP var byte encoding which saves the
4 bytes that were just carying zero's before thsi fix.

Change-Id: I033969b407aa3426df8c85c3836206c9366fb0a2
Signed-off-by: Stephane Lejeune <stlejeun@cisco.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2351
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
resource/csdk/connectivity/inc/caprotocolmessage.h
resource/csdk/connectivity/lib/libcoap-4.1.1/encode.c
resource/csdk/connectivity/lib/libcoap-4.1.1/encode.h
resource/csdk/connectivity/lib/libcoap-4.1.1/option.c
resource/csdk/connectivity/lib/libcoap-4.1.1/option.h
resource/csdk/connectivity/src/caprotocolmessage.c
resource/csdk/stack/src/ocobserve.c
resource/csdk/stack/src/ocserverrequest.c
resource/csdk/stack/src/ocstack.c