OSDN Git Service

Add epoll version.
[ultramonkey-l7/ultramonkey-l7-v3.git] / snmpagent / dispatcher.h
1 //
2 //!    @file    dispatcher.h
3 //!    @brief    snmpagent dispatch 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 L7AG_DISPATCHER_H
14 #define L7AG_DISPATCHER_H
15
16 #include <map>
17 #include <string>
18 #include "lockedqueue.h"
19 #include "QueueContainer.h"
20 #include "trapdata.h"
21 #include "parameter.h"
22 #include "logger.h"
23 #include "message.h"
24 #include <boost/function.hpp>
25 #include <boost/bind.hpp>
26
27 //! messagequeue typedef
28 typedef lockedqueue<QueueContainer> MessageQueue;
29 //! lockqueue typedef
30 typedef lockedqueue<trapdata>       TrapQueue;
31
32 //
33 //! @class    l7ag_dispatcher
34 //!    @brief    message dispatch class
35 class l7ag_dispatcher{
36
37 private:
38     bool        stop_flag;            //! stopping flag
39     pthread_t   dispatch_thread;    //!    dispatch thread id
40
41     MessageQueue*   message_que;    //! message queue object pointer
42     TrapQueue*      trap_que;        //!    trap queue object pointer
43
44     size_t  msg_size;                //! message size
45     char*   msg;                    //! message pointer
46     size_t  msg_pos;                //! message posision
47
48     std::map< int,boost::function<void (void*)> > dispatch_functions;
49
50     l7ag_dispatcher();
51
52 protected:
53     static void* run( void* );
54
55     void dispatch_message();
56     void process_setting_command( void* );
57     void process_trap_request( void* );
58     void process_mib_collect_response_vs( void* );
59     void process_mib_collect_response_rs( void* );
60
61     void change_loglevel( unsigned long long , unsigned long long );
62     void reload_configure();
63     void init_dispatcher_function_map();
64
65 public:
66     l7ag_dispatcher( MessageQueue*, TrapQueue* );
67     ~l7ag_dispatcher();
68
69     bool start();
70     bool stop();
71
72     MessageQueue*   get_MessageQueue(){ return message_que; }
73     TrapQueue*      get_TrapQueue(){ return trap_que; }
74 };
75
76 #endif //__L7AG_DISPATCHER_H__
77