• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • Directories
  • File List
  • Globals

tcp_stats.h

00001 /* 
00002  * $Id$
00003  * 
00004  * Copyright (C) 2009 iptelorg GmbH
00005  *
00006  * Permission to use, copy, modify, and distribute this software for any
00007  * purpose with or without fee is hereby granted, provided that the above
00008  * copyright notice and this permission notice appear in all copies.
00009  *
00010  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
00011  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00012  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
00013  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00014  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00015  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
00016  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00017  */
00018 /*
00019  * tcp_stats.h - tcp statistics macros
00020  */
00021 /*
00022  * History:
00023  * --------
00024  *  2009-04-08  initial version (andrei)
00025 */
00026 
00027 #ifndef __tcp_stats_h
00028 #define __tcp_stats_h
00029 
00030 /* enable tcp stats by default */
00031 #ifndef NO_TCP_STATS
00032 #define USE_TCP_STATS
00033 #endif
00034 
00035 #ifndef USE_TCP_STATS
00036 
00037 #define INIT_TCP_STATS() 0 /* success */
00038 #define DESTROY_TCP_STATS()
00039 
00040 #define TCP_STATS_ESTABLISHED(state)
00041 #define TCP_STATS_CONNECT_FAILED()
00042 #define TCP_STATS_LOCAL_REJECT()
00043 #define TCP_STATS_CON_TIMEOUT()
00044 #define TCP_STATS_CON_RESET()
00045 #define TCP_STATS_SEND_TIMEOUT()
00046 #define TCP_STATS_SENDQ_FULL()
00047 
00048 #else /* USE_TCP_STATS */
00049 
00050 #include "counters.h"
00051 
00052 struct tcp_counters_h {
00053         counter_handle_t established;
00054         counter_handle_t passive_open;
00055         counter_handle_t connect_success;
00056         counter_handle_t connect_failed;
00057         counter_handle_t local_reject;
00058         counter_handle_t con_timeout;
00059         counter_handle_t con_reset;
00060         counter_handle_t send_timeout;
00061         counter_handle_t sendq_full;
00062 };
00063 
00064 extern struct tcp_counters_h tcp_cnts_h;
00065 
00066 int tcp_stats_init(void);
00067 void tcp_stats_destroy(void);
00068 
00069 #define INIT_TCP_STATS() tcp_stats_init()
00070 
00071 #define DESTROY_TCP_STATS() tcp_stats_destroy()
00072 
00073 
00081 #define TCP_STATS_ESTABLISHED(state) \
00082         do { \
00083                 counter_inc(tcp_cnts_h.established); \
00084                 if (state == S_CONN_ACCEPT) \
00085                         counter_inc(tcp_cnts_h.passive_open); \
00086                 else \
00087                         counter_inc(tcp_cnts_h.connect_success); \
00088         }while(0)
00089 
00091 #define TCP_STATS_CONNECT_FAILED() \
00092         counter_inc(tcp_cnts_h.connect_failed)
00093 
00097 #define TCP_STATS_LOCAL_REJECT() \
00098         counter_inc(tcp_cnts_h.local_reject)
00099 
00100 
00104 #define TCP_STATS_CON_TIMEOUT() \
00105         counter_inc(tcp_cnts_h.con_timeout)
00106 
00107 
00109 #define TCP_STATS_CON_RESET() \
00110         counter_inc(tcp_cnts_h.con_reset)
00111 
00116 #define TCP_STATS_SEND_TIMEOUT() \
00117         counter_inc(tcp_cnts_h.send_timeout)
00118 
00122 #define TCP_STATS_SENDQ_FULL() \
00123         counter_inc(tcp_cnts_h.sendq_full)
00124 
00125 #endif /* USE_TCP_STATS */
00126 
00127 #endif /*__tcp_stats_h*/
00128 
00129 /* vi: set ts=4 sw=4 tw=79:ai:cindent: */

Generated on Tue May 22 2012 13:10:17 for SIP Router by  doxygen 1.7.1