|
1 /* |
|
2 * Copyright 2007 Baylor University |
|
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 _PROPHET_ROUTER_H_ |
|
18 #define _PROPHET_ROUTER_H_ |
|
19 |
|
20 #include "prophet/Alarm.h" |
|
21 #include "prophet/Params.h" |
|
22 #include "prophet/Controller.h" |
|
23 #include "ProphetBundleCore.h" |
|
24 #include "BundleRouter.h" |
|
25 #include <oasys/thread/SpinLock.h> |
|
26 |
|
27 namespace dtn |
|
28 { |
|
29 |
|
30 class ProphetRouter : public BundleRouter |
|
31 { |
|
32 public: |
|
33 typedef prophet::ProphetParams Params; |
|
34 |
|
35 /** |
|
36 * Constructor |
|
37 */ |
|
38 ProphetRouter(); |
|
39 |
|
40 /** |
|
41 * Destructor |
|
42 */ |
|
43 virtual ~ProphetRouter(); |
|
44 |
|
45 /** |
|
46 * Post-constructor initialization routine |
|
47 */ |
|
48 void initialize(); |
|
49 |
|
50 /** |
|
51 * Query the router as to whether initialization is complete |
|
52 */ |
|
53 static bool is_init() { return is_init_; } |
|
54 |
|
55 /** |
|
56 * Write out routing state to StringBuffer |
|
57 */ |
|
58 void get_routing_state(oasys::StringBuffer*); |
|
59 |
|
60 ///@{ Virtual from BundleRouter |
|
61 bool accept_bundle(Bundle*,int*); |
|
62 void handle_event(BundleEvent*); |
|
63 void handle_bundle_received(BundleReceivedEvent*); |
|
64 void handle_bundle_delivered(BundleDeliveredEvent*); |
|
65 void handle_bundle_expired(BundleExpiredEvent*); |
|
66 void handle_bundle_transmitted(BundleTransmittedEvent*); |
|
67 void handle_contact_up(ContactUpEvent*); |
|
68 void handle_contact_down(ContactDownEvent*); |
|
69 void handle_link_available(LinkAvailableEvent*); |
|
70 void shutdown(); |
|
71 ///@} |
|
72 |
|
73 ///@{ Callback methods for handling runtime configuration changes |
|
74 void set_queue_policy(); |
|
75 void set_hello_interval(); |
|
76 void set_max_route(); |
|
77 ///@} |
|
78 |
|
79 /** |
|
80 * Prophet's configuration and default values |
|
81 */ |
|
82 static prophet::ProphetParams params_; |
|
83 |
|
84 protected: |
|
85 |
|
86 ProphetBundleCore* core_; ///< facade interface into BundleDaemon, etc |
|
87 prophet::Controller* oracle_; ///< list of active Prophet peering sessions |
|
88 oasys::SpinLock* lock_; ///< control concurrent access to core_ and oracle_ |
|
89 static bool is_init_; ///< flag to indicate whether initialization has run |
|
90 |
|
91 }; // class ProphetRouter |
|
92 |
|
93 }; // namespace dtn |
|
94 |
|
95 #endif // _PROPHET_ROUTER_H_ |