OSDN Git Service

7aa9efeb8645b01a7151ffe51bdceb5a4b6499d9
[ultramonkey-l7/ultramonkey-l7-v3.git] / snmpagent / dispatcher.h
1 //
2 //!    @file    dispatcher.h
3 //!    @brief    snmpagent dispatch header
4 //
5 //    Copyright (C) 2008  NTT COMWARE Corporation.
6 //
7 //    Distributed under the Boost Software License, Version 1.0. (See accompanying
8 //    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10
11 #ifndef L7AG_DISPATCHER_H
12 #define L7AG_DISPATCHER_H
13
14 #include <map>
15 #include <string>
16 #include "lockedqueue.h"
17 #include "QueueContainer.h"
18 #include "trapdata.h"
19 #include "parameter.h"
20 #include "logger.h"
21 #include "message.h"
22 #include <boost/function.hpp>
23 #include <boost/bind.hpp>
24
25 //! messagequeue typedef
26 typedef lockedqueue<QueueContainer> MessageQueue;
27 //! lockqueue typedef
28 typedef lockedqueue<trapdata>       TrapQueue;
29
30 //
31 //! @class    l7ag_dispatcher
32 //!    @brief    message dispatch class
33 class l7ag_dispatcher
34 {
35
36 private:
37         bool        stop_flag;            //! stopping flag
38         pthread_t   dispatch_thread;    //!    dispatch thread id
39
40         MessageQueue   *message_que;    //! message queue object pointer
41         TrapQueue      *trap_que;        //!    trap queue object pointer
42
43         size_t  msg_size;                //! message size
44         char   *msg;                    //! message pointer
45         size_t  msg_pos;                //! message posision
46
47         std::map< int, boost::function<void (void *)> > dispatch_functions;
48
49         l7ag_dispatcher();
50
51 protected:
52         static void *run(void *);
53
54         void dispatch_message();
55         void process_setting_command(void *);
56         void process_trap_request(void *);
57         void process_mib_collect_response_vs(void *);
58         void process_mib_collect_response_rs(void *);
59
60         void change_loglevel(unsigned long long , unsigned long long);
61         void reload_configure();
62         void init_dispatcher_function_map();
63
64 public:
65         l7ag_dispatcher(MessageQueue *, TrapQueue *);
66         ~l7ag_dispatcher();
67
68         bool start();
69         bool stop();
70
71         MessageQueue   *get_MessageQueue() {
72                 return message_que;
73         }
74         TrapQueue      *get_TrapQueue() {
75                 return trap_que;
76         }
77 };
78
79 #endif //__L7AG_DISPATCHER_H__
80