ConvergenceLayer.cc

Go to the documentation of this file.
00001 /*
00002  * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By
00003  * downloading, copying, installing or using the software you agree to
00004  * this license. If you do not agree to this license, do not download,
00005  * install, copy or use the software.
00006  * 
00007  * Intel Open Source License 
00008  * 
00009  * Copyright (c) 2004 Intel Corporation. All rights reserved. 
00010  * 
00011  * Redistribution and use in source and binary forms, with or without
00012  * modification, are permitted provided that the following conditions are
00013  * met:
00014  * 
00015  *   Redistributions of source code must retain the above copyright
00016  *   notice, this list of conditions and the following disclaimer.
00017  * 
00018  *   Redistributions in binary form must reproduce the above copyright
00019  *   notice, this list of conditions and the following disclaimer in the
00020  *   documentation and/or other materials provided with the distribution.
00021  * 
00022  *   Neither the name of the Intel Corporation nor the names of its
00023  *   contributors may be used to endorse or promote products derived from
00024  *   this software without specific prior written permission.
00025  *  
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00027  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00028  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00029  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
00030  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00031  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00032  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00033  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00034  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00035  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00036  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037  */
00038 #include <config.h>
00039 #include "ConvergenceLayer.h"
00040 #include "EthConvergenceLayer.h"
00041 #include "FileConvergenceLayer.h"
00042 #include "NullConvergenceLayer.h"
00043 #include "TCPConvergenceLayer.h"
00044 #include "UDPConvergenceLayer.h"
00045 #include "BluetoothConvergenceLayer.h"
00046 
00047 namespace dtn {
00048 
00049 ConvergenceLayer::CLVec ConvergenceLayer::clayers_;
00050 
00051 //----------------------------------------------------------------------
00052 ConvergenceLayer::~ConvergenceLayer()
00053 {
00054 }
00055 
00056 //----------------------------------------------------------------------
00057 void
00058 ConvergenceLayer::add_clayer(ConvergenceLayer* cl)
00059 {
00060     clayers_.push_back(cl);
00061 }
00062     
00063 //----------------------------------------------------------------------
00064 void
00065 ConvergenceLayer::init_clayers()
00066 {
00067     add_clayer(new NullConvergenceLayer());
00068     add_clayer(new TCPConvergenceLayer());
00069     add_clayer(new UDPConvergenceLayer());
00070 #ifdef __linux__
00071     add_clayer(new EthConvergenceLayer());
00072 #endif
00073 #ifdef OASYS_BLUETOOTH_ENABLED
00074     add_clayer(new BluetoothConvergenceLayer());
00075 #endif
00076     // XXX/demmer fixme
00077     // add_clayer("file", new FileConvergenceLayer());
00078 }
00079 
00080 //----------------------------------------------------------------------
00081 ConvergenceLayer*
00082 ConvergenceLayer::find_clayer(const char* name)
00083 {
00084     CLVec::iterator iter;
00085     for (iter = clayers_.begin(); iter != clayers_.end(); ++iter)
00086     {
00087         if (strcasecmp(name, (*iter)->name()) == 0) {
00088             return *iter;
00089         }
00090     }
00091 
00092     return NULL;
00093 }
00094 
00095 //----------------------------------------------------------------------
00096 bool
00097 ConvergenceLayer::set_interface_defaults(int argc, const char* argv[],
00098                                          const char** invalidp)
00099 {
00100     if (argc == 0) {
00101         return true;
00102     } else {
00103         invalidp = &argv[0];
00104         return false;
00105     }
00106 }
00107 
00108 //----------------------------------------------------------------------
00109 bool
00110 ConvergenceLayer::set_link_defaults(int argc, const char* argv[],
00111                                     const char** invalidp)
00112 {
00113     if (argc == 0) {
00114         return true;
00115     } else {
00116         invalidp = &argv[0];
00117         return false;
00118     }
00119 }
00120 
00121 //----------------------------------------------------------------------
00122 bool
00123 ConvergenceLayer::interface_up(Interface* iface,
00124                                int argc, const char* argv[])
00125 {
00126     (void)iface;
00127     (void)argc;
00128     (void)argv;
00129     log_debug("init interface %s", iface->name().c_str());
00130     return true;
00131 }
00132 
00133 //----------------------------------------------------------------------
00134 bool
00135 ConvergenceLayer::interface_down(Interface* iface)
00136 {
00137     (void)iface;
00138     log_debug("stopping interface %s", iface->name().c_str());
00139     return true;
00140 }
00141 
00142 //----------------------------------------------------------------------
00143 void
00144 ConvergenceLayer::dump_interface(Interface* iface, oasys::StringBuffer* buf)
00145 {
00146     (void)iface;
00147     (void)buf;
00148 }
00149 
00150 //----------------------------------------------------------------------
00151 bool
00152 ConvergenceLayer::init_link(Link* link, int argc, const char* argv[])
00153 {
00154     (void)link;
00155     (void)argc;
00156     (void)argv;
00157     log_debug("init link %s", link->nexthop());
00158     return true;
00159 }
00160 
00161 //----------------------------------------------------------------------
00162 void
00163 ConvergenceLayer::dump_link(Link* link, oasys::StringBuffer* buf)
00164 {
00165     (void)link;
00166     (void)buf;
00167 }
00168 
00169 //----------------------------------------------------------------------
00170 bool
00171 ConvergenceLayer::reconfigure_link(Link* link, int argc, const char* argv[])
00172 {
00173     (void)link;
00174     (void)argv;
00175     return (argc == 0);
00176 }
00177 
00178 //----------------------------------------------------------------------
00179 bool
00180 ConvergenceLayer::close_contact(const ContactRef& contact)
00181 {
00182     (void)contact;
00183     log_debug("closing contact *%p", contact.object());
00184     return true;
00185 }
00186 
00187 } // namespace dtn

Generated on Fri Dec 22 14:47:58 2006 for DTN Reference Implementation by  doxygen 1.5.1