|
1 /* |
|
2 * Copyright 2004-2006 Intel Corporation |
|
3 * |
|
4 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 * you may not use this file except in compliance with the License. |
|
6 * You may obtain a copy of the License at |
|
7 * |
|
8 * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 * |
|
10 * Unless required by applicable law or agreed to in writing, software |
|
11 * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 * See the License for the specific language governing permissions and |
|
14 * limitations under the License. |
|
15 */ |
|
16 |
|
17 #ifdef HAVE_CONFIG_H |
|
18 # include <dtn-config.h> |
|
19 #endif |
|
20 |
|
21 #include "ConvergenceLayer.h" |
|
22 #include "BluetoothConvergenceLayer.h" |
|
23 #include "EthConvergenceLayer.h" |
|
24 #include "FileConvergenceLayer.h" |
|
25 #include "NullConvergenceLayer.h" |
|
26 #include "SerialConvergenceLayer.h" |
|
27 #include "TCPConvergenceLayer.h" |
|
28 #include "UDPConvergenceLayer.h" |
|
29 #include "NORMConvergenceLayer.h" |
|
30 #include "LTPConvergenceLayer.h" |
|
31 #include "AX25CMConvergenceLayer.h" |
|
32 |
|
33 #include "bundling/BundleDaemon.h" |
|
34 |
|
35 namespace dtn { |
|
36 |
|
37 template<> |
|
38 CLVector* oasys::Singleton<CLVector>::instance_ = NULL; |
|
39 |
|
40 //---------------------------------------------------------------------- |
|
41 ConvergenceLayer::~ConvergenceLayer() |
|
42 { |
|
43 } |
|
44 |
|
45 //---------------------------------------------------------------------- |
|
46 void |
|
47 ConvergenceLayer::add_clayer(ConvergenceLayer* cl) |
|
48 { |
|
49 CLVector::instance()->push_back(cl); |
|
50 } |
|
51 |
|
52 //---------------------------------------------------------------------- |
|
53 void |
|
54 ConvergenceLayer::init_clayers() |
|
55 { |
|
56 add_clayer(new NullConvergenceLayer()); |
|
57 add_clayer(new SerialConvergenceLayer()); |
|
58 add_clayer(new TCPConvergenceLayer()); |
|
59 add_clayer(new UDPConvergenceLayer()); |
|
60 #ifdef __linux__ |
|
61 add_clayer(new EthConvergenceLayer()); |
|
62 #endif |
|
63 #ifdef OASYS_BLUETOOTH_ENABLED |
|
64 add_clayer(new BluetoothConvergenceLayer()); |
|
65 #endif |
|
66 #ifdef NORM_ENABLED |
|
67 add_clayer(new NORMConvergenceLayer()); |
|
68 #endif |
|
69 #ifdef LTP_ENABLED |
|
70 add_clayer(new LTPConvergenceLayer()); |
|
71 #endif |
|
72 #ifdef OASYS_AX25_ENABLED |
|
73 add_clayer(new AX25CMConvergenceLayer()); |
|
74 #endif |
|
75 // XXX/demmer fixme |
|
76 //add_clayer("file", new FileConvergenceLayer()); |
|
77 } |
|
78 //---------------------------------------------------------------------- |
|
79 CLVector::~CLVector() |
|
80 { |
|
81 while (!empty()) { |
|
82 delete back(); |
|
83 pop_back(); |
|
84 } |
|
85 } |
|
86 |
|
87 //---------------------------------------------------------------------- |
|
88 ConvergenceLayer* |
|
89 ConvergenceLayer::find_clayer(const char* name) |
|
90 { |
|
91 CLVector::iterator iter; |
|
92 for (iter = CLVector::instance()->begin(); |
|
93 iter != CLVector::instance()->end(); |
|
94 ++iter) |
|
95 { |
|
96 if (strcasecmp(name, (*iter)->name()) == 0) { |
|
97 return *iter; |
|
98 } |
|
99 } |
|
100 |
|
101 return NULL; |
|
102 } |
|
103 |
|
104 //---------------------------------------------------------------------- |
|
105 void |
|
106 ConvergenceLayer::shutdown_clayers() |
|
107 { |
|
108 CLVector::iterator iter; |
|
109 for (iter = CLVector::instance()->begin(); |
|
110 iter != CLVector::instance()->end(); |
|
111 ++iter) |
|
112 { |
|
113 (*iter)->shutdown(); |
|
114 } |
|
115 } |
|
116 |
|
117 //---------------------------------------------------------------------- |
|
118 bool |
|
119 ConvergenceLayer::set_cla_parameters(AttributeVector ¶ms) |
|
120 { |
|
121 (void)params; |
|
122 log_debug("set cla parameters"); |
|
123 BundleDaemon::post(new CLAParamsSetEvent(this, "")); |
|
124 return true; |
|
125 } |
|
126 |
|
127 //---------------------------------------------------------------------- |
|
128 bool |
|
129 ConvergenceLayer::set_interface_defaults(int argc, const char* argv[], |
|
130 const char** invalidp) |
|
131 { |
|
132 if (argc == 0) { |
|
133 return true; |
|
134 } else { |
|
135 invalidp = &argv[0]; |
|
136 return false; |
|
137 } |
|
138 } |
|
139 |
|
140 //---------------------------------------------------------------------- |
|
141 bool |
|
142 ConvergenceLayer::set_link_defaults(int argc, const char* argv[], |
|
143 const char** invalidp) |
|
144 { |
|
145 if (argc == 0) { |
|
146 return true; |
|
147 } else { |
|
148 invalidp = &argv[0]; |
|
149 return false; |
|
150 } |
|
151 } |
|
152 |
|
153 //---------------------------------------------------------------------- |
|
154 bool |
|
155 ConvergenceLayer::interface_up(Interface* iface, |
|
156 int argc, const char* argv[]) |
|
157 { |
|
158 (void)iface; |
|
159 (void)argc; |
|
160 (void)argv; |
|
161 log_debug("init interface %s", iface->name().c_str()); |
|
162 return true; |
|
163 } |
|
164 |
|
165 //---------------------------------------------------------------------- |
|
166 bool |
|
167 ConvergenceLayer::interface_down(Interface* iface) |
|
168 { |
|
169 (void)iface; |
|
170 log_debug("stopping interface %s", iface->name().c_str()); |
|
171 return true; |
|
172 } |
|
173 |
|
174 //---------------------------------------------------------------------- |
|
175 void |
|
176 ConvergenceLayer::dump_interface(Interface* iface, oasys::StringBuffer* buf) |
|
177 { |
|
178 (void)iface; |
|
179 (void)buf; |
|
180 } |
|
181 |
|
182 //---------------------------------------------------------------------- |
|
183 bool |
|
184 ConvergenceLayer::init_link(const LinkRef& link, int argc, const char* argv[]) |
|
185 { |
|
186 (void)link; |
|
187 (void)argc; |
|
188 (void)argv; |
|
189 log_debug("init link %s", link->nexthop()); |
|
190 return true; |
|
191 } |
|
192 |
|
193 //---------------------------------------------------------------------- |
|
194 void |
|
195 ConvergenceLayer::delete_link(const LinkRef& link) |
|
196 { |
|
197 ASSERT(link != NULL); |
|
198 ASSERT(!link->isdeleted()); |
|
199 log_debug("ConvergenceLayer::delete_link: link %s deleted", link->name()); |
|
200 } |
|
201 |
|
202 //---------------------------------------------------------------------- |
|
203 void |
|
204 ConvergenceLayer::dump_link(const LinkRef& link, oasys::StringBuffer* buf) |
|
205 { |
|
206 (void)link; |
|
207 (void)buf; |
|
208 } |
|
209 |
|
210 //---------------------------------------------------------------------- |
|
211 bool |
|
212 ConvergenceLayer::reconfigure_link(const LinkRef& link, |
|
213 int argc, const char* argv[]) |
|
214 { |
|
215 (void)link; |
|
216 (void)argv; |
|
217 return (argc == 0); |
|
218 } |
|
219 |
|
220 //---------------------------------------------------------------------- |
|
221 void |
|
222 ConvergenceLayer::reconfigure_link(const LinkRef& link, |
|
223 AttributeVector& params) |
|
224 { |
|
225 (void)link; |
|
226 (void)params; |
|
227 log_debug("reconfigure link %s", link->name()); |
|
228 } |
|
229 |
|
230 //---------------------------------------------------------------------- |
|
231 bool |
|
232 ConvergenceLayer::close_contact(const ContactRef& contact) |
|
233 { |
|
234 (void)contact; |
|
235 log_debug("closing contact *%p", contact.object()); |
|
236 return true; |
|
237 } |
|
238 |
|
239 //---------------------------------------------------------------------- |
|
240 void |
|
241 ConvergenceLayer::cancel_bundle(const LinkRef& link, const BundleRef& bundle) |
|
242 { |
|
243 (void)link; |
|
244 (void)bundle; |
|
245 } |
|
246 |
|
247 //---------------------------------------------------------------------- |
|
248 void |
|
249 ConvergenceLayer::is_eid_reachable(const std::string& query_id, |
|
250 Interface* iface, |
|
251 const std::string& endpoint) |
|
252 { |
|
253 (void)iface; |
|
254 (void)endpoint; |
|
255 |
|
256 BundleDaemon::post(new EIDReachableReportEvent(query_id, false)); |
|
257 } |
|
258 |
|
259 //---------------------------------------------------------------------- |
|
260 void |
|
261 ConvergenceLayer::query_link_attributes(const std::string& query_id, |
|
262 const LinkRef& link, |
|
263 const AttributeNameVector& attributes) |
|
264 { |
|
265 (void)attributes; |
|
266 |
|
267 ASSERT(link != NULL); |
|
268 if (link->isdeleted()) { |
|
269 log_debug("ConvergenceLayer::query_link_attributes: " |
|
270 "link %s already deleted", link->name()); |
|
271 return; |
|
272 } |
|
273 |
|
274 AttributeVector attrib_values; |
|
275 BundleDaemon::post(new LinkAttributesReportEvent(query_id, attrib_values)); |
|
276 } |
|
277 |
|
278 //---------------------------------------------------------------------- |
|
279 void |
|
280 ConvergenceLayer::query_iface_attributes(const std::string& query_id, |
|
281 Interface* iface, |
|
282 const AttributeNameVector& attributes) |
|
283 { |
|
284 (void)iface; |
|
285 (void)attributes; |
|
286 |
|
287 AttributeVector attrib_values; |
|
288 BundleDaemon::post(new IfaceAttributesReportEvent(query_id, attrib_values)); |
|
289 } |
|
290 |
|
291 //---------------------------------------------------------------------- |
|
292 void |
|
293 ConvergenceLayer::query_cla_parameters(const std::string& query_id, |
|
294 const AttributeNameVector& parameters) |
|
295 { |
|
296 (void)parameters; |
|
297 |
|
298 AttributeVector param_values; |
|
299 BundleDaemon::post(new CLAParametersReportEvent(query_id, param_values)); |
|
300 } |
|
301 |
|
302 } // namespace dtn |