Evgeniy Polyakov wrote:
> Hello.
> 
> I was asked several times to include userspace example code into
> Documentation, so if there is no policy against it, consider attached patch 
> for 2.6.18. This program works with included 
> Documentation/connector/cn_test.c 
> connector module.

> +     l_local.nl_family = AF_NETLINK;
> +     l_local.nl_groups = 0x123;
> +     l_local.nl_pid = 0;
> +
> +     if (bind(s, (struct sockaddr *)&l_local, sizeof(struct sockaddr_nl)) == 
> -1) {
> +             perror("bind");
> +             close(s);
> +             return -1;
> +     }
> +
> +     {
> +             int on = l_local.nl_groups;
> +             setsockopt(s, 270, 1, &on, sizeof(on));
> +     }

Example code shouldn't use magic numbers, please use the proper defines.
And the code is wrong, using the same group number for bind (which takes
a bitmask) and setsockopt (which takes a group number) doesn't work.
Its not necessary to use setsockopt if you already used bind anyway.

-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to