diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2023-08-17 16:12:44 +0200 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2023-08-23 13:09:11 +0200 |
commit | 8183983c2c1cc50e3e0c82a8ab08d5fd66e0dc86 (patch) | |
tree | 005c33c3d3df3dde7c7f01abce816fa6202daed5 /src/lib/serdes-oep.c | |
parent | 868c7be8f599404a23f1d5178b1ba18379df1132 (diff) | |
download | ouroboros-8183983c2c1cc50e3e0c82a8ab08d5fd66e0dc86.tar.gz ouroboros-8183983c2c1cc50e3e0c82a8ab08d5fd66e0dc86.zip |
ipcpd: Add IDs to enrollment
The enrollment messages now have a 64-bit ID to easier track
enrollments in the logs in larger scale tests.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/serdes-oep.c')
-rw-r--r-- | src/lib/serdes-oep.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/lib/serdes-oep.c b/src/lib/serdes-oep.c index cae5c598..f5034a4a 100644 --- a/src/lib/serdes-oep.c +++ b/src/lib/serdes-oep.c @@ -26,12 +26,13 @@ #include <ouroboros/serdes-oep.h> -ssize_t enroll_req_ser(buffer_t buf) +ssize_t enroll_req_ser(const struct enroll_req * req, + buffer_t buf) { enroll_req_msg_t * msg; ssize_t sz; - msg = enroll_req_s_to_msg(); + msg = enroll_req_s_to_msg(req); if (msg == NULL) goto fail_msg; @@ -46,24 +47,33 @@ ssize_t enroll_req_ser(buffer_t buf) return sz; fail_pack: - enroll_req_msg__free_unpacked(msg, NULL); + enroll_req_msg__free_unpacked(msg, NULL); fail_msg: return -1; } -int enroll_req_des(const buffer_t buf) +int enroll_req_des(struct enroll_req * req, + const buffer_t buf) { enroll_req_msg_t * msg; msg = enroll_req_msg__unpack(NULL, buf.len, buf.data); if (msg == NULL) - return -1; + goto fail_unpack; - /* Nothing in request yet, if it unpacks, it's good. */ + if (msg->id.len != ENROLL_ID_LEN) + goto fail_id; + + *req = enroll_req_msg_to_s(msg); enroll_req_msg__free_unpacked(msg, NULL); return 0; + + fail_id: + enroll_req_msg__free_unpacked(msg, NULL); + fail_unpack: + return -1; } ssize_t enroll_resp_ser(const struct enroll_resp * resp, @@ -80,9 +90,6 @@ ssize_t enroll_resp_ser(const struct enroll_resp * resp, if (sz < 0 || (size_t) sz > buf.len) goto fail_pack; - msg->t_sec = resp->t.tv_sec; - msg->t_nsec = resp->t.tv_nsec; - enroll_resp_msg__pack(msg, buf.data); enroll_resp_msg__free_unpacked(msg, NULL); @@ -111,13 +118,13 @@ int enroll_resp_des(struct enroll_resp * resp, return 0; } -ssize_t enroll_ack_ser(const int response, - buffer_t buf) +ssize_t enroll_ack_ser(const struct enroll_ack * ack, + buffer_t buf) { enroll_ack_msg_t * msg; ssize_t sz; - msg = enroll_ack_s_to_msg(response); + msg = enroll_ack_s_to_msg(ack); if (msg == NULL) goto fail_msg; @@ -138,8 +145,8 @@ ssize_t enroll_ack_ser(const int response, } -int enroll_ack_des(int * response, - const buffer_t buf) +int enroll_ack_des(struct enroll_ack * ack, + const buffer_t buf) { enroll_ack_msg_t * msg; @@ -147,7 +154,7 @@ int enroll_ack_des(int * response, if (msg == NULL) return -1; - *response = enroll_ack_msg_to_s(msg); + *ack = enroll_ack_msg_to_s(msg); enroll_ack_msg__free_unpacked(msg, NULL); |