Skip to content

cord/endpoint: Full rewrite of CoRE RD endpoint module #20040

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

bergzand
Copy link
Member

@bergzand bergzand commented Nov 2, 2023

Contribution description

This PR is an almost full rewrite of the CORD endpoint module in RIOT. Changes:

  • Rename of cord_ep to cord_endpoint to make the module more clear
  • Rename of cord_ep_standalone to cord_endpoint_singleton as this is a closer match to the current functionality
  • Increase handling of CoAP and network error conditions making the module more robust against intermittent packet loss
  • Full autonomous operation. As long as the address of the RD is correct, the module should eventually be able to register itself
  • event_sys integration to subscribe on state machine updates
  • Multiple RD support
  • Merging of old epsim and ep module into one source file to simplify maintenance.

Testing procedure

The example modules and shell module have been adapted to work with the new module

Issues/PRs references

None

This is a full rewrite of the CORD module to improve reliability, mainly
by continuing registration attempts if the server for some reason stops
responding.
@bergzand bergzand added the Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. label Nov 2, 2023
@bergzand bergzand requested a review from chrysn November 2, 2023 09:08
@github-actions github-actions bot added Area: network Area: Networking Area: doc Area: Documentation Area: build system Area: Build system Area: sys Area: System Area: examples Area: Example Applications Area: Kconfig Area: Kconfig integration labels Nov 2, 2023
@bergzand bergzand force-pushed the pr/refactor_cord branch 2 times, most recently from a56c3d6 to 0780cf3 Compare November 2, 2023 10:44
@bergzand bergzand added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 2, 2023
@riot-ci
Copy link

riot-ci commented Nov 2, 2023

Murdock results

✔️ PASSED

dbe7cf0 shell: Adapt cord_ep commands to API change

Success Failures Total Runtime
7953 0 7953 16m:35s

Artifacts

@bergzand
Copy link
Member Author

bergzand commented Nov 2, 2023

Flash usage for examples/cord_endpoint is reduced by a rough 90 bytes and ram usage by 844 bytes compared to current master.

@bergzand bergzand removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 3, 2023
@Teufelchen1
Copy link
Contributor

Might be relevant: #18633

#endif

#ifndef MODULE_CORD_ENDPOINT
static const char wkrd[] = "/.well-known/rd";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
static const char wkrd[] = "/.well-known/rd";
static const char wellknown_rd[] = "/.well-known/rd";

static const char wkrd[] = "/.well-known/rd";
#endif

int _pkt_add_qstring(coap_pkt_t *pkt)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is your reasoning for "string" in the function name?

Suggested change
int _pkt_add_qstring(coap_pkt_t *pkt)
int _pkt_add_uri_query(coap_pkt_t *pkt)


int _pkt_add_qstring(coap_pkt_t *pkt)
{
/* extend the url with some query string options */
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, why is this done?

Suggested change
/* extend the url with some query string options */
/* extend the url with a 'key=value' query option: 'ep=cord_endpoint_name' */


/* [optional] set the lifetime parameter */
#if CONFIG_CORD_LT
char lt[11];
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, is 11 always long enough? Are there constraints on the lifetime (by the rfc, etc.)? Are they enforced at buildtime?

Suggested change
char lt[11];
char lifetime[11];

{
#ifndef CONFIG_CORD_ENDPOINT
if (cord_endpoint_name[0] == '\0') {
uint8_t luid[CORD_ENDPOINT_SUFFIX_LEN / 2];
Copy link
Contributor

Choose a reason for hiding this comment

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

Whats luid?

uint8_t luid[CORD_ENDPOINT_SUFFIX_LEN / 2];

if (PREFIX_LEN > 1) {
memcpy(cord_endpoint_name, CORD_ENDPOINT_PREFIX, (PREFIX_LEN - 1));
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this memcpy is safe as cord_endpoint_name has different size depending on the compilation settings?

return 0;
}

void _init_epname(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
void _init_epname(void)
/* Generate a locally unique endpoint name */
void _init_epname(void)

{
(void)cord;
#ifdef MODULE_CORD_ENDPOINT
memset(cord->rd_regif, 0, CORD_URI_MAX);
Copy link
Contributor

Choose a reason for hiding this comment

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

Either this or the check in line 139 is wrong?

Suggested change
memset(cord->rd_regif, 0, CORD_URI_MAX);
memset(cord->rd_regif, 0, sizeof(cord->rd_regif));

}
return 0;
}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#endif
#endif /* MODULE_CORD_ENDPOINT */

* @file
* @brief Standalone extension for the CoRE RD endpoint implementation
*
* @author Hauke Petersen <[email protected]>
Copy link
Contributor

Choose a reason for hiding this comment

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

Your name?

@Teufelchen1
Copy link
Contributor

Ping? The release is coming up...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Area: doc Area: Documentation Area: examples Area: Example Applications Area: Kconfig Area: Kconfig integration Area: network Area: Networking Area: sys Area: System Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants