00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _PROPHET_BUNDLE_TLV_H_
00018 #define _PROPHET_BUNDLE_TLV_H_
00019
00020 #include <sys/types.h>
00021 #include "BaseTLV.h"
00022 #include "BundleTLVEntry.h"
00023 #include "BundleTLVEntryList.h"
00024
00025 namespace prophet
00026 {
00027
00028 class BundleTLV : public BaseTLV
00029 {
00030 public:
00049 struct BundleTLVHeader {
00050 u_int8_t type;
00051 u_int8_t flags;
00052
00056 u_int16_t length;
00060 u_int16_t offer_count;
00061 u_int16_t unused__;
00062 } __attribute__((packed));
00063
00068 struct BundleEntry {
00073 u_int16_t dest_string_id;
00098 u_int8_t b_flags;
00099 u_int8_t unused__;
00100 u_int32_t creation_timestamp;
00101 u_int32_t seqno;
00102 } __attribute__((packed));
00103
00108 typedef enum {
00109 CUSTODY = 1 << 0,
00110 ACCEPTED = 1 << 1,
00111 ACK = 1 << 7
00112 } bundletlv_flags_t;
00113
00114 static const size_t BundleTLVHeaderSize = sizeof(struct BundleTLVHeader);
00115
00116 static const size_t BundleEntrySize = sizeof(struct BundleEntry);
00117
00121 virtual ~BundleTLV() {}
00122
00123 protected:
00127 BundleTLV(BaseTLV::prophet_tlv_t type = BaseTLV::UNKNOWN_TLV,
00128 u_int8_t flags = 0, u_int16_t length = 0)
00129 : BaseTLV(type,flags,length) {}
00130
00135 size_t write_bundle_entry(u_int32_t cts, u_int32_t seq, u_int16_t sid,
00136 bool custody, bool accept, bool ack,
00137 BundleTLVEntry::bundle_entry_t type,
00138 u_char* bp, size_t len) const;
00139
00144 size_t read_bundle_entry(u_int32_t *cts, u_int32_t *seq, u_int16_t *sid,
00145 bool *custody, bool *accept, bool *ack,
00146 BundleTLVEntry::bundle_entry_t *type,
00147 const u_char* bp, size_t len );
00148 };
00149
00150 };
00151
00152 #endif // _PROPHET_BUNDLE_TLV_H_