00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #ifndef _MESSAGE_HH_
00062 #define _MESSAGE_HH_
00063
00064 #ifdef HAVE_CONFIG_H
00065 #include "config.h"
00066 #endif // HAVE_CONFIG_H
00067
00068 #include "nr/nr.hh"
00069 #include "header.hh"
00070 #include "attrs.hh"
00071
00072 class Message {
00073 public:
00074
00075 int8_t version_;
00076 int8_t msg_type_;
00077 u_int16_t source_port_;
00078 int16_t data_len_;
00079 int16_t num_attr_;
00080 int32_t pkt_num_;
00081 int32_t rdm_id_;
00082 int32_t next_hop_;
00083 int32_t last_hop_;
00084
00085
00086 int new_message_;
00087 u_int16_t next_port_;
00088
00089
00090 NRAttrVec *msg_attr_vec_;
00091
00092 Message(int8_t version, int8_t msg_type, u_int16_t source_port,
00093 u_int16_t data_len, u_int16_t num_attr, int32_t pkt_num,
00094 int32_t rdm_id, int32_t next_hop, int32_t last_hop) :
00095 version_(version),
00096 msg_type_(msg_type),
00097 source_port_(source_port),
00098 data_len_(data_len),
00099 num_attr_(num_attr),
00100 pkt_num_(pkt_num),
00101 rdm_id_(rdm_id),
00102 next_hop_(next_hop),
00103 last_hop_(last_hop)
00104 {
00105 msg_attr_vec_ = NULL;
00106 next_port_ = 0;
00107 new_message_ = 1;
00108
00109 }
00110
00111 ~Message()
00112 {
00113 if (msg_attr_vec_){
00114 ClearAttrs(msg_attr_vec_);
00115 delete msg_attr_vec_;
00116 }
00117 }
00118 };
00119
00120 extern NRSimpleAttributeFactory<void *> ControlMsgAttr;
00121 extern NRSimpleAttributeFactory<void *> OriginalHdrAttr;
00122
00123 #define CONTROL_MESSAGE_KEY 1400
00124 #define ORIGINAL_HEADER_KEY 1401
00125
00126
00127 typedef enum ctl_t_ {
00128 ADD_UPDATE_FILTER,
00129 REMOVE_FILTER,
00130 SEND_MESSAGE,
00131 ADD_TO_BLACKLIST,
00132 CLEAR_BLACKLIST
00133 } ctl_t;
00134
00135 class ControlMessage {
00136 public:
00137
00138 ControlMessage(int32_t command, int32_t param1, int32_t param2) :
00139 command_(command), param1_(param1), param2_(param2) {};
00140
00141 int32_t command_;
00142 int32_t param1_;
00143 int32_t param2_;
00144 };
00145
00146 class RedirectMessage {
00147 public:
00148
00149 RedirectMessage(int8_t new_message, int8_t msg_type, u_int16_t source_port,
00150 u_int16_t data_len, u_int16_t num_attr, int32_t rdm_id,
00151 int32_t pkt_num, int32_t next_hop, int32_t last_hop,
00152 int32_t handle, u_int16_t next_port) :
00153 new_message_(new_message), msg_type_(msg_type), source_port_(source_port),
00154 data_len_(data_len), num_attr_(num_attr), rdm_id_(rdm_id),
00155 pkt_num_(pkt_num), next_hop_(next_hop), last_hop_(last_hop),
00156 handle_(handle), next_port_(next_port) {};
00157
00158 int8_t new_message_;
00159 int8_t msg_type_;
00160 u_int16_t source_port_;
00161 u_int16_t data_len_;
00162 u_int16_t num_attr_;
00163 int32_t rdm_id_;
00164 int32_t pkt_num_;
00165 int32_t next_hop_;
00166 int32_t last_hop_;
00167 int32_t handle_;
00168 u_int16_t next_port_;
00169 };
00170
00171 Message * CopyMessage(Message *msg);
00172
00173 #endif // !_MESSAGE_HH_