#include <srcrt.hh>
Inheritance diagram for SrcRtFilter:


Public Member Functions | |
| SrcRtFilter (int argc, char **argv) | |
| void | run () |
| void | recv (Message *msg, handle h) |
Protected Member Functions | |
| handle | setupFilter () |
| Message * | ProcessMessage (Message *msg) |
| void | usage (char *s) |
| void | parseCommandLine (int argc, char **argv) |
Protected Attributes | |
| handle | filter_handle_ |
| SrcRtFilterReceive * | filter_callback_ |
| NR * | dr_ |
| u_int16_t | diffusion_port_ |
| char * | config_file_ |
|
||||||||||||
|
Definition at line 161 of file srcrt.cc. References NR::createNR(), DEBUG_ALWAYS, DiffPrint(), DiffApp::diffusion_port_, DiffApp::dr_, filter_callback_, filter_handle_, DiffApp::parseCommandLine(), and setupFilter().
00162 {
00163 #endif // NS_DIFFUSION
00164
00165 // Create Diffusion Routing class
00166 #ifndef NS_DIFFUSION
00167 parseCommandLine(argc, argv);
00168 dr_ = NR::createNR(diffusion_port_);
00169 #endif // !NS_DIFFUSION
00170
00171 filter_callback_ = new SrcRtFilterReceive(this);
00172
00173 #ifndef NS_DIFFUSION
00174 // Set up the filter
00175 filter_handle_ = setupFilter();
00176 DiffPrint(DEBUG_ALWAYS, "SrcRtFilter filter received handle %ld\n",
00177 filter_handle_);
00178 DiffPrint(DEBUG_ALWAYS, "SrcRtFilter filter initialized !\n");
00179 #endif // !NS_DIFFUSION
00180 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 59 of file diffapp.cc. References DiffApp::config_file_, DEBUG_ALWAYS, DEFAULT_DIFFUSION_PORT, DiffPrint(), DiffApp::diffusion_port_, global_debug_level, optarg, u_int16_t, and DiffApp::usage(). Referenced by GeoRoutingFilter::GeoRoutingFilter(), GradientFilter::GradientFilter(), PingSenderApp::PingSenderApp(), PushSenderApp::PushSenderApp(), and SrcRtFilter().
00060 {
00061 u_int16_t diff_port = DEFAULT_DIFFUSION_PORT;
00062 int debug_level;
00063 int opt;
00064
00065 config_file_ = NULL;
00066 opterr = 0;
00067
00068 while (1){
00069 opt = getopt(argc, argv, "f:hd:p:");
00070 switch (opt){
00071
00072 case 'p':
00073
00074 diff_port = (u_int16_t) atoi(optarg);
00075 if ((diff_port < 1024) || (diff_port >= 65535)){
00076 DiffPrint(DEBUG_ALWAYS, "Error: Diffusion port must be between 1024 and 65535 !\n");
00077 exit(-1);
00078 }
00079
00080 break;
00081
00082 case 'h':
00083
00084 usage(argv[0]);
00085
00086 break;
00087
00088 case 'd':
00089
00090 debug_level = atoi(optarg);
00091
00092 if (debug_level < 1 || debug_level > 10){
00093 DiffPrint(DEBUG_ALWAYS, "Error: Debug level outside range or missing !\n");
00094 usage(argv[0]);
00095 }
00096
00097 global_debug_level = debug_level;
00098
00099 break;
00100
00101 case 'f':
00102
00103 if (!strncasecmp(optarg, "-", 1)){
00104 DiffPrint(DEBUG_ALWAYS, "Error: Parameter missing !\n");
00105 usage(argv[0]);
00106 }
00107
00108 config_file_ = strdup(optarg);
00109
00110 break;
00111
00112 case '?':
00113
00114 DiffPrint(DEBUG_ALWAYS,
00115 "Error: %c isn't a valid option or its parameter is missing !\n", optopt);
00116 usage(argv[0]);
00117
00118 break;
00119
00120 case ':':
00121
00122 DiffPrint(DEBUG_ALWAYS, "Parameter missing !\n");
00123 usage(argv[0]);
00124
00125 break;
00126
00127 }
00128
00129 if (opt == -1)
00130 break;
00131 }
00132
00133 diffusion_port_ = diff_port;
00134 }
|
Here is the call graph for this function:

|
|
Definition at line 73 of file srcrt.cc. References DEBUG_ALWAYS, DiffPrint(), DiffApp::dr_, filter_handle_, NRSimpleAttribute< T >::getVal(), int32_t, len, Message::msg_attr_vec_, Message::next_hop_, NRSimpleAttribute< T >::setVal(), and SourceRouteAttr. Referenced by recv().
00074 {
00075 char *original_route, *new_route, *p;
00076 int len;
00077 int32_t next_hop;
00078 NRSimpleAttribute<char *> *route = NULL;
00079
00080 route = SourceRouteAttr.find(msg->msg_attr_vec_);
00081 if (!route){
00082 DiffPrint(DEBUG_ALWAYS, "Error: Can't find the route attribute !\n");
00083 return msg;
00084 }
00085
00086 original_route = route->getVal();
00087 len = strlen(original_route);
00088
00089 // Check if we are the last hop
00090 if (len == 0)
00091 return msg;
00092
00093 // Get the next hop
00094 next_hop = atoi(original_route);
00095
00096 // Remove last hop from source route
00097 p = strstr(original_route, ":");
00098 if (!p){
00099 // There's just one more hop
00100 new_route = new char[1];
00101 new_route[0] = '\0';
00102 }
00103 else{
00104 p++;
00105 len = strlen(p);
00106 new_route = new char[(len + 1)];
00107 strncpy(new_route, p, (len + 1));
00108 if (new_route[len] != '\0')
00109 DiffPrint(DEBUG_ALWAYS, "Warning: String must end with NULL !\n");
00110 }
00111
00112 route->setVal(new_route);
00113
00114 // Free memory
00115 delete [] new_route;
00116
00117 // Send the packet to the next hop
00118 msg->next_hop_ = next_hop;
00119 ((DiffusionRouting *)dr_)->sendMessage(msg, filter_handle_);
00120
00121 delete msg;
00122
00123 return NULL;
00124 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 55 of file srcrt.cc. References DEBUG_ALWAYS, DiffPrint(), DiffApp::dr_, filter_handle_, and ProcessMessage(). Referenced by SrcRtFilterReceive::recv().
00056 {
00057 Message *return_msg = NULL;
00058
00059 if (h != filter_handle_){
00060 DiffPrint(DEBUG_ALWAYS, "Error: Received a message for handle %ld when subscribing to handle %ld !\n", h, filter_handle_);
00061 return;
00062 }
00063
00064 return_msg = ProcessMessage(msg);
00065
00066 if (return_msg){
00067 ((DiffusionRouting *)dr_)->sendMessage(msg, h);
00068
00069 delete msg;
00070 }
00071 }
|
Here is the call graph for this function:

|
|
Implements DiffApp. Definition at line 141 of file srcrt.cc. References DEBUG_ALWAYS, DiffPrint(), filter_handle_, and setupFilter(). Referenced by main().
00142 {
00143 #ifdef NS_DIFFUSION
00144 filter_handle_ = setupFilter();
00145 DiffPrint(DEBUG_ALWAYS, "SrcRtFilter filter received handle %ld\n",
00146 filter_handle_);
00147 DiffPrint(DEBUG_ALWAYS, "SrcRtFilter filter initialized !\n");
00148 #else
00149 // Doesn't do anything
00150 while (1){
00151 sleep(1000);
00152 }
00153 #endif // NS_DIFFUSION
00154 }
|
Here is the call graph for this function:

|
|
Definition at line 126 of file srcrt.cc. References ClearAttrs(), DiffApp::dr_, NRAttribute::EQ_ANY, filter_callback_, handle, SourceRouteAttr, and SRCRT_FILTER_PRIORITY. Referenced by run(), and SrcRtFilter().
00127 {
00128 NRAttrVec attrs;
00129 handle h;
00130
00131 // Match all packets with a SourceRoute Attribute
00132 attrs.push_back(SourceRouteAttr.make(NRAttribute::EQ_ANY, ""));
00133
00134 h = ((DiffusionRouting *)dr_)->addFilter(&attrs, SRCRT_FILTER_PRIORITY,
00135 filter_callback_);
00136
00137 ClearAttrs(&attrs);
00138 return h;
00139 }
|
Here is the call graph for this function:

|
|
Definition at line 49 of file diffapp.cc. References DEBUG_ALWAYS, and DiffPrint(). Referenced by DiffApp::parseCommandLine().
00049 {
00050 DiffPrint(DEBUG_ALWAYS, "Usage: %s [-d debug] [-p port] [-f file] [-h]\n\n", s);
00051 DiffPrint(DEBUG_ALWAYS, "\t-d - Sets debug level (0-10)\n");
00052 DiffPrint(DEBUG_ALWAYS, "\t-p - Uses port 'port' to talk to diffusion\n");
00053 DiffPrint(DEBUG_ALWAYS, "\t-f - Specifies a config file\n");
00054 DiffPrint(DEBUG_ALWAYS, "\t-h - Prints this information\n");
00055 DiffPrint(DEBUG_ALWAYS, "\n");
00056 exit(0);
00057 }
|
Here is the call graph for this function:

|
|
Definition at line 57 of file diffapp.hh. Referenced by DiffApp::parseCommandLine(). |
|
|
Definition at line 56 of file diffapp.hh. Referenced by GeoRoutingFilter::GeoRoutingFilter(), GradientFilter::GradientFilter(), DiffApp::parseCommandLine(), PingSenderApp::PingSenderApp(), PushSenderApp::PushSenderApp(), and SrcRtFilter(). |
|
|
|
Definition at line 65 of file srcrt.hh. Referenced by setupFilter(), and SrcRtFilter(). |
|
|
Definition at line 62 of file srcrt.hh. Referenced by ProcessMessage(), recv(), run(), and SrcRtFilter(). |
1.3.3