diff options
author | Dimitri Staessens <[email protected]> | 2022-03-26 09:39:49 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2022-03-30 15:05:05 +0200 |
commit | 63dde087796bfcd730508b069ebae7c79b7cebe8 (patch) | |
tree | e5e338b9583d023c5895ed0d3a20b679fae76ddf /src/lib/shm_rdrbuff.c | |
parent | 0b45e1e5363f61febc7033f1b9bda14689c88644 (diff) | |
download | ouroboros-63dde087796bfcd730508b069ebae7c79b7cebe8.tar.gz ouroboros-63dde087796bfcd730508b069ebae7c79b7cebe8.zip |
lib: Refactor reading packet from rbuff
Reading packets from the rbuff and checking their validity (non-zero
size, pass crc check, pass decryption) is now extracted into a
function.
Also adds a function to get the length of an sdu_du_buff instead of
subtracting the tail and head pointers.
Signed-off-by: Dimitri Staessens <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/lib/shm_rdrbuff.c')
-rw-r--r-- | src/lib/shm_rdrbuff.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lib/shm_rdrbuff.c b/src/lib/shm_rdrbuff.c index dfa45af6..e283388f 100644 --- a/src/lib/shm_rdrbuff.c +++ b/src/lib/shm_rdrbuff.c @@ -532,6 +532,13 @@ uint8_t * shm_du_buff_tail(struct shm_du_buff * sdb) return (uint8_t *) (sdb + 1) + sdb->du_tail; } +size_t shm_du_buff_len(struct shm_du_buff * sdb) +{ + assert(sdb); + + return sdb->du_tail - sdb->du_head; +} + uint8_t * shm_du_buff_head_alloc(struct shm_du_buff * sdb, size_t size) { |