ConvergenceLayer.h

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 #ifndef _CONVERGENCE_LAYER_H_
00039 #define _CONVERGENCE_LAYER_H_
00040 
00041 #include <string>
00042 #include <vector>
00043 
00044 #include "contacts/Contact.h"
00045 #include "contacts/Interface.h"
00046 
00047 // forward declaration
00048 namespace oasys {
00049 class StringBuffer;
00050 }
00051 
00052 namespace dtn {
00053 
00057 class ConvergenceLayer : public oasys::Logger {
00058 public:
00062     ConvergenceLayer(const char* classname,
00063                      const char* name)
00064         : Logger(classname, "/dtn/cl/%s", name),
00065           name_(name)
00066     {
00067     }
00068 
00072     virtual ~ConvergenceLayer();
00073 
00077     virtual bool set_interface_defaults(int argc, const char* argv[],
00078                                         const char** invalidp);
00079     
00083     virtual bool set_link_defaults(int argc, const char* argv[],
00084                                    const char** invalidp);
00085     
00089     virtual bool interface_up(Interface* iface,
00090                               int argc, const char* argv[]);
00091 
00095     virtual bool interface_down(Interface* iface);
00096 
00100     virtual void dump_interface(Interface* iface, oasys::StringBuffer* buf);
00101 
00105     virtual bool init_link(Link* link, int argc, const char* argv[]);
00106 
00110     virtual void dump_link(Link* link, oasys::StringBuffer* buf);
00111 
00115     virtual bool reconfigure_link(Link* link, int argc, const char* argv[]);
00116 
00123     virtual bool open_contact(const ContactRef& contact) = 0;
00124     
00136     virtual bool close_contact(const ContactRef& contact);
00137 
00146     virtual void send_bundle(const ContactRef& contact, Bundle* bundle) = 0;
00147     
00151     virtual bool cancel_bundle(const ContactRef& contact, Bundle* bundle)
00152     {
00153         (void)contact;
00154         (void)bundle;
00155         return false;
00156     }
00157     
00162     virtual bool is_queued(const ContactRef& contact, Bundle* bundle)
00163     {
00164         (void)contact;
00165         (void)bundle;
00166         return false;
00167     }
00168     
00173     static void init_clayers();
00174     static void add_clayer(ConvergenceLayer* cl);
00175     
00180     static ConvergenceLayer* find_clayer(const char* proto);
00181 
00185     const char* name() { return name_; }
00186     
00190     static const u_int32_t MAGIC = 0x64746e21; //'DTN!'
00191     
00192 protected:
00196     const char* name_;
00197 
00202     typedef std::vector<ConvergenceLayer*> CLVec;
00203     static CLVec clayers_;
00204 };
00205 
00210 class CLInfo {
00211 public:
00212     virtual ~CLInfo() {}
00213 };
00214 
00215 } // namespace dtn
00216 
00217 #endif /* _CONVERGENCE_LAYER_H_ */

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