// SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0 #ifndef REPORTMANAGER_H_INCLUDED #define REPORTMANAGER_H_INCLUDED #include "ud3tn/bundle.h" #include #include /** * Initializes a new administrative record structure. * * @return a heap-allocated AR structure, or NULL on allocation failure */ struct bundle_administrative_record *init_administrative_record(void); /** * Initializes a new bundle status report structure. * * @return a heap-allocated SR structure, or NULL on allocation failure */ struct bundle_status_report *init_status_report(void); /** * Generates an administrative record of type "Bundle status report", encapsulated in a bundle * destined for the Report-To EID of the provided bundle. * * @param bundle Bundle for which the status report should be created * @param status the status report status flags; note that only one bit must be set * @param reason the status report reason code * @param source source EID for the status report bundle * @param status_timestamp_ms the DTN time when the SR was generated (typically the current time) * * @return a bundle representing the SR, or NULL on error */ struct bundle *generate_status_report( const struct bundle *bundle, enum bundle_status_report_status_flags status, enum bundle_status_report_reason reason, const struct eid source, uint64_t status_timestamp_ms); /** * Parses the payload block of an administrative record bundle. * If case of error, NULL will be returned. * * @param protocol_version the BP version of the encapsulating bundle, determining the AR version * @param data the binary data representing the AR (i.e. the AR bundle payload) * @param length the length of the data array * * @return a heap-allocated AR data structure representint the parsed AR, or NULL on error */ struct bundle_administrative_record *parse_administrative_record( uint8_t protocol_version, const uint8_t *const data, const size_t length); /** * Free the given administrative record structure and release the associated memory. * * @param record the heap-allocated AR structure to be freed */ void free_administrative_record(struct bundle_administrative_record *record); #endif /* REPORTMANAGER_H_INCLUDED */