On Fri, Aug 25, 2006 at 08:57:23AM +0200, Patrick McHardy ([EMAIL PROTECTED]) 
wrote:
> 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.

I put there explicit socket option to show how it works in case there
will be several group requests, which will not be placed into initial
bind call.
But you are right, that magic numbers are not that good.
I will update program with appropriate changes.
Thank you.

-- 
        Evgeniy Polyakov
-
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