parser/sdp: more suggestive debug message
[sip-router] / events.c
index 61abc5f..d26ae9b 100644 (file)
--- a/events.c
+++ b/events.c
@@ -32,6 +32,9 @@
 static sr_event_cb_t _sr_events_list;
 static int _sr_events_inited = 0;
 
+/**
+ *
+ */
 void sr_event_cb_init(void)
 {
        if(_sr_events_inited == 0)
@@ -41,6 +44,9 @@ void sr_event_cb_init(void)
        }
 }
 
+/**
+ *
+ */
 int sr_event_register_cb(int type, sr_event_cb_f f)
 {
        sr_event_cb_init();
@@ -65,22 +71,62 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
                                        _sr_events_list.run_action = f;
                                else return -1;
                        break;
+               case SREV_PKG_SET_USED:
+                               if(_sr_events_list.pkg_set_used==0)
+                                       _sr_events_list.pkg_set_used = f;
+                               else return -1;
+                       break;
+               case SREV_PKG_SET_REAL_USED:
+                               if(_sr_events_list.pkg_set_real_used==0)
+                                       _sr_events_list.pkg_set_real_used = f;
+                               else return -1;
+                       break;
+               case SREV_NET_DGRAM_IN:
+                               if(_sr_events_list.net_dgram_in==0)
+                                       _sr_events_list.net_dgram_in = f;
+                               else return -1;
+                       break;
+               case SREV_TCP_HTTP_100C:
+                               if(_sr_events_list.tcp_http_100c==0)
+                                       _sr_events_list.tcp_http_100c = f;
+                               else return -1;
+                       break;
+               case SREV_TCP_MSRP_FRAME:
+                               if(_sr_events_list.tcp_msrp_frame==0)
+                                       _sr_events_list.tcp_msrp_frame = f;
+                               else return -1;
+                       break;
+               case SREV_TCP_WS_FRAME_IN:
+                               if(_sr_events_list.tcp_ws_frame_in==0)
+                                       _sr_events_list.tcp_ws_frame_in = f;
+                               else return -1;
+                       break;
+               case SREV_TCP_WS_FRAME_OUT:
+                               if(_sr_events_list.tcp_ws_frame_out==0)
+                                       _sr_events_list.tcp_ws_frame_out = f;
+                               else return -1;
+                       break;
                default:
                        return -1;
        }
        return 0;
 }
 
+/**
+ *
+ */
 int sr_event_exec(int type, void *data)
 {
        int ret;
+#ifdef EXTRA_DEBUG
        str *p;
+#endif /* EXTRA_DEBUG */
        switch(type) {
                case SREV_NET_DATA_IN:
                                if(unlikely(_sr_events_list.net_data_in!=0))
                                {
-                                       p = (str*)data;
 #ifdef EXTRA_DEBUG
+                                       p = (str*)data;
                                        LM_DBG("PRE-IN ++++++++++++++++++++++++++++++++\n"
                                                        "%.*s\n+++++\n", p->len, p->s);
 #endif /* EXTRA_DEBUG */
@@ -95,8 +141,8 @@ int sr_event_exec(int type, void *data)
                case SREV_NET_DATA_OUT:
                                if(unlikely(_sr_events_list.net_data_out!=0))
                                {
-                                       p = (str*)data;
 #ifdef EXTRA_DEBUG
+                                       p = (str*)data;
                                        LM_DBG("PRE-OUT ++++++++++++++++++++\n"
                                                        "%.*s\n+++++++++++++++++++\n", p->len, p->s);
 #endif /* EXTRA_DEBUG */
@@ -121,11 +167,56 @@ int sr_event_exec(int type, void *data)
                                        ret = _sr_events_list.run_action(data);
                                        return ret;
                                } else return 1;
+               case SREV_PKG_SET_USED:
+                               if(unlikely(_sr_events_list.pkg_set_used!=0))
+                               {
+                                       ret = _sr_events_list.pkg_set_used(data);
+                                       return ret;
+                               } else return 1;
+               case SREV_PKG_SET_REAL_USED:
+                               if(unlikely(_sr_events_list.pkg_set_real_used!=0))
+                               {
+                                       ret = _sr_events_list.pkg_set_real_used(data);
+                                       return ret;
+                               } else return 1;
+               case SREV_NET_DGRAM_IN:
+                               if(unlikely(_sr_events_list.net_dgram_in!=0))
+                               {
+                                       ret = _sr_events_list.net_dgram_in(data);
+                                       return ret;
+                               } else return 1;
+               case SREV_TCP_HTTP_100C:
+                               if(unlikely(_sr_events_list.tcp_http_100c!=0))
+                               {
+                                       ret = _sr_events_list.tcp_http_100c(data);
+                                       return ret;
+                               } else return 1;
+               case SREV_TCP_MSRP_FRAME:
+                               if(unlikely(_sr_events_list.tcp_msrp_frame!=0))
+                               {
+                                       ret = _sr_events_list.tcp_msrp_frame(data);
+                                       return ret;
+                               } else return 1;
+               case SREV_TCP_WS_FRAME_IN:
+                               if(unlikely(_sr_events_list.tcp_ws_frame_in!=0))
+                               {
+                                       ret = _sr_events_list.tcp_ws_frame_in(data);
+                                       return ret;
+                               } else return 1;
+               case SREV_TCP_WS_FRAME_OUT:
+                               if(unlikely(_sr_events_list.tcp_ws_frame_out!=0))
+                               {
+                                       ret = _sr_events_list.tcp_ws_frame_out(data);
+                                       return ret;
+                               } else return 1;
                default:
                        return -1;
        }
 }
 
+/**
+ *
+ */
 int sr_event_enabled(int type)
 {
        switch(type) {
@@ -137,6 +228,20 @@ int sr_event_enabled(int type)
                                return (_sr_events_list.core_stats!=0)?1:0;
                case SREV_CFG_RUN_ACTION:
                                return (_sr_events_list.run_action!=0)?1:0;
+               case SREV_PKG_SET_USED:
+                               return (_sr_events_list.pkg_set_used!=0)?1:0;
+               case SREV_PKG_SET_REAL_USED:
+                               return (_sr_events_list.pkg_set_real_used!=0)?1:0;
+               case SREV_NET_DGRAM_IN:
+                               return (_sr_events_list.net_dgram_in!=0)?1:0;
+               case SREV_TCP_HTTP_100C:
+                               return (_sr_events_list.tcp_http_100c!=0)?1:0;
+               case SREV_TCP_MSRP_FRAME:
+                               return (_sr_events_list.tcp_msrp_frame!=0)?1:0;
+               case SREV_TCP_WS_FRAME_IN:
+                               return (_sr_events_list.tcp_ws_frame_in!=0)?1:0;
+               case SREV_TCP_WS_FRAME_OUT:
+                               return (_sr_events_list.tcp_ws_frame_out!=0)?1:0;
        }
        return 0;
 }