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

Linux, Apache, MySQL, PHP

 
AnswerRe: treeview creation Pin
Mohammad Dayyan10-Nov-08 16:28
Mohammad Dayyan10-Nov-08 16:28 
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 
Hi,

While trying to send routing header by using following raw socket program, i am getting invalid argument error. Can anyone tell me what wrong with this.

#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;

bzero (&msg, sizeof(msg));

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] = 0xfe80;
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] = 0x021d;
daddr->sin6_addr.s6_addr16[5] = 0x09ff;
daddr->sin6_addr.s6_addr16[6] = 0xfe17;
daddr->sin6_addr.s6_addr16[7] = 0x5d0e;

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] = 0xfe80;
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] = 0x021d;
pinfo.ipi6_addr.s6_addr16[5] = 0x09ff;
pinfo.ipi6_addr.s6_addr16[6] = 0xfe17;
pinfo.ipi6_addr.s6_addr16[7] = 0x58c7;

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

//Fill ancilliary data and call sendmsg
void *extptr;
socklen_t extlen;
struct cmsghdr *cmsgptr;

extlen = inet6_rth_space(IPV6_RTHDR_TYPE_0, 1);
cmsglen = CMSG_SPACE(extlen);
cmsgptr = malloc(cmsglen);
cmsgptr->cmsg_len = CMSG_LEN(extlen);
cmsgptr->cmsg_level = IPPROTO_IPV6;
cmsgptr->cmsg_type = IPV6_RTHDR;

extptr = CMSG_DATA(cmsgptr);
extptr = inet6_rth_init(extptr, extlen, IPV6_RTHDR_TYPE_0, 1);

int check = inet6_rth_add(extptr, &daddr->sin6_addr);

if (check < 0)
{
printf("FAILURE \n");

}

msg.msg_control = cmsgptr;
msg.msg_controllen = cmsglen;


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

strcpy(iovector->iov_base, "MAG-TO-LMA");
msg.msg_iov = iovector;
msg.msg_iovlen = 1;
msg.msg_name = (void *)daddr;
msg.msg_flags = 0;

msg.msg_namelen = sizeof(struct sockaddr_in6);



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

AnswerRe: Invalid argument error while sending routing header in ipv6 Pin
shekharban3-Nov-08 22:25
shekharban3-Nov-08 22:25 
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 

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.