2007-05-06 13:54:52 +00:00
/*****************************************************************************\
* * * *
* * LCR * *
* * * *
* * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *
* * Copyright : Andreas Eversberg * *
* * * *
* * reading interface . conf file and filling structure * *
* * * *
\ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include "main.h"
struct interface * interface_first = NULL ; /* first interface is current list */
struct interface * interface_newlist = NULL ; /* first interface in new list */
2012-01-27 06:27:52 +00:00
# ifdef WITH_MISDN
2007-06-27 06:23:50 +00:00
/* set default out_channel */
void default_out_channel ( struct interface_port * ifport )
2007-05-06 13:54:52 +00:00
{
struct select_channel * selchannel , * * selchannelp ;
2007-07-15 10:01:27 +00:00
selchannel = ( struct select_channel * ) MALLOC ( sizeof ( struct select_channel ) ) ;
2007-06-27 06:23:50 +00:00
memuse + + ;
2012-01-27 06:27:52 +00:00
2007-06-27 06:23:50 +00:00
if ( ifport - > mISDNport - > ntmode )
selchannel - > channel = CHANNEL_FREE ;
else
selchannel - > channel = CHANNEL_ANY ;
ifport - > out_channel = selchannel ;
/* additional channel selection for multipoint NT ports */
2009-05-14 18:31:43 +00:00
if ( ! ifport - > mISDNport - > ptp & & ifport - > mISDNport - > ntmode ) {
2007-06-27 06:23:50 +00:00
selchannelp = & ( selchannel - > next ) ;
2007-07-15 10:01:27 +00:00
selchannel = ( struct select_channel * ) MALLOC ( sizeof ( struct select_channel ) ) ;
2007-05-06 13:54:52 +00:00
memuse + + ;
2007-06-27 06:23:50 +00:00
selchannel - > channel = CHANNEL_NO ; // call waiting
2007-05-06 13:54:52 +00:00
* selchannelp = selchannel ;
}
2007-06-27 06:23:50 +00:00
}
/* set default in_channel */
void default_in_channel ( struct interface_port * ifport )
{
struct select_channel * selchannel ;
2007-05-06 13:54:52 +00:00
2007-07-15 10:01:27 +00:00
selchannel = ( struct select_channel * ) MALLOC ( sizeof ( struct select_channel ) ) ;
2007-05-06 13:54:52 +00:00
memuse + + ;
2007-06-27 06:23:50 +00:00
selchannel - > channel = CHANNEL_FREE ;
ifport - > in_channel = selchannel ;
2007-05-06 13:54:52 +00:00
}
2012-01-27 06:27:52 +00:00
# endif
2007-05-06 13:54:52 +00:00
/* parse string for a positive number */
static int get_number ( char * value )
{
int val = 0 ;
char text [ 10 ] ;
val = atoi ( value ) ;
SPRINT ( text , " %d " , val ) ;
if ( ! strcmp ( value , text ) )
return ( val ) ;
return ( - 1 ) ;
}
/* remove element from buffer
* and return pointer to next element in buffer */
static char * get_seperated ( char * buffer )
{
2009-05-14 18:31:43 +00:00
while ( * buffer ) {
if ( * buffer = = ' , ' | | * buffer < = 32 ) { /* seperate */
2007-05-06 13:54:52 +00:00
* buffer + + = ' \0 ' ;
while ( ( * buffer > ' \0 ' & & * buffer < = 32 ) | | * buffer = = ' , ' )
buffer + + ;
return ( buffer ) ;
}
buffer + + ;
}
return ( buffer ) ;
}
/*
* parameter processing
*/
static int inter_block ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
2009-05-14 18:31:43 +00:00
if ( ! interface - > ifport ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
/* add value */
2009-05-14 18:31:43 +00:00
if ( value [ 0 ] ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects no value. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
ifport - > block = 1 ;
return ( 0 ) ;
}
static int inter_extension ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
2009-09-23 08:07:00 +00:00
if ( interface - > external ) {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' not allowed, because interface is external interface. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
2009-05-14 18:31:43 +00:00
if ( value [ 0 ] ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects no value. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
interface - > extension = 1 ;
return ( 0 ) ;
}
2009-09-23 08:07:00 +00:00
static int inter_extern ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
if ( interface - > extension ) {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' not allowed, because interface is an extension. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
if ( value [ 0 ] ) {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects no value. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
interface - > external = 1 ;
return ( 0 ) ;
}
2007-05-06 13:54:52 +00:00
static int inter_ptp ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
2009-05-14 18:31:43 +00:00
if ( ! interface - > ifport ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
2009-05-14 18:31:43 +00:00
if ( interface - > ifport - > ptmp ) {
2007-05-09 05:39:20 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' previously ptmp was given. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
2007-05-06 13:54:52 +00:00
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
/* add value */
2009-05-14 18:31:43 +00:00
if ( value [ 0 ] ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects no value. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
ifport - > ptp = 1 ;
return ( 0 ) ;
}
2008-04-24 07:24:04 +00:00
#if 0
2007-05-09 05:39:20 +00:00
static int inter_ptmp ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
2009-05-14 18:31:43 +00:00
if ( ! interface - > ifport ) {
2007-05-09 05:39:20 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
2009-05-14 18:31:43 +00:00
if ( interface - > ifport - > ptp ) {
2007-05-09 05:39:20 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' previously ptp was given. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
/* add value */
2009-05-14 18:31:43 +00:00
if ( value [ 0 ] ) {
2007-05-09 05:39:20 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects no value. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
ifport - > ptmp = 1 ;
return ( 0 ) ;
}
2008-04-24 07:24:04 +00:00
# endif
2007-08-26 13:23:58 +00:00
static int inter_nt ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
2009-05-14 18:31:43 +00:00
if ( ! interface - > ifport ) {
2007-08-26 13:23:58 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
/* add value */
2009-05-14 18:31:43 +00:00
if ( value [ 0 ] ) {
2007-08-26 13:23:58 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects no value. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
ifport - > nt = 1 ;
return ( 0 ) ;
}
2008-09-21 06:57:51 +00:00
static int inter_tespecial ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
2009-05-14 18:31:43 +00:00
if ( ! interface - > ifport ) {
2008-09-21 06:57:51 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
/* add value */
2009-05-14 18:31:43 +00:00
if ( value [ 0 ] ) {
2008-09-21 06:57:51 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects no value. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
ifport - > tespecial = 1 ;
return ( 0 ) ;
}
2007-05-06 13:54:52 +00:00
static int inter_tones ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( value , " yes " ) ) {
2007-05-06 13:54:52 +00:00
interface - > is_tones = IS_YES ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( value , " no " ) ) {
2007-05-06 13:54:52 +00:00
interface - > is_tones = IS_NO ;
2009-05-14 18:31:43 +00:00
} else {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects value 'yes' or 'no'. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
return ( 0 ) ;
}
static int inter_earlyb ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( value , " yes " ) ) {
2007-05-06 13:54:52 +00:00
interface - > is_earlyb = IS_YES ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( value , " no " ) ) {
2007-05-06 13:54:52 +00:00
interface - > is_earlyb = IS_NO ;
2009-05-14 18:31:43 +00:00
} else {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects value 'yes' or 'no'. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
return ( 0 ) ;
}
static int inter_hunt ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( value , " linear " ) ) {
2007-05-06 13:54:52 +00:00
interface - > hunt = HUNT_LINEAR ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( value , " roundrobin " ) ) {
2007-05-06 13:54:52 +00:00
interface - > hunt = HUNT_ROUNDROBIN ;
2009-05-14 18:31:43 +00:00
} else {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects value 'linear' or 'roundrobin'. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
return ( 0 ) ;
}
static int inter_port ( struct interface * interface , char * filename , int line , char * parameter , char * value )
2008-09-06 11:59:48 +00:00
{
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' is outdated. \n Please use 'portnum' and decrease port number by 1! Ports are counted from 0 now. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
static int inter_portnum ( struct interface * interface , char * filename , int line , char * parameter , char * value )
2007-05-06 13:54:52 +00:00
{
2012-01-27 06:27:52 +00:00
# ifndef WITH_MISDN
SPRINT ( interface_error , " Error in %s (line %d): mISDN support is not compiled in. \n " , filename , line ) ;
return ( - 1 ) ;
# else
2007-05-06 13:54:52 +00:00
struct interface_port * ifport , * * ifportp ;
struct interface * searchif ;
int val ;
val = get_number ( value ) ;
2009-05-14 18:31:43 +00:00
if ( val = = - 1 ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects one numeric value. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* check for port already assigned */
searchif = interface_newlist ;
2009-05-14 18:31:43 +00:00
while ( searchif ) {
2007-07-07 15:13:20 +00:00
ifport = searchif - > ifport ;
2009-05-14 18:31:43 +00:00
while ( ifport ) {
if ( ifport - > portnum = = val ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): port '%d' already used above. \n " , filename , line , val ) ;
return ( - 1 ) ;
}
ifport = ifport - > next ;
}
searchif = searchif - > next ;
}
/* alloc port substructure */
2007-07-15 10:01:27 +00:00
ifport = ( struct interface_port * ) MALLOC ( sizeof ( struct interface_port ) ) ;
2007-05-06 13:54:52 +00:00
memuse + + ;
ifport - > interface = interface ;
/* set value */
ifport - > portnum = val ;
/* tail port */
ifportp = & interface - > ifport ;
while ( * ifportp )
ifportp = & ( ( * ifportp ) - > next ) ;
* ifportp = ifport ;
return ( 0 ) ;
2012-01-27 06:27:52 +00:00
# endif
2007-05-06 13:54:52 +00:00
}
2008-09-06 11:59:48 +00:00
static int inter_portname ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
2012-01-27 06:27:52 +00:00
# ifndef WITH_MISDN
SPRINT ( interface_error , " Error in %s (line %d): mISDN support is not compiled in. \n " , filename , line ) ;
return ( - 1 ) ;
# else
2008-09-07 08:31:58 +00:00
struct interface_port * ifport , * * ifportp ;
2010-05-31 16:45:02 +00:00
/* goto end of chain */
ifport = interface - > ifport ;
if ( ifport ) {
while ( ifport - > next )
ifport = ifport - > next ;
}
2008-09-07 08:31:58 +00:00
/* alloc port substructure */
ifport = ( struct interface_port * ) MALLOC ( sizeof ( struct interface_port ) ) ;
memuse + + ;
ifport - > interface = interface ;
/* set value */
ifport - > portnum = - 1 ; // disable until resolved
SCPY ( ifport - > portname , value ) ;
/* tail port */
ifportp = & interface - > ifport ;
while ( * ifportp )
ifportp = & ( ( * ifportp ) - > next ) ;
* ifportp = ifport ;
return ( 0 ) ;
2012-01-27 06:27:52 +00:00
# endif
2008-09-06 11:59:48 +00:00
}
2009-03-20 19:46:25 +00:00
static int inter_l1hold ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
2009-05-14 18:31:43 +00:00
if ( ! interface - > ifport ) {
2009-03-20 19:46:25 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
2009-05-14 18:31:43 +00:00
if ( ! strcmp ( value , " yes " ) ) {
2009-03-20 19:46:25 +00:00
ifport - > l1hold = 1 ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcmp ( value , " no " ) ) {
2009-03-20 19:46:25 +00:00
ifport - > l1hold = 0 ;
2009-05-14 18:31:43 +00:00
} else {
2009-03-20 19:46:25 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expecting parameter 'yes' or 'no'. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
return ( 0 ) ;
}
2008-04-24 07:24:04 +00:00
static int inter_l2hold ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
2009-05-14 18:31:43 +00:00
if ( ! interface - > ifport ) {
2008-04-24 07:24:04 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
2009-05-14 18:31:43 +00:00
if ( ! strcmp ( value , " yes " ) ) {
2008-04-24 07:24:04 +00:00
ifport - > l2hold = 1 ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcmp ( value , " no " ) ) {
2008-04-24 07:24:04 +00:00
ifport - > l2hold = - 1 ;
2009-05-14 18:31:43 +00:00
} else {
2008-04-24 07:24:04 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expecting parameter 'yes' or 'no'. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
return ( 0 ) ;
}
2007-05-06 13:54:52 +00:00
static int inter_channel_out ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
struct select_channel * selchannel , * * selchannelp ;
int val ;
char * p , * el ;
/* port in chain ? */
2009-05-14 18:31:43 +00:00
if ( ! interface - > ifport ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
p = value ;
2009-05-14 18:31:43 +00:00
while ( * p ) {
2007-05-06 13:54:52 +00:00
el = p ;
p = get_seperated ( p ) ;
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " force " ) ) {
2007-05-06 13:54:52 +00:00
ifport - > channel_force = 1 ;
2009-05-14 18:31:43 +00:00
if ( ifport - > out_channel ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): value 'force' may only appear as first element in list. \n " , filename , line ) ;
return ( - 1 ) ;
}
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " any " ) ) {
2007-06-27 06:23:50 +00:00
val = CHANNEL_ANY ;
2007-05-06 13:54:52 +00:00
goto selchannel ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " free " ) ) {
2007-06-27 06:23:50 +00:00
val = CHANNEL_FREE ;
2007-05-06 13:54:52 +00:00
goto selchannel ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " no " ) ) {
2007-06-27 06:23:50 +00:00
val = CHANNEL_NO ;
2007-05-06 13:54:52 +00:00
goto selchannel ;
2009-05-14 18:31:43 +00:00
} else {
2007-05-06 13:54:52 +00:00
val = get_number ( el ) ;
2009-05-14 18:31:43 +00:00
if ( val = = - 1 ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects a comma seperated list of 'force', 'any', 'free', 'no' and any channel number. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
2009-05-14 18:31:43 +00:00
if ( val < 1 | | val = = 16 | | val > 126 ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): channel '%d' out of range. \n " , filename , line , val ) ;
return ( - 1 ) ;
}
selchannel :
/* add to select-channel list */
2007-07-15 10:01:27 +00:00
selchannel = ( struct select_channel * ) MALLOC ( sizeof ( struct select_channel ) ) ;
2007-05-06 13:54:52 +00:00
memuse + + ;
/* set value */
selchannel - > channel = val ;
/* tail port */
2007-06-27 06:23:50 +00:00
selchannelp = & ifport - > out_channel ;
2007-05-06 13:54:52 +00:00
while ( * selchannelp )
selchannelp = & ( ( * selchannelp ) - > next ) ;
* selchannelp = selchannel ;
}
}
return ( 0 ) ;
}
static int inter_channel_in ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
struct select_channel * selchannel , * * selchannelp ;
int val ;
char * p , * el ;
/* port in chain ? */
2009-05-14 18:31:43 +00:00
if ( ! interface - > ifport ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
p = value ;
2009-05-14 18:31:43 +00:00
while ( * p ) {
2007-05-06 13:54:52 +00:00
el = p ;
p = get_seperated ( p ) ;
2009-05-14 18:31:43 +00:00
if ( ifport - > in_channel ) if ( ifport - > in_channel - > channel = = CHANNEL_FREE ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' has values behind 'free' keyword. They has no effect. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " free " ) ) {
2007-06-27 06:23:50 +00:00
val = CHANNEL_FREE ;
2007-05-06 13:54:52 +00:00
goto selchannel ;
2009-05-14 18:31:43 +00:00
} else {
2007-05-06 13:54:52 +00:00
val = get_number ( el ) ;
2009-05-14 18:31:43 +00:00
if ( val = = - 1 ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects a comma seperated list of channel numbers and 'free'. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
2009-05-14 18:31:43 +00:00
if ( val < 1 | | val = = 16 | | val > 126 ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): channel '%d' out of range. \n " , filename , line , val ) ;
return ( - 1 ) ;
}
selchannel :
/* add to select-channel list */
2007-07-15 10:01:27 +00:00
selchannel = ( struct select_channel * ) MALLOC ( sizeof ( struct select_channel ) ) ;
2007-05-06 13:54:52 +00:00
memuse + + ;
/* set value */
selchannel - > channel = val ;
/* tail port */
2007-06-27 06:23:50 +00:00
selchannelp = & ifport - > in_channel ;
2007-05-06 13:54:52 +00:00
while ( * selchannelp )
selchannelp = & ( ( * selchannelp ) - > next ) ;
* selchannelp = selchannel ;
}
}
return ( 0 ) ;
}
2008-01-12 11:28:22 +00:00
static int inter_timeouts ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
2008-02-16 08:09:35 +00:00
// struct select_channel *selchannel, **selchannelp;
// int val;
2008-01-12 11:28:22 +00:00
char * p , * el ;
/* port in chain ? */
2009-05-14 18:31:43 +00:00
if ( ! interface - > ifport ) {
2008-01-12 11:28:22 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
p = value ;
2009-05-14 18:31:43 +00:00
if ( ! * p ) {
2008-01-12 11:28:22 +00:00
nofive :
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects five timeout values. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
el = p ;
p = get_seperated ( p ) ;
ifport - > tout_setup = atoi ( el ) ;
if ( ! * p )
goto nofive ;
el = p ;
p = get_seperated ( p ) ;
ifport - > tout_dialing = atoi ( el ) ;
if ( ! * p )
goto nofive ;
el = p ;
p = get_seperated ( p ) ;
ifport - > tout_proceeding = atoi ( el ) ;
if ( ! * p )
goto nofive ;
el = p ;
p = get_seperated ( p ) ;
ifport - > tout_alerting = atoi ( el ) ;
if ( ! * p )
goto nofive ;
el = p ;
p = get_seperated ( p ) ;
ifport - > tout_disconnect = atoi ( el ) ;
return ( 0 ) ;
}
2007-05-06 13:54:52 +00:00
static int inter_msn ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_msn * ifmsn , * * ifmsnp ;
char * p , * el ;
2009-05-14 18:31:43 +00:00
if ( ! value [ 0 ] ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects one MSN number or a list. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
2009-05-14 18:31:43 +00:00
if ( interface - > ifscreen_in ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' not allowed with 'screen_in' parameter. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* process list */
p = value ;
2009-05-14 18:31:43 +00:00
while ( * p ) {
2007-05-06 13:54:52 +00:00
el = p ;
p = get_seperated ( p ) ;
/* add MSN to list */
2007-07-15 10:01:27 +00:00
ifmsn = ( struct interface_msn * ) MALLOC ( sizeof ( struct interface_msn ) ) ;
2007-05-06 13:54:52 +00:00
memuse + + ;
/* set value */
SCPY ( ifmsn - > msn , el ) ;
/* tail port */
ifmsnp = & interface - > ifmsn ;
while ( * ifmsnp )
ifmsnp = & ( ( * ifmsnp ) - > next ) ;
* ifmsnp = ifmsn ;
}
return ( 0 ) ;
}
static int inter_screen ( struct interface_screen * * ifscreenp , struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_screen * ifscreen ;
char * p , * el ;
2009-05-14 18:31:43 +00:00
if ( ! value [ 0 ] ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects old caller ID and new caller ID. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* add screen entry to list*/
2007-07-15 10:01:27 +00:00
ifscreen = ( struct interface_screen * ) MALLOC ( sizeof ( struct interface_screen ) ) ;
2007-05-06 13:54:52 +00:00
memuse + + ;
2007-05-15 20:59:29 +00:00
ifscreen - > match_type = - 1 ; /* unchecked */
ifscreen - > match_present = - 1 ; /* unchecked */
2007-05-06 13:54:52 +00:00
ifscreen - > result_type = - 1 ; /* unchanged */
ifscreen - > result_present = - 1 ; /* unchanged */
/* tail port */
while ( * ifscreenp )
ifscreenp = & ( ( * ifscreenp ) - > next ) ;
* ifscreenp = ifscreen ;
2008-01-05 21:58:22 +00:00
// printf("interface=%s\n", interface->name);
2007-05-06 13:54:52 +00:00
/* get match */
2007-12-22 09:10:18 +00:00
p = value ;
2009-05-14 18:31:43 +00:00
while ( * p ) {
2007-05-06 13:54:52 +00:00
el = p ;
p = get_seperated ( p ) ;
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " unknown " ) ) {
if ( ifscreen - > match_type ! = - 1 ) {
2007-05-06 13:54:52 +00:00
typeerror :
SPRINT ( interface_error , " Error in %s (line %d): number type already set earlier. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
ifscreen - > match_type = INFO_NTYPE_UNKNOWN ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " subscriber " ) ) {
2007-05-06 13:54:52 +00:00
if ( ifscreen - > match_type ! = - 1 )
goto typeerror ;
ifscreen - > match_type = INFO_NTYPE_SUBSCRIBER ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " national " ) ) {
2007-05-06 13:54:52 +00:00
if ( ifscreen - > match_type ! = - 1 )
goto typeerror ;
ifscreen - > match_type = INFO_NTYPE_NATIONAL ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " international " ) ) {
2007-05-06 13:54:52 +00:00
if ( ifscreen - > match_type ! = - 1 )
goto typeerror ;
ifscreen - > match_type = INFO_NTYPE_INTERNATIONAL ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " allowed " ) ) {
if ( ifscreen - > match_present ! = - 1 ) {
2007-05-06 13:54:52 +00:00
presenterror :
2007-05-15 20:59:29 +00:00
SPRINT ( interface_error , " Error in %s (line %d): presentation type already set earlier. \n " , filename , line ) ;
2007-05-06 13:54:52 +00:00
return ( - 1 ) ;
}
ifscreen - > match_present = INFO_PRESENT_ALLOWED ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " restrict " ) | | ! strcasecmp ( el , " restricted " ) ) {
2007-05-06 13:54:52 +00:00
if ( ifscreen - > match_present ! = - 1 )
goto presenterror ;
ifscreen - > match_present = INFO_PRESENT_RESTRICTED ;
} else {
SCPY ( ifscreen - > match , el ) ;
2007-05-15 20:59:29 +00:00
/* check for % at the end */
2009-05-14 18:31:43 +00:00
if ( strchr ( el , ' % ' ) ) {
if ( strchr ( el , ' % ' ) ! = el + strlen ( el ) - 1 ) {
2007-05-15 20:59:29 +00:00
SPRINT ( interface_error , " Error in %s (line %d): %% joker found, but must at the end. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
}
2007-05-06 13:54:52 +00:00
break ;
}
}
2009-05-14 18:31:43 +00:00
if ( ifscreen - > match [ 0 ] = = ' \0 ' ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects old caller ID. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* get result */
2009-05-14 18:31:43 +00:00
while ( * p ) {
2007-05-06 13:54:52 +00:00
el = p ;
p = get_seperated ( p ) ;
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " unknown " ) ) {
2007-05-06 13:54:52 +00:00
if ( ifscreen - > result_type ! = - 1 )
goto typeerror ;
ifscreen - > result_type = INFO_NTYPE_UNKNOWN ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " subscriber " ) ) {
2007-05-06 13:54:52 +00:00
if ( ifscreen - > result_type ! = - 1 )
goto typeerror ;
ifscreen - > result_type = INFO_NTYPE_SUBSCRIBER ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " national " ) ) {
2007-05-06 13:54:52 +00:00
if ( ifscreen - > result_type ! = - 1 )
goto typeerror ;
ifscreen - > result_type = INFO_NTYPE_NATIONAL ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " international " ) ) {
2007-05-06 13:54:52 +00:00
if ( ifscreen - > result_type ! = - 1 )
goto typeerror ;
ifscreen - > result_type = INFO_NTYPE_INTERNATIONAL ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " present " ) | | ! strcasecmp ( el , " presented " ) | | ! strcasecmp ( el , " allowed " ) | | ! strcasecmp ( el , " allow " ) ) {
2007-05-06 13:54:52 +00:00
if ( ifscreen - > result_present ! = - 1 )
goto presenterror ;
ifscreen - > result_present = INFO_PRESENT_ALLOWED ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( el , " restrict " ) | | ! strcasecmp ( el , " restricted " ) | | ! strcasecmp ( el , " deny " ) | | ! strcasecmp ( el , " denied " ) ) {
2007-05-06 13:54:52 +00:00
if ( ifscreen - > result_present ! = - 1 )
goto presenterror ;
ifscreen - > result_present = INFO_PRESENT_RESTRICTED ;
} else {
SCPY ( ifscreen - > result , el ) ;
2007-05-15 20:59:29 +00:00
/* check for % at the end */
2009-05-14 18:31:43 +00:00
if ( strchr ( el , ' % ' ) ) {
if ( strchr ( el , ' % ' ) ! = el + strlen ( el ) - 1 ) {
2007-05-15 20:59:29 +00:00
SPRINT ( interface_error , " Error in %s (line %d): %% joker found, but must at the end. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
}
2007-05-06 13:54:52 +00:00
break ;
}
}
2009-05-14 18:31:43 +00:00
if ( ifscreen - > result [ 0 ] = = ' \0 ' ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects new caller ID. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
return ( 0 ) ;
}
static int inter_screen_in ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
2009-05-14 18:31:43 +00:00
if ( interface - > ifmsn ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' not allowed with 'msn' parameter. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
return ( inter_screen ( & interface - > ifscreen_in , interface , filename , line , parameter , value ) ) ;
}
static int inter_screen_out ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
return ( inter_screen ( & interface - > ifscreen_out , interface , filename , line , parameter , value ) ) ;
}
2007-06-27 06:23:50 +00:00
static int inter_nodtmf ( struct interface * interface , char * filename , int line , char * parameter , char * value )
2007-05-06 13:54:52 +00:00
{
2007-06-27 06:23:50 +00:00
struct interface_port * ifport ;
/* port in chain ? */
2009-05-14 18:31:43 +00:00
if ( ! interface - > ifport ) {
2007-06-27 06:23:50 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
ifport - > nodtmf = 1 ;
return ( 0 ) ;
}
2012-12-16 07:57:57 +00:00
static int inter_dtmf_threshold ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
if ( ! interface - > ifport ) {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
ifport - > dtmf_threshold = atoi ( value ) ;
return ( 0 ) ;
}
2007-06-27 06:23:50 +00:00
static int inter_filter ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
2008-01-06 14:49:29 +00:00
char * p , * q ;
/* seperate parameter from filter */
p = value ;
while ( * p > 32 )
p + + ;
2009-05-14 18:31:43 +00:00
if ( * p ) {
2008-01-06 14:49:29 +00:00
* p + + = 0 ;
while ( * p > 0 & & * p < = 32 )
p + + ;
}
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( value , " gain " ) ) {
2008-01-06 14:49:29 +00:00
q = p ;
while ( * q > 32 )
q + + ;
2009-05-14 18:31:43 +00:00
if ( * q ) {
2008-01-06 14:49:29 +00:00
* q + + = 0 ;
while ( * q > 0 & & * q < = 32 )
q + + ;
}
2009-05-14 18:31:43 +00:00
if ( * p = = 0 | | * q = = 0 ) {
2008-01-06 14:49:29 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s %s' expects two gain values. \n " , filename , line , parameter , value ) ;
return ( - 1 ) ;
}
2009-05-14 18:31:43 +00:00
if ( atoi ( p ) < - 8 | | atoi ( p ) > 8 | | atoi ( q ) < - 8 | | atoi ( q ) > 8 ) {
2008-01-06 14:49:29 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s %s' gain values not in range. (-8...8) \n " , filename , line , parameter , value ) ;
return ( - 1 ) ;
}
2008-01-19 17:10:46 +00:00
interface - > tx_gain = atoi ( p ) ;
interface - > rx_gain = atoi ( q ) ;
2008-01-06 14:49:29 +00:00
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( value , " pipeline " ) ) {
if ( * p = = 0 ) {
2008-01-06 14:49:29 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s %s' expects pipeline string. \n " , filename , line , parameter , value ) ;
return ( - 1 ) ;
}
SCPY ( interface - > pipeline , p ) ;
} else
2009-05-14 18:31:43 +00:00
if ( ! strcasecmp ( value , " blowfish " ) ) {
2008-01-06 14:49:29 +00:00
unsigned char key [ 56 ] ;
int l ;
2009-05-14 18:31:43 +00:00
if ( ! ! strncmp ( p , " 0x " , 2 ) ) {
2008-01-06 14:49:29 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s %s' expects blowfish key starting with '0x'. \n " , filename , line , parameter , value ) ;
return ( - 1 ) ;
}
p + = 2 ;
l = 0 ;
2009-05-14 18:31:43 +00:00
while ( * p ) {
if ( l = = 56 ) {
2008-01-06 14:49:29 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s %s' key too long. \n " , filename , line , parameter , value ) ;
return ( - 1 ) ;
}
if ( * p > = ' 0 ' & & * p < = ' 9 ' )
key [ l ] = ( * p - ' 0 ' ) < < 4 ;
else if ( * p > = ' a ' & & * p < = ' f ' )
key [ l ] = ( * p - ' a ' + 10 ) < < 4 ;
else if ( * p > = ' A ' & & * p < = ' F ' )
key [ l ] = ( * p - ' A ' + 10 ) < < 4 ;
2009-05-14 18:31:43 +00:00
else {
2008-01-06 14:49:29 +00:00
digout :
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s %s' key has digits out of range. (0...9, a...f) \n " , filename , line , parameter , value ) ;
return ( - 1 ) ;
}
p + + ;
2009-05-14 18:31:43 +00:00
if ( * p = = 0 ) {
2008-01-06 14:49:29 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s %s' key must end on an 8 bit boundary (two character boundary). \n " , filename , line , parameter , value ) ;
return ( - 1 ) ;
}
if ( * p > = ' 0 ' & & * p < = ' 9 ' )
key [ l ] = ( * p - ' 0 ' ) < < 4 ;
else if ( * p > = ' a ' & & * p < = ' f ' )
key [ l ] = ( * p - ' a ' + 10 ) < < 4 ;
else if ( * p > = ' A ' & & * p < = ' F ' )
key [ l ] = ( * p - ' A ' + 10 ) < < 4 ;
else
goto digout ;
p + + ;
l + + ;
}
2009-05-14 18:31:43 +00:00
if ( l < 4 ) {
2008-01-06 14:49:29 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s %s' key must be at least 4 bytes (8 characters). \n " , filename , line , parameter , value ) ;
return ( - 1 ) ;
}
memcpy ( interface - > bf_key , key , l ) ;
interface - > bf_len = l ;
2009-05-14 18:31:43 +00:00
} else {
2008-01-06 14:49:29 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' has unknown filter '%s'. \n " , filename , line , parameter , value ) ;
return ( - 1 ) ;
}
2007-05-06 13:54:52 +00:00
return ( 0 ) ;
}
2009-02-15 08:04:14 +00:00
static int inter_dialmax ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
2009-05-14 18:31:43 +00:00
if ( ! interface - > ifport ) {
2009-02-15 08:04:14 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
ifport - > dialmax = atoi ( value ) ;
return ( 0 ) ;
}
2009-05-14 18:31:43 +00:00
static int inter_tones_dir ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
if ( ! interface - > ifport ) {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
SCPY ( ifport - > tones_dir , value ) ;
return ( 0 ) ;
}
2009-05-11 09:07:58 +00:00
static int inter_gsm ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
2010-05-31 16:45:02 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' is outdated. \n Please use 'gsm-bs' for base station or 'gsm-ms' for mobile station interface! \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
static int inter_gsm_bs ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
# ifndef WITH_GSM_BS
SPRINT ( interface_error , " Error in %s (line %d): GSM BS side not compiled in. \n " , filename , line ) ;
2009-05-11 09:07:58 +00:00
return ( - 1 ) ;
# else
struct interface * searchif ;
searchif = interface_newlist ;
2009-05-14 18:31:43 +00:00
while ( searchif ) {
2012-01-15 08:42:35 +00:00
if ( searchif - > gsm_bs ) {
SPRINT ( interface_error , " Error in %s (line %d): interface '%s' already uses gsm BS side. \n " , filename , line , searchif - > name ) ;
return ( - 1 ) ;
2009-05-11 09:07:58 +00:00
}
searchif = searchif - > next ;
}
2010-05-31 16:45:02 +00:00
/* goto end of chain again to set gsmflag */
2012-01-15 08:42:35 +00:00
interface - > gsm_bs = 1 ;
2010-05-31 16:45:02 +00:00
return ( 0 ) ;
# endif
}
2013-03-31 10:52:04 +00:00
static int inter_gsm_bs_hr ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
# ifndef WITH_GSM_BS
SPRINT ( interface_error , " Error in %s (line %d): GSM BS side not compiled in. \n " , filename , line ) ;
return ( - 1 ) ;
# else
interface - > gsm_bs_hr = 1 ;
return ( 0 ) ;
# endif
}
2010-05-31 16:45:02 +00:00
static int inter_gsm_ms ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
# ifndef WITH_GSM_MS
SPRINT ( interface_error , " Error in %s (line %d): GSM MS side not compiled in. \n " , filename , line ) ;
return ( - 1 ) ;
# else
struct interface * searchif ;
2012-01-15 08:42:35 +00:00
interface - > gsm_ms = 1 ;
2010-05-31 16:45:02 +00:00
/* copy values */
2011-09-02 09:08:56 +00:00
if ( ! value | | ! value [ 0 ] ) {
2010-05-31 16:45:02 +00:00
SPRINT ( interface_error , " Error in %s (line %d): Missing MS name and socket name. \n " , filename , line ) ;
return ( - 1 ) ;
}
2012-01-15 08:42:35 +00:00
SCPY ( interface - > gsm_ms_name , value ) ;
2010-05-31 16:45:02 +00:00
2011-02-26 16:49:21 +00:00
/* check if name is used multiple times */
2010-05-31 16:45:02 +00:00
searchif = interface_newlist ;
while ( searchif ) {
2012-03-25 14:40:24 +00:00
if ( searchif ! = interface & & ! strcmp ( searchif - > gsm_ms_name , interface - > gsm_ms_name ) ) {
2012-01-15 08:42:35 +00:00
SPRINT ( interface_error , " Error in %s (line %d): mobile '%s' already uses the given MS name '%s', choose a different one. \n " , filename , line , interface - > gsm_ms_name , searchif - > gsm_ms_name ) ;
return ( - 1 ) ;
2010-05-31 16:45:02 +00:00
}
searchif = searchif - > next ;
}
2009-05-11 09:07:58 +00:00
return ( 0 ) ;
# endif
}
2012-01-13 05:24:21 +00:00
static int inter_sip ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
# ifndef WITH_SIP
SPRINT ( interface_error , " Error in %s (line %d): SIP not compiled in. \n " , filename , line ) ;
return ( - 1 ) ;
# else
char * p ;
interface - > sip = 1 ;
/* copy values */
if ( ! value | | ! value [ 0 ] ) {
SPRINT ( interface_error , " Error in %s (line %d): Missing SIP local IP. \n " , filename , line ) ;
return ( - 1 ) ;
}
p = get_seperated ( value ) ;
if ( ! p [ 0 ] ) {
SPRINT ( interface_error , " Error in %s (line %d): Missing SIP remote IP. \n " , filename , line ) ;
return ( - 1 ) ;
}
2012-02-18 08:50:43 +00:00
SCPY ( interface - > sip_local_peer , value ) ;
SCPY ( interface - > sip_remote_peer , p ) ;
2012-01-13 05:24:21 +00:00
return ( 0 ) ;
# endif
}
2012-01-15 08:42:35 +00:00
static int inter_rtp_bridge ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
2012-02-01 16:52:36 +00:00
int supported = 0 ;
# ifdef WITH_GSM_BS
if ( interface - > gsm_bs )
supported = 1 ;
# endif
# ifdef WITH_SIP
if ( interface - > sip )
supported = 1 ;
# endif
if ( ! supported ) {
SPRINT ( interface_error , " Error in %s (line %d): Interface does not support RTP \n " , filename , line ) ;
return ( - 1 ) ;
}
2013-10-02 16:02:17 +00:00
if ( interface - > app ! = EAPP_TYPE_BRIDGE ) {
SPRINT ( interface_error , " Error in %s (line %d): '%s' requires previous 'bridge' parameter. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
2012-01-15 08:42:35 +00:00
interface - > rtp_bridge = 1 ;
return ( 0 ) ;
}
2012-02-01 16:52:36 +00:00
#if 0
static int inter_rtp_payload ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
# ifndef WITH_GSM_BS
SPRINT ( interface_error , " Error in %s (line %d): GSM BS side not compiled in. \n " , filename , line ) ;
return ( - 1 ) ;
# else
if ( ! interface - > gsm_bs ) {
SPRINT ( interface_error , " Error in %s (line %d): This parameter only works for GSM BS side interface \n " , filename , line ) ;
return ( - 1 ) ;
}
if ( ! interface - > rtp_bridge ) {
SPRINT ( interface_error , " Error in %s (line %d): This parameter only works here, if RTP bridging is enabled \n " , filename , line ) ;
return ( - 1 ) ;
}
if ( ! value [ 0 ] ) {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects one payload type \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
if ( interface - > gsm_bs_payloads = = sizeof ( interface - > gsm_bs_payload_types ) ) {
SPRINT ( interface_error , " Error in %s (line %d): Too many payload types defined \n " , filename , line ) ;
return ( - 1 ) ;
}
interface - > gsm_bs_payload_types [ interface - > gsm_bs_payloads + + ] = atoi ( value ) ;
return ( 0 ) ;
# endif
}
# endif
2010-01-15 20:55:25 +00:00
static int inter_nonotify ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
if ( ! interface - > ifport ) {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
ifport - > nonotify = 1 ;
return ( 0 ) ;
}
2009-09-26 11:20:29 +00:00
# ifdef WITH_SS5
static int inter_ss5 ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
char * element ;
/* port in chain ? */
if ( ! interface - > ifport ) {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
ifport - > ss5 | = SS5_ENABLE ;
while ( ( element = strsep ( & value , " " ) ) ) {
if ( element [ 0 ] = = ' \0 ' )
continue ;
if ( ! strcasecmp ( element , " connect " ) )
ifport - > ss5 | = SS5_FEATURE_CONNECT ;
else
if ( ! strcasecmp ( element , " nodisconnect " ) )
ifport - > ss5 | = SS5_FEATURE_NODISCONNECT ;
else
if ( ! strcasecmp ( element , " releaseguardtimer " ) )
ifport - > ss5 | = SS5_FEATURE_RELEASEGUARDTIMER ;
else
if ( ! strcasecmp ( element , " bell " ) )
ifport - > ss5 | = SS5_FEATURE_BELL ;
else
if ( ! strcasecmp ( element , " pulsedialing " ) )
ifport - > ss5 | = SS5_FEATURE_PULSEDIALING ;
else
if ( ! strcasecmp ( element , " delay " ) )
ifport - > ss5 | = SS5_FEATURE_DELAY ;
else
2015-11-28 12:03:48 +00:00
if ( ! strcasecmp ( element , " release " ) )
ifport - > ss5 | = SS5_FEATURE_RELEASE ;
else
2015-12-13 07:20:39 +00:00
if ( ! strcasecmp ( element , " mute-rx " ) )
ifport - > ss5 | = SS5_FEATURE_MUTE_RX ;
else
if ( ! strcasecmp ( element , " mute-tx " ) )
ifport - > ss5 | = SS5_FEATURE_MUTE_TX ;
2015-11-28 12:03:48 +00:00
else
if ( ! strcasecmp ( element , " quality " ) )
ifport - > ss5 | = SS5_FEATURE_QUALITY ;
2009-09-26 11:20:29 +00:00
else {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' does not allow value element '%s'. \n " , filename , line , parameter , element ) ;
return ( - 1 ) ;
}
}
return ( 0 ) ;
}
# endif
2010-12-13 08:22:49 +00:00
static int inter_remote ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface * searchif ;
if ( ! value [ 0 ] ) {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects application name as value. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
searchif = interface_newlist ;
while ( searchif ) {
2012-07-27 15:20:43 +00:00
if ( interface - > remote & & ! strcmp ( interface - > remote_app , value ) ) {
SPRINT ( interface_error , " Error in %s (line %d): interface '%s' already uses remote application '%s'. \n " , filename , line , interface - > name , value ) ;
return ( - 1 ) ;
2010-12-13 08:22:49 +00:00
}
searchif = searchif - > next ;
}
/* goto end of chain again to set application name */
2012-07-27 15:20:43 +00:00
interface - > remote = 1 ;
SCPY ( interface - > remote_app , value ) ;
return ( 0 ) ;
}
static int inter_context ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
if ( ! value [ 0 ] ) {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects application context as value. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
SCPY ( interface - > remote_context , value ) ;
2010-12-13 08:22:49 +00:00
return ( 0 ) ;
}
2012-12-16 08:31:36 +00:00
static int inter_pots_flash ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
if ( ! interface - > ifport ) {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
ifport - > pots_flash = 1 ;
return ( 0 ) ;
}
static int inter_pots_ring ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
if ( ! interface - > ifport ) {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
ifport - > pots_ring = 1 ;
return ( 0 ) ;
}
static int inter_pots_transfer ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
struct interface_port * ifport ;
/* port in chain ? */
if ( ! interface - > ifport ) {
SPRINT ( interface_error , " Error in %s (line %d): parameter '%s' expects previous 'port' definition. \n " , filename , line , parameter ) ;
return ( - 1 ) ;
}
/* goto end of chain */
ifport = interface - > ifport ;
while ( ifport - > next )
ifport = ifport - > next ;
ifport - > pots_transfer = 1 ;
return ( 0 ) ;
}
2012-01-13 04:13:30 +00:00
static int inter_shutdown ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
interface - > shutdown = 1 ;
return ( 0 ) ;
}
2012-01-16 08:14:22 +00:00
static int inter_bridge ( struct interface * interface , char * filename , int line , char * parameter , char * value )
{
if ( ! value | | ! value [ 0 ] ) {
SPRINT ( interface_error , " Error in %s (line %d): Missing destination interface name. \n " , filename , line ) ;
return ( - 1 ) ;
}
interface - > app = EAPP_TYPE_BRIDGE ;
SCPY ( interface - > bridge_if , value ) ;
return ( 0 ) ;
}
2012-01-13 04:13:30 +00:00
2007-05-06 13:54:52 +00:00
/*
* structure of parameters
*/
struct interface_param interface_param [ ] = {
{ " extension " , & inter_extension , " " ,
" If keyword is given, calls to interface are handled as internal extensions. " } ,
2009-09-23 08:07:00 +00:00
{ " extern " , & inter_extern , " " ,
" If keyword is given, this interface will be used for external calls. \n "
" Calls require an external interface, if the routing action 'extern' is used \n without specific interface given. \n "
" Calls forwarded by extension's 'settings' also require an external interface. " } ,
2007-05-06 13:54:52 +00:00
{ " tones " , & inter_tones , " yes | no " ,
2007-08-03 18:13:17 +00:00
" Interface generates tones during call setup and release, or not. \n By default only NT-mode ports generate tones. " } ,
2007-05-06 13:54:52 +00:00
{ " earlyb " , & inter_earlyb , " yes | no " ,
2007-08-03 18:13:17 +00:00
" Interface receives and bridges tones during call setup and release, or not. \n By default only TE-mode ports receive tones. " } ,
2007-05-06 13:54:52 +00:00
{ " hunt " , & inter_hunt , " linear | roundrobin " ,
" Select the algorithm for selecting port with free channel. " } ,
{ " port " , & inter_port , " <number> " ,
2008-09-06 11:59:48 +00:00
" " } ,
{ " portnum " , & inter_portnum , " <number> " ,
" Give exactly one port for this interface. \n To give multiple ports, add more lines with port parameters. " } ,
2008-09-07 08:31:58 +00:00
{ " portname " , & inter_portname , " <name> " ,
" Same as 'portnum', but the name is given instead. \n Use 'isdninfo' to list all available ports and names. " } ,
2007-05-06 13:54:52 +00:00
{ " block " , & inter_block , " " ,
" If keyword is given, calls on this interface are blocked. \n "
" This parameter must follow a 'port' parameter. " } ,
{ " ptp " , & inter_ptp , " " ,
" The given port above is opened as point-to-point. \n "
" This is required on NT-mode ports that are multipoint by default. \n "
" This parameter must follow a 'port' parameter. " } ,
2008-04-24 07:24:04 +00:00
#if 0
2007-05-09 05:39:20 +00:00
{ " ptmp " , & inter_ptmp , " " ,
" The given port above is opened as point-to-multipoint. \n "
" This is required on PRI NT-mode ports that are point-to-point by default. \n "
" This parameter must follow a 'port' parameter. " } ,
2008-04-24 07:24:04 +00:00
# endif
2007-08-26 13:23:58 +00:00
{ " nt " , & inter_nt , " " ,
" The given port above is opened in NT-mode. \n "
" This is required on interfaces that support both NT-mode and TE-mode. \n "
" This parameter must follow a 'port' parameter. " } ,
2007-05-09 05:39:20 +00:00
2008-09-21 06:57:51 +00:00
{ " te-special " , & inter_tespecial , " " ,
" The given port uses a modified TE-mode. \n "
" All information elements that are allowed Network->User will then be \n "
" transmitted User->Network also. This is usefull to pass all informations \n "
" between two interconnected LCRs, like 'redirected number' or 'display'. \n "
" Note that this is not compliant with ISDN protocol. \n "
" This parameter must follow a 'port' parameter. " } ,
2009-03-20 19:46:25 +00:00
{ " layer1hold " , & inter_l1hold , " yes | no " ,
" The given port will not release layer 1 after layer 2 is down. \n "
" It is required to keep layer 1 of telephones up, to solve activation problems. \n "
" This parameter must follow a 'port' parameter. " } ,
2008-04-24 07:24:04 +00:00
{ " layer2hold " , & inter_l2hold , " yes | no " ,
" The given port will continuously try to establish layer 2 link and hold it. \n "
" It is required for PTP links in most cases, therefore it is default. \n "
" This parameter must follow a 'port' parameter. " } ,
2007-07-26 12:23:56 +00:00
{ " channel-out " , & inter_channel_out , " [force,][<number>][,...][,free][,any][,no] " ,
2007-05-06 13:54:52 +00:00
" Channel selection list for all outgoing calls to the interface. \n "
" A free channels is searched in order of appearance. \n "
" This parameter must follow a 'port' parameter. \n "
2010-11-28 07:53:32 +00:00
" force - Forces the selected port with no acceptable alternative (see Q.931). \n "
" -> this will be automatically set for multipoint (ptmp) NT-mode ports \n "
2007-05-06 13:54:52 +00:00
" <number>[,...] - List of channels to search. \n "
" free - Select any free channel \n "
" any - On outgoing calls, signal 'any channel acceptable'. (see DSS1) \n "
" no - Signal 'no channel available' aka 'call waiting'. (see DSS1) " } ,
2007-08-11 08:12:10 +00:00
{ " channel-in " , & inter_channel_in , " [<number>][,...][,free] " ,
2008-01-19 17:10:46 +00:00
" Channel selection list for all incoming calls from the interface. \n "
2007-05-06 13:54:52 +00:00
" A free channels is accepted if in the list. \n "
2007-07-26 12:23:56 +00:00
" If any channel was requested, the first free channel found is selected. \n "
2007-05-06 13:54:52 +00:00
" This parameter must follow a 'port' parameter. \n "
" <number>[,...] - List of channels to accept. \n "
2007-06-27 06:23:50 +00:00
" free - Accept any free channel " } ,
2007-05-06 13:54:52 +00:00
2008-01-12 11:28:22 +00:00
{ " timeouts " , & inter_timeouts , " <setup> <dialing> <proceeding> <alerting> <disconnect> " ,
2008-01-19 17:10:46 +00:00
" Timeout values for call states. They are both for incoming and outgoing states. \n "
2008-01-12 11:28:22 +00:00
" The default is 120 seconds for all states. Use 0 to disable. \n "
" This parameter must follow a 'port' parameter. \n " } ,
2007-05-06 13:54:52 +00:00
{ " msn " , & inter_msn , " <default MSN>,[<additional MSN>[,...]] " ,
2008-01-19 17:10:46 +00:00
" Incoming caller ID is checked against given MSN numbers. \n "
2007-05-06 13:54:52 +00:00
" If the caller ID is not found in this list, it is overwritten by the first MSN " } ,
2007-08-03 18:13:17 +00:00
{ " screen-in " , & inter_screen_in , " [options] <old caller ID>[%] [options] <new caller ID>[%] " ,
2008-01-19 17:10:46 +00:00
" Adds an entry for incoming calls to the caller ID screen list. \n "
2007-05-06 13:54:52 +00:00
" If the given 'old caller ID' matches, it is replaced by the 'new caller ID' \n "
2007-08-03 18:13:17 +00:00
" If '%' is given after old caller ID, it matches even if caller ID has \n "
2007-05-06 13:54:52 +00:00
" additional digits. \n "
2007-08-03 18:13:17 +00:00
" If '%' is given after mew caller ID, additinal digits of the 'old caller ID' \n "
2007-05-06 13:54:52 +00:00
" are added. \n "
" Options can be: \n "
" unknown | subsciber | national | international - Change caller ID type. \n "
" present | restrict - Change presentation of caller ID. " } ,
2007-08-03 18:13:17 +00:00
{ " screen-out " , & inter_screen_out , " [options] <old caller ID>[%] [options] <new caller ID>[%] " ,
2007-05-06 13:54:52 +00:00
" Adds an entry for outgoing calls to the caller ID screen list. \n "
" See 'screen-in' for help. " } ,
2007-06-27 06:23:50 +00:00
{ " nodtmf " , & inter_nodtmf , " " ,
" Disables DTMF detection for this interface. \n "
" This parameter must follow a 'port' parameter. " } ,
2012-12-16 07:57:57 +00:00
{ " dtmf-threshold " , & inter_dtmf_threshold , " " ,
" Set threshold value for minimum DTMF tone level. \n "
" This parameter must follow a 'port' parameter. " } ,
2008-01-06 14:49:29 +00:00
{ " filter " , & inter_filter , " <filter> <parameters> " ,
2007-05-06 13:54:52 +00:00
" Adds/appends a filter. Filters are ordered in transmit direction. \n "
" gain <tx-volume> <rx-volume> - Changes volume (-8 .. 8) \n "
2008-01-06 14:49:29 +00:00
" pipeline <string> - Sets echo cancelation pipeline. \n "
2007-05-06 13:54:52 +00:00
" blowfish <key> - Adds encryption. Key must be 4-56 bytes (8-112 hex characters. " } ,
2009-02-15 08:04:14 +00:00
{ " dialmax " , & inter_dialmax , " <digits> " ,
" Limits the number of digits in setup/information message. " } ,
2009-05-14 18:31:43 +00:00
{ " tones_dir " , & inter_tones_dir , " <path> " ,
" Overrides the given tone_dir in options.conf. \n "
" To used kernel tones in mISDN_dsp.ko, say 'american', 'german', or 'oldgerman'. " } ,
2009-05-11 09:07:58 +00:00
{ " gsm " , & inter_gsm , " " ,
2010-05-31 16:45:02 +00:00
" " } ,
{ " gsm-bs " , & inter_gsm_bs , " " ,
2012-01-13 04:18:49 +00:00
" Sets up GSM base station interface for using OpenBSC. " } ,
2013-03-31 10:52:04 +00:00
{ " hr " , & inter_gsm_bs_hr , " " ,
" Enable and prefer half rate for mobile terminating calls. " } ,
2012-01-13 04:18:49 +00:00
{ " gsm-ms " , & inter_gsm_ms , " <socket> " ,
2010-05-31 16:45:02 +00:00
" Sets up GSM mobile station interface for using Osmocom-BB. \n "
" The name of the MS folows the interface name. \n "
" The socket is /tmp/osmocom_l2 by default and need to be changed when multiple \n "
" MS interfaces are used. " } ,
2012-01-13 05:24:21 +00:00
{ " sip " , & inter_sip , " <local IP> <remote IP> " ,
" Sets up SIP interface that represents one SIP endpoint. \n "
" Give SIP configuration file. " } ,
2012-01-15 08:42:35 +00:00
{ " rtp-bridge " , & inter_rtp_bridge , " " ,
2012-02-01 16:52:36 +00:00
" Enables RTP bridging directly from this interface. \n "
2013-10-02 16:02:17 +00:00
" This only works if both bridged interfaces use RTP, e.g. between gsm-bs and sip. \n "
" This parameter must follow a 'bridge' parameter. \n " } ,
2012-02-01 16:52:36 +00:00
#if 0
not needed , since ms defines what is supports and remote ( sip ) tells what is selected
{ " rtp-payload " , & inter_rtp_payload , " <codec> " ,
" Define RTP payload to use. Only valid in conjuntion with gsm-bs! \n "
" If multiple payloads are defined, the first has highest priority. \n "
" If none are defined, GSM fullrate V1 (type 3) is assumed. \n " } ,
# endif
2010-01-15 20:55:25 +00:00
{ " nonotify " , & inter_nonotify , " " ,
" Prevents sending notify messages to this interface. A call placed on hold will \n "
" Not affect the remote end (phone or telcom switch). \n "
" This parameter must follow a 'port' parameter. " } ,
2012-01-16 08:14:22 +00:00
{ " bridge " , & inter_bridge , " <destination interface> " ,
" Define bridge application for this interface. All calls received on this \n "
" interface will be directly bridged to the given destination interface. \n "
" There will be no PBX application, nor routing. " } ,
2009-05-11 09:07:58 +00:00
2009-09-26 11:20:29 +00:00
# ifdef WITH_SS5
{ " ccitt5 " , & inter_ss5 , " [<feature> [feature ...]] " ,
" Interface uses CCITT No. 5 inband signalling rather than D-channel. \n "
" This feature causes CPU load to rise and has no practical intend. \n "
" If you don't know what it is, you don't need it. \n "
" Features apply to protocol behaviour and blueboxing specials, they are: \n "
" connect - Connect incomming call to throughconnect audio, if required. \n "
" nodisconnect - Don't disconnect if incomming exchange disconnects. \n "
" releaseguardtimer - Tries to prevent Blueboxing by a longer release-guard. \n "
" bell - Allow releasing and pulse-dialing via 2600 Hz like old Bell systems. \n "
" pulsedialing - Use pulse dialing on outgoing exchange. (takes long!) \n "
" delay - Use on incomming exchange, to make you feel a delay when blueboxing. \n "
2015-12-13 07:20:39 +00:00
" release - Pulse dialing a star (11 pulses per digit) clears current call. \n "
" mutes-rx - Mute received 2600 and 2400 Hz tones when detected. (more realistic) \n "
" mutes-tx - Mute received 2600 and 2400 Hz tones while transmitting reply tone. (more hackable) " } ,
2009-09-26 11:20:29 +00:00
# endif
2010-12-13 08:22:49 +00:00
{ " remote " , & inter_remote , " <application> " ,
" Sets up an interface that communicates with the remote application. \n "
" Use \" asterisk \" to use chan_lcr as remote application. " } ,
2012-07-27 15:20:43 +00:00
{ " context " , & inter_context , " <context> " ,
" Give context for calls to application. " } ,
2010-12-13 08:22:49 +00:00
2012-12-16 08:31:36 +00:00
{ " pots-flash " , & inter_pots_flash , " " ,
" Allow flash button to hold an active call and setup a new call. \n "
" Ihis parameter only appies to POTS type of interfaces \n "
" This parameter must follow a 'port' parameter. \n " } ,
{ " pots-ring-after-hangup " , & inter_pots_ring , " " ,
" Allow ringing of last hold call after hangup. Other calls on hold will not be \n "
" released. \n "
" Ihis parameter only appies to POTS type of interfaces \n "
" This parameter must follow a 'port' parameter. \n " } ,
{ " pots-transfer-after-hangup " , & inter_pots_transfer , " " ,
" If two calls on hold, both are connected after hangup. \n "
" If one call is on hold and another one alerting, call on hold is tranfered. \n "
" Ihis parameter only appies to POTS type of interfaces \n "
" This parameter must follow a 'port' parameter. \n " } ,
2012-01-13 04:13:30 +00:00
{ " shutdown " , & inter_shutdown , " " ,
" Interface will not be loaded when processing interface.conf " } ,
2007-05-06 13:54:52 +00:00
{ NULL , NULL , NULL , NULL }
} ;
/* read interfaces
*
* read settings from interface . conf
*/
char interface_error [ 256 ] ;
struct interface * read_interfaces ( void )
{
FILE * fp = NULL ;
char filename [ 128 ] ;
char * p ;
unsigned int line , i ;
char buffer [ 256 ] ;
struct interface * interface = NULL , /* in case no interface */
* * interfacep = & interface_newlist ;
char parameter [ 128 ] ;
char value [ 256 ] ;
int expecting = 1 ; /* expecting new interface */
struct interface_param * ifparam ;
if ( interface_newlist ! = NULL )
2007-07-15 10:01:27 +00:00
FATAL ( " list is not empty. \n " ) ;
2007-05-06 13:54:52 +00:00
interface_error [ 0 ] = ' \0 ' ;
2008-09-21 06:57:51 +00:00
SPRINT ( filename , " %s/interface.conf " , CONFIG_DATA ) ;
2007-05-06 13:54:52 +00:00
2009-05-14 18:31:43 +00:00
if ( ! ( fp = fopen ( filename , " r " ) ) ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Cannot open '%s' \n " , filename ) ;
goto error ;
}
line = 0 ;
2009-10-27 06:53:27 +00:00
while ( ( GETLINE ( buffer , fp ) ) ) {
2007-05-06 13:54:52 +00:00
p = buffer ;
line + + ;
2009-05-14 18:31:43 +00:00
while ( * p < = 32 ) { /* skip spaces */
2007-05-06 13:54:52 +00:00
if ( * p = = 0 )
break ;
p + + ;
}
if ( * p = = 0 | | * p = = ' # ' ) /* ignore comments and empty line */
continue ;
parameter [ 0 ] = 0 ;
value [ 0 ] = 0 ;
i = 0 ; /* read parameter */
2009-05-14 18:31:43 +00:00
while ( * p > 32 ) {
if ( i + 1 > = sizeof ( parameter ) ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): parameter name too long. \n " , filename , line ) ;
goto error ;
}
parameter [ i + 1 ] = ' \0 ' ;
parameter [ i + + ] = * p + + ;
}
2009-05-14 18:31:43 +00:00
while ( * p < = 32 ) { /* skip spaces */
2007-05-06 13:54:52 +00:00
if ( * p = = 0 )
break ;
p + + ;
}
2009-05-14 18:31:43 +00:00
if ( * p ! = 0 & & * p ! = ' # ' ) { /* missing name */
2007-05-06 13:54:52 +00:00
i = 0 ; /* read until end */
2009-05-14 18:31:43 +00:00
while ( * p ! = 0 & & * p ! = ' # ' ) {
if ( i + 1 > = sizeof ( value ) ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): value too long. \n " , filename , line ) ;
goto error ;
}
value [ i + 1 ] = ' \0 ' ;
value [ i + + ] = * p + + ;
}
/* remove trailing spaces from value */
2009-05-14 18:31:43 +00:00
while ( i ) {
2007-05-06 13:54:52 +00:00
if ( value [ i - 1 ] = = 0 | | value [ i - 1 ] > 32 )
break ;
value [ i - 1 ] = ' \0 ' ;
i - - ;
}
}
/* check for interface name as first statement */
2009-05-14 18:31:43 +00:00
if ( expecting & & parameter [ 0 ] ! = ' [ ' ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): expecting interface name inside [ and ], but got: '%s'. \n " , filename , line , parameter ) ;
goto error ;
}
expecting = 0 ;
/* check for new interface */
2009-05-14 18:31:43 +00:00
if ( parameter [ 0 ] = = ' [ ' ) {
if ( parameter [ strlen ( parameter ) - 1 ] ! = ' ] ' ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): expecting interface name inside [ and ], but got: '%s'. \n " , filename , line , parameter ) ;
goto error ;
}
parameter [ strlen ( parameter ) - 1 ] = ' \0 ' ;
/* check if interface name already exists */
2007-07-07 15:13:20 +00:00
interface = interface_newlist ;
2009-05-14 18:31:43 +00:00
while ( interface ) {
if ( ! strcasecmp ( interface - > name , parameter + 1 ) ) {
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): interface name '%s' already defined above. \n " , filename , line , parameter + 1 ) ;
goto error ;
}
interface = interface - > next ;
}
/* append interface to new list */
2007-07-15 10:01:27 +00:00
interface = ( struct interface * ) MALLOC ( sizeof ( struct interface ) ) ;
2007-05-06 13:54:52 +00:00
memuse + + ;
/* name interface */
SCPY ( interface - > name , parameter + 1 ) ;
/* attach */
* interfacep = interface ;
interfacep = & interface - > next ;
continue ;
}
ifparam = interface_param ;
2009-05-14 18:31:43 +00:00
while ( ifparam - > name ) {
if ( ! strcasecmp ( parameter , ifparam - > name ) ) {
2007-05-06 13:54:52 +00:00
if ( ifparam - > func ( interface , filename , line , parameter , value ) )
goto error ;
2007-07-07 15:13:20 +00:00
break ;
2007-05-06 13:54:52 +00:00
}
ifparam + + ;
}
2007-07-07 15:13:20 +00:00
if ( ifparam - > name )
continue ;
2007-05-06 13:54:52 +00:00
SPRINT ( interface_error , " Error in %s (line %d): unknown parameter: '%s'. \n " , filename , line , parameter ) ;
goto error ;
}
if ( fp ) fclose ( fp ) ;
return ( interface_newlist ) ;
error :
PERROR_RUNTIME ( " %s " , interface_error ) ;
if ( fp ) fclose ( fp ) ;
free_interfaces ( interface_newlist ) ;
interface_newlist = NULL ;
return ( NULL ) ;
}
/*
* freeing chain of interfaces
*/
void free_interfaces ( struct interface * interface )
{
void * temp ;
struct interface_port * ifport ;
struct select_channel * selchannel ;
struct interface_msn * ifmsn ;
struct interface_screen * ifscreen ;
2009-05-14 18:31:43 +00:00
while ( interface ) {
2007-05-06 13:54:52 +00:00
ifport = interface - > ifport ;
2009-05-14 18:31:43 +00:00
while ( ifport ) {
2007-05-06 13:54:52 +00:00
selchannel = ifport - > in_channel ;
2009-05-14 18:31:43 +00:00
while ( selchannel ) {
2007-05-06 13:54:52 +00:00
temp = selchannel ;
selchannel = selchannel - > next ;
2007-07-15 10:01:27 +00:00
FREE ( temp , sizeof ( struct select_channel ) ) ;
2007-05-06 13:54:52 +00:00
memuse - - ;
}
selchannel = ifport - > out_channel ;
2009-05-14 18:31:43 +00:00
while ( selchannel ) {
2007-05-06 13:54:52 +00:00
temp = selchannel ;
selchannel = selchannel - > next ;
2007-07-15 10:01:27 +00:00
FREE ( temp , sizeof ( struct select_channel ) ) ;
2007-05-06 13:54:52 +00:00
memuse - - ;
}
temp = ifport ;
ifport = ifport - > next ;
2007-07-15 10:01:27 +00:00
FREE ( temp , sizeof ( struct interface_port ) ) ;
2007-05-06 13:54:52 +00:00
memuse - - ;
}
ifmsn = interface - > ifmsn ;
2009-05-14 18:31:43 +00:00
while ( ifmsn ) {
2007-05-06 13:54:52 +00:00
temp = ifmsn ;
ifmsn = ifmsn - > next ;
2007-07-15 10:01:27 +00:00
FREE ( temp , sizeof ( struct interface_msn ) ) ;
2007-05-06 13:54:52 +00:00
memuse - - ;
}
ifscreen = interface - > ifscreen_in ;
2009-05-14 18:31:43 +00:00
while ( ifscreen ) {
2007-05-06 13:54:52 +00:00
temp = ifscreen ;
ifscreen = ifscreen - > next ;
2007-07-15 10:01:27 +00:00
FREE ( temp , sizeof ( struct interface_screen ) ) ;
2007-05-06 13:54:52 +00:00
memuse - - ;
}
ifscreen = interface - > ifscreen_out ;
2009-05-14 18:31:43 +00:00
while ( ifscreen ) {
2007-05-06 13:54:52 +00:00
temp = ifscreen ;
ifscreen = ifscreen - > next ;
2007-07-15 10:01:27 +00:00
FREE ( temp , sizeof ( struct interface_screen ) ) ;
2007-05-06 13:54:52 +00:00
memuse - - ;
}
temp = interface ;
interface = interface - > next ;
2007-07-15 10:01:27 +00:00
FREE ( temp , sizeof ( struct interface ) ) ;
2007-05-06 13:54:52 +00:00
memuse - - ;
}
}
2012-01-27 06:27:52 +00:00
# ifdef WITH_MISDN
2007-07-15 10:01:27 +00:00
/*
* defaults of ports if not specified by config
*/
2012-01-27 06:27:52 +00:00
static void set_mISDN_defaults ( struct interface_port * ifport )
2007-07-15 10:01:27 +00:00
{
/* default channel selection list */
if ( ! ifport - > out_channel )
default_out_channel ( ifport ) ;
if ( ! ifport - > in_channel )
default_in_channel ( ifport ) ;
2010-11-28 07:53:32 +00:00
/* must force the channel on PTMP/NT ports */
if ( ! ifport - > mISDNport - > ptp & & ifport - > mISDNport - > ntmode )
ifport - > channel_force = 1 ;
2007-07-15 10:01:27 +00:00
/* default is_tones */
if ( ifport - > interface - > is_tones )
ifport - > mISDNport - > tones = ( ifport - > interface - > is_tones = = IS_YES ) ;
else
2009-09-26 11:20:29 +00:00
ifport - > mISDNport - > tones = ( ifport - > mISDNport - > ntmode | | ifport - > mISDNport - > ss5 ) ? 1 : 0 ;
2007-07-15 10:01:27 +00:00
/* default is_earlyb */
if ( ifport - > interface - > is_earlyb )
ifport - > mISDNport - > earlyb = ( ifport - > interface - > is_earlyb = = IS_YES ) ;
else
2009-09-26 11:20:29 +00:00
ifport - > mISDNport - > earlyb = ( ifport - > mISDNport - > ntmode & & ! ifport - > mISDNport - > ss5 ) ? 0 : 1 ;
2007-07-15 10:01:27 +00:00
/* set locally flag */
if ( ifport - > interface - > extension )
ifport - > mISDNport - > locally = 1 ;
else
ifport - > mISDNport - > locally = 0 ;
}
2012-01-27 06:27:52 +00:00
# endif
2007-07-15 10:01:27 +00:00
2007-05-06 13:54:52 +00:00
/*
* all links between mISDNport and interface are made
* unused mISDNports are closed , new mISDNports are opened
* also set default select_channel lists
*/
void relink_interfaces ( void )
{
2012-01-27 06:27:52 +00:00
# ifdef WITH_MISDN
2007-05-06 13:54:52 +00:00
struct mISDNport * mISDNport ;
struct interface_port * ifport ;
2012-01-27 06:27:52 +00:00
# endif
2012-05-20 14:36:06 +00:00
struct interface * interface , * temp , * found ;
2007-05-06 13:54:52 +00:00
2012-01-15 08:42:35 +00:00
interface = interface_first ;
while ( interface ) {
2012-05-20 14:36:06 +00:00
found = NULL ;
2012-01-15 08:42:35 +00:00
temp = interface_newlist ;
while ( temp ) {
if ( ! strcmp ( temp - > name , interface - > name ) )
2012-05-20 14:36:06 +00:00
found = temp ;
2012-01-15 08:42:35 +00:00
temp = temp - > next ;
}
if ( ! found ) {
2012-01-07 08:34:51 +00:00
# ifdef WITH_GSM_MS
2012-01-15 08:42:35 +00:00
if ( interface - > gsm_ms )
gsm_ms_delete ( interface - > gsm_ms_name ) ;
2012-01-07 08:34:51 +00:00
# endif
# ifdef WITH_GSM_BS
2012-01-15 08:42:35 +00:00
if ( interface - > gsm_bs )
2012-01-07 08:34:51 +00:00
gsm_bs_exit ( 0 ) ;
2012-01-13 05:24:21 +00:00
# endif
# ifdef WITH_SIP
2012-01-15 08:42:35 +00:00
if ( interface - > sip )
sip_exit_inst ( interface ) ;
# endif
2012-05-20 14:36:06 +00:00
} else {
# ifdef WITH_SIP
if ( interface - > sip ) {
/* move sip instance, if we keep interface */
found - > sip_inst = interface - > sip_inst ;
interface - > sip_inst = NULL ;
}
# endif
;
2012-01-15 08:42:35 +00:00
}
interface = interface - > next ;
}
interface = interface_newlist ;
while ( interface ) {
2012-05-20 14:36:06 +00:00
found = NULL ;
2012-01-15 08:42:35 +00:00
temp = interface_first ;
while ( temp ) {
if ( ! strcmp ( temp - > name , interface - > name ) )
2012-05-20 14:36:06 +00:00
found = temp ;
2012-01-15 08:42:35 +00:00
temp = temp - > next ;
}
if ( ! found ) {
# ifdef WITH_GSM_MS
if ( interface - > gsm_ms )
gsm_ms_new ( interface ) ;
# endif
# ifdef WITH_GSM_BS
if ( interface - > gsm_bs )
gsm_bs_init ( interface ) ;
# endif
# ifdef WITH_SIP
if ( interface - > sip )
sip_init_inst ( interface ) ;
2012-01-07 08:34:51 +00:00
# endif
}
2012-01-15 08:42:35 +00:00
interface = interface - > next ;
}
2012-01-27 06:27:52 +00:00
# ifdef WITH_MISDN
2012-01-15 08:42:35 +00:00
/* unlink all mISDNports */
mISDNport = mISDNport_first ;
while ( mISDNport ) {
2007-05-06 13:54:52 +00:00
mISDNport - > ifport = NULL ;
mISDNport = mISDNport - > next ;
}
/* relink existing mISDNports */
interface = interface_newlist ;
2009-05-14 18:31:43 +00:00
while ( interface ) {
2007-05-06 13:54:52 +00:00
ifport = interface - > ifport ;
2009-05-14 18:31:43 +00:00
while ( ifport ) {
2007-05-06 13:54:52 +00:00
mISDNport = mISDNport_first ;
2009-05-14 18:31:43 +00:00
while ( mISDNport ) {
2009-03-14 15:59:45 +00:00
if ( ! strcmp ( mISDNport - > name , ifport - > portname ) )
ifport - > portnum = mISDNport - > portnum ; /* same name, so we use same number */
2009-05-14 18:31:43 +00:00
if ( mISDNport - > portnum = = ifport - > portnum ) {
2010-01-04 18:20:06 +00:00
PDEBUG ( DEBUG_ISDN , " Port %d:%s relinking! \n " , ifport - > portnum , ifport - > portname ) ;
2007-05-06 13:54:52 +00:00
ifport - > mISDNport = mISDNport ;
mISDNport - > ifport = ifport ;
2012-01-27 06:27:52 +00:00
set_mISDN_defaults ( ifport ) ;
2007-05-06 13:54:52 +00:00
}
mISDNport = mISDNport - > next ;
}
ifport = ifport - > next ;
}
interface = interface - > next ;
}
/* close unused mISDNports */
closeagain :
mISDNport = mISDNport_first ;
2009-05-14 18:31:43 +00:00
while ( mISDNport ) {
if ( mISDNport - > ifport = = NULL ) {
2007-05-06 13:54:52 +00:00
PDEBUG ( DEBUG_ISDN , " Port %d is not used anymore and will be closed \n " , mISDNport - > portnum ) ;
2012-01-07 08:34:51 +00:00
/* destroy port */
2007-05-06 13:54:52 +00:00
mISDNport_close ( mISDNport ) ;
goto closeagain ;
}
mISDNport = mISDNport - > next ;
}
/* open and link new mISDNports */
interface = interface_newlist ;
2009-05-14 18:31:43 +00:00
while ( interface ) {
2007-05-06 13:54:52 +00:00
ifport = interface - > ifport ;
2009-05-14 18:31:43 +00:00
while ( ifport ) {
if ( ! ifport - > mISDNport ) {
2012-01-13 04:13:30 +00:00
if ( ! interface - > shutdown ) {
2012-01-27 06:27:52 +00:00
load_mISDN_port ( ifport ) ;
2012-01-13 04:13:30 +00:00
} else {
ifport - > block = 2 ;
}
2007-05-09 05:39:20 +00:00
}
2007-07-07 15:13:20 +00:00
ifport = ifport - > next ;
2007-05-06 13:54:52 +00:00
}
interface = interface - > next ;
}
2012-01-27 06:27:52 +00:00
# endif
2007-05-06 13:54:52 +00:00
}
2007-07-07 15:13:20 +00:00
2012-01-27 06:27:52 +00:00
# ifdef WITH_MISDN
2007-07-07 15:13:20 +00:00
/*
* load port
*/
2012-01-27 06:27:52 +00:00
void load_mISDN_port ( struct interface_port * ifport )
2007-07-07 15:13:20 +00:00
{
struct mISDNport * mISDNport ;
/* open new port */
2010-01-15 20:55:25 +00:00
mISDNport = mISDNport_open ( ifport ) ;
2009-05-14 18:31:43 +00:00
if ( mISDNport ) {
2007-07-07 15:13:20 +00:00
/* link port */
ifport - > mISDNport = mISDNport ;
mISDNport - > ifport = ifport ;
2008-09-07 08:31:58 +00:00
/* set number and name */
ifport - > portnum = mISDNport - > portnum ;
SCPY ( ifport - > portname , mISDNport - > name ) ;
/* set defaults */
2012-01-27 06:27:52 +00:00
set_mISDN_defaults ( ifport ) ;
2009-09-26 11:20:29 +00:00
/* load static port instances */
mISDNport_static ( mISDNport ) ;
2009-05-14 18:31:43 +00:00
} else {
2007-07-07 15:13:20 +00:00
ifport - > block = 2 ; /* not available */
}
}
2012-01-27 06:27:52 +00:00
# endif
2007-07-07 15:13:20 +00:00
2007-05-06 13:54:52 +00:00
/*
* give summary of interface syntax
*/
void doc_interface ( void )
{
struct interface_param * ifparam ;
printf ( " Syntax overview \n " ) ;
printf ( " --------------- \n \n " ) ;
printf ( " [<name>] \n " ) ;
ifparam = interface_param ;
2009-05-14 18:31:43 +00:00
while ( ifparam - > name ) {
2008-09-06 11:59:48 +00:00
if ( ifparam - > name [ 0 ] )
printf ( " %s %s \n " , ifparam - > name , ifparam - > usage ) ;
2007-05-06 13:54:52 +00:00
ifparam + + ;
}
ifparam = interface_param ;
2009-05-14 18:31:43 +00:00
while ( ifparam - > name ) {
if ( ifparam - > name [ 0 ] ) {
2008-09-06 11:59:48 +00:00
printf ( " \n Parameter: %s %s \n " , ifparam - > name , ifparam - > usage ) ;
printf ( " %s \n " , ifparam - > help ) ;
}
2007-05-06 13:54:52 +00:00
ifparam + + ;
}
}
2008-01-05 21:58:22 +00:00
/* screen caller id
2008-01-19 17:10:46 +00:00
* out = = 0 : incoming caller id , out = = 1 : outgoing caller id
2008-01-05 21:58:22 +00:00
*/
2012-01-15 08:42:35 +00:00
void do_screen ( int out , char * id , int idsize , int * type , int * present , const char * interface_name )
2008-01-05 21:58:22 +00:00
{
char * msn1 ;
struct interface_msn * ifmsn ;
struct interface_screen * ifscreen ;
char suffix [ 64 ] ;
2012-01-15 08:42:35 +00:00
struct interface * interface = interface_first ;
2012-01-20 09:05:41 +00:00
interface = getinterfacebyname ( interface_name ) ;
2012-01-15 08:42:35 +00:00
if ( ! interface )
return ;
2008-01-05 21:58:22 +00:00
/* screen incoming caller id */
2009-05-14 18:31:43 +00:00
if ( ! out ) {
2008-01-05 21:58:22 +00:00
/* check for MSN numbers, use first MSN if no match */
msn1 = NULL ;
ifmsn = interface - > ifmsn ;
2009-05-14 18:31:43 +00:00
while ( ifmsn ) {
2008-01-05 21:58:22 +00:00
if ( ! msn1 )
msn1 = ifmsn - > msn ;
2009-05-14 18:31:43 +00:00
if ( ! strcmp ( ifmsn - > msn , id ) ) {
2008-01-05 21:58:22 +00:00
break ;
}
ifmsn = ifmsn - > next ;
}
2009-05-14 18:31:43 +00:00
if ( ifmsn ) {
2008-09-14 10:27:11 +00:00
start_trace ( - 1 , interface , numberrize_callerinfo ( id , * type , options . national , options . international ) , NULL , DIRECTION_IN , 0 , 0 , " SCREEN (found in MSN list) " ) ;
2008-01-05 21:58:22 +00:00
add_trace ( " msn " , NULL , " %s " , id ) ;
end_trace ( ) ;
}
2009-05-14 18:31:43 +00:00
if ( ! ifmsn & & msn1 ) { // not in list, first msn given
2008-09-14 10:27:11 +00:00
start_trace ( - 1 , interface , numberrize_callerinfo ( id , * type , options . national , options . international ) , NULL , DIRECTION_IN , 0 , 0 , " SCREEN (not found in MSN list) " ) ;
2008-01-05 21:58:22 +00:00
add_trace ( " msn " , " given " , " %s " , id ) ;
add_trace ( " msn " , " used " , " %s " , msn1 ) ;
end_trace ( ) ;
UNCPY ( id , msn1 , idsize ) ;
id [ idsize - 1 ] = ' \0 ' ;
}
}
/* check screen list */
if ( out )
ifscreen = interface - > ifscreen_out ;
else
ifscreen = interface - > ifscreen_in ;
2009-05-14 18:31:43 +00:00
while ( ifscreen ) {
2008-01-05 21:58:22 +00:00
if ( ifscreen - > match_type = = - 1 | | ifscreen - > match_type = = * type )
2009-05-14 18:31:43 +00:00
if ( ifscreen - > match_present = = - 1 | | ifscreen - > match_present = = * present ) {
if ( strchr ( ifscreen - > match , ' % ' ) ) {
2008-01-05 21:58:22 +00:00
if ( ! strncmp ( ifscreen - > match , id , strchr ( ifscreen - > match , ' % ' ) - ifscreen - > match ) )
break ;
2009-05-14 18:31:43 +00:00
} else {
2008-01-05 21:58:22 +00:00
if ( ! strcmp ( ifscreen - > match , id ) )
break ;
}
}
ifscreen = ifscreen - > next ;
}
2009-05-14 18:31:43 +00:00
if ( ifscreen ) { // match
2008-09-14 10:27:11 +00:00
start_trace ( - 1 , interface , numberrize_callerinfo ( id , * type , options . national , options . international ) , NULL , out ? DIRECTION_OUT : DIRECTION_IN , 0 , 0 , " SCREEN (found in screen list) " ) ;
2009-05-14 18:31:43 +00:00
switch ( * type ) {
2008-01-05 21:58:22 +00:00
case INFO_NTYPE_UNKNOWN :
add_trace ( " given " , " type " , " unknown " ) ;
break ;
case INFO_NTYPE_SUBSCRIBER :
add_trace ( " given " , " type " , " subscriber " ) ;
break ;
case INFO_NTYPE_NATIONAL :
add_trace ( " given " , " type " , " national " ) ;
break ;
case INFO_NTYPE_INTERNATIONAL :
add_trace ( " given " , " type " , " international " ) ;
break ;
}
2009-05-14 18:31:43 +00:00
switch ( * present ) {
2008-01-05 21:58:22 +00:00
case INFO_PRESENT_ALLOWED :
add_trace ( " given " , " present " , " allowed " ) ;
break ;
case INFO_PRESENT_RESTRICTED :
add_trace ( " given " , " present " , " restricted " ) ;
break ;
case INFO_PRESENT_NOTAVAIL :
add_trace ( " given " , " present " , " not available " ) ;
break ;
}
add_trace ( " given " , " id " , " %s " , id [ 0 ] ? id : " <empty> " ) ;
2009-05-14 18:31:43 +00:00
if ( ifscreen - > result_type ! = - 1 ) {
2008-01-05 21:58:22 +00:00
* type = ifscreen - > result_type ;
2009-05-14 18:31:43 +00:00
switch ( * type ) {
2008-01-05 21:58:22 +00:00
case INFO_NTYPE_UNKNOWN :
add_trace ( " used " , " type " , " unknown " ) ;
break ;
case INFO_NTYPE_SUBSCRIBER :
add_trace ( " used " , " type " , " subscriber " ) ;
break ;
case INFO_NTYPE_NATIONAL :
add_trace ( " used " , " type " , " national " ) ;
break ;
case INFO_NTYPE_INTERNATIONAL :
add_trace ( " used " , " type " , " international " ) ;
break ;
}
}
2009-05-14 18:31:43 +00:00
if ( ifscreen - > result_present ! = - 1 ) {
2008-01-05 21:58:22 +00:00
* present = ifscreen - > result_present ;
2009-05-14 18:31:43 +00:00
switch ( * present ) {
2008-01-05 21:58:22 +00:00
case INFO_PRESENT_ALLOWED :
add_trace ( " used " , " present " , " allowed " ) ;
break ;
case INFO_PRESENT_RESTRICTED :
add_trace ( " used " , " present " , " restricted " ) ;
break ;
case INFO_PRESENT_NOTAVAIL :
add_trace ( " used " , " present " , " not available " ) ;
break ;
}
}
2009-05-14 18:31:43 +00:00
if ( strchr ( ifscreen - > match , ' % ' ) ) {
2008-01-05 21:58:22 +00:00
SCPY ( suffix , strchr ( ifscreen - > match , ' % ' ) - ifscreen - > match + id ) ;
UNCPY ( id , ifscreen - > result , idsize ) ;
id [ idsize - 1 ] = ' \0 ' ;
2009-05-14 18:31:43 +00:00
if ( strchr ( id , ' % ' ) ) {
2008-01-05 21:58:22 +00:00
* strchr ( id , ' % ' ) = ' \0 ' ;
UNCAT ( id , suffix , idsize ) ;
id [ idsize - 1 ] = ' \0 ' ;
}
2009-05-14 18:31:43 +00:00
} else {
2008-01-05 21:58:22 +00:00
UNCPY ( id , ifscreen - > result , idsize ) ;
id [ idsize - 1 ] = ' \0 ' ;
}
add_trace ( " used " , " id " , " %s " , id [ 0 ] ? id : " <empty> " ) ;
end_trace ( ) ;
}
}
2012-01-20 09:05:41 +00:00
struct interface * getinterfacebyname ( const char * name )
{
struct interface * interface = interface_first ;
while ( interface ) {
if ( ! strcmp ( interface - > name , name ) )
return interface ;
interface = interface - > next ;
}
return NULL ;
}