Module: kamailio
Branch: master
Commit: 93ab0791b409b9a708a1c7ac5cc4f94f7537d2ca
URL:
https://github.com/kamailio/kamailio/commit/93ab0791b409b9a708a1c7ac5cc4f94…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-06-18T13:18:39+02:00
core: event hook for sip reply out
---
Modified: src/core/events.c
Modified: src/core/events.h
---
Diff:
https://github.com/kamailio/kamailio/commit/93ab0791b409b9a708a1c7ac5cc4f94…
Patch:
https://github.com/kamailio/kamailio/commit/93ab0791b409b9a708a1c7ac5cc4f94…
---
diff --git a/src/core/events.c b/src/core/events.c
index 70d7179697..ebe47ee4b1 100644
--- a/src/core/events.c
+++ b/src/core/events.c
@@ -180,6 +180,15 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
_sr_events_list.net_data_send = f;
else return -1;
break;
+ case SREV_SIP_REPLY_OUT:
+ for(i=0; i<SREV_CB_LIST_SIZE; i++) {
+ if(_sr_events_list.sip_reply_out[i]==0) {
+ _sr_events_list.sip_reply_out[i] = f;
+ break;
+ }
+ }
+ if(i==SREV_CB_LIST_SIZE) return -1;
+ break;
default:
return -1;
}
@@ -317,6 +326,15 @@ int sr_event_exec(int type, sr_event_param_t *evp)
ret = _sr_events_list.net_data_send(evp);
return ret;
} else return 1;
+ case SREV_SIP_REPLY_OUT:
+ if(unlikely(_sr_events_list.net_data_in[0]!=0))
+ {
+ ret = 0;
+ for(i=0; i<SREV_CB_LIST_SIZE
+ && _sr_events_list.sip_reply_out[i]; i++) {
+ ret |= _sr_events_list.sip_reply_out[i](evp);
+ }
+ } else return 1;
default:
return -1;
}
@@ -358,6 +376,8 @@ int sr_event_enabled(int type)
return (_sr_events_list.net_data_recv!=0)?1:0;
case SREV_NET_DATA_SEND:
return (_sr_events_list.net_data_send!=0)?1:0;
+ case SREV_SIP_REPLY_OUT:
+ return (_sr_events_list.sip_reply_out[0]!=0)?1:0;
}
return 0;
}
diff --git a/src/core/events.h b/src/core/events.h
index df8a313055..f13c64a83a 100644
--- a/src/core/events.h
+++ b/src/core/events.h
@@ -37,6 +37,7 @@
#define SREV_TCP_CLOSED 13
#define SREV_NET_DATA_RECV 14
#define SREV_NET_DATA_SEND 15
+#define SREV_SIP_REPLY_OUT 16
#define SREV_CB_LIST_SIZE 8
@@ -44,6 +45,10 @@ typedef struct sr_event_param {
void *data;
receive_info_t* rcv;
dest_info_t *dst;
+ sip_msg_t *req;
+ sip_msg_t *rpl;
+ int rplcode;
+ int mode;
} sr_event_param_t;
typedef int (*sr_event_cb_f)(sr_event_param_t *evp);
@@ -64,6 +69,7 @@ typedef struct sr_event_cb {
sr_event_cb_f tcp_closed;
sr_event_cb_f net_data_recv;
sr_event_cb_f net_data_send;
+ sr_event_cb_f sip_reply_out[SREV_CB_LIST_SIZE];
} sr_event_cb_t;
void sr_event_cb_init(void);