[asterisk-dev] "56k" in dahdi/system.conf [was Re: [svn-commits] mattf: tools/trunk r4818 - /tools/trunk/dahdi_cfg.c]

Matthew Fredrickson creslin at digium.com
Mon Aug 25 11:10:39 CDT 2008


Matthew Fredrickson wrote:
> Tzafrir Cohen wrote:
>> Hi
>>
>> On Sun, Aug 24, 2008 at 05:54:12AM -0000, SVN commits to the Digium repositories wrote:
>>> Author: mattf
>>> Date: Sun Aug 24 00:54:11 2008
>>> New Revision: 4818
>>>
>>> URL: http://svn.digium.com/view/dahdi?view=rev&rev=4818
>>> Log:
>>> Add support for 56 KB HDLC as well as selectable rate in system.conf
>>>
>>> Modified:
>>>     tools/trunk/dahdi_cfg.c
>> What does it mean? Where should it be used?
>>
>> Something in the lines of:
>>
>> (immedietly following the description of dacsrbs)
>>
>> # 56k::
>> #   Set a D-channel (which has already been set above as 'bchan',
>> #   'hardhdlc' or 'nethdlc') to use 56kbps HDLC.
>>
>> The name "56k" sounds strange and and maybe not descriptive enough.
> 
> It is basically a call that puts whatever channel that maybe running an 
> HDLC encoder or decoder (nethdlc, dchan, mtp2, etc) into 56kbps HDLC mode.

Oh yeah, this also could be applicable on channels that are not running 
HDLC encoders at dahdi_cfg time, but are dynamically turned on via ioctl 
  as well. (i.e. DAHDI_HDLCRAWMODE and DAHDI_HDLCFCSMODE), giving the 
option of setting the default HDLC rate via system.conf.

Matthew Fredrickson
Digium, Inc.

> 
>> Also:
>>
>>> Modified: tools/trunk/dahdi_cfg.c
>>> URL: http://svn.digium.com/view/dahdi/tools/trunk/dahdi_cfg.c?view=diff&rev=4818&r1=4817&r2=4818
>>> ==============================================================================
>>> --- tools/trunk/dahdi_cfg.c (original)
>>> +++ tools/trunk/dahdi_cfg.c Sun Aug 24 00:54:11 2008
>>> @@ -85,6 +85,8 @@
>>>  static const char *sig[DAHDI_MAX_CHANNELS];		/* Signalling */
>>>  
>>>  static int slineno[DAHDI_MAX_CHANNELS];	/* Line number where signalling specified */
>>> +
>>> +static int fiftysixkhdlc[DAHDI_MAX_CHANNELS];
>>>  
>>>  static int spans=0;
>>>  
>>> @@ -646,6 +648,49 @@
>>>  	return 0;
>>>  }
>>>  
>>> +static int setfiftysixkhdlc(char *keyword, char *args)
>>> +{
>>> +	int res;
>>> +
>>> +	res = apply_channels(fiftysixkhdlc, args);
>>> +	if (res <= 0)
>>> +		return -1;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +static void apply_fiftysix(void)
>>> +{
>>> +	int x;
>>> +	int rate;
>>> +	int chanfd;
>>> +
>>> +	for (x = 1; x < DAHDI_MAX_CHANNELS; x++) {
>>> +		chanfd = open("/dev/dahdi/channel", O_RDWR);
>>> +		if (chanfd == -1) {
>>> +			fprintf(stderr, "Couldn't open /dev/zap/channel\n");
>>> +			exit(-1);
>>> +		}
>>> +
>>> +		if (ioctl(chanfd, DAHDI_SPECIFY, &x)) {
>>> +			continue;
>>> +		}
>>> +
>>> +		if (fiftysixkhdlc[x]) {
>>> +			printf("Setting channel %d to 56K mode (only valid on HDLC channels)\n", x);
>>> +			rate = 56;
>>> +		} else {
>>> +			rate = 64;
>>> +		}
>>> +
>>> +		if (ioctl(chanfd, DAHDI_HDLC_RATE, &rate)) {
>>> +			fprintf(stderr, "Error setting HDLC rate\n");
>>> +			exit(-1);
>>> +		}
>>> +		close(chanfd);
>>> +	}
>>> +}
>>> +
>>>  static int setechocan(char *keyword, char *args)
>>>  {
>>>  	int res;
>>> @@ -1310,6 +1355,7 @@
>>>  	{ "channel", rad_chanconfig },
>>>  	{ "channels", rad_chanconfig },
>>>  	{ "echocanceller", setechocan },
>>> +	{ "56k", setfiftysixkhdlc },
>>>  };
>>>  
>>>  static char *readline()
>> Here we are in the end of main()
>>
>>> @@ -1586,5 +1632,6 @@
>>>  		fprintf(stderr, "\n%d error(s) detected\n\n", errcnt);
>>>  		exit(1);
>>>  	}
>>> +	apply_fiftysix();
>>>  	exit(0);
>>>  }
>> Why run this is a separate loop? Re-open /dev/dahdi/channel regardless
>> of whether this directive was ever used.
> 
> Because if you previously had 56K HDLC enabled on a channel, and 
> subsequently you change your system.conf to disable it, that is the only 
> way it will be disabled.
> 
> The flag is a sticky flag, and is not reset when the channel is closed 
> or anything like that.
> 
>> The loop above for applying configuration to channels is indeed not a
>> pretty sight. 3 nesting levels can be easily removed from it (OK to
>> commit that now?)
>>
> 
> Feel free to improve as you see fit :-)
> 
> Matthew Fredrickson
> Digium, Inc.
> 
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
> 
> AstriCon 2008 - September 22 - 25 Phoenix, Arizona
> Register Now: http://www.astricon.net
> 
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-dev




More information about the asterisk-dev mailing list