tech-net archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: in_pcbsetport(), in6_pcbsetport()
On Wed, Apr 29, 2009 at 09:09:11PM +0300, Elad Efrat wrote:
> On Wed, Apr 29, 2009 at 8:54 PM, Manuel Bouyer
> <bouyer%antioche.eu.org@localhost> wrote:
>
> > It looks like in udp6_output.c you're going to change in6_any.sin6_addr,
> > I can't see how this can be right (if pr_domain is const there's probably
> > a reason :). You should copy the content to a local sockaddr_in6 instead.
> >
> > BTW, you did a similar change to the netinet/ code, with a UNCONST here too.
> > While it may be safe here (it seems you're not writing to the pointer),
> > it would be better to not use UNCONST() here and make the pointer's
> > copy const instead.
>
> Good catch! :)
>
> Would something like the following be okay?
>
> struct sockaddr_in6 lsin6 =
> *((struct sockaddr_in6
> *)__UNCONST(in6p->in6p_socket->so_proto->pr_domain->dom_sa_any));
> lsin6.sin6_addr = *laddr;
There's no need for __UNCONST(). Let the appearance of __UNCONST() in
your code be your cue to revisit your assumptions or your design.
If this is not in a fast path, then this is fairly concise and correct:
struct sockaddr_in6 lsin6 =
*satocsin6(sockaddr_any_by_family(AF_INET6));
lsin6.sin6_addr = *laddr;
but I suggest:
struct sockaddr_in6 lsin6;
sockaddr_in6_init(&lsin6, laddr, 0, 0, 0);
Dave
--
David Young OJC Technologies
dyoung%ojctech.com@localhost Urbana, IL * (217) 278-3933
Home |
Main Index |
Thread Index |
Old Index