Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended Range Options #81

Open
h0ru5 opened this issue Dec 7, 2016 · 4 comments
Open

Extended Range Options #81

h0ru5 opened this issue Dec 7, 2016 · 4 comments

Comments

@h0ru5
Copy link

h0ru5 commented Dec 7, 2016

The CoAP spec in RFC 7252 defines number ranges for options:

          +-------------+---------------------------------------+
          |       Range | Registration Procedures               |
          +-------------+---------------------------------------+
          |       0-255 | IETF Review or IESG Approval          |
          |    256-2047 | Specification Required                |
          |  2048-64999 | Expert Review                         |
          | 65000-65535 | Experimental use (no operational use) |
          +-------------+---------------------------------------+

           Table 8: CoAP Option Numbers: Registration Procedures

Other CoAP libs (e.g. californium in Java) allow you to retrieve these unkwon options just handling their number and value as bytes. It enables you to also use extended options which is crucial e.g. when mapping between coap and HTTP.

To use this, it would just require some small tweaks in the option handling as currently the delta-encoding is geared just towards a single byte and options that are not in the RFC are ignored.

see also: https://tools.ietf.org/html/rfc7252#section-3.1

@zubairhamed
Copy link
Owner

Thanks for the hint.

I just went through a major refactoring and now i'm fixing all my broken test cases.

I'll need to comb thru the CoAP specs again and start implementing/testing the fine details such as the one you've mentioned here.

zubairhamed added a commit that referenced this issue Dec 14, 2016
Options beyond 256 are now captured and returned as part of the request/response payload
@zubairhamed
Copy link
Owner

zubairhamed commented Dec 14, 2016

@h0ru5 , Would the option identified as critical (Critical = (onum & 1) also apply to options beyond 256?

Unrecognized options of class "critical" that occur in a
Confirmable request MUST cause the return of a 4.02 (Bad Option)
response.  This response SHOULD include a diagnostic payload
describing the unrecognized option(s) (see Section 5.5.2).

@h0ru5
Copy link
Author

h0ru5 commented Dec 21, 2016

The problem is: if the option is recognized or not is actually something that can be answered by the user of your library.

I would recommend to just document it that if there is a critical option with a number >255 where the application does not know how to handle, then the application should return the error, but not do any automated "Bad Option" replies in the library.

@mkovatsc : given your experience in CoAP, maybe you could comment how you would recommend handling critical non-standard Options for a library?

@h0ru5
Copy link
Author

h0ru5 commented Jan 23, 2017

After discussing with some colleagues, the suggestion would be following:

  • to insert a function parallel to BytesToMessage (as Golang does not support optional parameters)
  • that has an additional parameter to accept a callback of type func(*CoapMessage msg, OptionCode code, []byte value) bool that gets called for every received extended Option allows users to handle custom/extended options.
  • The boolean return can indicate whether on not the option was handled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants