2022-02-17 16:14:33 +01:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0
|
2025-06-05 10:43:26 +02:00
|
|
|
#ifndef BUNDLE_V7_BUNDLE7_H_INCLUDED
|
|
|
|
|
#define BUNDLE_V7_BUNDLE7_H_INCLUDED
|
2020-11-13 10:42:31 +01:00
|
|
|
|
2020-11-17 12:49:29 +01:00
|
|
|
#include "ud3tn/bundle.h"
|
|
|
|
|
#include "ud3tn/result.h"
|
2020-11-13 10:42:31 +01:00
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
2025-06-05 10:43:53 +02:00
|
|
|
#include <stdbool.h>
|
2020-11-13 10:42:31 +01:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
2023-09-29 14:35:03 +02:00
|
|
|
// Default CRC type, see enum bundle_crc_type in bundle.h.
|
|
|
|
|
#ifndef DEFAULT_BPV7_CRC_TYPE
|
|
|
|
|
#define DEFAULT_BPV7_CRC_TYPE BUNDLE_CRC_TYPE_16
|
|
|
|
|
#endif // DEFAULT_CRC_TYPE
|
2020-11-13 10:42:31 +01:00
|
|
|
|
2025-06-05 10:43:53 +02:00
|
|
|
/**
|
|
|
|
|
* Perform basic validation of the provided bundle.
|
|
|
|
|
*
|
|
|
|
|
* This function asserts basic properties that are specified as mandatory by RFC 9171 and are
|
|
|
|
|
* not already asserted by the parser or bundle-creation functions provided in this component.
|
|
|
|
|
*/
|
|
|
|
|
bool bundle7_is_valid(const struct bundle *bundle);
|
|
|
|
|
|
2020-11-13 10:42:31 +01:00
|
|
|
/**
|
|
|
|
|
* Returns the number of bytes that will be required for the CBORepresentation
|
|
|
|
|
* of the passed unsigned integer.
|
|
|
|
|
*/
|
|
|
|
|
size_t bundle7_cbor_uint_sizeof(uint64_t num);
|
|
|
|
|
|
2022-11-21 09:41:03 +01:00
|
|
|
/**
|
|
|
|
|
* Returns the number of bytes that will be required for the CBORepresentation
|
|
|
|
|
* of the passed EID.
|
|
|
|
|
*/
|
|
|
|
|
size_t bundle7_eid_sizeof(const char *eid);
|
2020-11-13 10:42:31 +01:00
|
|
|
|
|
|
|
|
/**
|
2020-11-17 15:11:51 +01:00
|
|
|
* Converts the unified uD3TN flags into BPv7-bis protocol-compliant block
|
2020-11-13 10:42:31 +01:00
|
|
|
* processing flags.
|
|
|
|
|
*
|
|
|
|
|
* @return BPv7-bis bundle block processing flags
|
|
|
|
|
*/
|
|
|
|
|
uint16_t bundle7_convert_to_protocol_block_flags(
|
|
|
|
|
const struct bundle_block *block);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the byte-length of the CBORepresentation of an extension block.
|
|
|
|
|
*/
|
|
|
|
|
size_t bundle7_block_get_size(struct bundle_block *block);
|
|
|
|
|
|
|
|
|
|
size_t bundle7_get_serialized_size(struct bundle *bundle);
|
|
|
|
|
size_t bundle7_get_serialized_size_without_payload(struct bundle *bundle);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Recalculates the length of the primary block stored in the
|
|
|
|
|
* "primary_block_length" field. You should call this function if you change
|
|
|
|
|
* something in the primary block.
|
|
|
|
|
*/
|
|
|
|
|
void bundle7_recalculate_primary_block_length(struct bundle *bundle);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the minimal number of serialized bytes of the first fragment of the
|
|
|
|
|
* given bundle.
|
|
|
|
|
*
|
|
|
|
|
* The minimal fragment contains:
|
|
|
|
|
*
|
|
|
|
|
* - all extension blocks
|
|
|
|
|
* - minimal header for the payload block
|
|
|
|
|
*/
|
|
|
|
|
size_t bundle7_get_first_fragment_min_size(struct bundle *bundle);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the minimal number of serialized bytes of the last fragment of the
|
|
|
|
|
* given bundle.
|
|
|
|
|
*
|
|
|
|
|
* The minimal fragment contains:
|
|
|
|
|
*
|
|
|
|
|
* - all extension blocks containing the "replicated in every fragment" flag
|
|
|
|
|
* - minimal header for the payload block
|
|
|
|
|
*/
|
|
|
|
|
size_t bundle7_get_last_fragment_min_size(struct bundle *bundle);
|
|
|
|
|
|
2025-06-05 10:43:26 +02:00
|
|
|
#endif // BUNDLE_V7_BUNDLE7_H_INCLUDED
|