Return-Path: MIME-Version: 1.0 In-Reply-To: <8b5debfa0902230540n4573363dtee4f3e9fbca64fe0@mail.gmail.com> References: <8b5debfa0902200602o58dfe669g2c4ef600460ef480@mail.gmail.com> <1235160469.24255.11.camel@californication> <8b5debfa0902230540n4573363dtee4f3e9fbca64fe0@mail.gmail.com> Date: Tue, 3 Mar 2009 21:10:21 +0530 Message-ID: <8b5debfa0903030740j7131d4abmc1e8b22702f5be4d@mail.gmail.com> Subject: Re: [PATCH]Generic Netlink Interface From: alok barsode To: Marcel Holtmann Cc: linux-bluetooth@vger.kernel.org Content-Type: multipart/mixed; boundary=0016e64cc5fec4d4b3046438c0b8 List-ID: --0016e64cc5fec4d4b3046438c0b8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi Marcel, I am attaching a modified patch for the netlink interface. The changes are: 1. Adding a HOST command. It take INDEX and EVENT as parameter. EVENT can be UP or DOWN. this is similar to hciconfig hci0 up/down. 2. Registering a bluetooth-events multicast group. Userspace can subscribe to this group and receive the following events a. HOST events (device is up or down through 'changed' flag) b. NEWHOST (a new device is registered) c. DELHOST (an existing device is unregistered) All above events include the INDEX. I am attaching a simple program (listen.c) which can be used to test and above events. It subscribes to bluetooth-events grp and listens to the events. Do let me know what you think of it. Cheers, Alok. On Mon, Feb 23, 2009 at 7:10 PM, alok barsode wrote: > Hi Marcel, > > On Sat, Feb 21, 2009 at 1:37 AM, Marcel Holtmann wrote: >> Hi Alok, >> >>> 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 ? >> >> the first thing that we have to change the try_lock() change. We can't >> do that. It has way to many implications on the code. So why do you >> really need the try_lock() in this case. And if, then don't change >> current locking code. Just create a new define for the the try_lock() >> case. > > I was using try_lock to safeguard the code from being re-entrant. > will create a new define in netlink.c. > >> >> I am thinking about not exposing the ->flags directly and just creating >> a new one for the netlink interface. For example for PSCAN and ISCAN I >> like to have clear primitives that say connectable, discoverable etc. >> >> We did a lot of changes in the D-Bus API for 4.x during the last month >> and the best way would be if the netlink API reflects these changes in a >> more closer way. So it might be better to just have primitives that map >> 1:1 the properties powered, connectable, discoverable etc. > > sounds good. > >> >> We could actually just have PROPERTY primitive and then turn the >> properties into parameters. Netlink should be fine with listing multiple >> parameters in the same message. > > PROPERTY can be a nested primitive which holds the parameter value> pair. > so NEWHOST takes a list of parameter name:value pairs. > > did I understand you correctly? > > Cheers, > Alok. > --0016e64cc5fec4d4b3046438c0b8 Content-Type: text/x-diff; charset=US-ASCII; name="0001-Initial-Netlink-support.patch" Content-Disposition: attachment; filename="0001-Initial-Netlink-support.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_fruquoc30 RnJvbSA3ZTJhYTM3YTM1NzIzYWI3MmU1M2U3OGQ1OGMzNDhlM2NhZjFhZTc4IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBBbG9rIEJhcnNvZGUgPGFsb2tiYXJzb2RlQGdtYWlsLmNvbT4K RGF0ZTogVHVlLCAzIE1hciAyMDA5IDIwOjU3OjAxICswNTMwClN1YmplY3Q6IFtQQVRDSF0gSW5p dGlhbCBOZXRsaW5rIHN1cHBvcnQuCgpTaWduZWQtb2ZmLWJ5OiBBbG9rIEJhcnNvZGUgPGFsb2ti YXJzb2RlQGdtYWlsLmNvbT4KLS0tCiBpbmNsdWRlL25ldC9ibHVldG9vdGgvYmx1ZXRvb3RoLmgg fCAgICAzICsKIGluY2x1ZGUvbmV0L2JsdWV0b290aC9oY2lfY29yZS5oICB8ICAgIDIgKwogbmV0 L2JsdWV0b290aC9NYWtlZmlsZSAgICAgICAgICAgIHwgICAgMiArLQogbmV0L2JsdWV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mx1ZXRvb3RoIGludGVyZmFjZS4KKyAqCisgKiBDb3B5 cmlnaHQgMjAwOCBBbG9rIEJhcnNvZGUgPGFsb2suYmFyc29kZUBhemluZ28uY29tPgorICovCisj aWZuZGVmIF9fTkVUTElOS19ICisjZGVmaW5lIF9fTkVUTElOS19ICisKKyNkZWZpbmUgVkVSU0lP TiAweDAxCisjZGVmaW5lIGxvY2soZCkJCWRvd25fdHJ5bG9jaygmZC0+cmVxX2xvY2spCisjZGVm aW5lIHVubG9jayhkKQl1cCgmZC0+cmVxX2xvY2spCisKKyNkZWZpbmUgRE9XTgkwCisjZGVmaW5l IFVQCTEKKworZW51bSB7CisJQVRUUl9VTlNQRUMsCisJSU5ERVgsCisJQ0hBTkdFRCwKKwlFVkVO VCwKKwlHUlBJRCwKKwkvKiBBZGQgYXR0cmlidXRlcyBoZXJlICovCisJX19BVFRSX01BWCwKKwlB VFRSX01BWCAgPSAgX19BVFRSX01BWCAtIDEKK307CisKK2VudW0geworCUNNRF9VTlNQRUMsCisJ TkVXSE9TVCwKKwlERUxIT1NULAorCUhPU1QsCisJR0VUR1JQSUQsCisJLyogQWRkIGNvbW1hbmQg aGVyZSAqLworCV9fQ01EX01BWCwKKwlDTURfTUFYICA9IF9fQ01EX01BWCAtIDEKK307CisKK2lu dCBibHVldG9vdGhfbm90aWZ5KHN0cnVjdCBoY2lfZGV2ICpoZGV2LCBpbnQgZXZlbnQpOworCisj ZW5kaWYgLyogX19ORVRMSU5LX0ggKi8KLS0gCjEuNS42LjMKCg== --0016e64cc5fec4d4b3046438c0b8 Content-Type: text/x-csrc; charset=US-ASCII; name="listen.c" Content-Disposition: attachment; filename="listen.c" Content-Transfer-Encoding: base64 X-Attachment-Id: f_fruqupqq1 I2luY2x1ZGUgPG5ldGxpbmsvbmV0bGluay5oPgojaW5jbHVkZSA8bmV0bGluay9nZW5sL2dlbmwu aD4KI2luY2x1ZGUgPG5ldGxpbmsvZ2VubC9jdHJsLmg+CiNpbmNsdWRlIDxu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