OSDN Git Service

Merge pull request #36314 (suigintoh/ultramonkey-l7-v3/fix_signum_cast into master).
[ultramonkey-l7/ultramonkey-l7-v3.git] / l7vsd / include / mibdata.h
1 /*!
2  * @file  mibdata.h
3  * @brief mibdata module.
4  *
5  * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6  * Copyright (C) 2010  NTT COMWARE Corporation.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  **********************************************************************/
24 #ifndef __MIBDATA_H__
25 #define __MIBDATA_H__
26
27 #include "error_code.h"
28 #include "l7vsd.h"
29 #include "snmp_info.h"
30 #include <vector>
31 #include <net-snmp/net-snmp-config.h>
32 #include <net-snmp/net-snmp-includes.h>
33 #include <net-snmp/agent/net-snmp-agent-includes.h>
34
35 #define   L7VS_IPADDR_LEN  (128)
36
37 namespace l7vs
38 {
39
40 //! @class    mibdata
41 //! @brief    this class is mib data cache class.
42 class mibdata : private boost::noncopyable
43 {
44 protected:
45         netsnmp_table_data_set  *vs_table;
46         netsnmp_table_data_set  *rs_table;
47         int  vs_table_size;
48         int  rs_table_size;
49         int  replication_state;
50
51         mibdata() {};
52         ~mibdata() {};
53         mibdata(const mibdata &);
54         mibdata &operator=(const mibdata &);
55
56         /*!
57          * update virtual service table information.
58          *
59          * @param   l7vsd * l7vsd pointer
60          * @param   error_code & error code
61          * @retrun  void
62          */
63         void  update_vs_table(l7vsd *, error_code &);
64
65         /*!
66          * update real server table information.
67          *
68          * @param   const std::vector<rsdata> & temporary real server list
69          * @param   error_code & error code
70          * @retrun  void
71          */
72         void  update_rs_table(const std::vector<rsdata> &, error_code &);
73
74         /*!
75          * update replication state.
76          *
77          * @param   l7vsd * l7vsd pointer
78          * @param   error_code & error code
79          * @retrun  void
80          */
81         void  update_replication_state(l7vsd *, error_code &);
82
83 public:
84         /*!
85          * get mibdata instance.
86          *
87          * @retrun  mibdata instance
88          */
89         static mibdata  &get_instance();
90
91         /*!
92          * collect mibdata in l7vsd.
93          *
94          * @param   l7vsd * l7vsd pointer
95          * @param   error_code & error code
96          * @retrun  void
97          */
98         void  collect_mibdata(l7vsd *, error_code &);
99
100         /*!
101          * set virtual service data set.
102          *
103          * @param   netsnmp_table_data_set * virtual service data set
104          * @retrun  void
105          */
106         void  set_vs_table(netsnmp_table_data_set *);
107
108         /*!
109          * set real server data set.
110          *
111          * @param   netsnmp_table_data_set * real server data set
112          * @retrun  void
113          */
114         void  set_rs_table(netsnmp_table_data_set *);
115
116         /*!
117          * get virtual service table size
118          *
119          * @retrun  int virtual service table size
120          */
121         inline int   get_vs_table_size() {
122                 return vs_table_size;
123         }
124
125         /*!
126          * get replication state.
127          *
128          * @retrun  int replication state
129          */
130         inline int   get_replication_state() {
131                 return replication_state;
132         }
133 };
134 }
135
136 #endif //__MIBDATA_H__