[asterisk-commits] branch crichter/0.4.0 r29393 - in
/team/crichter/0.4.0: channels/ channels/mi...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon May 22 07:29:32 MST 2006
Author: crichter
Date: Mon May 22 09:29:31 2006
New Revision: 29393
URL: http://svn.digium.com/view/asterisk?rev=29393&view=rev
Log:
added max_incoming and max_outgoing config elemnts
Modified:
team/crichter/0.4.0/channels/chan_misdn.c
team/crichter/0.4.0/channels/misdn/chan_misdn_config.h
team/crichter/0.4.0/channels/misdn_config.c
team/crichter/0.4.0/configs/misdn.conf.sample
Modified: team/crichter/0.4.0/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_misdn.c?rev=29393&r1=29392&r2=29393&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_misdn.c (original)
+++ team/crichter/0.4.0/channels/chan_misdn.c Mon May 22 09:29:31 2006
@@ -314,6 +314,11 @@
static int misdn_facility_exec(struct ast_channel *chan, void *data);
int chan_misdn_jb_empty(struct misdn_bchannel *bc, char *buf, int len);
+
+
+int add_out_calls(int port);
+int add_in_calls(int port);
+
/*************** Helpers *****************/
@@ -668,7 +673,7 @@
int port;
int dotimer=0;
for ( port=misdn_cfg_get_next_port(0);
- port;
+ port>0;
port=misdn_cfg_get_next_port(port)) {
int l1timer;
misdn_cfg_get( port, MISDN_CFG_L1_TIMER, &l1timer, sizeof(l1timer));
@@ -818,15 +823,15 @@
}
-static int misdn_show_stats (int fd, int argc, char *argv[])
+static int misdn_show_ports_stats (int fd, int argc, char *argv[])
{
int port;
- ast_cli(fd, "Port\t|in_calls\tout_calls\n");
+ ast_cli(fd, "Port\tin_calls\tout_calls\n");
for (port=misdn_cfg_get_next_port(0); port > 0;
port=misdn_cfg_get_next_port(port)) {
- ast_cli(fd,"%d\t%d\t%d\n",port,misdn_in_calls[port],misdn_out_calls[port]);
+ ast_cli(fd,"%d\t%d\t\t%d\n",port,misdn_in_calls[port],misdn_out_calls[port]);
}
ast_cli(fd,"\n");
@@ -1132,11 +1137,11 @@
"Usage: misdn show stacks\n"
};
-static struct ast_cli_entry cli_show_stats =
-{ {"misdn","show","stats", NULL},
- misdn_show_stats,
- "Shows chan_misdns call statistics",
- "Usage: misdn show stats\n"
+static struct ast_cli_entry cli_show_ports_stats =
+{ {"misdn","show","ports","stats", NULL},
+ misdn_show_ports_stats,
+ "Shows chan_misdns call statistics per port",
+ "Usage: misdn show port stats\n"
};
@@ -1582,7 +1587,14 @@
port=newbc->port;
strncpy(newbc->dad,ext,sizeof( newbc->dad));
strncpy(ast->exten,ext,sizeof(ast->exten));
- misdn_out_calls[port]++;
+
+ int exceed;
+ if ((exceed=add_out_calls(port))) {
+ char tmp[16];
+ sprintf(tmp,"%d",exceed);
+ pbx_builtin_setvar_helper(ast,"MAX_OVERFLOW",tmp);
+ return -1;
+ }
chan_misdn_log(1, port, "* CALL: %s\n",dest);
@@ -3038,6 +3050,40 @@
}
+int add_in_calls(int port)
+{
+ int max_in_calls;
+
+ misdn_cfg_get( port, MISDN_CFG_MAX_IN, &max_in_calls, sizeof(max_in_calls));
+
+ misdn_in_calls[port]++;
+
+ if (max_in_calls >=0 && max_in_calls<misdn_in_calls[port]) {
+ ast_log(LOG_NOTICE,"Marking Incoming Call on port[%d]\n",port);
+ return misdn_in_calls[port]-max_in_calls;
+ }
+
+ return 0;
+}
+
+int add_out_calls(int port)
+{
+ int max_out_calls;
+
+ misdn_cfg_get( port, MISDN_CFG_MAX_OUT, &max_out_calls, sizeof(max_out_calls));
+
+
+ if (max_out_calls >=0 && max_out_calls<=misdn_out_calls[port]) {
+ ast_log(LOG_NOTICE,"Rejecting Outgoing Call on port[%d]\n",port);
+ return (misdn_out_calls[port]+1)-max_out_calls;
+ }
+
+ misdn_out_calls[port]++;
+
+ return 0;
+}
+
+
/************************************************************/
/* Receive Events from isdn_lib here */
@@ -3236,13 +3282,13 @@
return RESPONSE_IGNORE_SETUP; /* Ignore MSNs which are not in our List */
}
- misdn_in_calls[bc->port]++;
print_bearer(bc);
{
struct chan_list *ch=init_chan_list(ORG_MISDN);
struct ast_channel *chan;
+ int exceed;
if (!ch) { chan_misdn_log(-1, bc->port, "cb_events: malloc for chan_list failed!\n"); return 0;}
@@ -3253,6 +3299,12 @@
chan=misdn_new(ch, AST_STATE_RESERVED,bc->dad, bc->oad, AST_FORMAT_ALAW, bc->port, bc->channel);
ch->ast = chan;
+
+ if ((exceed=add_in_calls(bc->port))) {
+ char tmp[16];
+ sprintf(tmp,"%d",exceed);
+ pbx_builtin_setvar_helper(chan,"MAX_OVERFLOW",tmp);
+ }
read_config(ch, ORG_MISDN);
@@ -3851,7 +3903,7 @@
ast_cli_register(&cli_show_config);
ast_cli_register(&cli_show_port);
ast_cli_register(&cli_show_stacks);
- ast_cli_register(&cli_show_stats);
+ ast_cli_register(&cli_show_ports_stats);
ast_cli_register(&cli_restart_port);
ast_cli_register(&cli_port_up);
@@ -3910,7 +3962,7 @@
ast_cli_unregister(&cli_show_cl);
ast_cli_unregister(&cli_show_config);
ast_cli_unregister(&cli_show_port);
- ast_cli_unregister(&cli_show_stats);
+ ast_cli_unregister(&cli_show_ports_stats);
ast_cli_unregister(&cli_restart_port);
ast_cli_unregister(&cli_port_up);
ast_cli_unregister(&cli_port_down);
Modified: team/crichter/0.4.0/channels/misdn/chan_misdn_config.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/chan_misdn_config.h?rev=29393&r1=29392&r2=29393&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/chan_misdn_config.h (original)
+++ team/crichter/0.4.0/channels/misdn/chan_misdn_config.h Mon May 22 09:29:31 2006
@@ -107,4 +107,9 @@
int misdn_cfg_is_port_valid(int port);
int misdn_cfg_is_group_method(char *group, enum misdn_cfg_method meth);
+#if 0
+char *misdn_cfg_get_next_group(char *group);
+int misdn_cfg_get_next_port_in_group(int port, char *group);
#endif
+
+#endif
Modified: team/crichter/0.4.0/channels/misdn_config.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn_config.c?rev=29393&r1=29392&r2=29393&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn_config.c (original)
+++ team/crichter/0.4.0/channels/misdn_config.c Mon May 22 09:29:31 2006
@@ -144,6 +144,10 @@
static int *ptp;
/* maps enum config elements to array positions */
static int *map;
+
+#if 0
+static char **categories=NULL;
+#endif
static ast_mutex_t config_mutex;
@@ -519,6 +523,36 @@
return (p > 0) ? p : misdn_cfg_get_next_port(0);
}
+#if 0
+char *misdn_cfg_get_next_group(char *group)
+{
+ char **tmpcats=categories;
+
+ for (; *tmpcats; tmpcats++)
+ if ( !strcasecmp(group, *tmpcats) ) return *tmpcats;
+
+ return NULL;
+}
+
+
+int misdn_cfg_get_next_port_in_group(int port, char *group)
+{
+ int p = -1;
+ int gn = map[MISDN_CFG_GROUPNAME];
+
+ misdn_cfg_lock();
+ for (port++; port <= max_ports; port++) {
+ if (port_cfg[port][gn].str && !strcasecmp(port_cfg[port][gn].str,group)) {
+ p = port;
+ break;
+ }
+ }
+ misdn_cfg_unlock();
+
+ return p;
+}
+#endif
+
static int _parse (union misdn_cfg_pt *dest, char *value, enum misdn_cfg_type type, int boolint_def)
{
int re = 0;
@@ -757,6 +791,28 @@
memset(general_cfg, 0, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS);
memset(ptp, 0, sizeof(int) * (max_ports + 1));
}
+#if 0
+ int cat_cnt=0;
+ for ( cat=ast_category_browse(cfg,NULL);
+ cat;
+ cat=ast_category_browse(cfg,NULL)) {
+ cat_cnt++;
+ }
+
+ if (cat_cnt) {
+ categories=malloc(cat_cnt+1);
+ if (!categories) {
+ ast_log(LOG_ERROR,"couldn't malloc!\n");
+ return ;
+ }
+ memset(categories,0,cat_cnt);
+ } else {
+ ast_log(LOG_ERROR,"Is your misdn.conf empty?\n");
+ return ;
+ }
+
+ char **tmpcats=categories;
+#endif
cat = ast_category_browse(cfg, NULL);
@@ -767,6 +823,11 @@
} else {
_build_port_config(v, cat);
}
+#if 0
+ *tmpcats=strdup(cat);
+ tmpcats++;
+#endif
+
cat = ast_category_browse(cfg,cat);
}
@@ -775,3 +836,5 @@
misdn_cfg_unlock();
AST_DESTROY_CFG(cfg);
}
+
+
Modified: team/crichter/0.4.0/configs/misdn.conf.sample
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/configs/misdn.conf.sample?rev=29393&r1=29392&r2=29393&view=diff
==============================================================================
--- team/crichter/0.4.0/configs/misdn.conf.sample (original)
+++ team/crichter/0.4.0/configs/misdn.conf.sample Mon May 22 09:29:31 2006
@@ -296,6 +296,21 @@
; another channel type or to an application.
;
hdlc=no
+
+
+;
+; defines the maximum amount of incoming calls per port for
+; this group. Calls which exceed the maximum will be marked with
+; the channel varible MAX_OVERFLOW. It will contain the amount of
+; overflowed calls
+;
+max_incoming=-1
+
+;
+; defines the maximum amount of outgoing calls per port for this group
+; exceeding calls will be rejected
+;
+max_outgoing=-1
[intern]
; define your ports, e.g. 1,2 (depends on mISDN-driver loading order)
More information about the asterisk-commits
mailing list