00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _TCA_CONTROLBUNDLE_H_
00019 #define _TCA_CONTROLBUNDLE_H_
00020
00021
00022
00023
00024
00025 #include <string>
00026 #include <vector>
00027
00028 namespace dtn {
00029
00030
00031
00032
00033
00034
00035
00036 class TcaControlBundle
00037 {
00038 public:
00039
00040 enum TypeCode {
00041 CB_NULL,
00042 CB_ADV,
00043 CB_ADV_SENT,
00044 CB_ASK,
00045 CB_ASK_RECEIVED,
00046 CB_ASK_SENT,
00047 CB_COA,
00048 CB_COA_SENT,
00049 CB_REG_RECEIVED,
00050 CB_ROUTES,
00051 CB_UNB,
00052 CB_LINK_ANNOUNCE,
00053 CB_LINK_AVAILABLE,
00054 CB_LINK_UNAVAILABLE,
00055 CB_CONTACT_UP,
00056 CB_CONTACT_DOWN,
00057 CB_UNKNOWN
00058 };
00059
00060 TypeCode type_;
00061 std::string code_;
00062 std::vector<std::string> args_;
00063
00064 TcaControlBundle() : type_(CB_NULL), code_(), args_() { };
00065
00066
00067
00068 TcaControlBundle(const std::string& payload);
00069
00070 virtual ~TcaControlBundle() { }
00071
00072
00073 virtual std::string str() const;
00074
00075 void dump(const std::string& intro) const;
00076
00077
00078 static std::string eat_to_tab(std::string& s);
00079
00080 protected:
00081
00082 static bool parse_payload(const std::string& payload,
00083 TypeCode& type,
00084 std::string& code, std::string& body);
00085
00086 };
00087
00088
00089
00090
00091
00092
00093
00094
00095 class TcaWrappedBundle : public TcaControlBundle
00096 {
00097 public:
00098
00099
00100 TcaWrappedBundle(const std::string& payload) : TcaControlBundle(payload) {}
00101
00102
00103 TcaWrappedBundle(const TcaControlBundle& cb) : TcaControlBundle(cb) {}
00104
00105
00106 TcaWrappedBundle(const std::string& code,
00107 const std::string& src, const std::string& dest);
00108
00109 const std::string source() const;
00110 const std::string dest() const;
00111
00112 void append_arg(const std::string& arg) { args_.push_back(arg); }
00113 };
00114
00115 }
00116
00117 #endif