mirror of
https://gitlab.com/d3tn/ud3tn.git
synced 2026-08-13 12:33:27 +02:00
- A new `struct eid` is introduced, which can represent EIDs in a
scheme-based manner; specifically, this means that `ipn` EIDs are
now represented as tuples of two 64-bit integers and the `dtn` null
endpoint is now represented as a `NULL` pointer (similar to the CBOR
representation in RFC 9171).
- We assume that any `struct eid` instance has been validated before,
e.g. by decoding a string via `eid_from_string`.
- Note that the FIB is still using the (normalized) string format of
node IDs. It performs a lookup in a hash table anyway and, later, we
plan to support EID patterns (current IETF draft).
- Changes to parsers and serializers:
- The BPv7 parser validates EIDs separately from `eid_from_string`.
This is intentional: No full normalizationis performed for incoming
bundles; as long as the EID is valid, it is passed through, to
prevent changes to the immutable (as per RFC9171) primary block.
This means that, e.g., there are two representations of the null
endpoint (`dtn:none` and `ipn:0.0`), which are kept as such now.
- The BPv6 parser and serializer will rewrite the primary block of
passing bundles -- they do this anyway as the "dictionary" is
re-constructed by the serializer.
- Dedicated string representations of the EIDs (`source_str`, etc.)
are added to the bundle struct on reception (`cla_contact_tx_task`)
and creation -- this is done for convenience when processing the
bundle further (especially to still be able to print log messages
referring to the EIDs in the BP and so on). We may remove it in the
future to reduce the number of EID-to-string conversions.
- Other changes:
- Some terminology is cleaned up in the process: e.g., variables
referring to the local administrative endpoint identifier are
renamed as such. The previously-used terms "local node ID" or,
worse, "local EID" are inaccurate -- according to the standards,
any locally registered singleton EID is a node ID of the local
bundle node.
- In some places, log messages are harmonized (e.g. by always using
quotes around EIDs and no quotes for agent sink IDs). Sometimes,
EIDs were printed in logs which have been removed now to prevent
an unnecessary EID-to-string conversion.
- `aap2_agent`: the manual deallocation of string parts of the AAP2
message is now replaced by a less fragile `pb_release` in most
cases.
- `bundle.h`: `struct endpoint_list` is replaced in BPv6 by a
`struct eid_list` containing the new `struct eid`; the DFCF
("compat") router still uses the old variant with strings
- `init`: `preprocess_local_eid` is simplified and moved to
`cmdline.c`. It now uses `eid_from_string`, which tolerates missing
trailing slashes for `dtn`. Also, we do not support `ipn:x` without
service number anymore on the command line, as it is an invalid
format and only makes the coe more complex.
It is recommended to review the changes to `ud3tn/eid.[c|h]` and the
associated unit tests (`test_eid.c`) first, to get an overall idea of
the added and adapted functionality plus the expected behaviors. Before
reviewing the individual changes to all functions dealing with EIDs, it
is also advisable to take a quick look at the other associated
(following) commits.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
71 lines
2 KiB
C
71 lines
2 KiB
C
// SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0
|
|
#ifndef BUNDLE6_BUNDLE6_H_INCLUDED
|
|
#define BUNDLE6_BUNDLE6_H_INCLUDED
|
|
|
|
#include "ud3tn/bundle.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
/**
|
|
* Perform basic validation of the provided bundle.
|
|
*
|
|
* This function asserts basic properties that are specified as mandatory by RFC 5050 and are
|
|
* not already asserted by the parser or bundle-creation functions provided in this component.
|
|
*/
|
|
bool bundle6_is_valid(const struct bundle *bundle);
|
|
|
|
// ---------------------
|
|
// Serialization helpers
|
|
// ---------------------
|
|
|
|
struct bundle6_eid_reference {
|
|
uint64_t scheme_offset;
|
|
uint64_t ssp_offset;
|
|
};
|
|
|
|
struct bundle6_eid_info {
|
|
char *str_ptr;
|
|
const char *ssp_ptr;
|
|
uint64_t dict_scheme_offset;
|
|
uint64_t dict_ssp_offset;
|
|
};
|
|
|
|
struct bundle6_dict_descriptor {
|
|
size_t dict_length_bytes;
|
|
size_t eid_reference_count;
|
|
struct bundle6_eid_info destination_eid_info;
|
|
struct bundle6_eid_info source_eid_info;
|
|
struct bundle6_eid_info report_to_eid_info;
|
|
struct bundle6_eid_info custodian_eid_info;
|
|
// can be written out by memcopying parts and appending zero terminators
|
|
struct bundle6_eid_info eid_references[];
|
|
};
|
|
|
|
/**
|
|
* Serializes the bundle dictionary into the given buffer
|
|
*/
|
|
void bundle6_serialize_dictionary(char *buf,
|
|
const struct bundle6_dict_descriptor *desc);
|
|
|
|
// ----------------------
|
|
// Bundle and block sizes
|
|
// ----------------------
|
|
|
|
struct bundle6_dict_descriptor *bundle6_calculate_dict(const struct bundle *bundle);
|
|
void bundle6_free_dict_descriptor(struct bundle6_dict_descriptor *const ddesc);
|
|
void bundle6_recalculate_header_length(struct bundle *bundle);
|
|
size_t bundle6_get_serialized_size(struct bundle *bundle);
|
|
|
|
|
|
// -------------------
|
|
// Fragmentation sizes
|
|
// -------------------
|
|
|
|
size_t bundle6_get_first_fragment_min_size(struct bundle *bundle);
|
|
size_t bundle6_get_mid_fragment_min_size(struct bundle *bundle);
|
|
size_t bundle6_get_last_fragment_min_size(struct bundle *bundle);
|
|
|
|
|
|
#endif /* BUNDLE6_BUNDLE6_H_INCLUDED */
|