core: events - increased SREV_CB_LIST_SIZE
[sip-router] / src / core / events.h
1 /**
2  *
3  * Copyright (C) 2009 SIP-Router.org
4  *
5  * This file is part of Kamailio, a free SIP server.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19
20 #ifndef _SR_EVENTS_H_
21 #define _SR_EVENTS_H_
22
23 #include "parser/msg_parser.h"
24
25 #define SREV_NET_DATA_IN                1
26 #define SREV_NET_DATA_OUT               2
27 #define SREV_CORE_STATS                 3
28 #define SREV_CFG_RUN_ACTION             4
29 #define SREV_PKG_UPDATE_STATS           5
30 #define SREV_RCV_NOSIP                  6
31 #define SREV_NET_DGRAM_IN               7
32 #define SREV_TCP_HTTP_100C              8
33 #define SREV_TCP_MSRP_FRAME             9
34 #define SREV_TCP_WS_FRAME_IN            10
35 #define SREV_TCP_WS_FRAME_OUT           11
36 #define SREV_STUN_IN                    12
37 #define SREV_TCP_CLOSED                 13
38 #define SREV_NET_DATA_RECV              14
39 #define SREV_NET_DATA_SEND              15
40
41 #define SREV_CB_LIST_SIZE       8
42
43 typedef struct sr_event_param {
44         void *data;
45         receive_info_t* rcv;
46         dest_info_t *dst;
47 } sr_event_param_t;
48
49 typedef int (*sr_event_cb_f)(sr_event_param_t *evp);
50
51 typedef struct sr_event_cb {
52         sr_event_cb_f net_data_in[SREV_CB_LIST_SIZE];
53         sr_event_cb_f net_data_out[SREV_CB_LIST_SIZE];
54         sr_event_cb_f core_stats;
55         sr_event_cb_f run_action;
56         sr_event_cb_f pkg_update_stats;
57         sr_event_cb_f net_dgram_in;
58         sr_event_cb_f tcp_http_100c;
59         sr_event_cb_f tcp_msrp_frame;
60         sr_event_cb_f tcp_ws_frame_in;
61         sr_event_cb_f tcp_ws_frame_out;
62         sr_event_cb_f stun_in;
63         sr_event_cb_f rcv_nosip;
64         sr_event_cb_f tcp_closed;
65         sr_event_cb_f net_data_recv;
66         sr_event_cb_f net_data_send;
67 } sr_event_cb_t;
68
69 void sr_event_cb_init(void);
70 int sr_event_register_cb(int type, sr_event_cb_f f);
71 int sr_event_exec(int type, sr_event_param_t *evp);
72 int sr_event_enabled(int type);
73
74
75 /* shortcut types for core event routes */
76 /* initial parsing error in message receive function */
77 #define SR_CORE_ERT_RECEIVE_PARSE_ERROR         1
78
79 void sr_core_ert_init(void);
80 void sr_core_ert_run(sip_msg_t *msg, int e);
81
82 typedef void (*sr_corecb_void_f)(void);
83 typedef struct sr_corecb {
84         sr_corecb_void_f app_ready;
85         sr_corecb_void_f app_shutdown;
86 } sr_corecb_t;
87
88 sr_corecb_t *sr_corecb_get(void);
89
90 #define sr_corecb_void_exec(fname) \
91         do { \
92                 sr_corecb_t *__cbp = sr_corecb_get(); \
93                 if(__cbp && __cbp->fname) { \
94                         __cbp->fname(); \
95                 } \
96         } while(0);
97
98 #endif