Refactor message marshalling - parent path max length#90
Refactor message marshalling - parent path max length#90
Conversation
The maximum path length is no longer hard coded/set at compile time. Instead, parsing the parent path is deferred, so that the number of compressed input slices need not be known and allocated in advance.
LCOV of commit
|
There was a problem hiding this comment.
Pull request overview
Refactors NAT20 service message marshalling for the “parent path” field to remove the compile-time maximum path length and defer decoding until iteration, reducing up-front allocation requirements.
Changes:
- Introduces
n20_parent_path_t(encoded/decoded representation) plusn20_msg_parent_path_iterate()for on-demand traversal. - Updates message read/write logic to preserve an encoded CBOR slice for parent paths instead of decoding into a fixed-size array.
- Refactors/extends unit tests to cover round-trips and iterator behavior for both encoded and decoded parent-path inputs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
include/nat20/service/messages.h |
Adds n20_parent_path_t API + iterator and updates request payload structs to use it. |
src/service/messages.c |
Implements deferred parent-path parsing, iterator, and updates request read/write paths accordingly. |
src/service/test/messages.cpp |
Updates round-trip tests and adds iterator success/error-path tests for parent paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR refactors NAT20 service message marshalling to remove the compile-time maximum parent-path length by storing parent paths as either an encoded CBOR slice or a decoded slice array, and deferring per-element parsing until iteration.
Changes:
- Replace fixed-size
parent_patharrays +parent_path_lengthwithn20_parent_path_tacross request payloads. - Update message read/write logic to preserve an encoded parent-path slice and add
n20_msg_parent_path_iterate()for on-demand decoding. - Refactor/extend tests to validate round-trips and parent-path iteration behavior (including error propagation).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
src/service/messages.c |
Implements encoded/decoded parent-path read/write, adds iterator API, and updates request parsing/serialization. |
include/nat20/service/messages.h |
Introduces the n20_parent_path_t public type + iterator API and updates request payload structs to use it. |
src/service/test/messages.cpp |
Updates round-trip tests to use n20_parent_path_t and adds iterator success/error tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| static n20_error_t n20_msg_compressed_context_array_read(n20_istream_t* istream, | ||
| n20_parent_path_t* compressed_context) { | ||
|
|
There was a problem hiding this comment.
nit: remove extra newline.
The maximum path length is no longer hard coded/set at compile time. Instead, parsing the parent path is deferred, so that the number of compressed input slices need not be known and allocated in advance.