ConvergenceLayer.cc

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 #include <config.h>
00018 #include "ConvergenceLayer.h"
00019 #include "EthConvergenceLayer.h"
00020 #include "FileConvergenceLayer.h"
00021 #include "NullConvergenceLayer.h"
00022 #include "TCPConvergenceLayer.h"
00023 #include "UDPConvergenceLayer.h"
00024 #include "BluetoothConvergenceLayer.h"
00025 
00026 namespace dtn {
00027 
00028 template<>
00029 CLVector* oasys::Singleton<CLVector>::instance_ = NULL;
00030 
00031 //----------------------------------------------------------------------
00032 ConvergenceLayer::~ConvergenceLayer()
00033 {
00034 }
00035 
00036 //----------------------------------------------------------------------
00037 void
00038 ConvergenceLayer::add_clayer(ConvergenceLayer* cl)
00039 {
00040     CLVector::instance()->push_back(cl);
00041 }
00042     
00043 //----------------------------------------------------------------------
00044 void
00045 ConvergenceLayer::init_clayers()
00046 {
00047     add_clayer(new NullConvergenceLayer());
00048     add_clayer(new TCPConvergenceLayer());
00049     add_clayer(new UDPConvergenceLayer());
00050 #ifdef __linux__
00051     add_clayer(new EthConvergenceLayer());
00052 #endif
00053 #ifdef OASYS_BLUETOOTH_ENABLED
00054     add_clayer(new BluetoothConvergenceLayer());
00055 #endif
00056     // XXX/demmer fixme
00057     // add_clayer("file", new FileConvergenceLayer());
00058 }
00059 
00060 //----------------------------------------------------------------------
00061 CLVector::~CLVector()
00062 {
00063     while (!empty()) {
00064         delete back();
00065         pop_back();
00066     }
00067 }
00068 
00069 //----------------------------------------------------------------------
00070 ConvergenceLayer*
00071 ConvergenceLayer::find_clayer(const char* name)
00072 {
00073     CLVector::iterator iter;
00074     for (iter = CLVector::instance()->begin();
00075          iter != CLVector::instance()->end();
00076          ++iter)
00077     {
00078         if (strcasecmp(name, (*iter)->name()) == 0) {
00079             return *iter;
00080         }
00081     }
00082 
00083     return NULL;
00084 }
00085 
00086 //----------------------------------------------------------------------
00087 bool
00088 ConvergenceLayer::set_interface_defaults(int argc, const char* argv[],
00089                                          const char** invalidp)
00090 {
00091     if (argc == 0) {
00092         return true;
00093     } else {
00094         invalidp = &argv[0];
00095         return false;
00096     }
00097 }
00098 
00099 //----------------------------------------------------------------------
00100 bool
00101 ConvergenceLayer::set_link_defaults(int argc, const char* argv[],
00102                                     const char** invalidp)
00103 {
00104     if (argc == 0) {
00105         return true;
00106     } else {
00107         invalidp = &argv[0];
00108         return false;
00109     }
00110 }
00111 
00112 //----------------------------------------------------------------------
00113 bool
00114 ConvergenceLayer::interface_up(Interface* iface,
00115                                int argc, const char* argv[])
00116 {
00117     (void)iface;
00118     (void)argc;
00119     (void)argv;
00120     log_debug("init interface %s", iface->name().c_str());
00121     return true;
00122 }
00123 
00124 //----------------------------------------------------------------------
00125 bool
00126 ConvergenceLayer::interface_down(Interface* iface)
00127 {
00128     (void)iface;
00129     log_debug("stopping interface %s", iface->name().c_str());
00130     return true;
00131 }
00132 
00133 //----------------------------------------------------------------------
00134 void
00135 ConvergenceLayer::dump_interface(Interface* iface, oasys::StringBuffer* buf)
00136 {
00137     (void)iface;
00138     (void)buf;
00139 }
00140 
00141 //----------------------------------------------------------------------
00142 bool
00143 ConvergenceLayer::init_link(Link* link, int argc, const char* argv[])
00144 {
00145     (void)link;
00146     (void)argc;
00147     (void)argv;
00148     log_debug("init link %s", link->nexthop());
00149     return true;
00150 }
00151 
00152 //----------------------------------------------------------------------
00153 void
00154 ConvergenceLayer::dump_link(Link* link, oasys::StringBuffer* buf)
00155 {
00156     (void)link;
00157     (void)buf;
00158 }
00159 
00160 //----------------------------------------------------------------------
00161 bool
00162 ConvergenceLayer::reconfigure_link(Link* link, int argc, const char* argv[])
00163 {
00164     (void)link;
00165     (void)argv;
00166     return (argc == 0);
00167 }
00168 
00169 //----------------------------------------------------------------------
00170 bool
00171 ConvergenceLayer::close_contact(const ContactRef& contact)
00172 {
00173     (void)contact;
00174     log_debug("closing contact *%p", contact.object());
00175     return true;
00176 }
00177 
00178 } // namespace dtn

Generated on Sat Sep 8 08:43:26 2007 for DTN Reference Implementation by  doxygen 1.5.3