1998-12-27 21:47:14 +00:00
|
|
|
/*
|
2000-10-09 13:18:17 +00:00
|
|
|
* Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
|
1998-12-27 21:47:14 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* i4b_q931.c - Q931 received messages handling
|
|
|
|
* --------------------------------------------
|
|
|
|
*
|
2000-10-09 13:18:17 +00:00
|
|
|
* $Id: i4b_q931.c,v 1.32 2000/08/24 11:48:58 hm Exp $
|
1998-12-27 21:47:14 +00:00
|
|
|
*
|
1999-12-14 20:48:35 +00:00
|
|
|
* $FreeBSD$
|
|
|
|
*
|
2000-10-09 13:18:17 +00:00
|
|
|
* last edit-date: [Mon May 29 16:56:52 2000]
|
1998-12-27 21:47:14 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include "i4bq931.h"
|
|
|
|
#else
|
|
|
|
#define NI4BQ931 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if NI4BQ931 > 0
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
|
|
|
|
#include <sys/callout.h>
|
|
|
|
#endif
|
|
|
|
|
1998-12-27 21:47:14 +00:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <machine/i4b_debug.h>
|
|
|
|
#include <machine/i4b_ioctl.h>
|
|
|
|
#include <machine/i4b_cause.h>
|
|
|
|
#else
|
|
|
|
#include <i4b/i4b_debug.h>
|
|
|
|
#include <i4b/i4b_ioctl.h>
|
|
|
|
#include <i4b/i4b_cause.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <i4b/include/i4b_isdnq931.h>
|
|
|
|
#include <i4b/include/i4b_l3l4.h>
|
|
|
|
#include <i4b/include/i4b_global.h>
|
|
|
|
|
|
|
|
#include <i4b/layer3/i4b_l3.h>
|
|
|
|
#include <i4b/layer3/i4b_l3fsm.h>
|
|
|
|
#include <i4b/layer3/i4b_q931.h>
|
|
|
|
|
|
|
|
#include <i4b/layer4/i4b_l4.h>
|
|
|
|
|
|
|
|
#ifndef __FreeBSD__
|
|
|
|
#define memcpy(d,s,l) bcopy(s,d,l)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
unsigned int i4b_l3_debug = L3_DEBUG_DEFAULT;
|
|
|
|
|
|
|
|
ctrl_desc_t ctrl_desc[MAX_CONTROLLERS]; /* controller description array */
|
|
|
|
int utoc_tab[MAX_CONTROLLERS]; /* unit to controller conversion */
|
|
|
|
|
|
|
|
/* protocol independent causes -> Q.931 causes */
|
|
|
|
|
|
|
|
unsigned char cause_tab_q931[CAUSE_I4B_MAX] = {
|
|
|
|
CAUSE_Q850_NCCLR, /* CAUSE_I4B_NORMAL -> normal call clearing */
|
|
|
|
CAUSE_Q850_USRBSY, /* CAUSE_I4B_BUSY -> user busy */
|
|
|
|
CAUSE_Q850_NOCAVAIL, /* CAUSE_I4B_NOCHAN -> no circuit/channel available*/
|
|
|
|
CAUSE_Q850_INCDEST, /* CAUSE_I4B_INCOMP -> incompatible destination */
|
|
|
|
CAUSE_Q850_CALLREJ, /* CAUSE_I4B_REJECT -> call rejected */
|
|
|
|
CAUSE_Q850_DSTOOORDR, /* CAUSE_I4B_OOO -> destination out of order */
|
|
|
|
CAUSE_Q850_TMPFAIL, /* CAUSE_I4B_TMPFAIL -> temporary failure */
|
2000-10-09 13:18:17 +00:00
|
|
|
CAUSE_Q850_USRBSY, /* CAUSE_I4B_L1ERROR -> L1 error / persistent deact XXX */
|
|
|
|
CAUSE_Q850_USRBSY, /* CAUSE_I4B_LLDIAL -> no dialout on leased line XXX */
|
1998-12-27 21:47:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* setup cr ref flag according to direction
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
unsigned char
|
|
|
|
setup_cr(call_desc_t *cd, unsigned char cr)
|
|
|
|
{
|
|
|
|
if(cd->crflag == CRF_ORIG)
|
|
|
|
return(cr & 0x7f); /* clear cr ref flag */
|
|
|
|
else if(cd->crflag == CRF_DEST)
|
|
|
|
return(cr | 0x80); /* set cr ref flag */
|
|
|
|
else
|
|
|
|
panic("setup_cr: invalid crflag!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* decode and process a Q.931 message
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
i4b_decode_q931(int unit, int msg_len, u_char *msg_ptr)
|
|
|
|
{
|
|
|
|
call_desc_t *cd;
|
|
|
|
int codeset = CODESET_0;
|
|
|
|
int old_codeset = CODESET_0;
|
|
|
|
int shift_flag = UNSHIFTED;
|
|
|
|
int crlen = 0;
|
|
|
|
int crval = 0;
|
|
|
|
int crflag = 0;
|
|
|
|
int i;
|
|
|
|
int offset;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
/* check protocol discriminator */
|
|
|
|
|
|
|
|
if(*msg_ptr != PD_Q931)
|
|
|
|
{
|
2000-10-09 13:18:17 +00:00
|
|
|
static int protoflag = -1; /* print only once .. */
|
|
|
|
|
|
|
|
if(*msg_ptr != protoflag)
|
|
|
|
{
|
|
|
|
NDBGL3(L3_P_ERR, "unknown protocol discriminator 0x%x!", *msg_ptr);
|
|
|
|
protoflag = *msg_ptr;
|
|
|
|
}
|
1998-12-27 21:47:14 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-10-09 13:18:17 +00:00
|
|
|
|
1998-12-27 21:47:14 +00:00
|
|
|
msg_ptr++;
|
|
|
|
msg_len--;
|
|
|
|
|
|
|
|
s = SPLI4B(); /* this has to be protected ! */
|
|
|
|
|
|
|
|
/* extract call reference */
|
|
|
|
|
|
|
|
crlen = *msg_ptr & CRLENGTH_MASK;
|
|
|
|
msg_ptr++;
|
|
|
|
msg_len--;
|
|
|
|
|
|
|
|
if(crlen != 0)
|
|
|
|
{
|
|
|
|
crval += *msg_ptr & 0x7f;
|
|
|
|
crflag = (*msg_ptr >> 7) & 0x01;
|
|
|
|
msg_ptr++;
|
|
|
|
msg_len--;
|
|
|
|
|
|
|
|
for(i=1; i < crlen; i++)
|
|
|
|
{
|
|
|
|
crval += *msg_ptr;
|
|
|
|
msg_ptr++;
|
|
|
|
msg_len--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
crval = 0;
|
|
|
|
crflag = 0;
|
|
|
|
}
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_MSG, "Call Ref, len %d, val %d, flag %d", crlen, crval, crflag);
|
1998-12-27 21:47:14 +00:00
|
|
|
|
|
|
|
/* find or allocate calldescriptor */
|
|
|
|
|
|
|
|
if((cd = cd_by_unitcr(unit, crval,
|
|
|
|
crflag == CRF_DEST ? CRF_ORIG : CRF_DEST)) == NULL)
|
|
|
|
{
|
|
|
|
if(*msg_ptr == SETUP)
|
|
|
|
{
|
|
|
|
/* get and init new calldescriptor */
|
|
|
|
|
|
|
|
cd = reserve_cd(); /* cdid filled in */
|
|
|
|
cd->controller = utoc_tab[unit];
|
|
|
|
cd->cr = crval;
|
|
|
|
cd->crflag = CRF_DEST; /* we are the dest side */
|
|
|
|
cd->ilt = NULL; /* reset link tab ptrs */
|
|
|
|
cd->dlt = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*XXX*/ if(crval != 0) /* ignore global call references */
|
|
|
|
{
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_ERR, "cannot find calldescriptor for cr = 0x%x, crflag = 0x%x, msg = 0x%x, frame = ", crval, crflag, *msg_ptr);
|
1998-12-27 21:47:14 +00:00
|
|
|
i4b_print_frame(msg_len, msg_ptr);
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
/* decode and handle message type */
|
|
|
|
|
|
|
|
i4b_decode_q931_message(unit, cd, *msg_ptr);
|
|
|
|
msg_ptr++;
|
|
|
|
msg_len--;
|
|
|
|
|
|
|
|
/* process information elements */
|
|
|
|
|
|
|
|
while(msg_len > 0)
|
|
|
|
{
|
|
|
|
/* check for shift codeset IE */
|
|
|
|
|
|
|
|
if((*msg_ptr & 0x80) && ((*msg_ptr & 0xf0) == SOIE_SHIFT))
|
|
|
|
{
|
|
|
|
if(!(*msg_ptr & SHIFT_LOCK))
|
|
|
|
shift_flag = SHIFTED;
|
|
|
|
|
|
|
|
old_codeset = codeset;
|
|
|
|
codeset = *msg_ptr & CODESET_MASK;
|
|
|
|
|
|
|
|
if((shift_flag != SHIFTED) &&
|
|
|
|
(codeset <= old_codeset))
|
|
|
|
{
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_ERR, "Q.931 lockingshift proc violation, shift %d -> %d", old_codeset, codeset);
|
1998-12-27 21:47:14 +00:00
|
|
|
codeset = old_codeset;
|
|
|
|
}
|
|
|
|
msg_len--;
|
|
|
|
msg_ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* process one IE for selected codeset */
|
|
|
|
|
|
|
|
switch(codeset)
|
|
|
|
{
|
|
|
|
case CODESET_0:
|
|
|
|
offset = i4b_decode_q931_cs0_ie(unit, cd, msg_len, msg_ptr);
|
|
|
|
msg_len -= offset;
|
|
|
|
msg_ptr += offset;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_ERR, "unknown codeset %d, ", codeset);
|
1998-12-27 21:47:14 +00:00
|
|
|
i4b_print_frame(msg_len, msg_ptr);
|
|
|
|
msg_len = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for non-locking shifts */
|
|
|
|
|
|
|
|
if(shift_flag == SHIFTED)
|
|
|
|
{
|
|
|
|
shift_flag = UNSHIFTED;
|
|
|
|
codeset = old_codeset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
next_l3state(cd, cd->event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* decode and process one Q.931 codeset 0 information element
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
int
|
|
|
|
i4b_decode_q931_cs0_ie(int unit, call_desc_t *cd, int msg_len, u_char *msg_ptr)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
switch(*msg_ptr)
|
|
|
|
{
|
2000-10-09 13:18:17 +00:00
|
|
|
|
|
|
|
/*********/
|
|
|
|
/* Q.931 */
|
|
|
|
/*********/
|
1998-12-27 21:47:14 +00:00
|
|
|
/* single byte IE's */
|
|
|
|
|
|
|
|
case IEI_SENDCOMPL:
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_MSG, "IEI_SENDCOMPL");
|
1998-12-27 21:47:14 +00:00
|
|
|
return(1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* multi byte IE's */
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
case IEI_SEGMMSG: /* segmented message */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_SEGMENTED_MESSAGE");
|
|
|
|
break;
|
|
|
|
|
1998-12-27 21:47:14 +00:00
|
|
|
case IEI_BEARERCAP: /* bearer capability */
|
|
|
|
switch(msg_ptr[2])
|
|
|
|
{
|
|
|
|
case 0x80: /* speech */
|
|
|
|
case 0x89: /* restricted digital info */
|
|
|
|
case 0x90: /* 3.1KHz audio */
|
|
|
|
/* XXX */ cd->bprot = BPROT_NONE;
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_MSG, "IEI_BEARERCAP - Telephony");
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x88: /* unrestricted digital info */
|
|
|
|
/* XXX */ cd->bprot = BPROT_RHDLC;
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_MSG, "IEI_BEARERCAP - Raw HDLC");
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* XXX */ cd->bprot = BPROT_NONE;
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_ERR, "IEI_BEARERCAP - Unsupported B-Protocol 0x%x", msg_ptr[2]);
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEI_CAUSE: /* cause */
|
|
|
|
if(msg_ptr[2] & 0x80)
|
|
|
|
{
|
|
|
|
cd->cause_in = msg_ptr[3] & 0x7f;
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_MSG, "IEI_CAUSE = %d", msg_ptr[3] & 0x7f);
|
1998-12-27 21:47:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cd->cause_in = msg_ptr[4] & 0x7f;
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_MSG, "IEI_CAUSE = %d", msg_ptr[4] & 0x7f);
|
1998-12-27 21:47:14 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
case IEI_CALLID: /* call identity */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_CALL_IDENTITY");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEI_CALLSTATE: /* call state */
|
|
|
|
cd->call_state = msg_ptr[2] & 0x3f;
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_CALLSTATE = %d", cd->call_state);
|
|
|
|
break;
|
|
|
|
|
1998-12-27 21:47:14 +00:00
|
|
|
case IEI_CHANNELID: /* channel id */
|
|
|
|
if((msg_ptr[2] & 0xf4) != 0x80)
|
|
|
|
{
|
|
|
|
cd->channelid = CHAN_NO;
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_ERR, "IEI_CHANNELID, unsupported value 0x%x", msg_ptr[2]);
|
1998-12-27 21:47:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch(msg_ptr[2] & 0x03)
|
|
|
|
{
|
|
|
|
case IE_CHAN_ID_NO:
|
|
|
|
cd->channelid = CHAN_NO;
|
|
|
|
break;
|
|
|
|
case IE_CHAN_ID_B1:
|
|
|
|
cd->channelid = CHAN_B1;
|
|
|
|
break;
|
|
|
|
case IE_CHAN_ID_B2:
|
|
|
|
cd->channelid = CHAN_B2;
|
|
|
|
break;
|
|
|
|
case IE_CHAN_ID_ANY:
|
|
|
|
cd->channelid = CHAN_ANY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cd->channelexcl = (msg_ptr[2] & 0x08) >> 3;
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_MSG, "IEI_CHANNELID - channel %d, exclusive = %d", cd->channelid, cd->channelexcl);
|
1998-12-27 21:47:14 +00:00
|
|
|
|
|
|
|
/* if this is a setup message, reserve channel */
|
|
|
|
|
|
|
|
if(cd->event == EV_SETUP)
|
|
|
|
{
|
|
|
|
if((cd->channelid == CHAN_B1) || (cd->channelid == CHAN_B2))
|
|
|
|
{
|
|
|
|
if(ctrl_desc[cd->controller].bch_state[cd->channelid] == BCH_ST_FREE)
|
|
|
|
ctrl_desc[cd->controller].bch_state[cd->channelid] = BCH_ST_RSVD;
|
|
|
|
else
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_ERR, "IE ChannelID, Channel NOT free!!");
|
1998-12-27 21:47:14 +00:00
|
|
|
}
|
|
|
|
else if(cd->channelid == CHAN_NO)
|
|
|
|
{
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_MSG, "IE ChannelID, SETUP with channel = No channel (CW)");
|
1998-12-27 21:47:14 +00:00
|
|
|
}
|
|
|
|
else /* cd->channelid == CHAN_ANY */
|
|
|
|
{
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_ERR, "ERROR: IE ChannelID, SETUP with channel = Any channel!");
|
1998-12-27 21:47:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
case IEI_PROGRESSI: /* progress indicator */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_PROGRESSINDICATOR");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEI_NETSPCFAC: /* network specific fac */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_NETSPCFAC");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEI_NOTIFIND: /* notification indicator */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_NOTIFICATION_INDICATOR");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEI_DISPLAY: /* display */
|
|
|
|
memcpy(cd->display, &msg_ptr[2], min(DISPLAY_MAX, msg_ptr[1]));
|
|
|
|
cd->display[min(DISPLAY_MAX, msg_ptr[1])] = '\0';
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_DISPLAY = %s", cd->display);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEI_DATETIME: /* date/time */
|
|
|
|
i = 2;
|
|
|
|
j = msg_ptr[1];
|
|
|
|
p = &(cd->datetime[0]);
|
|
|
|
*p = '\0';
|
|
|
|
|
|
|
|
for(j = msg_ptr[1]; j > 0; j--, i++)
|
|
|
|
sprintf(p+strlen(p), "%02d", msg_ptr[i]);
|
|
|
|
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_DATETIME = %s", cd->datetime);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEI_KEYPAD: /* keypad facility */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_KEYPAD_FACILITY");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEI_SIGNAL: /* signal type */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_SIGNAL = %d", msg_ptr[2]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEI_INFRATE: /* information rate */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_INFORMATION_RATE");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEI_ETETDEL: /* end to end transit delay */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_END_TO_END_TRANSIT_DELAY");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEI_CUG: /* closed user group */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_CLOSED_USER_GROUP");
|
|
|
|
break;
|
|
|
|
|
1998-12-27 21:47:14 +00:00
|
|
|
case IEI_CALLINGPN: /* calling party no */
|
|
|
|
if(msg_ptr[2] & 0x80) /* no presentation/screening indicator ? */
|
|
|
|
{
|
|
|
|
memcpy(cd->src_telno, &msg_ptr[3], min(TELNO_MAX, msg_ptr[1]-1));
|
|
|
|
cd->src_telno[min(TELNO_MAX, msg_ptr[1] - 1)] = '\0';
|
|
|
|
cd->scr_ind = SCR_NONE;
|
2000-10-09 13:18:17 +00:00
|
|
|
cd->prs_ind = PRS_NONE;
|
1998-12-27 21:47:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memcpy(cd->src_telno, &msg_ptr[4], min(TELNO_MAX, msg_ptr[1]-2));
|
|
|
|
cd->src_telno[min(TELNO_MAX, msg_ptr[1] - 2)] = '\0';
|
|
|
|
cd->scr_ind = (msg_ptr[3] & 0x03) + SCR_USR_NOSC;
|
2000-10-09 13:18:17 +00:00
|
|
|
cd->prs_ind = ((msg_ptr[3] >> 5) & 0x03) + PRS_ALLOWED;
|
1998-12-27 21:47:14 +00:00
|
|
|
}
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_MSG, "IEI_CALLINGPN = %s", cd->src_telno);
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
case IEI_CALLINGPS: /* calling party subaddress */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_CALLINGPS");
|
|
|
|
break;
|
|
|
|
|
1998-12-27 21:47:14 +00:00
|
|
|
case IEI_CALLEDPN: /* called party number */
|
|
|
|
memcpy(cd->dst_telno, &msg_ptr[3], min(TELNO_MAX, msg_ptr[1]-1));
|
|
|
|
cd->dst_telno[min(TELNO_MAX, msg_ptr [1] - 1)] = '\0';
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_MSG, "IEI_CALLED = %s", cd->dst_telno);
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
case IEI_CALLEDPS: /* called party subaddress */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_CALLEDPS");
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
2000-10-09 13:18:17 +00:00
|
|
|
|
|
|
|
case IEI_REDIRNO: /* redirecting number */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_REDIRECTING_NUMBER");
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
2000-10-09 13:18:17 +00:00
|
|
|
|
|
|
|
case IEI_TRNSEL: /* transit network selection */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_TRANSIT_NETWORK_SELECTION");
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
2000-10-09 13:18:17 +00:00
|
|
|
|
|
|
|
case IEI_RESTARTI: /* restart indicator */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_RESTART_INDICATOR");
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
2000-10-09 13:18:17 +00:00
|
|
|
|
|
|
|
case IEI_LLCOMPAT: /* low layer compat */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_LLCOMPAT");
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
case IEI_HLCOMPAT: /* high layer compat */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_HLCOMPAT");
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
case IEI_USERUSER: /* user-user */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_USER_USER");
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
case IEI_ESCAPE: /* escape for extension */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_ESCAPE");
|
1999-05-20 10:14:57 +00:00
|
|
|
break;
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
/*********/
|
|
|
|
/* Q.932 */
|
|
|
|
/*********/
|
|
|
|
case IEI_FACILITY: /* facility */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_FACILITY");
|
|
|
|
if(i4b_aoc(msg_ptr, cd) > -1)
|
|
|
|
i4b_l4_charging_ind(cd);
|
1999-05-20 10:14:57 +00:00
|
|
|
break;
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
/*********/
|
|
|
|
/* Q.95x */
|
|
|
|
/*********/
|
|
|
|
case IEI_CONCTDNO: /* connected number */
|
|
|
|
NDBGL3(L3_P_MSG, "IEI_CONCTDNO");
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
|
1998-12-27 21:47:14 +00:00
|
|
|
default:
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_ERR, "Unknown IE %d - ", *msg_ptr);
|
1998-12-27 21:47:14 +00:00
|
|
|
i4b_print_frame(msg_ptr[1]+2, msg_ptr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(msg_ptr[1] + 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* decode and process one Q.931 codeset 0 information element
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
i4b_decode_q931_message(int unit, call_desc_t *cd, u_char message_type)
|
|
|
|
{
|
2000-10-09 13:18:17 +00:00
|
|
|
char *m = NULL;
|
1998-12-27 21:47:14 +00:00
|
|
|
|
2000-10-09 13:18:17 +00:00
|
|
|
cd->event = EV_ILL;
|
|
|
|
|
1998-12-27 21:47:14 +00:00
|
|
|
switch(message_type)
|
|
|
|
{
|
|
|
|
/* call establishment */
|
|
|
|
|
|
|
|
case ALERT:
|
|
|
|
cd->event = EV_ALERT;
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "ALERT";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CALL_PROCEEDING:
|
|
|
|
cd->event = EV_CALLPRC;
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "CALL_PROCEEDING";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROGRESS:
|
|
|
|
cd->event = EV_PROGIND;
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "PROGRESS";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SETUP:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "SETUP";
|
1998-12-27 21:47:14 +00:00
|
|
|
cd->bprot = BPROT_NONE;
|
|
|
|
cd->cause_in = 0;
|
|
|
|
cd->cause_out = 0;
|
|
|
|
cd->dst_telno[0] = '\0';
|
|
|
|
cd->src_telno[0] = '\0';
|
|
|
|
cd->channelid = CHAN_NO;
|
|
|
|
cd->channelexcl = 0;
|
|
|
|
cd->display[0] = '\0';
|
|
|
|
cd->datetime[0] = '\0';
|
|
|
|
cd->event = EV_SETUP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CONNECT:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "CONNECT";
|
1998-12-27 21:47:14 +00:00
|
|
|
cd->datetime[0] = '\0';
|
|
|
|
cd->event = EV_CONNECT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SETUP_ACKNOWLEDGE:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "SETUP_ACKNOWLEDGE";
|
1998-12-27 21:47:14 +00:00
|
|
|
cd->event = EV_SETUPAK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CONNECT_ACKNOWLEDGE:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "CONNECT_ACKNOWLEDGE";
|
1998-12-27 21:47:14 +00:00
|
|
|
cd->event = EV_CONACK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* call information */
|
|
|
|
|
|
|
|
case USER_INFORMATION:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "USER_INFORMATION";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SUSPEND_REJECT:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "SUSPEND_REJECT";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RESUME_REJECT:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "RESUME_REJECT";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HOLD:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "HOLD";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SUSPEND:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "SUSPEND";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RESUME:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "RESUME";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HOLD_ACKNOWLEDGE:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "HOLD_ACKNOWLEDGE";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SUSPEND_ACKNOWLEDGE:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "SUSPEND_ACKNOWLEDGE";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RESUME_ACKNOWLEDGE:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "RESUME_ACKNOWLEDGE";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HOLD_REJECT:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "HOLD_REJECT";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RETRIEVE:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "RETRIEVE";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RETRIEVE_ACKNOWLEDGE:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "RETRIEVE_ACKNOWLEDGE";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RETRIEVE_REJECT:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "RETRIEVE_REJECT";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* call clearing */
|
|
|
|
|
|
|
|
case DISCONNECT:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "DISCONNECT";
|
1998-12-27 21:47:14 +00:00
|
|
|
cd->event = EV_DISCONN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RESTART:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "RESTART";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RELEASE:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "RELEASE";
|
1998-12-27 21:47:14 +00:00
|
|
|
cd->event = EV_RELEASE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RESTART_ACKNOWLEDGE:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "RESTART_ACKNOWLEDGE";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RELEASE_COMPLETE:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "RELEASE_COMPLETE";
|
1998-12-27 21:47:14 +00:00
|
|
|
cd->event = EV_RELCOMP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* misc messages */
|
|
|
|
|
|
|
|
case SEGMENT:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "SEGMENT";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FACILITY:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "FACILITY";
|
1998-12-27 21:47:14 +00:00
|
|
|
cd->event = EV_FACILITY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REGISTER:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "REGISTER";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTIFY:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "NOTIFY";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STATUS_ENQUIRY:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "STATUS_ENQUIRY";
|
1998-12-27 21:47:14 +00:00
|
|
|
cd->event = EV_STATENQ;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CONGESTION_CONTROL:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "CONGESTION_CONTROL";
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case INFORMATION:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "INFORMATION";
|
1998-12-27 21:47:14 +00:00
|
|
|
cd->event = EV_INFO;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STATUS:
|
2000-10-09 13:18:17 +00:00
|
|
|
m = "STATUS";
|
1998-12-27 21:47:14 +00:00
|
|
|
cd->event = EV_STATUS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2000-10-09 13:18:17 +00:00
|
|
|
NDBGL3(L3_P_ERR, "unit %d, cr = 0x%02x, msg = 0x%02x", unit, cd->cr, message_type);
|
1998-12-27 21:47:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-10-09 13:18:17 +00:00
|
|
|
if(m)
|
|
|
|
{
|
|
|
|
NDBGL3(L3_PRIM, "%s: unit %d, cr = 0x%02x\n", m, unit, cd->cr);
|
|
|
|
}
|
1998-12-27 21:47:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* NI4BQ931 > 0 */
|