[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(usagi-users 02068) recvfrom ipv6
- To: usagi-users@xxxxxxxxxxxxxx
- Subject: (usagi-users 02068) recvfrom ipv6
- From: Abdul Basit <basit@xxxxxxxx>
- Date: Tue, 7 Jan 2003 08:52:28 -0600 (CST)
- In-reply-to: <20030107.233554.99321869.yoshfuji@linux-ipv6.org>
- Reply-to: usagi-users@xxxxxxxxxxxxxx
Hello all,
I was trying to catch icmpv6 stuff , but getting different behaviours
on other systems
like my code snippet is
-- start
struct ip6_hdr *ip6;
struct icmp6_hdr *icmp6;
struct sockaddr_storage *s6;
struct sockaddr_in6 *in6;
static char src6host[128];
socklen_t len6;
struct icmp6_filter fil;
ICMP6_FILTER_SETBLOCKALL (&fil);
ICMP6_FILTER_SETPASS (ICMP6_ECHO_REQUEST, &fil);
setsockopt (sock6fd, IPPROTO_ICMPV6, ICMP6_FILTER, &fil, sizeof (fil));
for (;;)
{
n6 =
recvfrom (sock6fd, buf6,
sizeof (struct ip6_hdr) + sizeof (struct icmp6_hdr), 0,
(struct sockaddr *) s6, &len6);
if (n6 > 0)
{
ip6 = (struct ip6_hdr *) buf6;
ip6_len = sizeof (struct ip6_hdr);
icmp6 = (struct icmp6_hdr *) (buf6 + ip6_len);
in6 = (struct sockaddr_in6 *) s6;
// a tricky way, inet_ntoa doesn't support struct sockaddr_in6 ..
inet_ntop (AF_INET6, &in6->sin6_addr, src6host, sizeof (src6host));
if (icmp6->icmp6_type == 0)
{
printf("hello.. ipv6 icmp request");
......................
-- end
see, everytime if i write like if (icmp6->icmp6_type == ICMP6_ECHO_REQUEST)
{ , it never matches, everytime i am getting icmp6_type == 0 , 0 value in
icmp6.h is defined for more than one #define ,
#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
#define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */
#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
Why its not matching ICMP6_ECHO_REQUEST and instead matching against 0
If i try to print next header value from ip6->ip6_nxt, it shows 118 ,
and 118 is not defined anywhere in headers ?
also on some glibc 2.2.5 with stock linux(2.4.17) kernel , the above
recvfrom(... ) statement returns n6 == -1 , but on my system USAGI
snap 6'th jan. with glibc 2.3.1 , it pass things correclty.
seems the fifth argument in above recvfrom(..) is doing something wrong
if i set that to NULL, it will work everywhere(no matter what glibc , what
ipv6 implementation) but then how i'd be able to get source address of
icmp (from ip6 header?)
sorry for very long msg :(, i hope someone will reply
-- basit