[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4CC8BBCE.70609@hp.com>
Date: Wed, 27 Oct 2010 19:54:54 -0400
From: Brian Haley <brian.haley@...com>
To: Jan Engelhardt <jengelh@...ozas.de>
CC: netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <eric.dumazet@...il.com>
Subject: Re: IPV6 raw socket denies bind(2)
On 10/27/2010 06:01 PM, Jan Engelhardt wrote:
> int main(void)
> {
> struct sockaddr_in6 src = {};
> int sk;
>
> sk = socket(AF_INET6, SOCK_RAW, IPPROTO_UDP);
> memset(&src, 0, sizeof(src));
> inet_pton(AF_INET6, "::1", &src);
> src.sin6_family = AF_INET6;
>
> if (bind(sk, (void *)&src, sizeof(src)) < 0) {
> perror("bind");
> abort();
> }
> return 0;
> }
You're trashing the sockaddr, try this patch:
< inet_pton(AF_INET6, "::1", &src);
---
> inet_pton(AF_INET6, "::1", &src.sin6_addr);
-Brian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists