Skip to content

Vendor TLV is inconsistent with format specified in draft RFC #32

@mikewadsten

Description

@mikewadsten

I have been trying to implement a CSMP server. Naturally, the first step in doing so is code that can parse TLVs from the CoAP payload. Everything is working okay there, except when the sample application creates Vendor Defined TLVs.

Per the draft spec, the Vendor Defined TLV:

  • follows the same format as a Standard TLV (that is, it consists of Type | Length | Value)
  • Type is 127
  • Value contains one or more SubTLVs of the format SubType | Length | Value
  • SubType 1 is reserved to indicate Vendor Private Enterprise Number

Therefore, I would expect a Vendor Defined TLV to look like:

7F        # Type: 127
__        # Length (of all following content)
01        # SubType 1
__        # Length of encoded Vendor PEN
____      # Vendor PEN
...       # Other SubTLVs

However, src/csmptlv/csmptlv.c does not follow that format. Instead, it writes the Vendor Defined TLV as Type | Vendor PEN | SubType | Length | Value.

if (tlvid.vendor != 0) {
rv = ProtobufVarint_encodeUINT32(p_cur,len - used,CSMP_TYPE_VENDOR);
p_cur += rv; used += rv;
if ((rv == 0) || (used > len)) {
DPRINTF("csmptlv_write error: (rv == 0) || (used=%d > len=%ld)\n", used, len);
return 0;
}
rv = ProtobufVarint_encodeUINT32(p_cur,len - used,tlvid.vendor);
p_cur += rv; used += rv;
if ((rv == 0) || (used > len)) {
DPRINTF("csmptlv_write error: (rv == 0) || (used=%d > len=%ld)\n", used, len);
return 0;
}
}

7F        # Type: 127
____      # Vendor PEN
...       # One SubTLV (SubType | Length | Value)

This inconsistency breaks the assumption that the CoAP payload is merely the concatenation of Type | Length | Value TLVs.

Is csmp-agent-lib out of compliance with the open specification? Or does the open specification not reflect how the Vendor Defined TLV actually looks?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions