#ifdef __KERNEL__
-struct atm_clip_ops {
- int (*clip_create)(int number);
- int (*clip_mkip)(struct atm_vcc *vcc,int timeout);
- int (*clip_setentry)(struct atm_vcc *vcc,u32 ip);
- int (*clip_encap)(struct atm_vcc *vcc,int mode);
- void (*clip_push)(struct atm_vcc *vcc,struct sk_buff *skb);
- int (*atm_init_atmarp)(struct atm_vcc *vcc);
- struct module *owner;
-};
-
-void atm_clip_ops_set(struct atm_clip_ops *);
-#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
-int try_atm_clip_ops(void);
-#else
-static inline int try_atm_clip_ops(void)
-{
- return 0;
-}
-#endif
-
-
extern struct neigh_table *clip_tbl_hook;
-extern struct atm_clip_ops *atm_clip_ops;
#endif
#endif
return 0;
}
-static struct atm_clip_ops __atm_clip_ops = {
- .clip_create = clip_create,
- .clip_mkip = clip_mkip,
- .clip_setentry = clip_setentry,
- .clip_encap = clip_encap,
- .clip_push = clip_push,
- .atm_init_atmarp = atm_init_atmarp,
- .owner = THIS_MODULE
+static int clip_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
+{
+ struct atm_vcc *vcc = ATM_SD(sock);
+ int err = 0;
+
+ switch (cmd) {
+ case SIOCMKCLIP:
+ case ATMARPD_CTRL:
+ case ATMARP_MKIP:
+ case ATMARP_SETENTRY:
+ case ATMARP_ENCAP:
+ if (!capable(CAP_NET_ADMIN))
+ return -EPERM;
+ break;
+ default:
+ return -ENOIOCTLCMD;
+ }
+
+ switch (cmd) {
+ case SIOCMKCLIP:
+ err = clip_create(arg);
+ break;
+ case ATMARPD_CTRL:
+ err = atm_init_atmarp(vcc);
+ if (!err) {
+ sock->state = SS_CONNECTED;
+ __module_get(THIS_MODULE);
+ }
+ break;
+ case ATMARP_MKIP:
+ err = clip_mkip(vcc ,arg);
+ break;
+ case ATMARP_SETENTRY:
+ err = clip_setentry(vcc, arg);
+ break;
+ case ATMARP_ENCAP:
+ err = clip_encap(vcc, arg);
+ break;
+ }
+ return err;
+}
+
+static struct atm_ioctl clip_ioctl_ops = {
+ .owner = THIS_MODULE,
+ .ioctl = clip_ioctl,
};
#ifdef CONFIG_PROC_FS
struct seq_file *seq;
int rc = -EAGAIN;
- if (!try_atm_clip_ops())
- goto out;
-
state = kmalloc(sizeof(*state), GFP_KERNEL);
if (!state) {
rc = -ENOMEM;
- goto out_put;
+ goto out_kfree;
}
rc = seq_open(file, &arp_seq_ops);
out:
return rc;
-out_put:
- module_put(atm_clip_ops->owner);
out_kfree:
kfree(state);
goto out;
static int arp_seq_release(struct inode *inode, struct file *file)
{
- module_put(atm_clip_ops->owner);
return seq_release_private(inode, file);
}
skb_queue_head_init(&clip_tbl.proxy_queue);
clip_tbl_hook = &clip_tbl;
- atm_clip_ops_set(&__atm_clip_ops);
+ register_atm_ioctl(&clip_ioctl_ops);
return 0;
}
remove_proc_entry("arp", atm_proc_root);
- atm_clip_ops_set(NULL);
+ deregister_atm_ioctl(&clip_ioctl_ops);
neigh_ifdown(&clip_tbl, NULL);
dev = clip_devs;
#include <linux/sonet.h> /* for ioctls */
#include <linux/atmsvc.h>
#include <linux/atmmpc.h>
+#include <net/atmclip.h>
#include <asm/ioctls.h>
-#ifdef CONFIG_ATM_CLIP
-#include <net/atmclip.h> /* for clip_create */
-#endif
#include "resources.h"
#include "signaling.h" /* for WAITING and sigd_attach */
#endif
#endif
-#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
-#include <net/atmclip.h>
-struct atm_clip_ops *atm_clip_ops;
-static DECLARE_MUTEX(atm_clip_ops_mutex);
-
-void atm_clip_ops_set(struct atm_clip_ops *hook)
-{
- down(&atm_clip_ops_mutex);
- atm_clip_ops = hook;
- up(&atm_clip_ops_mutex);
-}
-
-int try_atm_clip_ops(void)
-{
- down(&atm_clip_ops_mutex);
- if (atm_clip_ops && try_module_get(atm_clip_ops->owner)) {
- up(&atm_clip_ops_mutex);
- return 1;
- }
- up(&atm_clip_ops_mutex);
- return 0;
-}
-
-#ifdef CONFIG_ATM_CLIP_MODULE
-EXPORT_SYMBOL(atm_clip_ops);
-EXPORT_SYMBOL(try_atm_clip_ops);
-EXPORT_SYMBOL(atm_clip_ops_set);
-#endif
-#endif
-
static DECLARE_MUTEX(ioctl_mutex);
static LIST_HEAD(ioctl_list);
if (!error)
sock->state = SS_CONNECTED;
goto done;
-#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
- case SIOCMKCLIP:
- if (!capable(CAP_NET_ADMIN)) {
- error = -EPERM;
- goto done;
- }
- if (try_atm_clip_ops()) {
- error = atm_clip_ops->clip_create(arg);
- module_put(atm_clip_ops->owner);
- } else
- error = -ENOSYS;
- goto done;
- case ATMARPD_CTRL:
- if (!capable(CAP_NET_ADMIN)) {
- error = -EPERM;
- goto done;
- }
-#if defined(CONFIG_ATM_CLIP_MODULE)
- if (!atm_clip_ops)
- request_module("clip");
-#endif
- if (try_atm_clip_ops()) {
- error = atm_clip_ops->atm_init_atmarp(vcc);
- if (!error)
- sock->state = SS_CONNECTED;
- } else
- error = -ENOSYS;
- goto done;
- case ATMARP_MKIP:
- if (!capable(CAP_NET_ADMIN)) {
- error = -EPERM;
- goto done;
- }
- if (try_atm_clip_ops()) {
- error = atm_clip_ops->clip_mkip(vcc, arg);
- module_put(atm_clip_ops->owner);
- } else
- error = -ENOSYS;
- goto done;
- case ATMARP_SETENTRY:
- if (!capable(CAP_NET_ADMIN)) {
- error = -EPERM;
- goto done;
- }
- if (try_atm_clip_ops()) {
- error = atm_clip_ops->clip_setentry(vcc, arg);
- module_put(atm_clip_ops->owner);
- } else
- error = -ENOSYS;
- goto done;
- case ATMARP_ENCAP:
- if (!capable(CAP_NET_ADMIN)) {
- error = -EPERM;
- goto done;
- }
- if (try_atm_clip_ops()) {
- error = atm_clip_ops->clip_encap(vcc, arg);
- module_put(atm_clip_ops->owner);
- } else
- error = -ENOSYS;
- goto done;
-#endif
#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
case ATMLEC_CTRL:
if (!capable(CAP_NET_ADMIN)) {
if (cmd == ATMMPC_CTRL || cmd == ATMMPC_DATA)
request_module("mpoa");
+ if (cmd == ATMARPD_CTRL)
+ request_module("clip");
error = -ENOIOCTLCMD;
int atm_init_aal0(struct atm_vcc *vcc); /* "raw" AAL0 */
int atm_init_aal34(struct atm_vcc *vcc);/* "raw" AAL3/4 transport */
int atm_init_aal5(struct atm_vcc *vcc); /* "raw" AAL5 transport */
-int atm_init_atmarp(struct atm_vcc *vcc);/* ATM ARP */
#endif