From 05b9910ea45cb34816ce2eb4143c4d3f2919a10b Mon Sep 17 00:00:00 2001 From: tilghman Date: Thu, 11 May 2006 22:50:08 +0000 Subject: Bug 6816 - Allow nethdlc device to take optional alternative name git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1053 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- zaptel.c | 22 +++++++++++++++++++++- zaptel.conf.sample | 8 +++++++- zaptel.h | 1 + ztcfg.c | 4 ++++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/zaptel.c b/zaptel.c index 512b23f..44f52fc 100644 --- a/zaptel.c +++ b/zaptel.c @@ -1321,6 +1321,26 @@ static int zt_net_open(hdlc_device *hdlc) return 0; } +#ifdef LINUX26 +static int zt_register_hdlc_device(struct net_device *dev, const char *dev_name) +{ + int result; + + if (dev_name && *dev_name) { + if ((result = dev_alloc_name(dev, dev_name)) < 0) + return result; + } + result = register_netdev(dev); + if (result != 0) + return -EIO; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,14) + if (netif_carrier_ok(dev)) + netif_carrier_off(dev); /* no carrier until DCD goes up */ +#endif + return 0; +} +#endif + #ifdef NEW_HDLC_INTERFACE static int zt_net_stop(struct net_device *dev) { @@ -3345,7 +3365,7 @@ static int zt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd dev_to_hdlc(chans[ch.chan]->hdlcnetdev->netdev)->xmit = zt_xmit; spin_unlock_irqrestore(&chans[ch.chan]->lock, flags); /* Briefly restore interrupts while we register the device */ - res = register_hdlc_device(chans[ch.chan]->hdlcnetdev->netdev); + res = zt_register_hdlc_device(chans[ch.chan]->hdlcnetdev->netdev, ch.netdev_name); spin_lock_irqsave(&chans[ch.chan]->lock, flags); } else { printk("Unable to allocate hdlc: *shrug*\n"); diff --git a/zaptel.conf.sample b/zaptel.conf.sample index 6fc4893..3a10217 100644 --- a/zaptel.conf.sample +++ b/zaptel.conf.sample @@ -105,7 +105,13 @@ # hardware. # "nethdlc" : The zaptel driver bundles the channels together into an # hdlc network device, which in turn can be configured with -# sethdlc (available separately). +# sethdlc (available separately). In 2.6.x kernels you can also optionally +# pass the name for the network interface after the channel list. +# Syntax: +# nethdlc=[:interface name] +# Use original names, don't use the names which have been already registered +# in system e.g eth. +# # "dacs" : The zaptel driver cross connects the channels starting at # the channel number listed at the end, after a colon # "dacsrbs" : The zaptel driver cross connects the channels starting at diff --git a/zaptel.h b/zaptel.h index 0b85236..00c2e0a 100644 --- a/zaptel.h +++ b/zaptel.h @@ -239,6 +239,7 @@ int deflaw; /* Default law (ZT_LAW_DEFAULT, ZT_LAW_MULAW, or ZT_LAW_ALAW */ int master; /* Master channel if sigtype is ZT_SLAVE */ int idlebits; /* Idle bits (if this is a CAS channel) or channel to monitor (if this is DACS channel) */ +char netdev_name[16]; /*name for the hdlc network device*/ } ZT_CHANCONFIG; typedef struct zt_sfconfig diff --git a/ztcfg.c b/ztcfg.c index 15af02a..660f28e 100644 --- a/ztcfg.c +++ b/ztcfg.c @@ -552,11 +552,15 @@ static int chanconfig(char *keyword, char *args) } } else if (!strcasecmp(keyword, "nethdlc")) { sig[x] = sigtype_to_str(ZT_SIG_HDLCNET); + memset(cc[x].netdev_name, 0, sizeof(cc[x].netdev_name)); if (master) { cc[x].sigtype = ZT_SIG_SLAVE; cc[x].master = master; } else { cc[x].sigtype = ZT_SIG_HDLCNET; + if (idle) { + strncpy(cc[x].netdev_name, idle, sizeof(cc[x].netdev_name) - 1); + } master = x; } } else if (!strcasecmp(keyword, "fcshdlc")) { -- cgit v1.2.3