Re: Connector - how to start?

Evgeniy Polyakov
2006-04-16T11:40:42Z

On Sun, Apr 16, 2006 at 01:26:10PM +0200, Libor Vanek (libor.vanek@gmail.com) wrote:
> Hi,
>
> > I've attached simple userspace program used with w1, which sends
> > and receives connector messages. It can be also used as example of
> > netlink usage from userspace point of view.
>
> Maybe I'm really stupid and/or blind but I can't find in this example
> (from my point of view) quite important features:
>
> - there is no way how can user-space part say what "cb_id.idx" and
> "cb_id.val" it should accept (as far as I understand these are used
> for settings "message type" - what SW is using these)

"idx" field is a group number userspace binds to, "val" is a private
identificator which is used as you like.

> - I can't find neither in cn_test.c nor w1_netlink.c (which is the
> only part I found connector used in) any way of detecting if message
> was delivered to/from user-space

If cn_netlink_send() returns zero this means message was queued into
userspace socket. In case of error negative value is returned.

> - the very same is for detecting if there is some user-space
> "reciever" (there is some mention about this in
> Documentantation/connector/connector.txt but it's not working to
> myself - I got 2.6.17-pre1-mm2)

connector uses netlink_has_listeners(), but it can produce false
positives, in this case netlink_broadcast() will say the final word.
If message has been added into socket's queue netlink_broadcast(), which
is used in connector, returns zero, and it's return value is propagated
back to original caller of cn_netlink_send().

Message from userspace is always delivered, and in this case appropriate
callback is called.

> Maybe connector doesn't support these things... ?
>
> Libor Vanek