Skip to contentSkip to conversation

Questions regarding NetLink APIs.

PATCH New Alok 2 participants 3 messages Oct 17, 2008 – Oct 30, 2008

Subsystems (2)
lore
Share & tools
lore

Alok

author
#0 lore raw

Marcel,

I had a few queries regarding the netlink APIs. I have been referring to net/wireless/nl80211.c for reference.

1. Would the ioctls on raw sock(BTPROTO_HCI), be converted into netlink commands?
eg HCIGETDEVLIST (NLBLUETOOTH_CMD_GET_DEVLIST),
HCIGETDEVINFO (NLBLUETOOTH_CMD_GET_DEV_INFO),
HCIDEVUP (NLBLUETOOTH_CMD_DEVUP) .. etc

2. Would the netlink attributes consist of HCI Ioctl requests structures ? or individual structure members?
eg:

[NLBLUETOOTH_ATTR_DEV_INFO] = {.len = sizeof(struct hci_dev_info)}

3. Would it be a separate kernel module?

Thanks,
Alok.

maintainer
#1 lore raw

Hi Alok,

Quoted 8 lines

I had a few queries regarding the netlink APIs. I have been referring to net/wireless/nl80211.c for reference.

1. Would the ioctls on raw sock(BTPROTO_HCI), be converted into netlink commands?
eg HCIGETDEVLIST (NLBLUETOOTH_CMD_GET_DEVLIST),
HCIGETDEVINFO (NLBLUETOOTH_CMD_GET_DEV_INFO),
HCIDEVUP (NLBLUETOOTH_CMD_DEVUP) .. etc

yes.

Quoted 5 lines

2. Would the netlink attributes consist of HCI Ioctl requests structures ? or individual structure members?
eg:

[NLBLUETOOTH_ATTR_DEV_INFO] = {.len = sizeof(struct hci_dev_info)}

No. We will have the parameters inside the structure as direct attributes.

Quoted 1 line

3. Would it be a separate kernel module?

No. It will be within bluetooth.ko.

Regards

Marcel

author
#2 lore raw

PATCH 1/1 NetLink patches.

Marcel,

Attaching 2 patches for netlink support.

1. Adds net/bluetooth/netlink.c for netlink support with initialization and exit functions.

2. Registers a generic netlink family "bluetooth".

Let me know if anything needs to be modified.

Thanks,
Alok.

Quoted 1 line

From c81a88be8536f0369aa4106d2722357c36734a20 Mon Sep 17 00:00:00 2001

From: Alok Barsode <[email protected]>
Date: Thu, 30 Oct 2008 16:50:15 +0530
Subject: [PATCH] Adding net/bluetooth/netlink.c for netlink support.

---
 include/net/bluetooth/bluetooth.h |    3 +++
 net/bluetooth/Makefile            |    2 +-
 net/bluetooth/af_bluetooth.c      |    6 ++++++
 net/bluetooth/netlink.c           |   24 ++++++++++++++++++++++++
 4 files changed, 34 insertions(+), 1 deletions(-)
 create mode 100644 net/bluetooth/netlink.c
include/net/bluetooth/bluetooth.h +3 -0
index 6f8418b..b02c7aa 100644
@@ -178,4 +178,7 @@ extern void bt_sysfs_cleanup(void);
 
 extern struct class *bt_class;
 
+extern int nlbluetooth_init(void);
+extern void nlbluetooth_cleanup(void);
+
 #endif /* __BLUETOOTH_H */
net/bluetooth/Makefile +1 -1
index d1e433f..f014d48 100644
@@ -10,4 +10,4 @@ obj-$(CONFIG_BT_BNEP)	+= bnep/
 obj-$(CONFIG_BT_CMTP)	+= cmtp/
 obj-$(CONFIG_BT_HIDP)	+= hidp/
 
-bluetooth-objs := af_bluetooth.o hci_core.o hci_conn.o hci_event.o hci_sock.o hci_sysfs.o lib.o
+bluetooth-objs := af_bluetooth.o hci_core.o hci_conn.o hci_event.o hci_sock.o hci_sysfs.o lib.o netlink.o
net/bluetooth/af_bluetooth.c +6 -0
index 8907eff..b6487dc 100644
@@ -436,6 +436,10 @@ static int __init bt_init(void)
 	if (err < 0)
 		return err;
 
+	err = nlbluetooth_init();
+	if (err < 0)
+		return err;
+
 	err = sock_register(&bt_sock_family_ops);
 	if (err < 0) {
 		bt_sysfs_cleanup();
@@ -456,6 +460,8 @@ static void __exit bt_exit(void)
 	sock_unregister(PF_BLUETOOTH);
 
 	bt_sysfs_cleanup();
+
+	nlbluetooth_cleanup();
 }
 
 subsys_initcall(bt_init);
net/bluetooth/netlink.c new file +24 -0
new file mode 100644
index 0000000..4606bbc
@@ -0,0 +1,24 @@
+/*
+ * This is the netlink-based bluetooth interface.
+ *
+ * Copyright 2008 Alok Barsode <[email protected]>
+ */
+
+#include <net/genetlink.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+#include <net/bluetooth/bluetooth.h>
+#include <net/bluetooth/hci_core.h>
+
+/* initialisation/exit functions */
+
+int __init nlbluetooth_init(void)
+{
+	return 0;
+}
+
+void nlbluetooth_cleanup(void)
+{
+
+}
Signature · 1 line
1.5.4.3
Quoted 1 line

From 7c32b72b7e3ba502069fe87754e424d4f7f297e9 Mon Sep 17 00:00:00 2001

From: Alok Barsode <[email protected]>
Date: Mon, 27 Oct 2008 21:01:59 +0530
Subject: [PATCH] Registering general netlink family - bluetooth.

---
 net/bluetooth/netlink.c |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)
net/bluetooth/netlink.c +25 -1
index 4606bbc..fafc6f2 100644
@@ -11,14 +11,38 @@
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
 
+#define VERSION 1
+
+enum nlbluetooth_attr {
+	NLBLUETOOTH_ATTR_UNSPEC,
+	__NLBLUETOOTH_ATTR_MAX,
+};
+
+#define NLBLUETOOTH_ATTR_MAX ( __NLBLUETOOTH_ATTR_MAX - 1)
+
+/* family definition */
+static struct genl_family nlbluetooth_fam = {
+	.id = GENL_ID_GENERATE,
+	.hdrsize = 0,
+	.name = "bluetooth",
+	.version = VERSION,
+	.maxattr = NLBLUETOOTH_ATTR_MAX
+};
+
 /* initialisation/exit functions */
 
 int __init nlbluetooth_init(void)
 {
+	int err;
+
+	err = genl_register_family(&nlbluetooth_fam);
+	if (err)
+		return err;
+
 	return 0;
 }
 
 void nlbluetooth_cleanup(void)
 {
-
+	genl_unregister_family(&nlbluetooth_fam);
 }
Signature · 1 line
1.5.4.3