Commit 74408ad7 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: New file for net interface config and basic setup

Add a new file isdn_net_lib.c, where code which is shared among different
kind of network interface will gradually migrate to.

For now, move the ioctl config code out of isdn_{common,net}.c there,
and the basic register_netdev() + associated methods.
parent e2d5b146
......@@ -11,9 +11,10 @@ obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o
# Multipart objects.
isdn-objs := isdn_net.o isdn_tty.o \
isdn_v110.o isdn_common.o \
isdn_ciscohdlck.o
isdn-objs := isdn_net.o isdn_net_lib.o \
isdn_ciscohdlck.o \
isdn_tty.o isdn_v110.o \
isdn_common.o \
# Optional parts of multipart objects.
......
......@@ -1010,19 +1010,6 @@ static int
isdn_status_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
{
int ret;
union iocpar {
char name[10];
char bname[22];
isdn_ioctl_struct iocts;
isdn_net_ioctl_phone phone;
isdn_net_ioctl_cfg cfg;
} iocpar;
#define name iocpar.name
#define bname iocpar.bname
#define iocts iocpar.iocts
#define phone iocpar.phone
#define cfg iocpar.cfg
switch (cmd) {
case IIOCGETDVR:
......@@ -1044,26 +1031,11 @@ isdn_status_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
} else
return -EINVAL;
break;
#ifdef CONFIG_NETDEVICES
case IIOCNETGPN:
/* Get peer phone number of a connected
* isdn network interface */
if (arg) {
if (copy_from_user((char *) &phone, (char *) arg, sizeof(phone)))
return -EFAULT;
return isdn_net_getpeer(&phone, (isdn_net_ioctl_phone *) arg);
} else
return -EINVAL;
#endif
return isdn_net_ioctl(inode, file, cmd, arg);
default:
return -EINVAL;
}
#undef name
#undef bname
#undef iocts
#undef phone
#undef cfg
}
static struct file_operations isdn_status_fops =
......@@ -1221,19 +1193,15 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
int ret;
int i;
char *p;
union iocpar {
char name[10];
/* save stack space */
union {
char bname[20];
isdn_ioctl_struct iocts;
isdn_net_ioctl_phone phone;
isdn_net_ioctl_cfg cfg;
} iocpar;
#define name iocpar.name
#define bname iocpar.bname
#define iocts iocpar.iocts
#define phone iocpar.phone
#define cfg iocpar.cfg
#define bname iocpar.bname
/*
* isdn net devices manage lots of configuration variables as linked lists.
* Those lists must only be manipulated from user space. Some of the ioctl's
......@@ -1242,134 +1210,19 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
* are serialized by means of a semaphore.
*/
switch (cmd) {
case IIOCNETDWRSET:
printk(KERN_INFO "INFO: ISDN_DW_ABC_EXTENSION not enabled\n");
return(-EINVAL);
case IIOCNETLCR:
printk(KERN_INFO "INFO: ISDN_ABC_LCR_SUPPORT not enabled\n");
return -ENODEV;
#ifdef CONFIG_NETDEVICES
case IIOCNETAIF:
/* Add a network-interface */
if (copy_from_user(name, (char *) arg, sizeof(name) - 1))
return -EFAULT;
name[sizeof(name)-1] = 0;
ret = down_interruptible(&dev->sem);
if (ret)
return ret;
ret = isdn_net_new(name, NULL);
up(&dev->sem);
return ret;
case IIOCNETASL:
/* Add a slave to a network-interface */
if (copy_from_user(bname, (char *) arg, sizeof(bname) - 1))
return -EFAULT;
bname[sizeof(bname)-1] = 0;
ret = down_interruptible(&dev->sem);
if (ret)
return ret;
ret = isdn_net_newslave(bname);
up(&dev->sem);
return ret;
case IIOCNETDIF:
/* Delete a network-interface */
if (arg) {
if (copy_from_user(name, (char *) arg, sizeof(name)))
return -EFAULT;
ret = down_interruptible(&dev->sem);
if( ret ) return ret;
ret = isdn_net_rm(name);
up(&dev->sem);
return ret;
} else
return -EINVAL;
case IIOCNETSCF:
/* Set configurable parameters of a network-interface */
if (arg) {
if (copy_from_user((char *) &cfg, (char *) arg, sizeof(cfg)))
return -EFAULT;
return isdn_net_setcfg(&cfg);
} else
return -EINVAL;
case IIOCNETGCF:
/* Get configurable parameters of a network-interface */
if (arg) {
if (copy_from_user((char *) &cfg, (char *) arg, sizeof(cfg)))
return -EFAULT;
if (!(ret = isdn_net_getcfg(&cfg))) {
if (copy_to_user((char *) arg, (char *) &cfg, sizeof(cfg)))
return -EFAULT;
}
return ret;
} else
return -EINVAL;
case IIOCNETANM:
/* Add a phone-number to a network-interface */
if (arg) {
if (copy_from_user((char *) &phone, (char *) arg, sizeof(phone)))
return -EFAULT;
ret = down_interruptible(&dev->sem);
if( ret ) return ret;
ret = isdn_net_addphone(&phone);
up(&dev->sem);
return ret;
} else
return -EINVAL;
case IIOCNETGNM:
/* Get list of phone-numbers of a network-interface */
if (arg) {
if (copy_from_user((char *) &phone, (char *) arg, sizeof(phone)))
return -EFAULT;
ret = down_interruptible(&dev->sem);
if( ret ) return ret;
ret = isdn_net_getphones(&phone, (char *) arg);
up(&dev->sem);
return ret;
} else
return -EINVAL;
case IIOCNETDNM:
/* Delete a phone-number of a network-interface */
if (arg) {
if (copy_from_user((char *) &phone, (char *) arg, sizeof(phone)))
return -EFAULT;
ret = down_interruptible(&dev->sem);
if( ret ) return ret;
ret = isdn_net_delphone(&phone);
up(&dev->sem);
return ret;
} else
return -EINVAL;
case IIOCNETDIL:
/* Force dialing of a network-interface */
if (arg) {
if (copy_from_user(name, (char *) arg, sizeof(name)))
return -EFAULT;
return isdn_net_force_dial(name);
} else
return -EINVAL;
#ifdef CONFIG_ISDN_PPP
case IIOCNETALN:
if (!arg)
return -EINVAL;
if (copy_from_user(name, (char *) arg, sizeof(name)))
return -EFAULT;
return isdn_ppp_dial_slave(name);
case IIOCNETDLN:
if (!arg)
return -EINVAL;
if (copy_from_user(name, (char *) arg, sizeof(name)))
return -EFAULT;
return isdn_ppp_hangup_slave(name);
#endif
case IIOCNETHUP:
/* Force hangup of a network-interface */
if (!arg)
return -EINVAL;
if (copy_from_user(name, (char *) arg, sizeof(name)))
return -EFAULT;
return isdn_net_force_hangup(name);
break;
#endif /* CONFIG_NETDEVICES */
return isdn_net_ioctl(inode, file, cmd, arg);
case IIOCSETVER:
dev->net_verbose = arg;
printk(KERN_INFO "isdn: Verbose-Level is %d\n", dev->net_verbose);
......@@ -1577,12 +1430,8 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
} else
return -EINVAL;
}
#undef name
#undef bname
#undef iocts
#undef phone
#undef cfg
#undef bname
}
static struct file_operations isdn_ctrl_fops =
......@@ -2430,7 +2279,7 @@ static int __init isdn_init(void)
printk("\n");
#endif
isdn_info_update();
isdn_net_init_module();
isdn_net_init();
return 0;
err_tty_modem:
......@@ -2456,8 +2305,7 @@ static void __exit isdn_exit(void)
#endif
save_flags(flags);
cli();
if (isdn_net_rmall() < 0)
BUG();
isdn_net_exit();
isdn_tty_exit();
if (unregister_chrdev(ISDN_MAJOR, "isdn"))
......
......@@ -52,6 +52,8 @@ do { printk(KERN_WARNING "ISDN Bug at %s:%d\n", __FILE__, __LINE__); \
#define HERE printk("%s:%d (%s)\n", __FILE__, __LINE__, __FUNCTION__)
extern struct list_head isdn_net_devs;
/* Prototypes */
extern void isdn_MOD_INC_USE_COUNT(void);
extern void isdn_MOD_DEC_USE_COUNT(void);
......@@ -82,8 +84,6 @@ struct dial_info {
unsigned char *phone;
};
extern struct list_head isdn_net_devs;
extern int isdn_get_free_slot(int, int, int, int, int, char *);
extern void isdn_slot_free(int slot, int usage);
extern void isdn_slot_all_eaz(int slot);
......
This diff is collapsed.
......@@ -32,32 +32,30 @@
#define CISCO_SLARP_REPLY 1
#define CISCO_SLARP_KEEPALIVE 2
extern void isdn_net_init_module(void);
extern void isdn_net_init(void);
extern void isdn_net_exit(void);
extern void isdn_net_hangup_all(void);
extern int isdn_net_ioctl(struct inode *, struct file *, uint, ulong);
extern int register_isdn_netif(int encap, struct isdn_netif_ops *ops);
extern int isdn_net_autodial(struct sk_buff *skb, struct net_device *ndev);
extern int isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev);
extern int isdn_net_new(char *, isdn_net_local *);
extern int isdn_net_newslave(char *);
extern int isdn_net_rm(char *);
extern int isdn_net_rmall(void);
extern int isdn_net_stat_callback(int, isdn_ctrl *);
extern int isdn_net_setcfg(isdn_net_ioctl_cfg *);
extern int isdn_net_getcfg(isdn_net_ioctl_cfg *);
extern int isdn_net_addphone(isdn_net_ioctl_phone *);
extern int isdn_net_getphones(isdn_net_ioctl_phone *, char *);
extern int isdn_net_getpeer(isdn_net_ioctl_phone *, isdn_net_ioctl_phone *);
extern int isdn_net_delphone(isdn_net_ioctl_phone *);
extern int isdn_net_find_icall(int, int, int, setup_parm *);
extern int isdn_net_dev_dial(isdn_net_dev *idev);
extern void isdn_net_hangup(isdn_net_dev *);
extern void isdn_net_hangup_all(void);
extern int isdn_net_force_hangup(char *);
extern int isdn_net_force_dial(char *);
extern isdn_net_dev *isdn_net_findif(char *);
extern int isdn_net_rcv_skb(int, struct sk_buff *);
extern int isdn_net_dial_req(isdn_net_dev *);
extern void isdn_net_writebuf_skb(isdn_net_dev *, struct sk_buff *skb);
extern void isdn_net_write_super(isdn_net_dev *, struct sk_buff *skb);
extern int isdn_net_online(isdn_net_dev *);
extern int isdn_net_autodial(struct sk_buff *skb, struct net_device *ndev);
extern int isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev);
enum {
ST_CHARGE_NULL,
ST_CHARGE_GOT_CINF, /* got a first charge info */
ST_CHARGE_HAVE_CINT, /* got a second chare info and thus the timing */
};
#define ISDN_NET_MAX_QUEUE_LENGTH 2
......
This diff is collapsed.
......@@ -312,7 +312,6 @@ struct isdn_netif_ops {
/* Local interface-data */
typedef struct isdn_net_local_s {
ulong magic;
spinlock_t lock;
struct net_device_stats stats; /* Ethernet Statistics */
int flags; /* Connection-flags */
int dialmax; /* Max. Number of Dial-retries */
......@@ -402,7 +401,7 @@ typedef struct isdn_net_dev_s {
struct tasklet_struct tlet;
isdn_net_local *mlp; /* Ptr to master device for all devs*/
struct isdn_net_dev_s *slave; /* Ptr to Slave device for masters */
struct isdn_net_dev_s *slave; /* Ptr to Slave device for masters */ // FIXME kill
struct list_head slaves; /* Members of local->slaves */
struct list_head online; /* Members of local->online */
......
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