|
1 /* |
|
2 * Copyright 2005-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 #ifndef _BUNDLE_ACTIONS_H_ |
|
18 #define _BUNDLE_ACTIONS_H_ |
|
19 |
|
20 #include <vector> |
|
21 #include <oasys/debug/Log.h> |
|
22 #include "ForwardingInfo.h" |
|
23 #include "BundleProtocol.h" |
|
24 #include "contacts/Link.h" |
|
25 |
|
26 namespace dtn { |
|
27 |
|
28 class Bundle; |
|
29 class BundleList; |
|
30 class CustodyTimerSpec; |
|
31 class EndpointID; |
|
32 class Interface; |
|
33 |
|
34 /** |
|
35 * Intermediary class that provides a utility interface to help |
|
36 * routers more easily deal with the rest of the system. |
|
37 */ |
|
38 class BundleActions : public oasys::Logger { |
|
39 public: |
|
40 BundleActions() : Logger("BundleActions", "/dtn/bundle/actions") {} |
|
41 virtual ~BundleActions() {} |
|
42 |
|
43 /** |
|
44 * Open a link for bundle transmission. The link should be in |
|
45 * state AVAILABLE for this to be called. |
|
46 * |
|
47 * This may either immediately open the link in which case the |
|
48 * link's state will be OPEN, or post a request for the |
|
49 * convergence layer to complete the session initiation in which |
|
50 * case the link state is OPENING. |
|
51 */ |
|
52 virtual void open_link(const LinkRef& link); |
|
53 |
|
54 /** |
|
55 * Open a link for bundle transmission. The link should be in an |
|
56 * open state for this to be called. |
|
57 */ |
|
58 virtual void close_link(const LinkRef& link); |
|
59 |
|
60 /** |
|
61 * Queue the bundle for transmission on the given link. |
|
62 * |
|
63 * @param bundle the bundle |
|
64 * @param link the link on which to send the bundle |
|
65 * @param action the forwarding action that was taken, |
|
66 * recorded in the log |
|
67 * @param custody_timer custody timer specification |
|
68 * |
|
69 * @return true if the transmission was successfully initiated |
|
70 */ |
|
71 virtual bool queue_bundle(Bundle* bundle, const LinkRef& link, |
|
72 ForwardingInfo::action_t action, |
|
73 const CustodyTimerSpec& custody_timer); |
|
74 |
|
75 /** |
|
76 * Attempt to cancel transmission of a bundle on the given link. |
|
77 * |
|
78 * @param bundle the bundle |
|
79 * @param link the link on which the bundle was queued |
|
80 * |
|
81 * @return true if successful |
|
82 */ |
|
83 virtual void cancel_bundle(Bundle* bundle, const LinkRef& link); |
|
84 |
|
85 /** |
|
86 * Inject a new bundle into the core system, which places it in |
|
87 * the pending bundles list as well as in the persistent store. |
|
88 * This is typically used by routing algorithms that need to |
|
89 * generate their own bundles for distribuing route announcements. |
|
90 * It does not, therefore, generate a BundleReceivedEvent. |
|
91 * |
|
92 * @param bundle the new bundle |
|
93 */ |
|
94 virtual void inject_bundle(Bundle* bundle); |
|
95 |
|
96 /** |
|
97 * Attempt to delete a bundle from the system. |
|
98 * |
|
99 * @param bundle The bundle |
|
100 * @param reason Bundle Status Report reason code |
|
101 * @param log_on_error Set to false to suppress error logging |
|
102 * |
|
103 * @return true if successful |
|
104 */ |
|
105 virtual bool delete_bundle(Bundle* bundle, |
|
106 BundleProtocol::status_report_reason_t |
|
107 reason = BundleProtocol::REASON_NO_ADDTL_INFO, |
|
108 bool log_on_error = true); |
|
109 |
|
110 protected: |
|
111 // The protected functions (exposed only to the BundleDaemon) and |
|
112 // serve solely for the simulator abstraction |
|
113 friend class BundleDaemon; |
|
114 |
|
115 /** |
|
116 * Add the given bundle to the data store. |
|
117 */ |
|
118 virtual void store_add(Bundle* bundle); |
|
119 |
|
120 /** |
|
121 * Update the on-disk version of the given bundle, after it's |
|
122 * bookkeeping or header fields have been modified. |
|
123 */ |
|
124 virtual void store_update(Bundle* bundle); |
|
125 |
|
126 /** |
|
127 * Remove the given bundle from the data store. |
|
128 */ |
|
129 virtual void store_del(Bundle* bundle); |
|
130 }; |
|
131 |
|
132 } // namespace dtn |
|
133 |
|
134 #endif /* _BUNDLE_ACTIONS_H_ */ |