32 #define BUFFER_LENGTH 100
46 buffer[offset++] = report->status_flags;
47 buffer[offset++] = report->reason_code;
50 if( report->fragment ) {
55 ret =
sdnv_encode(report->dtn_time_seconds, &buffer[offset], length - offset);
61 ret =
sdnv_encode(report->dtn_time_seconds, &buffer[offset], length - offset);
73 ret =
sdnv_encode(report->dtn_time_seconds, &buffer[offset], length - offset);
79 ret =
sdnv_encode(report->dtn_time_nanoseconds, &buffer[offset], length - offset);
85 ret =
sdnv_encode(report->bundle_creation_timestamp, &buffer[offset], length - offset);
91 ret =
sdnv_encode(report->bundle_sequence_number, &buffer[offset], length - offset);
97 offset +=
eid_create_full_length(report->source_eid_node, report->source_eid_service, &buffer[offset], length - offset);
102 int statusreport_decode(
status_report_t * report, uint8_t * buffer, uint8_t length)
109 LOG(LOGD_DTN, LOG_AGENT, LOGL_WRN,
"Status Report Format mismatch");
114 report->fragment = 1;
121 report->status_flags = buffer[offset++];
122 report->reason_code = buffer[offset++];
125 if( report->fragment ) {
127 ret =
sdnv_decode(&buffer[offset], length - offset, &report->dtn_time_seconds);
133 ret =
sdnv_decode(&buffer[offset], length - offset, &report->dtn_time_seconds);
141 ret =
sdnv_decode(&buffer[offset], length - offset, &report->dtn_time_seconds);
147 ret =
sdnv_decode(&buffer[offset], length - offset, &report->dtn_time_nanoseconds);
153 ret =
sdnv_decode(&buffer[offset], length - offset, &report->bundle_creation_timestamp);
159 ret =
sdnv_decode(&buffer[offset], length - offset, &report->bundle_sequence_number);
165 ret =
eid_parse_full_length(&buffer[offset], length - offset, &report->source_eid_node, &report->source_eid_service);
180 uint32_t bundle_flags;
181 uint32_t report_node_id;
182 uint32_t report_service_id;
185 struct mmem * report_bundle =
NULL;
188 uint8_t buffer[BUFFER_LENGTH];
193 if( !(bundle_flags & BUNDLE_FLAG_REPORT) ) {
197 LOG(LOGD_DTN, LOG_AGENT, LOGL_DBG,
"Sending out status report for status %u and reason %u", status, reason);
201 report.status_flags = status;
202 report.reason_code = reason;
205 report.dtn_time_seconds = clock_seconds();
206 report.dtn_time_nanoseconds = 0;
211 bundle_get_attr(bundlemem, TIME_STAMP, &report.bundle_creation_timestamp);
212 bundle_get_attr(bundlemem, TIME_STAMP_SEQ_NR, &report.bundle_sequence_number);
219 if( report_node_id == 0 ) {
220 LOG(LOGD_DTN, LOG_AGENT, LOGL_WRN,
"Cannot send status report, destination node is %lu", report_node_id);
227 if( report_bundle ==
NULL ) {
228 LOG(LOGD_DTN, LOG_AGENT, LOGL_ERR,
"Unable to allocate report bundle, storage has %u bundles left",
BUNDLE_STORAGE.free_space(
NULL));
235 bundle->source_process = &agent_process;
242 bundle_set_attr(report_bundle, TIME_STAMP, &report.bundle_creation_timestamp);
244 LOG(LOGD_DTN, LOG_AGENT, LOGL_DBG,
"Report goes to %lu.%lu", report_node_id, report_service_id);
251 flags = BUNDLE_FLAG_ADM_REC;
263 ret =
bundle_add_block(report_bundle, BUNDLE_BLOCK_TYPE_PAYLOAD, BUNDLE_BLOCK_FLAG_NULL, buffer, ret);
277 "STATUSREPORT_BASIC",