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 #ifndef _MESSAGE_HH_
00042 #define _MESSAGE_HH_
00043
00044 #ifdef HAVE_CONFIG_H
00045 #include "config.h"
00046 #endif // HAVE_CONFIG_H
00047
00048 #include "nr/nr.hh"
00049 #include "header.hh"
00050 #include "attrs.hh"
00051
00052 class Message {
00053 public:
00054
00055 int8_t version_;
00056 int8_t msg_type_;
00057 u_int16_t source_port_;
00058 int16_t data_len_;
00059 int16_t num_attr_;
00060 int32_t pkt_num_;
00061 int32_t rdm_id_;
00062 int32_t next_hop_;
00063 int32_t last_hop_;
00064
00065
00066 int new_message_;
00067 u_int16_t next_port_;
00068
00069
00070 NRAttrVec *msg_attr_vec_;
00071
00072 Message(int8_t version, int8_t msg_type, u_int16_t source_port,
00073 u_int16_t data_len, u_int16_t num_attr, int32_t pkt_num,
00074 int32_t rdm_id, int32_t next_hop, int32_t last_hop) :
00075 version_(version),
00076 msg_type_(msg_type),
00077 source_port_(source_port),
00078 data_len_(data_len),
00079 num_attr_(num_attr),
00080 pkt_num_(pkt_num),
00081 rdm_id_(rdm_id),
00082 next_hop_(next_hop),
00083 last_hop_(last_hop)
00084 {
00085 msg_attr_vec_ = NULL;
00086 next_port_ = 0;
00087 new_message_ = 1;
00088
00089 }
00090
00091 ~Message()
00092 {
00093 if (msg_attr_vec_){
00094 ClearAttrs(msg_attr_vec_);
00095 delete msg_attr_vec_;
00096 }
00097 }
00098 };
00099
00100 extern NRSimpleAttributeFactory<void *> ControlMsgAttr;
00101 extern NRSimpleAttributeFactory<void *> OriginalHdrAttr;
00102
00103 #define CONTROL_MESSAGE_KEY 1400
00104 #define ORIGINAL_HEADER_KEY 1401
00105
00106
00107 typedef enum ctl_t_ {
00108 ADD_UPDATE_FILTER,
00109 REMOVE_FILTER,
00110 SEND_MESSAGE
00111 } ctl_t;
00112
00113 class ControlMessage {
00114 public:
00115
00116 ControlMessage(int32_t command, int32_t param1, int32_t param2) :
00117 command_(command), param1_(param1), param2_(param2) {};
00118
00119 int32_t command_;
00120 int32_t param1_;
00121 int32_t param2_;
00122 };
00123
00124 class RedirectMessage {
00125 public:
00126
00127 RedirectMessage(int8_t new_message, int8_t msg_type, u_int16_t source_port,
00128 u_int16_t data_len, u_int16_t num_attr, int32_t rdm_id,
00129 int32_t pkt_num, int32_t next_hop, int32_t last_hop,
00130 int32_t handle, u_int16_t next_port) :
00131 new_message_(new_message), msg_type_(msg_type), source_port_(source_port),
00132 data_len_(data_len), num_attr_(num_attr), rdm_id_(rdm_id),
00133 pkt_num_(pkt_num), next_hop_(next_hop), last_hop_(last_hop),
00134 handle_(handle), next_port_(next_port) {};
00135
00136 int8_t new_message_;
00137 int8_t msg_type_;
00138 u_int16_t source_port_;
00139 u_int16_t data_len_;
00140 u_int16_t num_attr_;
00141 int32_t rdm_id_;
00142 int32_t pkt_num_;
00143 int32_t next_hop_;
00144 int32_t last_hop_;
00145 int32_t handle_;
00146 u_int16_t next_port_;
00147 };
00148
00149 Message * CopyMessage(Message *msg);
00150
00151 #endif // !_MESSAGE_HH_