Return-Path: MIME-Version: 1.0 Date: Fri, 20 Feb 2009 19:32:04 +0530 Message-ID: <8b5debfa0902200602o58dfe669g2c4ef600460ef480@mail.gmail.com> Subject: [PATCH]Generic Netlink Interface From: alok barsode To: linux-bluetooth@vger.kernel.org Content-Type: multipart/mixed; boundary=001636417f81fe695b04635a18e3 Sender: linux-bluetooth-owner@vger.kernel.org List-ID: --001636417f81fe695b04635a18e3 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Marcel, As per our last discussion, i am attaching a patch for the generic netlink interface. I am also attaching a test program (can be compiled with -lnl ) to test the interface. I am using "flags" to bring up the device and returning "changed", which indicate the changed bits in the flags. right now the module only supports 'up', 'iscan' and 'pscan'. so i can issue a NEWHOST command with HCI_UP | HCI_PSCAN | HCI_ISCAN. I am not sure if this is the right approach. OR Do you want individual commands for operations ? Let me know what you think of this. Cheers, Alok. --001636417f81fe695b04635a18e3 Content-Type: text/x-diff; charset=US-ASCII; name="0001-Adding-netlink-support-to-bluetooth.patch" Content-Disposition: attachment; filename="0001-Adding-netlink-support-to-bluetooth.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_frc4nd0n0 RnJvbSAxZTVjYjBiYmUyYzBiYmZmZTRlNGQ1M2U4NjNiYjg3ODM5NWEwMzY3IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBBbG9rIEJhcnNvZGUgPGFsb2tiYXJzb2RlQGdtYWlsLmNvbT4K RGF0ZTogV2VkLCAxOCBGZWIgMjAwOSAxOTo1NDoyMCArMDUzMApTdWJqZWN0OiBbUEFUQ0hdIEFk ZGluZyBuZXRsaW5rIHN1cHBvcnQgdG8gYmx1ZXRvb3RoLgogQWRkaW5nIGZpbGVzIG5ldGxpbmsu YyBhbmQgbmV0bGluay5oIHRvIG5ldC9ibHVldG9vdGggZm9yIG5ldGxpbmsgc3VwcG9ydC4KIEFk ZGluZyBzdXBwb3J0IGZvciBORVdIT1NULgogUmVkZWZpbmluZy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sdWV0b290aCIKKworLyogZmFtaWx5IGRlZmluaXRp b24gKi8KK3N0YXRpYyBzdHJ1Y3QgZ2VubF9mYW1pbHkgZmFtaWx5ID0geworCS5pZCA9IEdFTkxf SURfR0VORVJBVEUsCisJLmhkcnNpemUgPSAwLAorCS5uYW1lID0gQkxVRVRPT1RIX0dFTkxfRkFN SUxZX05BTUUsCisJLnZlcnNpb24gPSBWRVJTSU9OLAorCS5tYXhhdHRyID0gQVRUUl9NQVgKK307 CisKK3N0YXRpYyBzdHJ1Y3QgbmxhX3BvbGljeSBwb2xpY3lbQVRUUl9NQVggKyAxXSA9IHsKKwlb SU5ERVhdCSAgPSB7IC50eXBlID0gTkxBX1UxNiB9LAorCVtUWVBFXQkgID0geyAudHlwZSA9IE5M QV9VMTYgfSwKKwlbRkxBR1NdICAgPSB7IC50eXBlID0gTkxBX1UzMiB9LAorCVtDSEFOR0VEXSA9 IHsgLnR5cGUgPSBOTEFfVTMyIH0sCit9OworCitzdGF0aWMgaW50IGJsdWV0b290aF9uZXdob3N0 KHN0cnVjdCBza19idWZmICpza2IsIHN0cnVjdCBnZW5sX2luZm8gKmluZm8pCit7CisJX191MTYg aW5kZXg7CisJdm9pZCAqaGRyOworCWludCByZXQ9MDsKKwl1bnNpZ25lZCBsb25nIGZsYWdzID0g MCwgY2hhbmdlZCA9IDA7CisJc3RydWN0IGhjaV9kZXYgKmhkZXY7CisJc3RydWN0IHNrX2J1ZmYg Km1zZzsKKworCWlmICghaW5mby0+YXR0cnNbSU5ERVhdKQorCQlyZXR1cm4gLUVJTlZBTDsKKwor CWluZGV4ID0gbmxhX2dldF91MTYoaW5mby0+YXR0cnNbSU5ERVhdKTsKKworCWlmICghKGhkZXYg PSBoY2lfZGV2X2dldChpbmRleCkpKQorCQlyZXR1cm4gLUVOT0RFVjsKKworCXByaW50aygiJXMg JXAiLCBoZGV2LT5uYW1lLCBoZGV2KTsKKworCWlmIChoY2lfcmVxX2xvY2soaGRldikpCisJCXJl dHVybiAtR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RlZmluZSBWRVJT SU9OIDB4MDEKKworZW51bSBibHVldG9vdGhfYXR0ciB7CisJQVRUUl9VTlNQRUMsCisJSU5ERVgs CisJVFlQRSwKKwlGTEFHUywKKwlDSEFOR0VELAorCS8qIEFkZCBhdHRyaWJ1dGVzIGhlcmUgKi8K KwlfX0FUVFJfTUFYLAorCUFUVFJfTUFYICA9ICBfX0FUVFJfTUFYIC0gMQorfTsKKworZW51bSBi bHVldG9vdGhfY21kcyB7CisJQ01EX1VOU1BFQywKKwlORVdIT1NULAorCURFTEhPU1QsCisJLyog QWRkIGNvbW1hbmQgaGVyZSAqLworCV9fQ01EX01BWCwKKwlDTURfTUFYICA9IF9fQ01EX01BWCAt IDEKK307CisKKyNlbmRpZiAvKiBfX05FVExJTktfSCAqLwotLSAKMS41LjYuMwoK --001636417f81fe695b04635a18e3 Content-Type: text/x-csrc; charset=US-ASCII; name="test-up.c" Content-Disposition: attachment; filename="test-up.c" Content-Transfer-Encoding: base64 X-Attachment-Id: f_frc4ndmv1 I2luY2x1ZGUgPG5ldGxpbmsvbmV0bGluay5oPgojaW5jbHVkZSA8bmV0bGluay9nZW5sL2dlbmwu aD4KI2luY2x1ZGUgPG5ldGxpbmsvZ2VubC9jdHJsLmg+CiNpbmNsdWRlIDxuZXRsaW5rL21zZy5o PgojaW5jbHVkZSA8bmV0bGluay9hdHRyLmg+CiNpbmNsdWRlIDxzeXMvdHlwZXMuaD4KI2luY2x1 ZGUgPHVuaXN0ZC5oPgojaW5jbHVkZSA8ZmNudGwuaD4KI2luY2x1ZGUgPGVycm5vLmg+CgojaW5j bHVkZSA8Ymx1ZXRvb3RoL2JsdWV0b290aC5oPgojaW5jbHVkZSA8Ymx1ZXRvb3RoL2hjaS5oPgoj aW5jbHVkZSA8Ymx1ZXRvb3RoL2hjaV9saWIuaD4KCiNkZWZpbmUgVkVSU0lPTiAweDAxCgplbnVt IGJsdWV0b290aF9hdHRyIHsKCUFUVFJfVU5TUEVDLAoJSU5ERVgsCglUW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