LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-24-2012, 02:44 PM   #1
shahlanuk
LQ Newbie
 
Registered: Sep 2012
Posts: 1

Rep: Reputation: Disabled
Cannot set Router Alert option in ICMPv6 packet


I am trying to to set Hop-By-Hop option in a packet before sending it out according to the example specified in Appendix C of http://www.ietf.org/rfc/rfc3542.txt . I don’t see any errors while using the APIs but the HBH option is not set in the sent packet.

This is my code:

set_rtr_alert_opt (struct msghdr *msg, struct cmsghdr *cmsg)
{
int ralen = 0, currentlen = 0;
void *hbhbuf = NULL, *optp = NULL;
u_int8_t rtr_alert;

rtr_alert = htons(IP6_ALERT_MLD);

/*
* Set the Router Alert option into the cmsg
*/
ralen = inet6_opt_init(NULL, 0);
if (ralen == -1) {
return(FALSE);
}

ralen = inet6_opt_append(NULL, 0, ralen, IP6OPT_ROUTER_ALERT, 2,
2, NULL);
if (ralen == -1) {
return(FALSE);
}

ralen = inet6_opt_finish(NULL, 0, ralen);
if (ralen == -1) {
return(FALSE);
}

cmsg->cmsg_len = CMSG_LEN(ralen);
cmsg->cmsg_level = IPPROTO_IPV6;
cmsg->cmsg_type = IPV6_HOPOPTS;
hbhbuf = CMSG_DATA(cmsg);
msg->msg_controllen += ALIGN(cmsg->cmsg_len);

currentlen = inet6_opt_init(hbhbuf, ralen);
if (currentlen == -1) {
return(FALSE);
}

currentlen = inet6_opt_append(hbhbuf, ralen, currentlen,
IP6OPT_ROUTER_ALERT, 2, 2, &optp);
if (currentlen == -1) {
return(FALSE);
}

inet6_opt_set_val(optp, 0, &rtr_alert, sizeof(rtr_alert));
currentlen = inet6_opt_finish(hbhbuf, ralen, currentlen);
if (currentlen == -1) {
return(FALSE);
}

return(TRUE);
}

After this i call sendmsg() to send the packet out. The packet does go out but the HBH option is not present in the packet.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I set up alert notification when services startup? struct Linux - Server 1 06-12-2011 01:57 AM
Wlan0: option 43 has zero length, failed to parse packet BobNutfield Linux - Networking 14 12-09-2010 07:45 PM
How do I set up a laptop as a router to connect wirelessly to my ADSL router hairysocks Linux - Networking 12 12-20-2009 06:51 AM
unsetting router alert(RA) option, when sending through rawsocket sudhir_pandey Linux - Networking 0 11-29-2007 07:55 AM
icmpv6 crashes system guzo Linux - Networking 2 04-26-2005 10:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration