3 * Copyright (C) 2009 SIP-Router.org
5 * This file is part of Kamailio, a free SIP server.
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.
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.
23 #include "parser/msg_parser.h"
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
41 #define SREV_CB_LIST_SIZE 8
43 typedef struct sr_event_param {
49 typedef int (*sr_event_cb_f)(sr_event_param_t *evp);
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;
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);
75 /* shortcut types for core event routes */
76 /* initial parsing error in message receive function */
77 #define SR_CORE_ERT_RECEIVE_PARSE_ERROR 1
79 void sr_core_ert_init(void);
80 void sr_core_ert_run(sip_msg_t *msg, int e);
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;
88 sr_corecb_t *sr_corecb_get(void);
90 #define sr_corecb_void_exec(fname) \
92 sr_corecb_t *__cbp = sr_corecb_get(); \
93 if(__cbp && __cbp->fname) { \