00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _CONVERGENCE_LAYER_H_
00018 #define _CONVERGENCE_LAYER_H_
00019
00020 #include <string>
00021 #include <vector>
00022 #include <oasys/util/Singleton.h>
00023 #include <oasys/serialize/Serialize.h>
00024
00025 #include "contacts/Contact.h"
00026 #include "contacts/Interface.h"
00027
00028
00029 namespace oasys {
00030 class StringBuffer;
00031 }
00032
00033 namespace dtn {
00034
00038 class ConvergenceLayer : public oasys::Logger {
00039 public:
00043 ConvergenceLayer(const char* classname,
00044 const char* name)
00045 : Logger(classname, "/dtn/cl/%s", name),
00046 name_(name)
00047 {
00048 }
00049
00053 virtual ~ConvergenceLayer();
00054
00058 virtual bool set_interface_defaults(int argc, const char* argv[],
00059 const char** invalidp);
00060
00064 virtual bool set_link_defaults(int argc, const char* argv[],
00065 const char** invalidp);
00066
00070 virtual bool interface_up(Interface* iface,
00071 int argc, const char* argv[]);
00072
00076 virtual bool interface_down(Interface* iface);
00077
00081 virtual void dump_interface(Interface* iface, oasys::StringBuffer* buf);
00082
00086 virtual bool init_link(Link* link, int argc, const char* argv[]);
00087
00091 virtual void dump_link(Link* link, oasys::StringBuffer* buf);
00092
00096 virtual bool reconfigure_link(Link* link, int argc, const char* argv[]);
00097
00104 virtual bool open_contact(const ContactRef& contact) = 0;
00105
00117 virtual bool close_contact(const ContactRef& contact);
00118
00127 virtual void send_bundle(const ContactRef& contact, Bundle* bundle) = 0;
00128
00132 virtual bool cancel_bundle(const ContactRef& contact, Bundle* bundle)
00133 {
00134 (void)contact;
00135 (void)bundle;
00136 return false;
00137 }
00138
00143 virtual bool is_queued(const ContactRef& contact, Bundle* bundle)
00144 {
00145 (void)contact;
00146 (void)bundle;
00147 return false;
00148 }
00149
00154 static void init_clayers();
00155 static void add_clayer(ConvergenceLayer* cl);
00156
00161 static ConvergenceLayer* find_clayer(const char* proto);
00162
00166 const char* name() { return name_; }
00167
00171 static const u_int32_t MAGIC = 0x64746e21;
00172
00173 protected:
00177 const char* name_;
00178
00179 };
00180
00185 class CLVector : public oasys::Singleton<CLVector>,
00186 public std::vector<ConvergenceLayer*> {
00187 public:
00188 virtual ~CLVector();
00189 };
00190
00195 class CLInfo : public oasys::SerializableObject {
00196 public:
00197 virtual ~CLInfo() {}
00198
00202 virtual void serialize( oasys::SerializeAction *) {}
00203 };
00204
00205 }
00206
00207 #endif