31 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
33 #include <linux/module.h>
34 #include <linux/kernel.h>
35 #include <linux/types.h>
36 #include <linux/fcntl.h>
38 #include <linux/ptrace.h>
42 #include <linux/slab.h>
43 #include <linux/string.h>
44 #include <linux/errno.h>
45 #include <linux/netdevice.h>
47 #include <linux/if_arp.h>
48 #include <linux/if_frad.h>
49 #include <linux/bitops.h>
55 #include <asm/uaccess.h>
71 const void *
saddr,
unsigned len)
74 struct dlci_local *dlp;
78 dlp = netdev_priv(dev);
80 hdr.control = FRAD_I_UI;
84 hdr.IP_NLPID = FRAD_P_IP;
85 hlen =
sizeof(
hdr.control) +
sizeof(
hdr.IP_NLPID);
91 hdr.pad = FRAD_P_PADDING;
92 hdr.NLPID = FRAD_P_SNAP;
110 struct dlci_local *dlp;
114 dlp = netdev_priv(dev);
115 if (!pskb_may_pull(skb,
sizeof(*hdr))) {
116 netdev_notice(dev,
"invalid data no header\n");
117 dev->
stats.rx_errors++;
122 hdr = (
struct frhdr *) skb->
data;
127 if (hdr->control != FRAD_I_UI)
129 netdev_notice(dev,
"Invalid header flag 0x%02X\n",
131 dev->
stats.rx_errors++;
134 switch (hdr->IP_NLPID)
137 if (hdr->NLPID != FRAD_P_SNAP)
139 netdev_notice(dev,
"Unsupported NLPID 0x%02X\n",
141 dev->
stats.rx_errors++;
145 if (hdr->OUI[0] + hdr->OUI[1] + hdr->OUI[2] != 0)
147 netdev_notice(dev,
"Unsupported organizationally unique identifier 0x%02X-%02X-%02X\n",
151 dev->
stats.rx_errors++;
156 header =
sizeof(
struct frhdr);
163 header =
sizeof(hdr->control) +
sizeof(hdr->IP_NLPID);
171 netdev_notice(dev,
"Unsupported NLPID 0x%02X\n",
173 dev->
stats.rx_errors++;
177 netdev_notice(dev,
"Invalid pad byte 0x%02X\n",
179 dev->
stats.rx_errors++;
186 skb_reset_mac_header(skb);
190 dev->
stats.rx_packets++;
198 struct dlci_local *dlp = netdev_priv(dev);
201 dlp->slave->netdev_ops->ndo_start_xmit(skb, dlp->slave);
208 struct dlci_local *dlp;
209 struct frad_local *flp;
212 dlp = netdev_priv(dev);
214 flp = netdev_priv(dlp->slave);
226 err = (*flp->dlci_conf)(dlp->slave, dev,
get);
241 struct dlci_local *dlp;
246 dlp = netdev_priv(dev);
254 strncpy(ifr->ifr_slave, dlp->slave->name,
sizeof(ifr->ifr_slave));
262 return dlci_config(dev, ifr->ifr_data, cmd ==
DLCI_GET_CONF);
271 static int dlci_change_mtu(
struct net_device *dev,
int new_mtu)
273 struct dlci_local *dlp = netdev_priv(dev);
280 struct dlci_local *dlp;
281 struct frad_local *flp;
284 dlp = netdev_priv(dev);
289 if (!netif_running(dlp->slave))
292 flp = netdev_priv(dlp->slave);
293 err = (*flp->activate)(dlp->slave, dev);
297 netif_start_queue(dev);
304 struct dlci_local *dlp;
305 struct frad_local *flp;
308 netif_stop_queue(dev);
310 dlp = netdev_priv(dev);
312 flp = netdev_priv(dlp->slave);
313 err = (*flp->deactivate)(dlp->slave, dev);
321 struct dlci_local *dlp;
322 struct frad_local *flp;
335 master =
alloc_netdev(
sizeof(
struct dlci_local),
"dlci%d",
345 if (dlp->slave == slave) {
353 dlp = netdev_priv(master);
357 flp = netdev_priv(slave);
358 err = (*flp->assoc)(slave, master);
368 list_add(&dlp->list, &dlci_devs);
381 static int dlci_del(
struct dlci_add *dlci)
383 struct dlci_local *dlp;
384 struct frad_local *flp;
393 if (netif_running(master)) {
397 dlp = netdev_priv(master);
399 flp = netdev_priv(slave);
402 err = (*flp->deassoc)(slave, master);
406 unregister_netdevice(master);
415 static int dlci_ioctl(
unsigned int cmd,
void __user *
arg)
437 err = dlci_del(&
add);
447 static const struct header_ops dlci_header_ops = {
448 .create = dlci_header,
452 .ndo_open = dlci_open,
453 .ndo_stop = dlci_close,
454 .ndo_do_ioctl = dlci_dev_ioctl,
455 .ndo_start_xmit = dlci_transmit,
456 .ndo_change_mtu = dlci_change_mtu,
459 static void dlci_setup(
struct net_device *dev)
461 struct dlci_local *dlp = netdev_priv(dev);
468 dlp->receive = dlci_receive;
486 struct dlci_local *dlp;
489 if (dlp->slave == dev) {
491 unregister_netdevice(dlp->master);
501 .notifier_call = dlci_dev_event,
504 static int __init init_dlci(
void)
514 static void __exit dlci_exit(
void)
516 struct dlci_local *dlp, *nxt;
523 unregister_netdevice(dlp->master);