[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(usagi-users 00512) Problem receiving the IPv6 headers
- To: usagi-users@xxxxxxxxxxxxxx
- Subject: (usagi-users 00512) Problem receiving the IPv6 headers
- From: SUPERJFG <SUPERJFG@xxxxxxxx>
- Date: Fri, 11 May 2001 13:18:53 +0200
- Reply-to: usagi-users@xxxxxxxxxxxxxx
Hi.
I'm trying to receive the IPv6 headers of the incoming packets, and
what I see is that the last header is always lost. As it's explained in
the RFC, first the reception of these headers must be enabled. This
corresponds to the following code:
#ifdef IPV6_RECVPKTINFO
setsockopt (socketDesc, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on,
sizeof(on));
#else
setsockopt (socketDesc, IPPROTO_IPV6, IPV6_PKTINFO, &on,
sizeof(on));
#endif
#ifdef IPV6_RECVHOPLIMIT
setsockopt (socketDesc, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on,
sizeof(on));
#else
setsockopt (socketDesc, IPPROTO_IPV6, IPV6_HOPLIMIT, &on,
sizeof(on));
#endif
#ifdef IPV6_RECVRTHDR
setsockopt (socketDesc, IPPROTO_IPV6, IPV6_RECVRTHDR, &on,
sizeof(on));
#else
setsockopt (socketDesc, IPPROTO_IPV6, IPV6_RTHDR, &on, sizeof(on));
#endif
#ifdef IPV6_RECVHOPOPTS
setsockopt (socketDesc, IPPROTO_IPV6, IPV6_RECVHOPOPTS, &on,
sizeof(on));
#else
setsockopt (socketDesc, IPPROTO_IPV6, IPV6_HOPOPTS, &on,
sizeof(on));
#endif
#ifdef IPV6_RECVDSTOPTS
setsockopt (socketDesc, IPPROTO_IPV6, IPV6_RECVDSTOPTS, &on,
sizeof(on));
#else
setsockopt (socketDesc, IPPROTO_IPV6, IPV6_DSTOPTS, &on,
sizeof(on));
#endif
After thar, I try to see what my socket has received with the following
code (I've simplified it just to show
you):
struct msghdr msg;
struct cmsghdr *cmsgptr;
The variables are correctly initializated and the recvmsg call doesn't
return any error, so in msg must be all the IPv6 headers.
for (cmsgptr = CMSG_FIRSTHDR(msg); cmsgptr != NULL;cmsgptr =
CMSG_NXTHDR(msg, cmsgptr)) {
if (cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type ==
IPV6_PKTINFO ) {
printf ("PKTINFO header\n");
}
if (cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type ==
IPV6_RTHDR ) {
printf ("RTHDR header\n");
}
if (cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type ==
IPV6_HOPOPTS ) {
printf ("HOPOPTS header\n");
}
if (cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type ==
IPV6_DSTOPTS ) {
printf ("DSTOPTS header\n");
}
if (cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type ==
IPV6_HOPLIMIT ) {
printf ("HOPLIMIT header\n");
}
}
It seems that the CMSG_NXTHDR macro ignores the last header (returns
NULL while there's a header remaining), because I've tried to send
several optional headers, and I always get all of them except for the
last one. Someone knows something about this or has had a similar
problem with this?
I should be very grateful if someone could help.
Thanks.
___________________________________________________________________
Consigue tu e-mail gratuito TERRA.ES
Haz clic en http://www.terra.es/correo/