X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=drivers%2Fnet%2Fwan%2Fhdlc_x25.c;h=c15cc11e399bed72fac105edbb1270469c9e8eb5;hb=7924e4f6519dd5b349ed146fe9fe35206730be67;hp=a867fb411f89b90d1219e2a05801b6b6ad8a9419;hpb=0a7d5f8ce960e74fa22986bda4af488539796e49;p=~andy%2Flinux diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c index a867fb411f8..c15cc11e399 100644 --- a/drivers/net/wan/hdlc_x25.c +++ b/drivers/net/wan/hdlc_x25.c @@ -2,7 +2,7 @@ * Generic HDLC support routines for Linux * X.25 support * - * Copyright (C) 1999 - 2003 Krzysztof Halasa + * Copyright (C) 1999 - 2006 Krzysztof Halasa * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License @@ -25,6 +25,8 @@ #include +static int x25_ioctl(struct net_device *dev, struct ifreq *ifr); + /* These functions are callbacks called by LAPB layer */ static void x25_connect_disconnect(struct net_device *dev, int reason, int code) @@ -162,7 +164,7 @@ static void x25_close(struct net_device *dev) static int x25_rx(struct sk_buff *skb) { - hdlc_device *hdlc = dev_to_hdlc(skb->dev); + struct hdlc_device *hdlc = dev_to_hdlc(skb->dev); if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) { hdlc->stats.rx_dropped++; @@ -178,14 +180,24 @@ static int x25_rx(struct sk_buff *skb) } +static struct hdlc_proto proto = { + .open = x25_open, + .close = x25_close, + .ioctl = x25_ioctl, + .netif_rx = x25_rx, + .module = THIS_MODULE, +}; + -int hdlc_x25_ioctl(struct net_device *dev, struct ifreq *ifr) +static int x25_ioctl(struct net_device *dev, struct ifreq *ifr) { hdlc_device *hdlc = dev_to_hdlc(dev); int result; switch (ifr->ifr_settings.type) { case IF_GET_PROTO: + if (dev_to_hdlc(dev)->proto != &proto) + return -EINVAL; ifr->ifr_settings.type = IF_PROTO_X25; return 0; /* return protocol only, no settable parameters */ @@ -200,21 +212,35 @@ int hdlc_x25_ioctl(struct net_device *dev, struct ifreq *ifr) if (result) return result; - hdlc_proto_detach(hdlc); - memset(&hdlc->proto, 0, sizeof(hdlc->proto)); - - hdlc->proto.open = x25_open; - hdlc->proto.close = x25_close; - hdlc->proto.netif_rx = x25_rx; - hdlc->proto.type_trans = NULL; - hdlc->proto.id = IF_PROTO_X25; + if ((result = attach_hdlc_protocol(dev, &proto, 0))) + return result; dev->hard_start_xmit = x25_xmit; - dev->hard_header = NULL; dev->type = ARPHRD_X25; - dev->addr_len = 0; netif_dormant_off(dev); return 0; } return -EINVAL; } + + +static int __init mod_init(void) +{ + register_hdlc_protocol(&proto); + return 0; +} + + + +static void __exit mod_exit(void) +{ + unregister_hdlc_protocol(&proto); +} + + +module_init(mod_init); +module_exit(mod_exit); + +MODULE_AUTHOR("Krzysztof Halasa "); +MODULE_DESCRIPTION("X.25 protocol support for generic HDLC"); +MODULE_LICENSE("GPL v2");