summaryrefslogtreecommitdiff
path: root/usr/src/lib/libsip/common/sip_miscdefs.h
diff options
context:
space:
mode:
authorgm209912 <none@none>2008-01-15 08:42:39 -0800
committergm209912 <none@none>2008-01-15 08:42:39 -0800
commit943efbc33954e332318b6365bf27037c05bff72c (patch)
tree3e4d8821b5482533452918abf346a5c5624a55fb /usr/src/lib/libsip/common/sip_miscdefs.h
parent347a77f277285a2c589b756c918c3f40eefbbb8b (diff)
downloadillumos-joyent-943efbc33954e332318b6365bf27037c05bff72c.tar.gz
PSARC 2008/007 SIP Statistics And Logging
6496355 SIP stack should provide Call Tracing, logging and stat counters
Diffstat (limited to 'usr/src/lib/libsip/common/sip_miscdefs.h')
-rw-r--r--usr/src/lib/libsip/common/sip_miscdefs.h95
1 files changed, 94 insertions, 1 deletions
diff --git a/usr/src/lib/libsip/common/sip_miscdefs.h b/usr/src/lib/libsip/common/sip_miscdefs.h
index c3129d873b..1f5df8f40e 100644
--- a/usr/src/lib/libsip/common/sip_miscdefs.h
+++ b/usr/src/lib/libsip/common/sip_miscdefs.h
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -36,6 +36,7 @@ extern "C" {
#include <pthread.h>
#include <sys/types.h>
#include <sys/time.h>
+#include <stdio.h>
#define SIP_CR '\r'
#define SIP_SP ' '
@@ -61,6 +62,10 @@ extern "C" {
#define SIP_SIZE_OF_STATUS_CODE 3
#define SIP_SPACE_LEN sizeof (char)
+#define SIP_TRANSACTION_LOG 0x0001
+#define SIP_DIALOG_LOG 0x0002
+#define SIP_ASSERT_ERROR 0x0004
+
#define SIP_MS 1L
#define SIP_SECONDS (1000 * SIP_MS)
#define SIP_MINUTES (60 * SIP_SECONDS)
@@ -126,6 +131,15 @@ typedef struct sip_timer_s {
#define SIP_IS_TIMER_RUNNING(timer) ((timer).sip_timerid != 0)
+#define SIP_UPDATE_COUNTERS(is_request, method, resp_code, outbound, size) { \
+ (void) pthread_mutex_lock(&sip_counters.sip_counter_mutex); \
+ if (sip_counters.enabled) { \
+ (void) sip_measure_traffic((is_request), (method), (resp_code),\
+ (outbound), (size)); \
+ } \
+ (void) pthread_mutex_unlock(&sip_counters.sip_counter_mutex); \
+}
+
/* This is the transaction list */
typedef struct sip_conn_cache_s {
void *obj;
@@ -147,6 +161,81 @@ typedef struct sip_conn_obj_pvt_s {
pthread_mutex_t sip_conn_obj_cache_lock;
} sip_conn_obj_pvt_t;
+/* SIP traffic counters structure */
+
+typedef struct sip_traffic_counters_s {
+ boolean_t enabled;
+ time_t starttime;
+ time_t stoptime;
+ uint64_t sip_total_bytes_rcvd;
+ uint64_t sip_total_bytes_sent;
+ uint64_t sip_total_req_rcvd;
+ uint64_t sip_total_req_sent;
+ uint64_t sip_total_resp_rcvd;
+ uint64_t sip_total_resp_sent;
+ uint64_t sip_ack_req_rcvd;
+ uint64_t sip_ack_req_sent;
+ uint64_t sip_bye_req_rcvd;
+ uint64_t sip_bye_req_sent;
+ uint64_t sip_cancel_req_rcvd;
+ uint64_t sip_cancel_req_sent;
+ uint64_t sip_info_req_rcvd;
+ uint64_t sip_info_req_sent;
+ uint64_t sip_invite_req_rcvd;
+ uint64_t sip_invite_req_sent;
+ uint64_t sip_notify_req_rcvd;
+ uint64_t sip_notify_req_sent;
+ uint64_t sip_options_req_rcvd;
+ uint64_t sip_options_req_sent;
+ uint64_t sip_prack_req_rcvd;
+ uint64_t sip_prack_req_sent;
+ uint64_t sip_refer_req_rcvd;
+ uint64_t sip_refer_req_sent;
+ uint64_t sip_register_req_rcvd;
+ uint64_t sip_register_req_sent;
+ uint64_t sip_subscribe_req_rcvd;
+ uint64_t sip_subscribe_req_sent;
+ uint64_t sip_update_req_rcvd;
+ uint64_t sip_update_req_sent;
+ uint64_t sip_1xx_resp_rcvd;
+ uint64_t sip_1xx_resp_sent;
+ uint64_t sip_2xx_resp_rcvd;
+ uint64_t sip_2xx_resp_sent;
+ uint64_t sip_3xx_resp_rcvd;
+ uint64_t sip_3xx_resp_sent;
+ uint64_t sip_4xx_resp_rcvd;
+ uint64_t sip_4xx_resp_sent;
+ uint64_t sip_5xx_resp_rcvd;
+ uint64_t sip_5xx_resp_sent;
+ uint64_t sip_6xx_resp_rcvd;
+ uint64_t sip_6xx_resp_sent;
+ pthread_mutex_t sip_counter_mutex; /* Mutex should be always at end */
+} sip_traffic_counters_t;
+
+/* SIP logfile structure */
+typedef struct sip_logfile_s {
+ boolean_t sip_logging_enabled;
+ FILE *sip_logfile;
+ pthread_mutex_t sip_logfile_mutex;
+} sip_logfile_t;
+
+typedef struct sip_msg_chain_s {
+ char *sip_msg;
+ int msg_seq;
+ time_t msg_timestamp;
+ struct sip_msg_chain_s *next;
+}sip_msg_chain_t;
+
+typedef struct sip_log_s {
+ sip_msg_chain_t *sip_msgs;
+ int sip_msgcnt;
+}sip_log_t;
+
+extern sip_traffic_counters_t sip_counters;
+
+extern sip_logfile_t trans_log;
+extern sip_logfile_t dialog_log;
+
extern boolean_t sip_manage_dialog;
/* To salt the hash function */
@@ -157,6 +246,10 @@ extern uint_t sip_timeout(void *, void (*)(void *), struct timeval *);
extern boolean_t sip_untimeout(uint_t);
extern void sip_md5_hash(char *, int, char *, int, char *, int,
char *, int, char *, int, char *, int, uchar_t *);
+extern void sip_measure_traffic(boolean_t, sip_method_t, int,
+ boolean_t, int);
+extern void sip_add_log(sip_log_t *, sip_msg_t, int, int);
+extern void sip_write_to_log(void *, int, char *, int);
#ifdef __cplusplus
}