SCTP Discussions

Text archives Help


[SCTP-Discussion] ipv6 querry


Chronological Thread 
  • From: Arun Prasad <arun AT netlab.hcltech.com>
  • To: sctpde <discussion AT sctp.de>
  • Subject: [SCTP-Discussion] ipv6 querry
  • Date: Thu Aug 8 05:52:01 2002
  • List-id: SCTP Discussions <discussion.sctp.de>

Hi all,
Just an implementation querry.... Does anyone have tried IPV6 support for
Solaris ??... if so

* I guess using recvmsg is the only solution to get the Destination address
of the
received IPV6 packet...

* Does the procedure stated in rfc:2292 fetches the IP-ADDR (ie., by using
IPPROTO_IPV6 and IPV6_PKTINFO constants in recvmsg)???
Its always returning IPV6 address as zero for the sample program written
here....

Does Solaris fully support this ( or Iam goofing up anything...)

Thanks
-arun





The sample code which I used to test.... This program receivs a IPV6 packet
generated for address "::1"
#include <stdio.h>

#include <sys/types.h>
#include <sys/socket.h>

#include <netinet/in.h>
#include <arpa/inet.h>

#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>




main()
{
int hlen,sfd,i;
socklen_t *len=(socklen_t *) malloc(sizeof(socklen_t));
struct sockaddr_in6 skdaddr;
char str[50];
int on=1;


const size_t ADO_BUF_SIZE = 1024;
const size_t BUFFER_LENGTH = 65536;

int ret;
uint8_t *ado_buffer;
uint8_t *my_buffer;
struct msghdr msg;
struct iovec iov;
int found = 0;
struct in6_pktinfo *info;
struct cmsghdr *cm;
struct in6_addr sender_address;
struct cmsghdr *rcmsgp;


ado_buffer = (uint8_t *)malloc(ADO_BUF_SIZE);
if (ado_buffer == NULL) exit(0);

my_buffer = (uint8_t *)malloc(BUFFER_LENGTH);
if (my_buffer == NULL) exit(0);

/* qui setti correttamente il buffer di destinazione */
iov.iov_base = my_buffer;
iov.iov_len = BUFFER_LENGTH;

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

msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control =(void*) ado_buffer;
msg.msg_controllen = ADO_BUF_SIZE;

rcmsgp = (struct cmsghdr *)ado_buffer;

rcmsgp->cmsg_level = IPPROTO_IPV6;
rcmsgp->cmsg_type = IPV6_PKTINFO;
rcmsgp->cmsg_len = CMSG_LEN (sizeof (struct in6_pktinfo));





if((sfd= socket(AF_INET6, SOCK_RAW,132 ))<0)
printf("sock_create failed %d",sfd);

setsockopt(sfd, IPPROTO_IPV6, IPV6_PKTINFO, &on, sizeof(on));


for(;;)
{
ret = recvmsg(sfd, &msg, 0);
printf ("ret - %d\n",ret);


for (cm =CMSG_FIRSTHDR(&msg); cm != NULL; cm = CMSG_NXTHDR(&msg, cm)) {
printf ("chiki...\n");
printf ("level = %d,type =%d\n",cm->cmsg_level,cm->cmsg_type);
if (cm->cmsg_level == IPPROTO_IPV6 &&
cm->cmsg_type == IPV6_PKTINFO ) {
info = (struct in6_pktinfo*)CMSG_DATA(cm);
printf ("HURRAY.\n");
inet_ntop(AF_INET6, (void *)&(info->ipi6_addr), str, 50);

printf ("Addr = %s\n",str);
}
}

}
}

:!gcc srx1.c -D_XPG4_2 -D__EXTENSIONS__ -lsocket -lnsl -o rmsg -g && ./rmsg
ret - 1400
chiki...
level = 41,type =11
HURRAY.
Addr = ::

--
****************************************************************
V.ARUN PRASAD
HCL Technologies Ltd.,
Networking Technologies Lab,
Ground Floor, Block - 1, Chandamama Building,
184 to 188,190,192 & 196, NSK Road,
Vadapalani,
Chennai - 600 026

Phone: Off: +91-44-3728366/67/69, +91-44-3728156/57 Extn. 1133
Fax: +91-44-4806640
****************************************************************





  • [SCTP-Discussion] ipv6 querry, Arun Prasad, 08/08/2002

Archive powered by MHonArc 2.6.19+.

Top of page