ConvergenceLayer.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2004-2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
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 // forward declaration
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; //'DTN!'
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 } // namespace dtn
00206 
00207 #endif /* _CONVERGENCE_LAYER_H_ */

Generated on Thu Jun 7 12:54:26 2007 for DTN Reference Implementation by  doxygen 1.5.1