All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Phonet: back-end for autoconfigured addresses
@ 2009-09-09 10:00 Rémi Denis-Courmont
  2009-09-09 10:00 ` [PATCH 2/2] cdc-phonet: autoconfigure Phonet address Rémi Denis-Courmont
  2009-09-11 19:38 ` [PATCH 1/2] Phonet: back-end for autoconfigured addresses David Miller
  0 siblings, 2 replies; 8+ messages in thread
From: Rémi Denis-Courmont @ 2009-09-09 10:00 UTC (permalink / raw)
  To: netdev; +Cc: Rémi Denis-Courmont

From: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>

In some cases, the network device driver knows what layer-3 address the
device should have. This adds support for the Phonet stack to
automatically request from the driver and add that address to the
network device.

Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
---
 include/linux/phonet.h |   17 +++++++++++++++++
 net/phonet/pn_dev.c    |   26 +++++++++++++++++++++++++-
 2 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/include/linux/phonet.h b/include/linux/phonet.h
index ee5e3c9..82b45d1 100644
--- a/include/linux/phonet.h
+++ b/include/linux/phonet.h
@@ -170,4 +170,21 @@ static inline __u8 pn_sockaddr_get_resource(const struct sockaddr_pn *spn)
 	return spn->spn_resource;
 }
 
+/* Phonet device ioctl requests */
+#ifdef __KERNEL__
+#define SIOCPNGAUTOCONF		(SIOCDEVPRIVATE + 0)
+
+struct if_phonet_autoconf {
+	uint8_t device;
+};
+
+struct if_phonet_req {
+	char ifr_phonet_name[16];
+	union {
+		struct if_phonet_autoconf ifru_phonet_autoconf;
+	} ifr_ifru;
+};
+#define ifr_phonet_autoconf ifr_ifru.ifru_phonet_autoconf
+#endif /* __KERNEL__ */
+
 #endif
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index 5ae4c01..2f65dca 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -28,6 +28,7 @@
 #include <linux/netdevice.h>
 #include <linux/phonet.h>
 #include <linux/proc_fs.h>
+#include <linux/if_arp.h>
 #include <net/sock.h>
 #include <net/netns/generic.h>
 #include <net/phonet/pn_dev.h>
@@ -195,14 +196,37 @@ found:
 	return err;
 }
 
+/* automatically configure a Phonet device, if supported */
+static int phonet_device_autoconf(struct net_device *dev)
+{
+	struct if_phonet_req req;
+	int ret;
+
+	if (!dev->netdev_ops->ndo_do_ioctl)
+		return -EOPNOTSUPP;
+
+	ret = dev->netdev_ops->ndo_do_ioctl(dev, (struct ifreq *)&req,
+						SIOCPNGAUTOCONF);
+	if (ret < 0)
+		return ret;
+	return phonet_address_add(dev, req.ifr_phonet_autoconf.device);
+}
+
 /* notify Phonet of device events */
 static int phonet_device_notify(struct notifier_block *me, unsigned long what,
 				void *arg)
 {
 	struct net_device *dev = arg;
 
-	if (what == NETDEV_UNREGISTER)
+	switch (what) {
+	case NETDEV_REGISTER:
+		if (dev->type == ARPHRD_PHONET)
+			phonet_device_autoconf(dev);
+		break;
+	case NETDEV_UNREGISTER:
 		phonet_device_destroy(dev);
+		break;
+	}
 	return 0;
 
 }
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-09-12  9:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-09 10:00 [PATCH 1/2] Phonet: back-end for autoconfigured addresses Rémi Denis-Courmont
2009-09-09 10:00 ` [PATCH 2/2] cdc-phonet: autoconfigure Phonet address Rémi Denis-Courmont
2009-09-09 10:24   ` Marcel Holtmann
2009-09-09 10:28     ` Rémi Denis-Courmont
2009-09-09 10:33       ` Marcel Holtmann
2009-09-11 19:38   ` David Miller
2009-09-12  9:20     ` Rémi Denis-Courmont
2009-09-11 19:38 ` [PATCH 1/2] Phonet: back-end for autoconfigured addresses David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.