New BPv7 with working UTS and patched cbor modules to support it - #5075
New BPv7 with working UTS and patched cbor modules to support it#5075BrianSipos wants to merge 6 commits into
Conversation
|
There seems to be some inconsistency with existing cborfields interface between use of |
fdf5a38 to
439ffe0
Compare
439ffe0 to
9ffc348
Compare
| # type: (CBOR_Packet) -> bytes | ||
| return b"".join(obj.build(pkt) for obj in self.seq) | ||
|
|
||
| class CBORF_ARRAY(CBORF_field[List[Any], List[Any]]): |
There was a problem hiding this comment.
The array could be refactored to be a subclass of CBORF_SEQUENCE with the encoded prefix CBOR head.
| if major_type != 4: | ||
| raise CBOR_Decoding_Error( | ||
| "Expected major type 4 (array), got %d" % major_type) | ||
| if count != len(self.seq): |
There was a problem hiding this comment.
This logic on seq does not account for optional or conditional fields not being part of the encoded array.
| cond, # type: Callable[[Packet], bool] | ||
| ): | ||
| fields.ConditionalField.__init__(self, fld, cond) | ||
| # Leave CBORF_field uninitialized |
There was a problem hiding this comment.
I don't know a good behavior here because ConditionalField.__getattr__ forwards all names to the sub-field.
| CBORF_UNSIGNED_INTEGER('block_num', default=None), | ||
| CBORF_UNSIGNED_INTEGER('block_flags', default=0), #FIXME FLAGS | ||
| CBORF_UNSIGNED_INTEGER('crc_type', default=CrcType.NONE), #FIXME ENUM | ||
| CBORF_BYTE_STRING_PACKET('btsd', default=None, |
There was a problem hiding this comment.
This logic is somewhat crude, but I can't find an analogy in other existing protocol definitions. The "btsd" field is the payload of this packet and bound to this layer via the "block_type" field. The nuance is that the payload is not at the end of the encoded bytes. Maybe something like how an Ethernet trailer is handled?
|
|
||
| CBOR_root = CBORF_INDEFINITE_ARRAY( | ||
| CBORF_PACKET('primary', default=PrimaryBlock(), cls=PrimaryBlock), | ||
| CBORF_SEQUENCE_OF('blocks', default=[], |
There was a problem hiding this comment.
Likewise here, the payload of the entire bundle is the btsd field of the block having block_type==1 (and supposed to be the last block in this sequence). Some magic could be added to copy/clone the payload content as a next-layer packet.
| bind_layers(CanonicalBlock, BundleAgeBlock, type_code=7) | ||
| bind_layers(CanonicalBlock, HopCountBlock, type_code=10) | ||
|
|
||
| """ |
There was a problem hiding this comment.
If the above strategy seems good, I can update the BPSec handling here to match the pattern.
Description
Add a BPv7 packet family (bundle, blocks, block-type-specific data) using the new CBOR packet and field modules, and eventually the CRC module.
Fixes #4874 eventually