Browse code

core: new event SREV_NET_DATA_RECV

- to be executed if a sip message has been received

Daniel-Constantin Mierla authored on 11/01/2016 21:21:37
Showing 2 changed files
... ...
@@ -170,6 +170,11 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
170 170
 					_sr_events_list.tcp_closed = f;
171 171
 				else return -1;
172 172
 			break;
173
+		case SREV_NET_DATA_RECV:
174
+				if(_sr_events_list.net_data_recv==0)
175
+					_sr_events_list.net_data_recv = f;
176
+				else return -1;
177
+			break;
173 178
 		case SREV_NET_DATA_SEND:
174 179
 				if(_sr_events_list.net_data_send==0)
175 180
 					_sr_events_list.net_data_send = f;
... ...
@@ -300,6 +305,12 @@ int sr_event_exec(int type, void *data)
300 300
 					ret = _sr_events_list.tcp_closed(data);
301 301
 					return ret;
302 302
 				} else return 1;
303
+		case SREV_NET_DATA_RECV:
304
+				if(unlikely(_sr_events_list.net_data_recv!=0))
305
+				{
306
+					ret = _sr_events_list.net_data_recv(data);
307
+					return ret;
308
+				} else return 1;
303 309
 		case SREV_NET_DATA_SEND:
304 310
 				if(unlikely(_sr_events_list.net_data_send!=0))
305 311
 				{
... ...
@@ -343,6 +354,8 @@ int sr_event_enabled(int type)
343 343
 				return (_sr_events_list.rcv_nosip!=0)?1:0;
344 344
 		case SREV_TCP_CLOSED:
345 345
 				return (_sr_events_list.tcp_closed!=0)?1:0;
346
+		case SREV_NET_DATA_RECV:
347
+				return (_sr_events_list.net_data_recv!=0)?1:0;
346 348
 		case SREV_NET_DATA_SEND:
347 349
 				return (_sr_events_list.net_data_send!=0)?1:0;
348 350
 	}
... ...
@@ -35,7 +35,8 @@
35 35
 #define SREV_TCP_WS_FRAME_OUT		11
36 36
 #define SREV_STUN_IN			12
37 37
 #define SREV_TCP_CLOSED			13
38
-#define SREV_NET_DATA_SEND		14
38
+#define SREV_NET_DATA_RECV		14
39
+#define SREV_NET_DATA_SEND		15
39 40
 
40 41
 #define SREV_CB_LIST_SIZE	3
41 42
 
... ...
@@ -55,6 +56,7 @@ typedef struct sr_event_cb {
55 55
 	sr_event_cb_f stun_in;
56 56
 	sr_event_cb_f rcv_nosip;
57 57
 	sr_event_cb_f tcp_closed;
58
+	sr_event_cb_f net_data_recv;
58 59
 	sr_event_cb_f net_data_send;
59 60
 } sr_event_cb_t;
60 61