Re: [PATCH 4/5] ieee802154: add virtual loopback driver

From: Patrick McHardy
Date: Thu Jun 18 2009 - 12:14:50 EST


Dmitry Eremin-Solenikov wrote:
fakelb is a virtual loopback driver implementing one or several
interconnected radios. Packets from the radio are either sent
back to the node (if no other fake radio are registered) or to
all other fake radio.

+static ssize_t
+adddev_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t n)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct fake_priv *priv = platform_get_drvdata(pdev);
+ char hw[8] = {};
+ int i, j, ch, err;
+
+ for (i = 0, j = 0; i < 16 && j < n; j++) {
+ ch = buf[j];
+ switch (buf[j]) {
+ default:
+ return -EINVAL;
+ case '0'...'9':
+ ch -= '0';
+ break;
+ case 'A'...'F':
+ ch -= 'A' - 10;
+ break;
+ case 'a'...'f':
+ ch -= 'a' - 10;
+ break;
+ case ':':
+ case '.':
+ continue;
+ }
+ if (i % 2)
+ hw[i/2] = (hw[i/2] & 0xf0) | ch;
+ else
+ hw[i/2] = ch << 4;
+ i++;
+ }
+ if (i != 16)
+ return -EINVAL;
+ err = ieee802154fake_add_priv(dev, priv, hw);
+ if (err)
+ return err;
+ return n;
+}
+
+static DEVICE_ATTR(adddev, 0200, NULL, adddev_store);
+
+static struct attribute *fake_attrs[] = {
+ &dev_attr_adddev.attr,
+ NULL,
+};


No new sysfs interfaces for network device creation please.
Please use the rtnl_link API.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/