/** "Parsing function for custody signal bundles." [DTN2] */ public static boolean parse_custody_signal(data_t data, IByteBuffer bp, int len) { // "1 byte Admin Payload Type + Flags:" [DTN2] byte type_and_flag_byte = bp.get(); if (len < 1) { return false; } data.admin_type_ = admin_record_type_t.get((byte) (type_and_flag_byte >> 4)); data.admin_flags_ = (byte) (type_and_flag_byte & 0xf); len--; // "validate the admin type" [DTN2] if (data.admin_type_ != BundleProtocol.admin_record_type_t.ADMIN_CUSTODY_SIGNAL) { return false; } int status_flag_byte = bp.get(); // Success flag and reason code if (len < 1) { return false; } data.succeeded_ = (status_flag_byte & 0x80) > 0; data.reason_ = BundleProtocol.custody_signal_reason_t.get((byte) (status_flag_byte & 0x7f)); len--; // "Fragment SDNV Fields (offset & length), if present:" [DTN2] if ((data.admin_flags_ & BundleProtocol.admin_record_flags_t.ADMIN_IS_FRAGMENT.getCode()) > 0) { int[] value = new int[1]; int sdnv_bytes = SDNV.decode(bp, len, value); if (sdnv_bytes == -1) { return false; } len -= sdnv_bytes; data.set_orig_frag_offset(value[0]); sdnv_bytes = SDNV.decode(bp, len, value); if (sdnv_bytes == -1) { return false; } len -= sdnv_bytes; data.set_orig_frag_length(value[0]); } int ts_len; // The signal DTNTime ts_len = DTNTime.SDNV_decoding_len(bp); if (ts_len < 0) { return false; } DTNTime.decodeSDNV(data.custody_signal_tv(), bp); len -= ts_len; // Bundle Creation Timestamp ts_len = BundleTimestamp.SDNV_decoding_len(bp); if (ts_len < 0) { return false; } BundleTimestamp.decodeSDNV(data.orig_creation_tv(), bp); len -= ts_len; // Source Endpoint ID of Bundle int[] EID_len = new int[1]; int num_bytes = SDNV.decode(bp, len, EID_len); if (num_bytes == -1) { return false; } len -= num_bytes; if (len != EID_len[0]) { return false; } byte[] source_eid_bytes = new byte[EID_len[0]]; bp.get(source_eid_bytes); boolean ok = data.orig_source_eid_.assign(source_eid_bytes); if (!ok) { return false; } return true; }