Skip to content

nanocoap: fixed setting of option length#17

Merged
kaspar030 merged 1 commit intokaspar030:masterfrom
haukepetersen:fix_nanocoap_optlen
Sep 6, 2017
Merged

nanocoap: fixed setting of option length#17
kaspar030 merged 1 commit intokaspar030:masterfrom
haukepetersen:fix_nanocoap_optlen

Conversation

@haukepetersen
Copy link
Copy Markdown
Contributor

Options with a length > 12 byte did break the CoAP package. This PR fixes this and adapts the option length notation is described in section 3.1 in the RFC.

@haukepetersen
Copy link
Copy Markdown
Contributor Author

@kaspar030: ping

unsigned delta = (onum - lastonum);
*buf = 0;

unsigned n = _put_opt_len(buf, 1, 4, delta);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is very confusing. _put_opt_len is used for both encoding the option length and the option delta, right?

Renaming the function is probably a good idea. At least there need to be proper comments.

int n = _put_odelta(buf, lastonum, onum, olen);

unsigned delta = (onum - lastonum);
*buf = 0;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why dis this needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the _put_opt_len function does not clear the length field anymore itself.

@haukepetersen
Copy link
Copy Markdown
Contributor Author

better?

@kaspar030
Copy link
Copy Markdown
Owner

better?

yes! please squash.

@haukepetersen
Copy link
Copy Markdown
Contributor Author

rebased and squashed

@haukepetersen
Copy link
Copy Markdown
Contributor Author

@kaspar030: are you ok to merge this now?

@haukepetersen
Copy link
Copy Markdown
Contributor Author

@ping @ping @ping

@kaspar030 kaspar030 merged commit de104ff into kaspar030:master Sep 6, 2017
@haukepetersen haukepetersen deleted the fix_nanocoap_optlen branch September 6, 2017 11:46
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

Successfully merging this pull request may close these issues.

2 participants