diff options
| author | eunhhu <[email protected]> | 2026-09-29 07:22:19 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-29 07:22:19 +0100 |
| commit | 5dbf6a536627f9a29f7358c547426218aa6f23c1 (patch) | |
| tree | 3e92fc3358b83877d694a76ab8c264091df3af39 /link/link-protocol.c | |
| parent | 7c6595c8a9229a2208ed5bd75b2dee249187923d (diff) | |
| download | pure-5dbf6a536627f9a29f7358c547426218aa6f23c1.tar.gz pure-5dbf6a536627f9a29f7358c547426218aa6f23c1.zip | |
Make the load generator's devices real link senders, many on one thread
links.c was a second implementation of the packet format; each device is
now a PureLinkSender on a socket of its own, keyed with a secret made
outside (pure_link_sender_shared: a key kept elsewhere, or a test's
many). M1 (1k, 10k) and M2 (10k, kill -9) pass with it: no silent step,
caught up in 0.2 s, every order applied once; the slowest store after
the restart is now the sender's 1 s wait for a word of the save
(STORED_WAIT), where the old devices tried again after 200 ms.
Diffstat (limited to 'link/link-protocol.c')
| -rw-r--r-- | link/link-protocol.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/link/link-protocol.c b/link/link-protocol.c index 94a965b..c8b5118 100644 --- a/link/link-protocol.c +++ b/link/link-protocol.c @@ -656,16 +656,25 @@ PureLinkSender *pure_link_sender(const char *source, const char *input, uint32_t return l; } -bool pure_link_sender_peer(PureLinkSender *l, const unsigned char peer[PURE_SEAL_KEY]) { +/* The receiver's key, with the secret made (or given) into l->secret: the + * keys of packets to it. */ +static bool keyed(PureLinkSender *l, const unsigned char peer[PURE_SEAL_KEY], const unsigned char *secret) { memcpy(l->peer, peer, PURE_SEAL_KEY); l->peer_id = key_id(peer); pure_aead_free(l->out); pure_aead_free(l->in); l->out = l->in = NULL; - return l->own && pure_link_secret(l->own, l->peer, l->secret) && + if (secret) memcpy(l->secret, secret, 32); + return (secret || (l->own && pure_link_secret(l->own, l->peer, l->secret))) && (l->out = aead_of(l->secret, l->own_public, l->peer, l->run, 0, l->out_base)); } +bool pure_link_sender_peer(PureLinkSender *l, const unsigned char peer[PURE_SEAL_KEY]) { return keyed(l, peer, NULL); } + +bool pure_link_sender_shared(PureLinkSender *l, const unsigned char peer[PURE_SEAL_KEY], const unsigned char secret[32]) { + return keyed(l, peer, secret); +} + uint64_t pure_link_sender_queued(const PureLinkSender *l) { return l->queued; } uint64_t pure_link_sender_stored(const PureLinkSender *l) { return l->stored; } |
