fixed problem that the dummybc chanels had no lock, checking for the lock now. Also fixed the channel restart stuff, we can now specify and restart particular channels too.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@68631 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2
Christian Richter 18 years ago
parent 086aba207e
commit 5cc2b1078e

@ -695,7 +695,7 @@ static int misdn_set_crypt_debug(int fd, int argc, char *argv[])
static int misdn_port_block(int fd, int argc, char *argv[])
{
int port;
if (argc != 4)
return RESULT_SHOWUSAGE;
@ -1096,13 +1096,18 @@ static int misdn_send_cd (int fd, int argc, char *argv[])
static int misdn_send_restart(int fd, int argc, char *argv[])
{
int port;
int channel;
if (argc != 4)
if ( (argc < 4) || (argc > 5) )
return RESULT_SHOWUSAGE;
port = atoi(argv[3]);
misdn_lib_send_restart(port);
if (argc==5) {
channel = atoi(argv[4]);
misdn_lib_send_restart(port, channel);
} else
misdn_lib_send_restart(port, -1 );
return 0;
}

@ -1386,3 +1386,23 @@ void dec_ie_useruser(unsigned char *p, Q931_info_t *qi, int *protocol, char *use
/* IE_DISPLAY */
static void enc_ie_restart_ind(unsigned char **ntmode, msg_t *msg, unsigned char rind, int nt, struct misdn_bchannel *bc)
{
unsigned char *p;
Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
/* if (MISDN_IE_DEBG) printf(" display='%s' (len=%d)\n", display, strlen((char *)display)); */
p = msg_put(msg, 3);
if (nt)
*ntmode = p+1;
else
qi->QI_ELEMENT(restart_ind) = p - (unsigned char *)qi - sizeof(Q931_info_t);
p[0] = IE_RESTART_IND;
p[1] = 1;
p[2] = rind;
}

@ -1122,9 +1122,6 @@ int init_bc(struct misdn_stack *stack, struct misdn_bchannel *bc, int midev, in
}
{
stack_info_t *stinf;
ret = mISDN_get_stack_info(midev, stack->port, buff, sizeof(buff));
@ -3189,13 +3186,15 @@ void misdn_lib_log_ies(struct misdn_bchannel *bc)
void misdn_send_lock(struct misdn_bchannel *bc)
{
//cb_log(0,bc->port,"Locking bc->pid:%d\n", bc->pid);
pthread_mutex_lock(&bc->send_lock->lock);
if (bc->send_lock)
pthread_mutex_lock(&bc->send_lock->lock);
}
void misdn_send_unlock(struct misdn_bchannel *bc)
{
//cb_log(0,bc->port,"UnLocking bc->pid:%d\n", bc->pid);
pthread_mutex_unlock(&bc->send_lock->lock);
if (bc->send_lock)
pthread_mutex_unlock(&bc->send_lock->lock);
}
int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
@ -3634,7 +3633,7 @@ int misdn_lib_pid_restart(int pid)
}
/*Sends Restart message for every bchnanel*/
int misdn_lib_send_restart(int port)
int misdn_lib_send_restart(int port, int channel)
{
struct misdn_stack *stack=find_stack_by_port(port);
cb_log(0, port, "Sending Restarts on this port.\n");
@ -3645,9 +3644,17 @@ int misdn_lib_send_restart(int port)
dummybc.l3_id=MISDN_ID_GLOBAL;
dummybc.nt=stack->nt;
/*default is all channels*/
int max=stack->pri?30:2;
int i;
for (i=1;i<=max;i++) {
int i=1;
/*if a channel is specified we restart only this one*/
if (channel > 0) {
i=channel;
max=channel;
}
for (;i<=max;i++) {
dummybc.channel=i;
cb_log(0, port, "Restarting channel %d\n",i);
misdn_lib_send_event(&dummybc, EVENT_RESTART);

@ -419,7 +419,7 @@ void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2);
int misdn_lib_port_restart(int port);
int misdn_lib_pid_restart(int pid);
int misdn_lib_send_restart(int port);
int misdn_lib_send_restart(int port, int channel);
int misdn_lib_get_port_info(int port);

@ -803,6 +803,7 @@ msg_t *build_restart (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
printf("Building RESTART Msg\n");
#endif
enc_ie_channel_id(&restart->CHANNEL_ID, msg, 1,bc->channel, nt,bc);
enc_ie_restart_ind(&restart->RESTART_IND, msg, 0x80, nt, bc);
cb_log(0,bc->port, "Restarting channel %d\n", bc->channel);

Loading…
Cancel
Save