aboutsummaryrefslogtreecommitdiffstats
path: root/channels/misdn
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-15 20:20:45 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-15 20:20:45 +0000
commit8c532dc217faba292d1ba83c4380f65aa10aa631 (patch)
tree903e2d19404e8b888fb1b49730d1087759dd3b62 /channels/misdn
parent08c3aa37921a36fbe430a1afbde1003b2ff27d1f (diff)
issue #5739 (plus ast_copy_string() usage conversion)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7105 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/misdn')
-rwxr-xr-xchannels/misdn/isdn_lib.c65
-rwxr-xr-xchannels/misdn/isdn_lib.h4
-rwxr-xr-xchannels/misdn/isdn_msg_parser.c2
3 files changed, 51 insertions, 20 deletions
diff --git a/channels/misdn/isdn_lib.c b/channels/misdn/isdn_lib.c
index 8b5d88c00..d912795ac 100755
--- a/channels/misdn/isdn_lib.c
+++ b/channels/misdn/isdn_lib.c
@@ -50,7 +50,8 @@ int misdn_lib_is_ptp(int port)
struct misdn_stack* get_stack_by_bc(struct misdn_bchannel *bc)
{
struct misdn_stack *stack=get_misdn_stack();
-
+
+ if (!bc) return NULL;
for ( ; stack; stack=stack->next) {
int i;
@@ -333,7 +334,8 @@ static int mypid=0;
int misdn_cap_is_speech(int cap)
/** Poor mans version **/
{
- if (cap != INFO_CAPABILITY_DIGITAL_UNRESTRICTED) return 1;
+ if ( (cap != INFO_CAPABILITY_DIGITAL_UNRESTRICTED) &&
+ (cap != INFO_CAPABILITY_DIGITAL_RESTRICTED) ) return 1;
return 0;
}
@@ -342,6 +344,7 @@ int misdn_inband_avail(struct misdn_bchannel *bc)
switch (bc->progress_indicator) {
case INFO_PI_INBAND_AVAILABLE:
case INFO_PI_CALL_NOT_E2E_ISDN:
+ case INFO_PI_CALLED_NOT_ISDN:
return 1;
default:
return 0;
@@ -400,6 +403,8 @@ int empty_chan_in_stack(struct misdn_stack *stack, int channel)
void empty_bc(struct misdn_bchannel *bc)
{
+ bc->state=STATE_NOTHING;
+
bc->channel = 0;
bc->in_use = 0;
@@ -674,6 +679,11 @@ static int create_process (int midev, struct misdn_bchannel *bc) {
}
+void misdn_lib_setup_bc(struct misdn_bchannel *bc)
+{
+ setup_bc(bc);
+}
+
int setup_bc(struct misdn_bchannel *bc)
{
@@ -687,15 +697,18 @@ int setup_bc(struct misdn_bchannel *bc)
int midev=stack->midev;
int channel=bc->channel-1-(bc->channel>16);
int b_stid=stack->b_stids[channel>=0?channel:0];
+
- if (bc->upset) {
- cb_log(5, stack->port, "$$$ bc already upsetted stid :%x\n", b_stid);
- return -1;
- }
-
+ if (bc->nodsp )
+ clean_up_bc(bc);
- if (bc->nodsp) {
+ if ( !misdn_cap_is_speech(bc->capability))
clean_up_bc(bc);
+
+
+ if (bc->upset) {
+ cb_log(4, stack->port, "$$$ bc already upsetted stid :%x\n", b_stid);
+ return -1;
}
cb_log(5, stack->port, "$$$ Setting up bc with stid :%x\n", b_stid);
@@ -704,7 +717,7 @@ int setup_bc(struct misdn_bchannel *bc)
cb_log(0, stack->port," -- Stid <=0 at the moment on port:%d channel:%d\n",stack->port,channel);
return 1;
}
-
+
bc->b_stid = b_stid;
@@ -756,11 +769,12 @@ int setup_bc(struct misdn_bchannel *bc)
if (bc->async == 1 || bc->nodsp) {
- cb_log(4, stack->port," --> TRANSPARENT Mode (no DSP)\n");
+ cb_log(4, stack->port," --> TRANSPARENT Mode (no DSP, no HDLC)\n");
pid.protocol[1] = ISDN_PID_L1_B_64TRANS;
pid.protocol[2] = ISDN_PID_L2_B_TRANS;
pid.protocol[3] = ISDN_PID_L3_B_USER;
pid.layermask = ISDN_LAYER((1)) | ISDN_LAYER((2)) | ISDN_LAYER((3));
+
} else if ( misdn_cap_is_speech(bc->capability)) {
cb_log(4, stack->port," --> TRANSPARENT Mode\n");
pid.protocol[1] = ISDN_PID_L1_B_64TRANS;
@@ -1201,7 +1215,12 @@ int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_t *frm)
struct misdn_stack *stack=get_stack_by_bc(bc);
if (stack->mode == TE_MODE) {
switch (event) {
+
+ case EVENT_CONNECT_ACKNOWLEDGE:
+ manager_bchannel_activate(bc);
+ break;
case EVENT_CONNECT:
+
if ( *bc->crypt_key ) {
cb_log(4, stack->port, "ENABLING BLOWFISH port:%d channel:%d oad%d:%s dad%d:%s\n", stack->port, bc->channel, bc->onumplan,bc->oad, bc->dnumplan,bc->dad);
@@ -1326,6 +1345,11 @@ int handle_cr ( iframe_t *frm)
void misdn_lib_release(struct misdn_bchannel *bc)
{
struct misdn_stack *stack=get_stack_by_bc(bc);
+
+ if (!stack) {
+ cb_log(1,0,"misdn_release: No Stack found\n");
+ return;
+ }
if (bc->channel>=0) {
empty_chan_in_stack(stack,bc->channel);
@@ -1489,13 +1513,14 @@ handle_event_nt(void *dat, void *arg)
}
break;
-
+
+ case CC_CONNECT|INDICATION:
case CC_ALERTING|INDICATION:
case CC_PROCEEDING|INDICATION:
- case CC_CONNECT|INDICATION:
+
{
struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo);
-
+
if (!bc) {
msg_t *dmsg;
cb_log(0, stack->port,"!!!! We didn't found our bc, dinfo:%x port:%d\n",hh->dinfo, stack->port);
@@ -1507,6 +1532,7 @@ handle_event_nt(void *dat, void *arg)
return 0;
}
+
setup_bc(bc);
}
break;
@@ -1850,8 +1876,9 @@ int handle_bchan(msg_t *msg)
case DL_ESTABLISH | CONFIRM:
cb_log(4, stack->port, "BCHAN: bchan ACT Confirm\n");
free_msg(msg);
- return 1;
+ return 1;
+
case PH_DEACTIVATE | INDICATION:
case DL_RELEASE | INDICATION:
cb_log (4, stack->port, "BCHAN: DeACT Ind\n");
@@ -1899,7 +1926,8 @@ int handle_bchan(msg_t *msg)
bc->bframe_len = frm->len;
/** Anyway flip the bufbits **/
- flip_buf_bits(bc->bframe, bc->bframe_len);
+ if ( misdn_cap_is_speech(bc->capability) )
+ flip_buf_bits(bc->bframe, bc->bframe_len);
#if MISDN_DEBUG
@@ -2417,6 +2445,8 @@ void misdn_lib_log_ies(struct misdn_bchannel *bc)
cb_log(2, stack->port, " --> channel:%d caps:%s pi:%x keypad:%s\n", bc->channel, bearer2str(bc->capability),bc->progress_indicator, bc->keypad);
+ cb_log(3, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1);
+
cb_log(3, stack->port, " --> pid:%d addr:%x l3id:%x\n", bc->pid, bc->addr, bc->l3_id);
cb_log(4, stack->port, " --> bc:%x h:%d sh:%d\n", bc, bc->holded, bc->stack_holder);
@@ -3030,8 +3060,9 @@ int manager_tx2misdn_frm(struct misdn_bchannel *bc, void *data, int len)
struct misdn_stack *stack=get_stack_by_bc(bc);
if (!bc->active) return -1;
-
- flip_buf_bits(data,len);
+
+ if ( misdn_cap_is_speech(bc->capability) )
+ flip_buf_bits(data,len);
if ( !bc->nojitter && misdn_cap_is_speech(bc->capability) ) {
if (len > ibuf_freecount(bc->misdnbuf)) {
diff --git a/channels/misdn/isdn_lib.h b/channels/misdn/isdn_lib.h
index 9b84ae110..92ebdf4db 100755
--- a/channels/misdn/isdn_lib.h
+++ b/channels/misdn/isdn_lib.h
@@ -235,8 +235,7 @@ struct misdn_bchannel {
int stack_holder;
int pres;
-
- int nohdlc;
+ int screen;
int capability;
int law;
@@ -350,6 +349,7 @@ void misdn_ibuf_memcpy_w(void *buf, char *from, int len);
/** Ibuf interface End **/
+void misdn_lib_setup_bc(struct misdn_bchannel *bc);
void misdn_lib_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
void misdn_lib_split_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
diff --git a/channels/misdn/isdn_msg_parser.c b/channels/misdn/isdn_msg_parser.c
index 4c8d95208..751d36f72 100755
--- a/channels/misdn/isdn_msg_parser.c
+++ b/channels/misdn/isdn_msg_parser.c
@@ -267,7 +267,7 @@ msg_t *build_setup (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
enc_ie_channel_id(&setup->CHANNEL_ID, msg, 1, bc->channel, nt,bc);
{
- int type=bc->onumplan,plan=1,present=bc->pres,screen=0;
+ int type=bc->onumplan,plan=1,present=bc->pres,screen=bc->screen;
enc_ie_calling_pn(&setup->CALLING_PN, msg, type, plan, present,
screen, bc->oad, nt, bc);
}