o wanrouter/wanmain: fix namespace, fixing the current problem with device_shutdown

parent 07ca08b1
...@@ -127,18 +127,21 @@ static void dbg_kfree(void * v, int line) { ...@@ -127,18 +127,21 @@ static void dbg_kfree(void * v, int line) {
* WAN device IOCTL handlers * WAN device IOCTL handlers
*/ */
static int device_setup(struct wan_device *wandev, wandev_conf_t *u_conf); static int wanrouter_device_setup(struct wan_device *wandev,
static int device_stat(struct wan_device *wandev, wandev_stat_t *u_stat); wandev_conf_t *u_conf);
static int device_shutdown(struct wan_device *wandev); static int wanrouter_device_stat(struct wan_device *wandev,
static int device_new_if(struct wan_device *wandev, wanif_conf_t *u_conf); wandev_stat_t *u_stat);
static int device_del_if(struct wan_device *wandev, char *u_name); static int wanrouter_device_shutdown(struct wan_device *wandev);
static int wanrouter_device_new_if(struct wan_device *wandev,
wanif_conf_t *u_conf);
static int wanrouter_device_del_if(struct wan_device *wandev, char *u_name);
/* /*
* Miscellaneous * Miscellaneous
*/ */
static struct wan_device *find_device (char *name); static struct wan_device *wanrouter_find_device(char *name);
static int delete_interface (struct wan_device *wandev, char *name); static int wanrouter_delete_interface(struct wan_device *wandev, char *name);
void lock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags); void lock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags);
void unlock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags); void unlock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags);
...@@ -148,19 +151,18 @@ void unlock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags); ...@@ -148,19 +151,18 @@ void unlock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags);
* Global Data * Global Data
*/ */
static char fullname[] = "Sangoma WANPIPE Router"; static char wanrouter_fullname[] = "Sangoma WANPIPE Router";
static char copyright[] = "(c) 1995-2000 Sangoma Technologies Inc."; static char wanrouter_copyright[] = "(c) 1995-2000 Sangoma Technologies Inc.";
static char modname[] = ROUTER_NAME; /* short module name */ static char wanrouter_modname[] = ROUTER_NAME; /* short module name */
struct wan_device* router_devlist; /* list of registered devices */ struct wan_device* wanrouter_router_devlist; /* list of registered devices */
static int devcnt;
/* /*
* Organize Unique Identifiers for encapsulation/decapsulation * Organize Unique Identifiers for encapsulation/decapsulation
*/ */
static unsigned char oui_ether[] = { 0x00, 0x00, 0x00 }; static unsigned char wanrouter_oui_ether[] = { 0x00, 0x00, 0x00 };
#if 0 #if 0
static unsigned char oui_802_2[] = { 0x00, 0x80, 0xC2 }; static unsigned char wanrouter_oui_802_2[] = { 0x00, 0x80, 0xC2 };
#endif #endif
#ifndef MODULE #ifndef MODULE
...@@ -172,12 +174,13 @@ int wanrouter_init(void) ...@@ -172,12 +174,13 @@ int wanrouter_init(void)
extern int sdladrv_init(void); extern int sdladrv_init(void);
printk(KERN_INFO "%s v%u.%u %s\n", printk(KERN_INFO "%s v%u.%u %s\n",
fullname, ROUTER_VERSION, ROUTER_RELEASE, copyright); wanrouter_fullname, ROUTER_VERSION, ROUTER_RELEASE,
wanrouter_copyright);
err = wanrouter_proc_init(); err = wanrouter_proc_init();
if (err){ if (err)
printk(KERN_INFO "%s: can't create entry in proc filesystem!\n", modname); printk(KERN_INFO "%s: can't create entry in proc filesystem!\n",
} wanrouter_modname);
/* /*
* Initialise compiled in boards * Initialise compiled in boards
...@@ -218,14 +221,14 @@ int init_module (void) ...@@ -218,14 +221,14 @@ int init_module (void)
int err; int err;
printk(KERN_INFO "%s v%u.%u %s\n", printk(KERN_INFO "%s v%u.%u %s\n",
fullname, ROUTER_VERSION, ROUTER_RELEASE, copyright); wanrouter_fullname, ROUTER_VERSION, ROUTER_RELEASE,
wanrouter_copyright);
err = wanrouter_proc_init(); err = wanrouter_proc_init();
if (err){ if (err)
printk(KERN_INFO printk(KERN_INFO "%s: can't create entry in proc filesystem!\n",
"%s: can't create entry in proc filesystem!\n", modname); wanrouter_modname);
}
return err; return err;
} }
...@@ -274,12 +277,12 @@ int register_wan_device(struct wan_device *wandev) ...@@ -274,12 +277,12 @@ int register_wan_device(struct wan_device *wandev)
if (!namelen || (namelen > WAN_DRVNAME_SZ)) if (!namelen || (namelen > WAN_DRVNAME_SZ))
return -EINVAL; return -EINVAL;
if (find_device(wandev->name) != NULL) if (wanrouter_find_device(wandev->name))
return -EEXIST; return -EEXIST;
#ifdef WANDEBUG #ifdef WANDEBUG
printk(KERN_INFO "%s: registering WAN device %s\n", printk(KERN_INFO "%s: registering WAN device %s\n",
modname, wandev->name); wanrouter_modname, wandev->name);
#endif #endif
/* /*
...@@ -289,7 +292,7 @@ int register_wan_device(struct wan_device *wandev) ...@@ -289,7 +292,7 @@ int register_wan_device(struct wan_device *wandev)
if (err) { if (err) {
printk(KERN_INFO printk(KERN_INFO
"%s: can't create /proc/net/router/%s entry!\n", "%s: can't create /proc/net/router/%s entry!\n",
modname, wandev->name); wanrouter_modname, wandev->name);
return err; return err;
} }
...@@ -300,9 +303,8 @@ int register_wan_device(struct wan_device *wandev) ...@@ -300,9 +303,8 @@ int register_wan_device(struct wan_device *wandev)
wandev->ndev = 0; wandev->ndev = 0;
wandev->dev = NULL; wandev->dev = NULL;
wandev->next = router_devlist; wandev->next = wanrouter_router_devlist;
router_devlist = wandev; wanrouter_router_devlist = wandev;
++devcnt;
MOD_INC_USE_COUNT; /* prevent module from unloading */ MOD_INC_USE_COUNT; /* prevent module from unloading */
return 0; return 0;
} }
...@@ -327,7 +329,7 @@ int unregister_wan_device(char *name) ...@@ -327,7 +329,7 @@ int unregister_wan_device(char *name)
if (name == NULL) if (name == NULL)
return -EINVAL; return -EINVAL;
for (wandev = router_devlist, prev = NULL; for (wandev = wanrouter_router_devlist, prev = NULL;
wandev && strcmp(wandev->name, name); wandev && strcmp(wandev->name, name);
prev = wandev, wandev = wandev->next) prev = wandev, wandev = wandev->next)
; ;
...@@ -335,18 +337,18 @@ int unregister_wan_device(char *name) ...@@ -335,18 +337,18 @@ int unregister_wan_device(char *name)
return -ENODEV; return -ENODEV;
#ifdef WANDEBUG #ifdef WANDEBUG
printk(KERN_INFO "%s: unregistering WAN device %s\n", modname, name); printk(KERN_INFO "%s: unregistering WAN device %s\n",
wanrouter_modname, name);
#endif #endif
if (wandev->state != WAN_UNCONFIGURED) if (wandev->state != WAN_UNCONFIGURED)
device_shutdown(wandev); wanrouter_device_shutdown(wandev);
if (prev) if (prev)
prev->next = wandev->next; prev->next = wandev->next;
else else
router_devlist = wandev->next; wanrouter_router_devlist = wandev->next;
--devcnt;
wanrouter_proc_delete(wandev); wanrouter_proc_delete(wandev);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
...@@ -381,14 +383,15 @@ int wanrouter_encapsulate(struct sk_buff *skb, struct net_device *dev, ...@@ -381,14 +383,15 @@ int wanrouter_encapsulate(struct sk_buff *skb, struct net_device *dev,
skb_push(skb, 7); skb_push(skb, 7);
skb->data[0] = 0; skb->data[0] = 0;
skb->data[1] = NLPID_SNAP; skb->data[1] = NLPID_SNAP;
memcpy(&skb->data[2], oui_ether, sizeof(oui_ether)); memcpy(&skb->data[2], wanrouter_oui_ether,
sizeof(wanrouter_oui_ether));
*((unsigned short*)&skb->data[5]) = htons(type); *((unsigned short*)&skb->data[5]) = htons(type);
break; break;
default: /* Unknown packet type */ default: /* Unknown packet type */
printk(KERN_INFO printk(KERN_INFO
"%s: unsupported Ethertype 0x%04X on interface %s!\n", "%s: unsupported Ethertype 0x%04X on interface %s!\n",
modname, type, dev->name); wanrouter_modname, type, dev->name);
hdr_len = -EINVAL; hdr_len = -EINVAL;
} }
return hdr_len; return hdr_len;
...@@ -418,10 +421,11 @@ unsigned short wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev) ...@@ -418,10 +421,11 @@ unsigned short wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev)
break; break;
case NLPID_SNAP: /* SNAP encapsulation */ case NLPID_SNAP: /* SNAP encapsulation */
if (memcmp(&skb->data[cnt + 1], oui_ether, sizeof(oui_ether))){ if (memcmp(&skb->data[cnt + 1], wanrouter_oui_ether,
sizeof(wanrouter_oui_ether))){
printk(KERN_INFO printk(KERN_INFO
"%s: unsupported SNAP OUI %02X-%02X-%02X " "%s: unsupported SNAP OUI %02X-%02X-%02X "
"on interface %s!\n", modname, "on interface %s!\n", wanrouter_modname,
skb->data[cnt+1], skb->data[cnt+2], skb->data[cnt+1], skb->data[cnt+2],
skb->data[cnt+3], dev->name); skb->data[cnt+3], dev->name);
return 0; return 0;
...@@ -435,7 +439,7 @@ unsigned short wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev) ...@@ -435,7 +439,7 @@ unsigned short wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev)
default: default:
printk(KERN_INFO printk(KERN_INFO
"%s: unsupported NLPID 0x%02X on interface %s!\n", "%s: unsupported NLPID 0x%02X on interface %s!\n",
modname, skb->data[cnt], dev->name); wanrouter_modname, skb->data[cnt], dev->name);
return 0; return 0;
} }
skb->protocol = ethertype; skb->protocol = ethertype;
...@@ -475,23 +479,23 @@ int wanrouter_ioctl(struct inode *inode, struct file *file, ...@@ -475,23 +479,23 @@ int wanrouter_ioctl(struct inode *inode, struct file *file,
switch (cmd) { switch (cmd) {
case ROUTER_SETUP: case ROUTER_SETUP:
err = device_setup(wandev, (void*)arg); err = wanrouter_device_setup(wandev, (void*)arg);
break; break;
case ROUTER_DOWN: case ROUTER_DOWN:
err = device_shutdown(wandev); err = wanrouter_device_shutdown(wandev);
break; break;
case ROUTER_STAT: case ROUTER_STAT:
err = device_stat(wandev, (void*)arg); err = wanrouter_device_stat(wandev, (void*)arg);
break; break;
case ROUTER_IFNEW: case ROUTER_IFNEW:
err = device_new_if(wandev, (void*)arg); err = wanrouter_device_new_if(wandev, (void*)arg);
break; break;
case ROUTER_IFDEL: case ROUTER_IFDEL:
err = device_del_if(wandev, (void*)arg); err = wanrouter_device_del_if(wandev, (void*)arg);
break; break;
case ROUTER_IFSTAT: case ROUTER_IFSTAT:
...@@ -519,7 +523,8 @@ int wanrouter_ioctl(struct inode *inode, struct file *file, ...@@ -519,7 +523,8 @@ int wanrouter_ioctl(struct inode *inode, struct file *file,
* o call driver's setup() entry point * o call driver's setup() entry point
*/ */
static int device_setup(struct wan_device *wandev, wandev_conf_t *u_conf) static int wanrouter_device_setup(struct wan_device *wandev,
wandev_conf_t *u_conf)
{ {
void *data = NULL; void *data = NULL;
wandev_conf_t *conf; wandev_conf_t *conf;
...@@ -595,7 +600,7 @@ static int device_setup(struct wan_device *wandev, wandev_conf_t *u_conf) ...@@ -595,7 +600,7 @@ static int device_setup(struct wan_device *wandev, wandev_conf_t *u_conf)
* o call driver's shutdown() entry point * o call driver's shutdown() entry point
*/ */
static int device_shutdown(struct wan_device *wandev) static int wanrouter_device_shutdown(struct wan_device *wandev)
{ {
struct net_device *dev; struct net_device *dev;
int err=0; int err=0;
...@@ -606,7 +611,8 @@ static int device_shutdown(struct wan_device *wandev) ...@@ -606,7 +611,8 @@ static int device_shutdown(struct wan_device *wandev)
printk(KERN_INFO "\n%s: Shutting Down!\n",wandev->name); printk(KERN_INFO "\n%s: Shutting Down!\n",wandev->name);
for (dev = wandev->dev; dev;) { for (dev = wandev->dev; dev;) {
if ((err=delete_interface(wandev, dev->name)) != 0) err = wanrouter_delete_interface(wandev, dev->name);
if (err)
return err; return err;
/* The above function deallocates the current dev /* The above function deallocates the current dev
* structure. Therefore, we cannot use dev->priv * structure. Therefore, we cannot use dev->priv
...@@ -628,7 +634,8 @@ static int device_shutdown(struct wan_device *wandev) ...@@ -628,7 +634,8 @@ static int device_shutdown(struct wan_device *wandev)
* Get WAN device status & statistics. * Get WAN device status & statistics.
*/ */
static int device_stat(struct wan_device *wandev, wandev_stat_t *u_stat) static int wanrouter_device_stat(struct wan_device *wandev,
wandev_stat_t *u_stat)
{ {
wandev_stat_t stat; wandev_stat_t stat;
...@@ -658,7 +665,8 @@ static int device_stat(struct wan_device *wandev, wandev_stat_t *u_stat) ...@@ -658,7 +665,8 @@ static int device_stat(struct wan_device *wandev, wandev_stat_t *u_stat)
* o register network interface * o register network interface
*/ */
static int device_new_if(struct wan_device *wandev, wanif_conf_t *u_conf) static int wanrouter_device_new_if(struct wan_device *wandev,
wanif_conf_t *u_conf)
{ {
wanif_conf_t conf; wanif_conf_t conf;
struct net_device *dev = NULL; struct net_device *dev = NULL;
...@@ -718,7 +726,7 @@ static int device_new_if(struct wan_device *wandev, wanif_conf_t *u_conf) ...@@ -718,7 +726,7 @@ static int device_new_if(struct wan_device *wandev, wanif_conf_t *u_conf)
#ifdef WANDEBUG #ifdef WANDEBUG
printk(KERN_INFO "%s: registering interface %s...\n", printk(KERN_INFO "%s: registering interface %s...\n",
modname, dev->name); wanrouter_modname, dev->name);
#endif #endif
err = register_netdev(dev); err = register_netdev(dev);
...@@ -775,7 +783,7 @@ static int device_new_if(struct wan_device *wandev, wanif_conf_t *u_conf) ...@@ -775,7 +783,7 @@ static int device_new_if(struct wan_device *wandev, wanif_conf_t *u_conf)
* o copy configuration data to kernel address space * o copy configuration data to kernel address space
*/ */
static int device_del_if(struct wan_device *wandev, char *u_name) static int wanrouter_device_del_if(struct wan_device *wandev, char *u_name)
{ {
char name[WAN_IFNAME_SZ + 1]; char name[WAN_IFNAME_SZ + 1];
int err = 0; int err = 0;
...@@ -788,7 +796,7 @@ static int device_del_if(struct wan_device *wandev, char *u_name) ...@@ -788,7 +796,7 @@ static int device_del_if(struct wan_device *wandev, char *u_name)
if (copy_from_user(name, u_name, WAN_IFNAME_SZ)) if (copy_from_user(name, u_name, WAN_IFNAME_SZ))
return -EFAULT; return -EFAULT;
err = delete_interface(wandev, name); err = wanrouter_delete_interface(wandev, name);
if (err) if (err)
return err; return err;
...@@ -816,11 +824,12 @@ static int device_del_if(struct wan_device *wandev, char *u_name) ...@@ -816,11 +824,12 @@ static int device_del_if(struct wan_device *wandev, char *u_name)
* Return pointer to the WAN device data space or NULL if device not found. * Return pointer to the WAN device data space or NULL if device not found.
*/ */
static struct wan_device *find_device(char *name) static struct wan_device *wanrouter_find_device(char *name)
{ {
struct wan_device *wandev; struct wan_device *wandev;
for (wandev = router_devlist;wandev && strcmp(wandev->name, name); for (wandev = wanrouter_router_devlist;
wandev && strcmp(wandev->name, name);
wandev = wandev->next); wandev = wandev->next);
return wandev; return wandev;
} }
...@@ -842,7 +851,7 @@ static struct wan_device *find_device(char *name) ...@@ -842,7 +851,7 @@ static struct wan_device *find_device(char *name)
* sure that opened interfaces are not removed! * sure that opened interfaces are not removed!
*/ */
static int delete_interface(struct wan_device *wandev, char *name) static int wanrouter_delete_interface(struct wan_device *wandev, char *name)
{ {
struct net_device *dev = NULL, *prev = NULL; struct net_device *dev = NULL, *prev = NULL;
unsigned long smp_flags=0; unsigned long smp_flags=0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment