core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
 1 1 deleted file mode 100644 ... ... @@ -1,120 +0,0 @@ 1 -/*  2 - * Copyright (C) 2010 iptelorg GmbH 3 - * 4 - * Permission to use, copy, modify, and distribute this software for any 5 - * purpose with or without fee is hereby granted, provided that the above 6 - * copyright notice and this permission notice appear in all copies. 7 - * 8 - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 - */ 16 - 17 -/** Kamailio core :: TCP statistics. 18 - * @file tcp_stats.c 19 - * @ingroup: core 20 - * Module: \ref core 21 - */ 22 - 23 -#ifdef USE_TCP 24 -#include "tcp_stats.h" 25 - 26 -#ifdef USE_TCP_STATS 27 - 28 -#include "counters.h" 29 -#include "tcp_info.h" 30 - 31 -struct tcp_counters_h tcp_cnts_h; 32 - 33 - 34 -enum tcp_info_req { TCP_INFO_NONE, TCP_INFO_CONN_NO, TCP_INFO_WR_QUEUE_SZ }; 35 - 36 -static counter_val_t tcp_info(counter_handle_t h, void* what); 37 - 38 -/* tcp counters definitions */ 39 -counter_def_t tcp_cnt_defs[] = { 40 - {&tcp_cnts_h.established, "established", 0, 0, 0, 41 - "incremented each time a tcp connection is established."}, 42 - {&tcp_cnts_h.passive_open, "passive_open", 0, 0, 0, 43 - "total number of accepted connections (so far)."}, 44 - {&tcp_cnts_h.connect_success, "connect_success", 0, 0, 0, 45 - "total number of successfully active opened connections" 46 - " (successful connect()s)."}, 47 - {&tcp_cnts_h.connect_failed, "connect_failed", 0, 0, 0, 48 - "number of failed active connection attempts."}, 49 - {&tcp_cnts_h.local_reject, "local_reject", 0, 0, 0, 50 - "number of rejected incoming connections."}, 51 - {&tcp_cnts_h.con_timeout, "con_timeout", 0, 0, 0, 52 - "total number of connections that did timeout (idle for too long)."}, 53 - {&tcp_cnts_h.con_reset, "con_reset", 0, 0, 0, 54 - "total number of TCP_RSTs received on established connections."}, 55 - {&tcp_cnts_h.send_timeout, "send_timeout", 0, 0, 0, 56 - "number of send attempts that failed due to a timeout" 57 - "(note: works only in tcp async mode)."}, 58 - {&tcp_cnts_h.sendq_full, "sendq_full", 0, 0, 0, 59 - "number of send attempts that failed because of exceeded buffering" 60 - "capacity (send queue full, works only in tcp async mode)."}, 61 - {0, "current_opened_connections", 0, 62 - tcp_info, (void*)(long)TCP_INFO_CONN_NO, 63 - "number of currently opened connections."}, 64 - {0, "current_write_queue_size", 0, 65 - tcp_info, (void*)(long)TCP_INFO_WR_QUEUE_SZ, 66 - "current sum of all the connections write queue sizes."}, 67 - {0, 0, 0, 0, 0, 0 } 68 -}; 69 - 70 - 71 - 72 -/** helper function for some stats (which are kept internally inside tcp). 73 - */ 74 -static counter_val_t tcp_info(counter_handle_t h, void* what) 75 -{ 76 - enum tcp_info_req w; 77 - struct tcp_gen_info ti; 78 - 79 - if (tcp_disable) 80 - return 0; 81 - w = (int)(long)what; 82 - tcp_get_info(&ti); 83 - switch(w) { 84 - case TCP_INFO_CONN_NO: 85 - return ti.tcp_connections_no; 86 - case TCP_INFO_WR_QUEUE_SZ: 87 - return ti.tcp_write_queued; 88 - case TCP_INFO_NONE: 89 - break; 90 - }; 91 - return 0; 92 -} 93 - 94 -/** initialize tcp statistics. 95 - * Must be called before forking. 96 - * @return < 0 on errror, 0 on success. 97 - */ 98 -int tcp_stats_init() 99 -{ 100 -#define TCP_REG_COUNTER(name) \ 101 - if (counter_register(&tcp_cnts_h.name, "tcp", # name, 0, 0, 0, 0) < 0) \ 102 - goto error; 103 - 104 - if (counter_register_array("tcp", tcp_cnt_defs) < 0) 105 - goto error; 106 - return 0; 107 -error: 108 - return -1; 109 -} 110 - 111 - 112 -void tcp_stats_destroy() 113 -{ 114 - /* do nothing */ 115 -} 116 - 117 - 118 -#endif /* USE_TCP_STATS */ 119 -#endif /* USE_TCP */ 120 -/* vi: set ts=4 sw=4 tw=79:ai:cindent: */

core: fix spelling errors catched by lintian #688

Victor Seva authored on 29/06/2016 14:29:17
Showing 1 changed files
 ... ... @@ -91,7 +91,7 @@ static counter_val_t tcp_info(counter_handle_t h, void* what) 91 91  return 0; 92 92  } 93 93   94 -/** intialize tcp statistics. 94 +/** initialize tcp statistics. 95 95  * Must be called before forking. 96 96  * @return < 0 on errror, 0 on success. 97 97  */

Core Removed history, svn $id$ and doxygen udpates on the .c files

Olle E. Johansson authored on 03/01/2015 09:53:17
Showing 1 changed files
 ... ... @@ -1,6 +1,4 @@ 1 1  /*  2 - * $Id$ 3 - *  4 2  * Copyright (C) 2010 iptelorg GmbH 5 3  * 6 4  * Permission to use, copy, modify, and distribute this software for any ... ... @@ -15,15 +13,12 @@ 15 13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 15  */ 18 -/** tcp statistics. 16 + 17 +/** Kamailio core :: TCP statistics. 19 18  * @file tcp_stats.c 20 19  * @ingroup: core 20 + * Module: \ref core 21 21  */ 22 -/* 23 - * History: 24 - * -------- 25 - * 2010-08-08 initial version (andrei) 26 -*/ 27 22   28 23  #ifdef USE_TCP 29 24  #include "tcp_stats.h"

tcp: switched to counter arrays + more stats

- use counters arrays
- don't attempt to compile if tcp support or tcp stats support are
disabled.
- more stats: current_opened_connections and
current_write_queue_size.

Andrei Pelinescu-Onciul authored on 09/08/2010 15:01:11
Showing 1 changed files
 ... ... @@ -25,11 +25,77 @@ 25 25  * 2010-08-08 initial version (andrei) 26 26  */ 27 27   28 +#ifdef USE_TCP 28 29  #include "tcp_stats.h" 30 + 31 +#ifdef USE_TCP_STATS 32 + 29 33  #include "counters.h" 34 +#include "tcp_info.h" 30 35   31 36  struct tcp_counters_h tcp_cnts_h; 32 37   38 + 39 +enum tcp_info_req { TCP_INFO_NONE, TCP_INFO_CONN_NO, TCP_INFO_WR_QUEUE_SZ }; 40 + 41 +static counter_val_t tcp_info(counter_handle_t h, void* what); 42 + 43 +/* tcp counters definitions */ 44 +counter_def_t tcp_cnt_defs[] = { 45 + {&tcp_cnts_h.established, "established", 0, 0, 0, 46 + "incremented each time a tcp connection is established."}, 47 + {&tcp_cnts_h.passive_open, "passive_open", 0, 0, 0, 48 + "total number of accepted connections (so far)."}, 49 + {&tcp_cnts_h.connect_success, "connect_success", 0, 0, 0, 50 + "total number of successfully active opened connections" 51 + " (successful connect()s)."}, 52 + {&tcp_cnts_h.connect_failed, "connect_failed", 0, 0, 0, 53 + "number of failed active connection attempts."}, 54 + {&tcp_cnts_h.local_reject, "local_reject", 0, 0, 0, 55 + "number of rejected incoming connections."}, 56 + {&tcp_cnts_h.con_timeout, "con_timeout", 0, 0, 0, 57 + "total number of connections that did timeout (idle for too long)."}, 58 + {&tcp_cnts_h.con_reset, "con_reset", 0, 0, 0, 59 + "total number of TCP_RSTs received on established connections."}, 60 + {&tcp_cnts_h.send_timeout, "send_timeout", 0, 0, 0, 61 + "number of send attempts that failed due to a timeout" 62 + "(note: works only in tcp async mode)."}, 63 + {&tcp_cnts_h.sendq_full, "sendq_full", 0, 0, 0, 64 + "number of send attempts that failed because of exceeded buffering" 65 + "capacity (send queue full, works only in tcp async mode)."}, 66 + {0, "current_opened_connections", 0, 67 + tcp_info, (void*)(long)TCP_INFO_CONN_NO, 68 + "number of currently opened connections."}, 69 + {0, "current_write_queue_size", 0, 70 + tcp_info, (void*)(long)TCP_INFO_WR_QUEUE_SZ, 71 + "current sum of all the connections write queue sizes."}, 72 + {0, 0, 0, 0, 0, 0 } 73 +}; 74 + 75 + 76 + 77 +/** helper function for some stats (which are kept internally inside tcp). 78 + */ 79 +static counter_val_t tcp_info(counter_handle_t h, void* what) 80 +{ 81 + enum tcp_info_req w; 82 + struct tcp_gen_info ti; 83 + 84 + if (tcp_disable) 85 + return 0; 86 + w = (int)(long)what; 87 + tcp_get_info(&ti); 88 + switch(w) { 89 + case TCP_INFO_CONN_NO: 90 + return ti.tcp_connections_no; 91 + case TCP_INFO_WR_QUEUE_SZ: 92 + return ti.tcp_write_queued; 93 + case TCP_INFO_NONE: 94 + break; 95 + }; 96 + return 0; 97 +} 98 + 33 99  /** intialize tcp statistics. 34 100  * Must be called before forking. 35 101  * @return < 0 on errror, 0 on success. ... ... @@ -40,15 +106,8 @@ int tcp_stats_init() 40 106  if (counter_register(&tcp_cnts_h.name, "tcp", # name, 0, 0, 0, 0) < 0) \ 41 107  goto error; 42 108   43 - TCP_REG_COUNTER(established); 44 - TCP_REG_COUNTER(passive_open); 45 - TCP_REG_COUNTER(connect_success); 46 - TCP_REG_COUNTER(connect_failed); 47 - TCP_REG_COUNTER(local_reject); 48 - TCP_REG_COUNTER(con_timeout); 49 - TCP_REG_COUNTER(con_reset); 50 - TCP_REG_COUNTER(send_timeout); 51 - TCP_REG_COUNTER(sendq_full); 109 + if (counter_register_array("tcp", tcp_cnt_defs) < 0) 110 + goto error; 52 111  return 0; 53 112  error: 54 113  return -1; ... ... @@ -61,5 +120,6 @@ void tcp_stats_destroy() 61 120  } 62 121   63 122   64 - 123 +#endif /* USE_TCP_STATS */ 124 +#endif /* USE_TCP */ 65 125  /* vi: set ts=4 sw=4 tw=79:ai:cindent: */

tcp: enable tcp statistics

tcp statistics implemented using the counters api.
Enabled by default (unless compiles with -DNO_TCP_STATS).
E.g.:
$sercmd cnt.grp_get_all tcp { con_reset: 4 con_timeout: 0 connect_failed: 6 connect_success: 1 established: 12 local_reject: 0 passive_open: 11 send_timeout: 0 sendq_full: 0 } Andrei Pelinescu-Onciul authored on 08/08/2010 22:16:54 Showing 1 changed files  1 1 new file mode 100644 ... ... @@ -0,0 +1,65 @@ 1 +/*  2 + *$Id\$ 3 + *  4 + * Copyright (C) 2010 iptelorg GmbH 5 + * 6 + * Permission to use, copy, modify, and distribute this software for any 7 + * purpose with or without fee is hereby granted, provided that the above 8 + * copyright notice and this permission notice appear in all copies. 9 + * 10 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 + */ 18 +/** tcp statistics. 19 + * @file tcp_stats.c 20 + * @ingroup: core 21 + */ 22 +/* 23 + * History: 24 + * -------- 25 + * 2010-08-08 initial version (andrei) 26 +*/ 27 + 28 +#include "tcp_stats.h" 29 +#include "counters.h" 30 + 31 +struct tcp_counters_h tcp_cnts_h; 32 + 33 +/** intialize tcp statistics. 34 + * Must be called before forking. 35 + * @return < 0 on errror, 0 on success. 36 + */ 37 +int tcp_stats_init() 38 +{ 39 +#define TCP_REG_COUNTER(name) \ 40 + if (counter_register(&tcp_cnts_h.name, "tcp", # name, 0, 0, 0, 0) < 0) \ 41 + goto error; 42 + 43 + TCP_REG_COUNTER(established); 44 + TCP_REG_COUNTER(passive_open); 45 + TCP_REG_COUNTER(connect_success); 46 + TCP_REG_COUNTER(connect_failed); 47 + TCP_REG_COUNTER(local_reject); 48 + TCP_REG_COUNTER(con_timeout); 49 + TCP_REG_COUNTER(con_reset); 50 + TCP_REG_COUNTER(send_timeout); 51 + TCP_REG_COUNTER(sendq_full); 52 + return 0; 53 +error: 54 + return -1; 55 +} 56 + 57 + 58 +void tcp_stats_destroy() 59 +{ 60 + /* do nothing */ 61 +} 62 + 63 + 64 + 65 +/* vi: set ts=4 sw=4 tw=79:ai:cindent: */