OSDN Git Service

ソースツリー再構成中(ほぼOK?)
[ultramonkey-l7/ultramonkey-l7-v3.git] / snmpagent / message.h
1 //
2 //!     @file   massage.h
3 //!     @brief  snmpagent - l7vsd message header
4 //
5 //      copyright(c) sdy corporation.2008
6 //      mail: h.okada at sdy.co.jp
7 //      Copyright (c) 2008 norihisa nakai (n dot nakai at sdy dot co do jp)
8 //
9 //      Distributed under the Boost Software License, Version 1.0. (See accompanying
10 //      file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 //
12
13 #ifndef MESSAGE_H
14 #define MESSAGE_H
15
16 #define PADDINGSIZE             (1)
17
18 #define OIDDATASIZE             (128)   // must 64 multiple number for structure byte offset
19 #define COMMANDDATASIZE         (256)
20 #define TRAPREQUESTMESSAGESIZE  (64)    // must 64 multiple number for structure byte offset
21 #define MIBREQUESTDATASIZE      (64)    // must 64 multiple number for structure byte offset
22 #define L7VS_MODNAME_LEN                (256)   // l7vs.h remove this numeric. define this,
23 #define L7VS_PROTOMOD_OPT_LEN   (512)   // l7vs.h remove this numeric, define this,
24
25 //message id definitions(l7vsd to subagent)
26 #define MESSAGE_ID_COMMANDREQUEST           (0)
27 #define MESSAGE_ID_TRAPREQUEST              (1)
28 #define MESSAGE_ID_MIBCOLLECTRESPONSE_VS    (2)
29 #define MESSAGE_ID_MIBCOLLECTRESPONSE_RS    (3)
30
31 //message id definitions(subagent to l7vsd)
32 #define MESSAGE_ID_MIBCOLLECTREQUEST        (100)
33
34 //setting command definitions
35 #define COMMAND_LOGLEVEL_CHANGE             (0x1)
36 #define COMMAND_SETTINGFILE_RELOAD          (0x2)
37
38 #define MIBDATA_CATEGORY_VS                 (1)
39 #define MIBDATA_CATEGORY_RS                 (2)
40
41 #define MAGIC_NUMBER_LENGTH                 (2)
42 #define MAGIC_MESSAGE_HEADER                "MG" // 0x4D 0x47
43 #define MAGIC_PAYLOAD_HEADER                "PY" // 0x50 0x59
44 #define MAGIC_SETTING_COMMAND               "ST" // 0x53 0x54
45 #define MAGIC_CHANGE_LOGLEVEL               "LL" // 0x4c 0x4c
46 #define MAGIC_TRAP_REQUEST                  "TR" // 0x54 0x52
47 #define MAGIC_VIRTUAL_SERVICE               "VS" // 0x56 0x53
48 #define MAGIC_REAL_SERVER                   "RS" // 0x52 0x53
49 #define MAGIC_MIB_REQUEST                   "RQ" // 0x52 0x51
50
51
52 struct  l7ag_message_header
53 {
54     char                magic[MAGIC_NUMBER_LENGTH]; //! Magic number
55     unsigned long long  version;                    //! Version
56     unsigned long long  time;                       //! Created time
57     unsigned long long  size;                       //! Message size
58     unsigned long long  payload_count;              //! Payload count
59 };
60
61 /*!
62  * 
63  */
64 struct  l7ag_payload_header
65 {
66     char                magic[MAGIC_NUMBER_LENGTH]; //! Magic number
67     unsigned long long  message_id;
68     unsigned long long  payload_datasize;
69 };
70
71 /*
72  * log level setting
73  */
74 struct  l7ag_settingcommand_message
75 {
76     char                magic[MAGIC_NUMBER_LENGTH]; //! Magic number
77     unsigned long long  command_id;                 //! 0 when change log level, 1 when reload config
78     unsigned char       data[COMMANDDATASIZE];      //! command parameter (set category when change log level)
79 };
80
81 /*!
82  * command parameter of change log level
83  */
84 struct  l7ag_changeloglevel_parameter
85 {
86     char                magic[MAGIC_NUMBER_LENGTH]; //! Magic number
87     unsigned long long  log_category;
88     unsigned long long  log_level;
89 };
90
91 /*!
92  * Request message of Trap
93  */
94 struct  l7ag_traprequest_message
95 {
96     char    magic[MAGIC_NUMBER_LENGTH];         //! Magic number
97     char    oid[OIDDATASIZE];                   //! OID (must "1.3.6.1.4.1.60000.1.0.2")
98     char    message[TRAPREQUESTMESSAGESIZE];    //! Errno
99 };
100
101 /*!
102  * Message for collect MIB data (VirtualService)
103  */
104 struct  l7ag_mibdata_payload_vs
105 {
106     char                magic[MAGIC_NUMBER_LENGTH];                     //! Magic number
107     int                 index;                                          //! VirtualService index
108     uint8_t             protocol;                                       //! Protocol
109     uint32_t            ipAddress;                                      //! IP
110     uint16_t            portNumber;                                     //! Port
111     char                scheduleModule[L7VS_MODNAME_LEN];               //! schedule module
112     char                protocolModule[L7VS_MODNAME_LEN];               //! protocol module
113     char                protocolModuleOption[L7VS_PROTOMOD_OPT_LEN];    //! protomod option
114     int                 reschedule;                                     //! reschedule flag
115     uint32_t            sorryIpAddress;                                 //! sorry IP
116     uint16_t            sorryPortNumber;                                //! sorry port
117     int                 sorryThreshold;                                 //! sorry threshold
118     int                 sorryForceFlag;                                 //! sorry flag
119     unsigned long long  QoSThresholdUp;                                 //! QoS Threashold value for up stream
120     unsigned long long  QoSThresholdDown;                               //! QoS Threashold value for down stream
121     unsigned long long  throughputUp;                                   //! Throughput for up stream
122     unsigned long long  throughputDown;                                 //! Throughput for down stream
123     int                 vs_count;                                       //! VirtualService count
124
125     bool    operator==( const l7ag_mibdata_payload_vs& in_data ) {
126         if (index == in_data.index) {
127             return true;
128         }
129         else {
130             return false;
131         }
132     }
133     l7ag_mibdata_payload_vs& operator=( const l7ag_mibdata_payload_vs& in_data ){
134         index               = in_data.index;
135         protocol            = in_data.protocol;
136         ipAddress           = in_data.ipAddress;
137         strncpy(scheduleModule, in_data.scheduleModule, L7VS_MODNAME_LEN);
138         strncpy(protocolModule, in_data.protocolModule, L7VS_MODNAME_LEN);
139         strncpy(protocolModuleOption, in_data.protocolModuleOption, L7VS_PROTOMOD_OPT_LEN);
140         reschedule          = in_data.reschedule;
141         sorryIpAddress      = in_data.sorryIpAddress;
142         sorryPortNumber     = in_data.sorryPortNumber;
143         sorryThreshold      = in_data.sorryThreshold;
144         sorryForceFlag      = in_data.sorryForceFlag;
145         QoSThresholdUp      = in_data.QoSThresholdUp;
146         QoSThresholdDown    = in_data.QoSThresholdDown;
147         throughputUp        = in_data.throughputUp;
148         throughputDown      = in_data.throughputDown;
149         vs_count            = in_data.vs_count;
150
151         return *this;
152     }
153 };
154
155
156 /*!
157  * Message for collect MIB data (RealServer)
158  */
159 struct  l7ag_mibdata_payload_rs
160 {
161     char                magic[MAGIC_NUMBER_LENGTH]; //! Magic number
162     int                 index;                      //! RealServer index
163     int                 virtualServiceIndex;        //! Relation VirtualService index
164     uint32_t            ipAddress;                  //! IP
165     uint16_t            portNumber;                 //! Port
166     int                 forwardMode;                //! forward mode
167     unsigned long long  weight;                     //! weight
168     unsigned long long  activeConn;                 //! active connection
169     unsigned long long  inactiveConn;               //! inactive connection
170     int                 rs_count;
171
172     bool    operator==( const l7ag_mibdata_payload_rs& in_data ) {
173         if (index == in_data.index) {
174             return true;
175         }
176         else {
177             return false;
178         }
179     }
180     l7ag_mibdata_payload_rs& operator=( const l7ag_mibdata_payload_rs& in_data ){
181         index               = in_data.index;
182         virtualServiceIndex = in_data.virtualServiceIndex;
183         ipAddress           = in_data.ipAddress;
184         portNumber          = in_data.portNumber;
185         forwardMode         = in_data.forwardMode;
186         weight              = in_data.weight;
187         activeConn          = in_data.activeConn;
188         inactiveConn        = in_data.inactiveConn;
189         rs_count            = in_data.rs_count;
190
191         return *this;
192     }
193 };
194
195 /*!
196  * Request message of collect MIB data
197  */
198 struct  l7ag_mibrequest_message
199 {
200     char            magic[MAGIC_NUMBER_LENGTH]; //! Magic number
201     unsigned char   oid[OIDDATASIZE];           //! OID. Get all data when set oid to 0
202     unsigned char   data[MIBREQUESTDATASIZE];   //! Expansion
203 };
204
205 #endif  //MESSAGE_H