Click here to Skip to main content
16,013,648 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
GeneralRe: treeview creation Pin
divyamistry27-Jan-09 22:07
professionaldivyamistry27-Jan-09 22:07 
GeneralRe: treeview creation Pin
Mohammad Dayyan27-Jan-09 22:37
Mohammad Dayyan27-Jan-09 22:37 
GeneralRe: treeview creation Pin
sk8te32029-Jan-09 18:35
sk8te32029-Jan-09 18:35 
GeneralRe: treeview creation Pin
divyamistry29-Jan-09 20:56
professionaldivyamistry29-Jan-09 20:56 
GeneralRe: treeview creation Pin
divyamistry29-Jan-09 21:02
professionaldivyamistry29-Jan-09 21:02 
AnswerRe: treeview creation Pin
Jules VDV29-Jan-09 8:39
Jules VDV29-Jan-09 8:39 
QuestionInvalid argument error while sending routing header in ipv6 Pin
shekharban3-Nov-08 3:24
shekharban3-Nov-08 3:24 
AnswerRe: Invalid argument error while sending routing header in ipv6 Pin
shekharban3-Nov-08 22:25
shekharban3-Nov-08 22:25 
Hi,

Meanwhile i was trying to send icmp packets; got to know that byte ordering of address is wrong. I tried the above program by changing the address byte order, but with no luck. Could any one please let me know how routing header can be sent as a ancilliary data in v6 and what might be wrong with this code.

#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
#include <errno.h>
#include <string.h>

void main()
{
int sock_fd;
int on = 1;
int offset = 4;
int ret = 0;

struct sockaddr_in6 *daddr;
struct in6_pktinfo pinfo;
struct msghdr msg;
struct cmsghdr *cmsg;
struct iovec *iovector;
socklen_t rthlen = 0;
int cmsglen;

sock_fd = socket(AF_INET6, SOCK_RAW, IPPROTO_IPV6);

if(sock_fd < 0)
{
printf("\nClient: Socket Creation Failed: Error %d\n", errno);
return;
}

iovector = (struct iovec*)calloc(1, sizeof(struct iovec));


/* Since for Mobility Header the checksum is located in offset 4, we need to
* set the offset to 4
*/

if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_RECVRTHDR, &on, sizeof(on)) < 0)
{
printf("\nClient: RTHDR option set failed\n");
return;
}

/* Our Destination Address is fe80::21d:9ff:fe17:5d0e eth0 interface
* i.e. fe80Blush | :O Blush | :O Blush | :O :021d:09ff:fe17:5d0e
*/
daddr = (struct sockaddr_in6*)calloc(1, sizeof(struct sockaddr_in6));

daddr->sin6_family = AF_INET6;

daddr->sin6_addr.s6_addr16[0] = 0x80fe;
daddr->sin6_addr.s6_addr16[1] = 0x0;
daddr->sin6_addr.s6_addr16[2] = 0x0;
daddr->sin6_addr.s6_addr16[3] = 0x0;
daddr->sin6_addr.s6_addr16[4] = 0x1d02;
daddr->sin6_addr.s6_addr16[5] = 0xff09;
daddr->sin6_addr.s6_addr16[6] = 0x17fe;
daddr->sin6_addr.s6_addr16[7] = 0x0e5d;

daddr->sin6_port = htons(IPPROTO_IPV6);

/* Our Source Address is fe80::21d:9ff:fe17:58c7 eth0 interface
* i.e. fe80Blush | :O Blush | :O Blush | :O :021d:09ff:fe17:58c7
*/
memset(&pinfo, 0, sizeof(struct in6_pktinfo));

pinfo.ipi6_addr.s6_addr16[0] = 0x80fe;
pinfo.ipi6_addr.s6_addr16[1] = 0x0;
pinfo.ipi6_addr.s6_addr16[2] = 0x0;
pinfo.ipi6_addr.s6_addr16[3] = 0x0;
pinfo.ipi6_addr.s6_addr16[4] = 0x1d02;
pinfo.ipi6_addr.s6_addr16[5] = 0xff09;
pinfo.ipi6_addr.s6_addr16[6] = 0x17fe;
pinfo.ipi6_addr.s6_addr16[7] = 0xc758;

pinfo.ipi6_ifindex = 2; /* Interface Id */


/* Fill the Routing Header in ancillary data */
rthlen = inet6_rth_space(IPV6_RTHDR_TYPE_0, 1);
cmsglen = CMSG_SPACE(rthlen);
printf("\nClient: rthlen is %d\n", rthlen);
cmsg = malloc(cmsglen);
if (cmsg == NULL)
{
printf("\nClient:Ancillary Data memory allocation failed\n");
return;
}

memset(cmsg, 0, cmsglen);
memset(&msg, 0, sizeof(msg));

iovector->iov_base = malloc(10);
iovector->iov_len = 10;

strcpy(iovector->iov_base, "TEST-4-RH");

msg.msg_control = (void *)cmsg;
msg.msg_controllen = cmsglen;
msg.msg_iov = iovector;
msg.msg_iovlen = 1;
msg.msg_name = (void *)daddr;
msg.msg_namelen = sizeof(struct sockaddr_in6);

void *rthp;

cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = CMSG_LEN(rthlen);
cmsg->cmsg_level = IPPROTO_IPV6;
cmsg->cmsg_type = IPV6_RTHDR;

rthp = CMSG_DATA(cmsg);
rthp = inet6_rth_init(rthp, rthlen, IPV6_RTHDR_TYPE_0, 1);

if(rthp == NULL)
{
printf("\nClient: Routing Header Init failed\n");
return;
}

inet6_rth_add(rthp, &daddr->sin6_addr);
rthp = NULL;

ret = sendmsg(sock_fd, &msg, 0);
if (ret < 0)
{
printf("\nClient:Send Message Failed: Error %d Ret %d\n", errno, ret);
free(iovector->iov_base);
free(iovector);
return;
}
}

Regards,
Shekharban

banshekhar
Questionhow detect "pressing key" Pin
Schehaider_Aymen2-Nov-08 3:26
Schehaider_Aymen2-Nov-08 3:26 
AnswerRe: how detect "pressing key" Pin
Shyam Bharath5-Nov-08 18:12
Shyam Bharath5-Nov-08 18:12 
Questiondownloading DSL Pin
Subin Alex27-Oct-08 4:57
Subin Alex27-Oct-08 4:57 
AnswerRe: downloading DSL Pin
L. Madhavan17-Dec-08 18:08
L. Madhavan17-Dec-08 18:08 
Questionshmget returning 0 Pin
Shaurya Rastogi26-Oct-08 18:23
Shaurya Rastogi26-Oct-08 18:23 
AnswerRe: shmget returning 0 Pin
Shyam Bharath26-Oct-08 19:16
Shyam Bharath26-Oct-08 19:16 
QuestionIs Linux worth it? Pin
Meer Osman Ali25-Oct-08 20:05
Meer Osman Ali25-Oct-08 20:05 
AnswerRe: Is Linux worth it? Pin
flydream204613-Dec-08 21:08
flydream204613-Dec-08 21:08 
QuestionWhat do I need to learn? Pin
MikeMarq20-Oct-08 9:20
MikeMarq20-Oct-08 9:20 
AnswerRe: What do I need to learn? [modified] Pin
Shyam Bharath26-Oct-08 19:07
Shyam Bharath26-Oct-08 19:07 
GeneralRe: What do I need to learn? Pin
MikeMarq31-Oct-08 12:03
MikeMarq31-Oct-08 12:03 
Questioncompiling more than 2 C files Pin
Schehaider_Aymen19-Oct-08 6:52
Schehaider_Aymen19-Oct-08 6:52 
AnswerRe: compiling more than 2 C files Pin
Moak19-Oct-08 14:49
Moak19-Oct-08 14:49 
GeneralRe: compiling more than 2 C files Pin
Schehaider_Aymen19-Oct-08 23:06
Schehaider_Aymen19-Oct-08 23:06 
AnswerRe: compiling more than 2 C files Pin
DevMentor.org24-Oct-08 17:58
DevMentor.org24-Oct-08 17:58 
QuestionMultithreading with Multi-Core and Linux Pin
Thanh.VD19-Oct-08 5:30
Thanh.VD19-Oct-08 5:30 
AnswerRe: Multithreading with Multi-Core and Linux Pin
Moak19-Oct-08 14:47
Moak19-Oct-08 14:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.