[asterisk-commits] dhubbard: branch 1.4 r80617 - /branches/1.4/channels/misdn/isdn_lib.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Aug 23 16:34:17 CDT 2007
Author: dhubbard
Date: Thu Aug 23 16:34:16 2007
New Revision: 80617
URL: http://svn.digium.com/view/asterisk?view=rev&rev=80617
Log:
make misdn/isdn_lib compile without warnings
Modified:
branches/1.4/channels/misdn/isdn_lib.c
Modified: branches/1.4/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/misdn/isdn_lib.c?view=diff&rev=80617&r1=80616&r2=80617
==============================================================================
--- branches/1.4/channels/misdn/isdn_lib.c (original)
+++ branches/1.4/channels/misdn/isdn_lib.c Thu Aug 23 16:34:16 2007
@@ -379,9 +379,10 @@
static int send_msg (int midev, struct misdn_bchannel *bc, msg_t *dmsg)
{
+ struct misdn_stack *stack;
iframe_t *frm;
frm = (iframe_t *)dmsg->data;
- struct misdn_stack *stack=get_stack_by_bc(bc);
+ stack=get_stack_by_bc(bc);
if (!stack) {
cb_log(0,bc->port,"send_msg: IEK!! no stack\n ");
@@ -474,6 +475,7 @@
static int find_free_chan_in_stack(struct misdn_stack *stack, struct misdn_bchannel *bc, int channel, int dec)
{
int i;
+ int bnums;
int chan=0;
if (bc->channel_found)
@@ -491,7 +493,7 @@
channel--;
- int bnums=stack->pri?stack->b_num:stack->b_num-1;
+ bnums=stack->pri?stack->b_num:stack->b_num-1;
if (dec) {
for (i = bnums; i >=0; i--) {
@@ -948,6 +950,9 @@
int setup_bc(struct misdn_bchannel *bc)
{
unsigned char buff[1025];
+ int midev, i;
+ int channel;
+ int b_stid;
mISDN_pid_t pid;
int ret;
@@ -960,9 +965,9 @@
return -1;
}
- int midev=stack->midev;
- int channel=bc->channel-1-(bc->channel>16);
- int b_stid=stack->b_stids[channel>=0?channel:0];
+ midev=stack->midev;
+ channel=bc->channel-1-(bc->channel>16);
+ b_stid=stack->b_stids[channel>=0?channel:0];
switch (bc->bc_state) {
@@ -976,7 +981,6 @@
cb_log(5, stack->port, "$$$ Setting up bc with stid :%x\n", b_stid);
/*check if the b_stid is alread initialized*/
- int i;
for (i=0; i <= stack->b_num; i++) {
if (stack->bc[i].b_stid == b_stid) {
cb_log(0, bc->port, "setup_bc: b_stid:%x already in use !!!\n", b_stid);
@@ -1592,13 +1596,14 @@
static int handle_cr ( struct misdn_stack *stack, iframe_t *frm)
{
+ struct misdn_bchannel* bc;
if (!stack) return -1;
switch (frm->prim) {
case CC_NEW_CR|INDICATION:
cb_log(7, stack->port, " --> lib: NEW_CR Ind with l3id:%x on this port.\n",frm->dinfo);
- struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1, 0);
+ bc=misdn_lib_get_free_bc(stack->port, 0, 1, 0);
if (!bc) {
cb_log(0, stack->port, " --> !! lib: No free channel!\n");
return -1;
@@ -1789,6 +1794,8 @@
switch(hh->prim){
case CC_RETRIEVE|INDICATION:
{
+ struct misdn_bchannel *bc;
+ struct misdn_bchannel *hold_bc;
iframe_t frm; /* fake te frm to add callref to global callreflist */
frm.dinfo = hh->dinfo;
@@ -1805,8 +1812,8 @@
return 0;
}
- struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo);
- struct misdn_bchannel *hold_bc=stack_holder_find(stack,bc->l3_id);
+ bc=find_bc_by_l3id(stack, hh->dinfo);
+ hold_bc=stack_holder_find(stack,bc->l3_id);
cb_log(4, stack->port, "bc_l3id:%x holded_bc_l3id:%x\n",bc->l3_id, hold_bc->l3_id);
if (hold_bc) {
@@ -2039,6 +2046,8 @@
isdn_msg_parse_event(msgs_g,msg,bc, 1);
switch (event) {
+ int channel;
+ int tmpcause;
case EVENT_SETUP:
if (bc->channel<=0 || bc->channel==0xff)
bc->channel=0;
@@ -2049,8 +2058,8 @@
case EVENT_RELEASE:
case EVENT_RELEASE_COMPLETE:
{
- int channel=bc->channel;
- int tmpcause=bc->cause;
+ channel=bc->channel;
+ tmpcause=bc->cause;
empty_bc(bc);
bc->cause=tmpcause;
clean_up_bc(bc);
@@ -2264,8 +2273,7 @@
static int handle_bchan(msg_t *msg)
{
iframe_t *frm= (iframe_t*)msg->data;
-
-
+ struct misdn_stack *stack;
struct misdn_bchannel *bc=find_bc_by_addr(frm->addr);
if (!bc) {
@@ -2273,7 +2281,7 @@
return 0 ;
}
- struct misdn_stack *stack=get_stack_by_bc(bc);
+ stack=get_stack_by_bc(bc);
if (!stack) {
cb_log(0, bc->port,"handle_bchan: STACK not found for prim:%x with addr:%x dinfo:%x\n", frm->prim, frm->addr, frm->dinfo);
@@ -2462,6 +2470,7 @@
cb_log(0,bc->port,"do_tone STOP (%d)\n",t);
#endif
if ( !t ) {
+ int i;
if ( misdn_cap_is_speech(bc->capability)) {
if ( !bc->nojitter ) {
@@ -2479,7 +2488,7 @@
cb_log(0,bc->port,"EVENT_B_DATA START\n");
#endif
- int i=cb_event( EVENT_BCHAN_DATA, bc, glob_mgr->user_data);
+ i=cb_event( EVENT_BCHAN_DATA, bc, glob_mgr->user_data);
#ifdef MISDN_B_DEBUG
cb_log(0,bc->port,"EVENT_B_DATA STOP\n");
#endif
@@ -2594,13 +2603,14 @@
handle_frm_bc:
if (bc ) {
+ int ret;
enum event_e event = isdn_msg_get_event(msgs_g, msg, 0);
enum event_response_e response=RESPONSE_OK;
isdn_msg_parse_event(msgs_g,msg,bc, 0);
/** Preprocess some Events **/
- int ret=handle_event(bc, event, frm);
+ ret=handle_event(bc, event, frm);
if (ret<0) {
cb_log(0,stack->port,"couldn't handle event\n");
free_msg(msg);
@@ -2681,8 +2691,8 @@
#endif
} else {
+ struct misdn_bchannel dummybc;
cb_log(0, stack->port, " --> Didn't find BC so temporarly creating dummy BC (l3id:%x) on this port.\n", frm->dinfo);
- struct misdn_bchannel dummybc;
memset (&dummybc,0,sizeof(dummybc));
dummybc.port=stack->port;
dummybc.l3_id=frm->dinfo;
@@ -2815,6 +2825,7 @@
static int handle_mgmt(msg_t *msg)
{
+ struct misdn_stack *stack;
iframe_t *frm = (iframe_t*) msg->data;
if ( (frm->addr == 0) && (frm->prim == (MGR_DELLAYER|CONFIRM)) ) {
@@ -2823,7 +2834,7 @@
return 1;
}
- struct misdn_stack * stack=find_stack_by_addr(frm->addr);
+ stack=find_stack_by_addr(frm->addr);
if (!stack) {
if (frm->prim == (MGR_DELLAYER|CONFIRM)) {
@@ -3099,6 +3110,7 @@
for (stack=glob_mgr->stack_list; stack; stack=stack->next) {
if (stack->port == port) {
+ int maxnum;
if (stack->blocked) {
cb_log(0,port,"Port is blocked\n");
return NULL;
@@ -3118,7 +3130,7 @@
}
}
- int maxnum=inout&&!stack->pri&&!stack->ptp?stack->b_num+1:stack->b_num;
+ maxnum=inout&&!stack->pri&&!stack->ptp?stack->b_num+1:stack->b_num;
if (dec) {
for (i = maxnum-1; i>=0; i--) {
@@ -3175,9 +3187,10 @@
void misdn_lib_log_ies(struct misdn_bchannel *bc)
{
+ struct misdn_stack *stack;
if (!bc) return;
- struct misdn_stack *stack=get_stack_by_bc(bc);
+ stack=get_stack_by_bc(bc);
if (!stack) return;
@@ -3227,11 +3240,12 @@
int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
{
msg_t *msg;
+ struct misdn_stack *stack;
int retval=0;
if (!bc) RETURN(-1,OUT_POST_UNLOCK);
- struct misdn_stack *stack=get_stack_by_bc(bc);
+ stack=get_stack_by_bc(bc);
if (!stack) {
cb_log(0,bc->port,"SENDEVENT: no Stack for event:%s oad:%s dad:%s \n", isdn_get_info(msgs_g, event, 0), bc->oad, bc->dad);
@@ -3330,9 +3344,11 @@
/*kill the bridge and clean the bchannel*/
if (stack->nt) {
+ int channel;
if (bc->bc_state == BCHAN_BRIDGED) {
+ struct misdn_bchannel *bc2;
misdn_split_conf(bc,bc->conf_id);
- struct misdn_bchannel *bc2=find_bc_by_confid(bc->conf_id);
+ bc2=find_bc_by_confid(bc->conf_id);
if (!bc2) {
cb_log(0,bc->port,"We have no second bc in bridge???\n");
} else {
@@ -3340,7 +3356,7 @@
}
}
- int channel=bc->channel;
+ channel=bc->channel;
empty_bc(bc);
clean_up_bc(bc);
@@ -3483,6 +3499,7 @@
case DL_DATA|INDICATION:
{
+ struct misdn_bchannel *bc;
int port=(frm->addr&MASTER_ID_MASK) >> 8;
int channel=(frm->addr&CHILD_ID_MASK) >> 16;
@@ -3494,7 +3511,7 @@
return 1;
- struct misdn_bchannel *bc=find_bc_by_channel( port , channel);
+ bc=find_bc_by_channel( port , channel);
if (!bc) {
struct misdn_stack *stack=find_stack_by_port( port );
@@ -3662,15 +3679,17 @@
/*Sends Restart message for every bchnanel*/
int misdn_lib_send_restart(int port, int channel)
{
+ int max;
+ int i;
+ struct misdn_bchannel dummybc;
struct misdn_stack *stack=find_stack_by_port(port);
cb_log(0, port, "Sending Restarts on this port.\n");
- struct misdn_bchannel dummybc;
make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0);
/*default is all channels*/
- int max=stack->pri?30:2;
- int i=1;
+ max=stack->pri?30:2;
+ i=1;
/*if a channel is specified we restart only this one*/
if (channel > 0) {
@@ -3679,6 +3698,7 @@
}
for (;i<=max;i++) {
+ int cnt;
dummybc.channel=i;
cb_log(0, port, "Restarting and cleaning channel %d\n",i);
misdn_lib_send_event(&dummybc, EVENT_RESTART);
@@ -3686,7 +3706,6 @@
/* clean up chan in stack, to be sure we don't think it's
* in use anymore */
- int cnt;
for (cnt=0; cnt<=stack->b_num; cnt++) {
if (stack->bc[cnt].channel == i) {
empty_bc(&stack->bc[cnt]);
@@ -3765,6 +3784,7 @@
case MGR_CLEARSTACK | REQUEST:
/*a queued bchannel cleanup*/
{
+ struct misdn_bchannel *bc;
struct misdn_stack *stack=find_stack_by_port(frm->dinfo);
if (!stack) {
cb_log(0,0,"no stack found with port [%d]!! so we cannot cleanup the bc\n",frm->dinfo);
@@ -3772,7 +3792,7 @@
break;
}
- struct misdn_bchannel *bc=find_bc_by_l3id(stack,frm->addr);
+ bc=find_bc_by_l3id(stack,frm->addr);
if (bc) {
cb_log(1,bc->port,"CLEARSTACK queued, cleaning up\n");
clean_up_bc(bc);
@@ -4039,9 +4059,9 @@
void manager_bchannel_deactivate(struct misdn_bchannel * bc)
{
-
+ char buf[128];
+ iframe_t dact;
struct misdn_stack *stack=get_stack_by_bc(bc);
-
switch (bc->bc_state) {
case BCHAN_ACTIVATED:
@@ -4059,12 +4079,10 @@
bc->generate_tone=0;
- iframe_t dact;
dact.prim = DL_RELEASE | REQUEST;
dact.addr = bc->addr | FLG_MSG_DOWN;
dact.dinfo = 0;
dact.len = 0;
- char buf[128];
mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC);
clear_ibuffer(bc->astbuf);
@@ -4077,6 +4095,9 @@
int misdn_lib_tx2misdn_frm(struct misdn_bchannel *bc, void *data, int len)
{
+ char buf[4096 + mISDN_HEADER_LEN];
+ iframe_t *frm;
+ int r;
struct misdn_stack *stack=get_stack_by_bc(bc);
switch (bc->bc_state) {
@@ -4088,9 +4109,7 @@
return -1;
}
- char buf[4096 + mISDN_HEADER_LEN];
- iframe_t *frm= (iframe_t*)buf;
- int r;
+ frm= (iframe_t*)buf;
frm->prim = DL_DATA|REQUEST;
frm->dinfo = 0;
@@ -4297,6 +4316,8 @@
void misdn_lib_send_tone(struct misdn_bchannel *bc, enum tone_e tone)
{
+ char buf[mISDN_HEADER_LEN+128];
+ iframe_t *frm;
switch(tone) {
case TONE_DIAL:
@@ -4316,8 +4337,7 @@
manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP);
}
- char buf[mISDN_HEADER_LEN+128];
- iframe_t *frm=(iframe_t*)buf;
+ frm=(iframe_t*)buf;
memset(buf,0,mISDN_HEADER_LEN+128);
frm->prim=DL_DATA|REQUEST;
@@ -4407,15 +4427,15 @@
void misdn_join_conf(struct misdn_bchannel *bc, int conf_id)
{
+ char data[16];
+ int len=15;
+
bc_state_change(bc,BCHAN_BRIDGED);
manager_ph_control(bc, CMX_RECEIVE_OFF, 0);
manager_ph_control(bc, CMX_CONF_JOIN, conf_id);
cb_log(3,bc->port, "Joining bc:%x in conf:%d\n",bc->addr,conf_id);
- char data[16];
- int len=15;
-
memset(data,0,15);
misdn_lib_tx2misdn_frm(bc, data, len);
@@ -4432,16 +4452,16 @@
cb_log(4,bc->port, "Splitting bc:%x in conf:%d\n",bc->addr,conf_id);
}
-void misdn_lib_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2) {
+void misdn_lib_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2)
+{
int conf_id=bc1->pid +1;
-
- cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port);
-
struct misdn_bchannel *bc_list[]={
bc1,bc2,NULL
};
struct misdn_bchannel **bc;
-
+
+ cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port);
+
for (bc=bc_list; *bc; bc++) {
(*bc)->conf_id=conf_id;
cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr);
More information about the asterisk-commits
mailing list