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

sys: add uuid module for central ID/addr generation #6314

Merged
merged 6 commits into from
Jan 19, 2017

Conversation

haukepetersen
Copy link
Contributor

Wanted to do this for a long time: this PR centralizes the generation of unique IDs/addresses. Now all network drivers use the same code to generate their hardware addresses.

Addresses #5055 (though not all problems are solved?!):

  • the issue of duplicate addresses for two devices of a kind is solved
  • but having repeatable addresses depends currently on the order in which the driver init functions are called -> for this I included already means to address this (by using uuid_custom()), but I did not yet think of a good value to use as custom generator param for this function...

@PeterKietzmann: feel free to postpone the milestone to 2017.04...

@haukepetersen haukepetersen added Area: drivers Area: Device drivers Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Jan 10, 2017
@haukepetersen haukepetersen added this to the Release 2017.01 milestone Jan 10, 2017
@kaspar030
Copy link
Contributor

255 ID's ought to be enough for everybody!

Seriously, would it be hard to use a larger type for last_used, and XOR all of it's bits?

@haukepetersen
Copy link
Contributor Author

would be slightly more overhead in two dimensions:

  1. 2 or 4 byte vs 1 byte of RAM for the last_used var
  2. more code for the XORing, as you would need to catch len < sizeof(last_used)

/**
* @defgroup sys_uuid
* @ingroup sys
* @brief Generate system wide unique IDs
Copy link
Member

Choose a reason for hiding this comment

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

With that name it maybe woth pointing out, that these "U"UIDs are not compatible to RFC 4122.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, other ideas how we could name the module so there is no confusion?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe not applicable due to the more generalized nature of your API, but what about devid (or dev_id, so nobody will call it like some Germans call Davids ;-))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm, I think a more general name would be the better fit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but now that I thought about it, let's do it like that: I add that comment you requested and if we find a better name, we can refactor then.

Copy link
Member

Choose a reason for hiding this comment

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

👍

*/

/**
* @defgroup sys_uuid
Copy link
Member

Choose a reason for hiding this comment

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

Name missing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ups

Copy link
Member

@LudwigKnuepfer LudwigKnuepfer left a comment

Choose a reason for hiding this comment

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

some documentation remarks

/**
* @brief Get a unique ID
*
* The resulting ID is build from the base ID XORed with an 8-bit incrementing
Copy link
Member

Choose a reason for hiding this comment

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

s/build from/built from

Copy link
Member

Choose a reason for hiding this comment

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

s/base ID/base ID generated with uuid_base() which is/

* The resulting ID is build from the base ID XORed with an 8-bit incrementing
* counter value into the most significant byte.
*
* @note The resulting UUID will repeat after 256 calls.
Copy link
Member

Choose a reason for hiding this comment

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

-1 for the base uuid?

*
* @param[out] buf memory location to copy the UUID into. MUST be able to
* hold at least @p len byte
* @param[in] len targeted length of the UUID in byte
Copy link
Member

Choose a reason for hiding this comment

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

s/targeted//
s/byte/bytes/

* @note The resulting UUID will repeat after 256 calls.
*
* @param[out] buf memory location to copy the UUID into. MUST be able to
* hold at least @p len byte
Copy link
Member

Choose a reason for hiding this comment

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

s/byte/bytes/

*
* @param[out] buf memory location to copy the UUID into. MUST be able to
* hold at least @p len byte
* @param[in] len targeted length of the UUID in byte
Copy link
Member

Choose a reason for hiding this comment

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

s/targeted//
s/byte/bytes/

* not.
*
* @param[out] buf memory location to copy the UUID into. MUST be able to
* hold at least @p len byte
Copy link
Member

Choose a reason for hiding this comment

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

s/byte/bytes/

/**
* @brief Get a custom unique ID based on a user given generator value
*
* The resulting ID is build from the base ID XORed with @p gen in the base
Copy link
Member

Choose a reason for hiding this comment

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

s/build/built/

*
* @param[out] buf memory location to copy the UUID into. MUST be able to
* hold at least @p len byte
* @param[in] len targeted length of the UUID in byte
Copy link
Member

Choose a reason for hiding this comment

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

compare other comments

* @brief Get a custom unique ID based on a user given generator value
*
* The resulting ID is build from the base ID XORed with @p gen in the base
* ID's most significant bytes.
Copy link
Member

Choose a reason for hiding this comment

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

Is this really true? It's late and the code is somewhat hard to read ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes.

@haukepetersen haukepetersen added the Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties label Jan 18, 2017
@haukepetersen
Copy link
Contributor Author

rebased and (hopefully) fixed doc issues

Copy link
Member

@LudwigKnuepfer LudwigKnuepfer left a comment

Choose a reason for hiding this comment

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

my comments have been addressed.

Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

I'm fine

@OlegHahm OlegHahm added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Jan 18, 2017
@haukepetersen
Copy link
Contributor Author

squashed and rebased.

@haukepetersen haukepetersen added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable labels Jan 18, 2017
Copy link
Member

@OlegHahm OlegHahm left a comment

Choose a reason for hiding this comment

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

ACKACKACKACKACKACKACKACKACK

@haukepetersen
Copy link
Contributor Author

rebased. Somehow Murdock failed, but can't really tell what the problem was..

@miri64
Copy link
Member

miri64 commented Jan 19, 2017

And go

@miri64 miri64 merged commit 7599a81 into RIOT-OS:master Jan 19, 2017
@haukepetersen haukepetersen deleted the add_uuid branch January 20, 2017 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: drivers Area: Device drivers CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants