00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifdef HAVE_CONFIG_H
00018 # include <dtn-config.h>
00019 #endif
00020
00021 #include "ConvergenceLayer.h"
00022 #include "BluetoothConvergenceLayer.h"
00023 #include "EthConvergenceLayer.h"
00024 #include "FileConvergenceLayer.h"
00025 #include "NullConvergenceLayer.h"
00026 #include "SerialConvergenceLayer.h"
00027 #include "TCPConvergenceLayer.h"
00028 #include "UDPConvergenceLayer.h"
00029
00030 #include "bundling/BundleDaemon.h"
00031
00032 namespace dtn {
00033
00034 template<>
00035 CLVector* oasys::Singleton<CLVector>::instance_ = NULL;
00036
00037
00038 ConvergenceLayer::~ConvergenceLayer()
00039 {
00040 }
00041
00042
00043 void
00044 ConvergenceLayer::add_clayer(ConvergenceLayer* cl)
00045 {
00046 CLVector::instance()->push_back(cl);
00047 }
00048
00049
00050 void
00051 ConvergenceLayer::init_clayers()
00052 {
00053 add_clayer(new NullConvergenceLayer());
00054 add_clayer(new SerialConvergenceLayer());
00055 add_clayer(new TCPConvergenceLayer());
00056 add_clayer(new UDPConvergenceLayer());
00057 #ifdef __linux__
00058 add_clayer(new EthConvergenceLayer());
00059 #endif
00060 #ifdef OASYS_BLUETOOTH_ENABLED
00061 add_clayer(new BluetoothConvergenceLayer());
00062 #endif
00063
00064
00065 }
00066
00067
00068 CLVector::~CLVector()
00069 {
00070 while (!empty()) {
00071 delete back();
00072 pop_back();
00073 }
00074 }
00075
00076
00077 ConvergenceLayer*
00078 ConvergenceLayer::find_clayer(const char* name)
00079 {
00080 CLVector::iterator iter;
00081 for (iter = CLVector::instance()->begin();
00082 iter != CLVector::instance()->end();
00083 ++iter)
00084 {
00085 if (strcasecmp(name, (*iter)->name()) == 0) {
00086 return *iter;
00087 }
00088 }
00089
00090 return NULL;
00091 }
00092
00093
00094 void
00095 ConvergenceLayer::shutdown_clayers()
00096 {
00097 CLVector::iterator iter;
00098 for (iter = CLVector::instance()->begin();
00099 iter != CLVector::instance()->end();
00100 ++iter)
00101 {
00102 (*iter)->shutdown();
00103 }
00104 }
00105
00106
00107 bool
00108 ConvergenceLayer::set_cla_parameters(AttributeVector ¶ms)
00109 {
00110 (void)params;
00111 log_debug("set cla parameters");
00112 BundleDaemon::post(new CLAParamsSetEvent(this, ""));
00113 return true;
00114 }
00115
00116
00117 bool
00118 ConvergenceLayer::set_interface_defaults(int argc, const char* argv[],
00119 const char** invalidp)
00120 {
00121 if (argc == 0) {
00122 return true;
00123 } else {
00124 invalidp = &argv[0];
00125 return false;
00126 }
00127 }
00128
00129
00130 bool
00131 ConvergenceLayer::set_link_defaults(int argc, const char* argv[],
00132 const char** invalidp)
00133 {
00134 if (argc == 0) {
00135 return true;
00136 } else {
00137 invalidp = &argv[0];
00138 return false;
00139 }
00140 }
00141
00142
00143 bool
00144 ConvergenceLayer::interface_up(Interface* iface,
00145 int argc, const char* argv[])
00146 {
00147 (void)iface;
00148 (void)argc;
00149 (void)argv;
00150 log_debug("init interface %s", iface->name().c_str());
00151 return true;
00152 }
00153
00154
00155 bool
00156 ConvergenceLayer::interface_down(Interface* iface)
00157 {
00158 (void)iface;
00159 log_debug("stopping interface %s", iface->name().c_str());
00160 return true;
00161 }
00162
00163
00164 void
00165 ConvergenceLayer::dump_interface(Interface* iface, oasys::StringBuffer* buf)
00166 {
00167 (void)iface;
00168 (void)buf;
00169 }
00170
00171
00172 bool
00173 ConvergenceLayer::init_link(const LinkRef& link, int argc, const char* argv[])
00174 {
00175 (void)link;
00176 (void)argc;
00177 (void)argv;
00178 log_debug("init link %s", link->nexthop());
00179 return true;
00180 }
00181
00182
00183 void
00184 ConvergenceLayer::delete_link(const LinkRef& link)
00185 {
00186 ASSERT(link != NULL);
00187 ASSERT(!link->isdeleted());
00188 log_debug("ConvergenceLayer::delete_link: link %s deleted", link->name());
00189 }
00190
00191
00192 void
00193 ConvergenceLayer::dump_link(const LinkRef& link, oasys::StringBuffer* buf)
00194 {
00195 (void)link;
00196 (void)buf;
00197 }
00198
00199
00200 bool
00201 ConvergenceLayer::reconfigure_link(const LinkRef& link,
00202 int argc, const char* argv[])
00203 {
00204 (void)link;
00205 (void)argv;
00206 return (argc == 0);
00207 }
00208
00209
00210 void
00211 ConvergenceLayer::reconfigure_link(const LinkRef& link,
00212 AttributeVector& params)
00213 {
00214 (void)link;
00215 (void)params;
00216 log_debug("reconfigure link %s", link->name());
00217 }
00218
00219
00220 bool
00221 ConvergenceLayer::close_contact(const ContactRef& contact)
00222 {
00223 (void)contact;
00224 log_debug("closing contact *%p", contact.object());
00225 return true;
00226 }
00227
00228
00229 void
00230 ConvergenceLayer::cancel_bundle(const LinkRef& link, const BundleRef& bundle)
00231 {
00232 (void)link;
00233 (void)bundle;
00234 }
00235
00236
00237 void
00238 ConvergenceLayer::is_eid_reachable(const std::string& query_id,
00239 Interface* iface,
00240 const std::string& endpoint)
00241 {
00242 (void)iface;
00243 (void)endpoint;
00244
00245 BundleDaemon::post(new EIDReachableReportEvent(query_id, false));
00246 }
00247
00248
00249 void
00250 ConvergenceLayer::query_link_attributes(const std::string& query_id,
00251 const LinkRef& link,
00252 const AttributeNameVector& attributes)
00253 {
00254 (void)attributes;
00255
00256 ASSERT(link != NULL);
00257 if (link->isdeleted()) {
00258 log_debug("ConvergenceLayer::query_link_attributes: "
00259 "link %s already deleted", link->name());
00260 return;
00261 }
00262
00263 AttributeVector attrib_values;
00264 BundleDaemon::post(new LinkAttributesReportEvent(query_id, attrib_values));
00265 }
00266
00267
00268 void
00269 ConvergenceLayer::query_iface_attributes(const std::string& query_id,
00270 Interface* iface,
00271 const AttributeNameVector& attributes)
00272 {
00273 (void)iface;
00274 (void)attributes;
00275
00276 AttributeVector attrib_values;
00277 BundleDaemon::post(new IfaceAttributesReportEvent(query_id, attrib_values));
00278 }
00279
00280
00281 void
00282 ConvergenceLayer::query_cla_parameters(const std::string& query_id,
00283 const AttributeNameVector& parameters)
00284 {
00285 (void)parameters;
00286
00287 AttributeVector param_values;
00288 BundleDaemon::post(new CLAParametersReportEvent(query_id, param_values));
00289 }
00290
00291 }