Feature/ssr pr1 foundation#149
Conversation
| if (old[i].state != SLOT_OCCUPIED) | ||
| continue; | ||
| int found; | ||
| size_t pos = probe(t, old[i].node_id, &found); |
There was a problem hiding this comment.
it should always find it but should the found be initialized to 0 and then checked after probe() just in case?
| return pos; | ||
| } | ||
| } | ||
| /* Should not happen with correct load-factor management. */ |
There was a problem hiding this comment.
Haven't fully understood the inner workings now but might be good to define some INVALID_SLOT (for (size_t) -1 above). Then if this function returns that value for some reason, it can be checked by the caller when *found is 0 to be extra safe.
| if (timestamp <= s->last_refresh) | ||
| return 0; | ||
| } | ||
| else |
There was a problem hiding this comment.
If probe() can return some INVALID_SLOT, it can be checked here
There was a problem hiding this comment.
Is there a reason to have several test executables, or just personal preference?
|
|
||
| if (use_ssr && (hop_count > SSR_MAX_HOPS || hops == NULL)) | ||
| { | ||
| return 6; |
There was a problem hiding this comment.
returned 6 in the previous if statement is a hacky way to convey the "invalid param" error to the MQTT interface, for example if the backend sends a too large message.
In this case the error doesn't depend on the user input (backend); it happens if we have an invalid value in the table, and it comes from the sink. So I think it should be okay to print an error and return a negative value to indicate internal error.
| return true; | ||
| } | ||
|
|
||
| void ssr_init(void) |
There was a problem hiding this comment.
Might be good to have this function return an error code so that WPC_initialize can fail as well.
a73abc2 to
2fd4cfe
Compare
This PR introduces the SSR foundation layer needed by the rest of the stack.
It adds the DSAP TX support for SSR payloads and the initial SSR core logic for
route learning and registration handling. The goal of this PR is to establish
the protocol primitives and internal bookkeeping without yet wiring SSR into the
main WPC send path.
dsap