|
@@ -31,6 +31,7 @@
|
|
* 2003-12-04 : global callbacks moved into transaction callbacks;
|
|
* 2003-12-04 : global callbacks moved into transaction callbacks;
|
|
* multiple events per callback added; single list per
|
|
* multiple events per callback added; single list per
|
|
* transaction for all its callbacks (bogdan)
|
|
* transaction for all its callbacks (bogdan)
|
|
|
|
+ * 2007-03-14 added *_SENT callbacks (andrei)
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
@@ -39,6 +40,15 @@
|
|
|
|
|
|
#include "defs.h"
|
|
#include "defs.h"
|
|
|
|
|
|
|
|
+/* if defined support for ONSEND callbacks will be added and
|
|
|
|
+ * the tmcb_params structure will get some additional members */
|
|
|
|
+/*
|
|
|
|
+#define TMCB_ONSEND
|
|
|
|
+*/
|
|
|
|
+#ifdef TMCB_ONSEND
|
|
|
|
+#include "../../ip_addr.h" /* dest_info */
|
|
|
|
+#endif
|
|
|
|
+
|
|
struct sip_msg;
|
|
struct sip_msg;
|
|
struct cell;
|
|
struct cell;
|
|
|
|
|
|
@@ -52,7 +62,13 @@ struct cell;
|
|
#define TMCB_RESPONSE_OUT_N 7
|
|
#define TMCB_RESPONSE_OUT_N 7
|
|
#define TMCB_LOCAL_COMPLETED_N 8
|
|
#define TMCB_LOCAL_COMPLETED_N 8
|
|
#define TMCB_LOCAL_RESPONSE_OUT_N 9
|
|
#define TMCB_LOCAL_RESPONSE_OUT_N 9
|
|
|
|
+#ifdef TMCB_ONSEND
|
|
|
|
+#define TMCB_REQUEST_SENT_N 10
|
|
|
|
+#define TMCB_RESPONSE_SENT_N 11
|
|
|
|
+#define TMCB_MAX_N 11
|
|
|
|
+#else
|
|
#define TMCB_MAX_N 9
|
|
#define TMCB_MAX_N 9
|
|
|
|
+#endif
|
|
|
|
|
|
#define TMCB_REQUEST_IN (1<<TMCB_REQUEST_IN_N)
|
|
#define TMCB_REQUEST_IN (1<<TMCB_REQUEST_IN_N)
|
|
#define TMCB_RESPONSE_IN (1<<TMCB_RESPONSE_IN_N)
|
|
#define TMCB_RESPONSE_IN (1<<TMCB_RESPONSE_IN_N)
|
|
@@ -64,6 +80,10 @@ struct cell;
|
|
#define TMCB_RESPONSE_OUT (1<<TMCB_RESPONSE_OUT_N)
|
|
#define TMCB_RESPONSE_OUT (1<<TMCB_RESPONSE_OUT_N)
|
|
#define TMCB_LOCAL_COMPLETED (1<<TMCB_LOCAL_COMPLETED_N)
|
|
#define TMCB_LOCAL_COMPLETED (1<<TMCB_LOCAL_COMPLETED_N)
|
|
#define TMCB_LOCAL_RESPONSE_OUT (1<<TMCB_LOCAL_RESPONSE_OUT_N)
|
|
#define TMCB_LOCAL_RESPONSE_OUT (1<<TMCB_LOCAL_RESPONSE_OUT_N)
|
|
|
|
+#ifdef TMCB_ONSEND
|
|
|
|
+#define TMCB_REQUEST_SENT (1<<TMCB_REQUEST_SENT_N)
|
|
|
|
+#define TMCB_RESPONSE_SENT (1<<TMCB_RESPONSE_SENT_N)
|
|
|
|
+#endif
|
|
#define TMCB_MAX ((1<<(TMCB_MAX_N+1))-1)
|
|
#define TMCB_MAX ((1<<(TMCB_MAX_N+1))-1)
|
|
|
|
|
|
|
|
|
|
@@ -199,11 +219,49 @@ struct cell;
|
|
* called multiple time quasi-simultaneously. No lock is held.
|
|
* called multiple time quasi-simultaneously. No lock is held.
|
|
* It's unsafe to register other TMCB callbacks.
|
|
* It's unsafe to register other TMCB callbacks.
|
|
*
|
|
*
|
|
|
|
+ * TMCB_ONSEND callbacks
|
|
|
|
+ *
|
|
|
|
+ * All of the following callbacks are called immediately after or before
|
|
|
|
+ * sending a message. All of them are read-only (no change can be made to
|
|
|
|
+ * the message). These callbacks use the t_rbuf, send_buf, dst, is_retr
|
|
|
|
+ * and the code members of the tmcb_params structure.
|
|
|
|
+ * For a request code is <=0. code values can be TYPE_LOCAL_ACK for an ACK
|
|
|
|
+ * generated by ser, TYPE_LOCAL_CANCEL for a CANCEL generated by ser
|
|
|
|
+ * and TYPE_REQUEST for all the other requests or requests generated via
|
|
|
|
+ * t_uac.
|
|
|
|
+ * For a reply the code is the response status (which is always >0, e.g. 200,
|
|
|
|
+ * 408, a.s.o).
|
|
|
|
+ * Note: - these callbacks can be used only if TMCB_ONSEND is defined.
|
|
|
|
+ * - the callbacks will be called sometimes with the REPLY lock held
|
|
|
|
+ * and sometimes without it, so trying to acquire the REPLY lock
|
|
|
|
+ * from these callbacks could lead to deadlocks (avoid it unless
|
|
|
|
+ * you really know what you're doing).
|
|
|
|
+ *
|
|
|
|
+ * TMCB_REQUEST_SENT (present only if TMCB_ONSEND is defined) -- called
|
|
|
|
+ * each time a request was sent (even for retransmissions), it includes
|
|
|
|
+ * local and forwarded request, ser generated CANCELs and ACKs. The
|
|
|
|
+ * tmcb_params structure will have the t_rbuf, dst, send_buf and is_retr
|
|
|
|
+ * members filled.
|
|
|
|
+ * This callback is "read-only", the message was already sent and no changes
|
|
|
|
+ * are allowed.
|
|
|
|
+ * Note: send_buf can be different from t_rbuf->buffer for ACKs (in this
|
|
|
|
+ * case t_rbuf->buf will contain the last request sent on the branch and
|
|
|
|
+ * its destination). The same goes for t_rbuf->dst and tmcb->dst for local
|
|
|
|
+ * transactions ACKs to 2xxs.
|
|
|
|
+ *
|
|
|
|
+ * TMCB_RESPONSE_SENT (present only if TMCB_ONSEND is defined) -- called
|
|
|
|
+ * each time a response was sent (even for retransmissions). The tmcb_params
|
|
|
|
+ * structure will have t_rbuf set to the reply retransmission buffer and
|
|
|
|
+ * send_buf set to the data sent (in this case it will always be the same
|
|
|
|
+ * with t_rbuf->buf). is_retr will also be set if the reply is retransmitted
|
|
|
|
+ * by ser.
|
|
|
|
+ * This callback is "read-only", the message was already sent and no changes
|
|
|
|
+ * are allowed.
|
|
*
|
|
*
|
|
|
|
|
|
the callback's param MUST be in shared memory and will
|
|
the callback's param MUST be in shared memory and will
|
|
NOT be freed by TM; you must do it yourself from the
|
|
NOT be freed by TM; you must do it yourself from the
|
|
- callback function id necessary.
|
|
|
|
|
|
+ callback function if necessary.
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
@@ -211,8 +269,22 @@ struct cell;
|
|
struct tmcb_params {
|
|
struct tmcb_params {
|
|
struct sip_msg* req;
|
|
struct sip_msg* req;
|
|
struct sip_msg* rpl;
|
|
struct sip_msg* rpl;
|
|
- int code;
|
|
|
|
void **param;
|
|
void **param;
|
|
|
|
+#ifdef TMCB_ONSEND
|
|
|
|
+ struct retr_buf* t_rbuf; /* transaction retr. buf., all the information
|
|
|
|
+ regarding destination, data that is/was
|
|
|
|
+ actually sent on the net, branch a.s.o is
|
|
|
|
+ inside */
|
|
|
|
+ struct dest_info* dst; /* destination */
|
|
|
|
+ str send_buf; /* what was/will be sent on the net, used for ACKs
|
|
|
|
+ (which don't have a retr_buf). */
|
|
|
|
+ short is_retr; /* set if this is a _ser_ retransmission (but not if
|
|
|
|
+ if it's a "forwarded" retr., like a retr. 200 Ok for
|
|
|
|
+ example) */
|
|
|
|
+ unsigned short branch;
|
|
|
|
+ /* could also be: send_buf, dst, branch */
|
|
|
|
+#endif
|
|
|
|
+ int code;
|
|
};
|
|
};
|
|
|
|
|
|
/* callback function prototype */
|
|
/* callback function prototype */
|
|
@@ -267,4 +339,10 @@ void run_trans_callbacks( int type , struct cell *trans,
|
|
/* run all REQUEST_IN callbacks */
|
|
/* run all REQUEST_IN callbacks */
|
|
void run_reqin_callbacks( struct cell *trans, struct sip_msg *req, int code );
|
|
void run_reqin_callbacks( struct cell *trans, struct sip_msg *req, int code );
|
|
|
|
|
|
|
|
+#ifdef TMCB_ONSEND
|
|
|
|
+void run_onsend_callbacks(int type, struct retr_buf* rbuf, int retr);
|
|
|
|
+void run_onsend_callbacks2(int type , struct retr_buf* rbuf, char* buf,
|
|
|
|
+ int buf_len, struct dest_info* dst, int code);
|
|
|
|
+#endif
|
|
|
|
+
|
|
#endif
|
|
#endif
|