[asterisk-dev] "56k" in dahdi/system.conf [was Re: [svn-commits] mattf: tools/trunk r4818 - /tools/trunk/dahdi_cfg.c]
Tzafrir Cohen
tzafrir.cohen at xorcom.com
Sun Aug 24 03:24:56 CDT 2008
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.
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.
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?)
--
Tzafrir Cohen
icq#16849755 jabber:tzafrir.cohen at xorcom.com
+972-50-7952406 mailto:tzafrir.cohen at xorcom.com
http://www.xorcom.com iax:guest at local.xorcom.com/tzafrir
More information about the asterisk-dev
mailing list