FreeBSD Bugzilla – Attachment 247054 Details for
Bug 275774
IPv4 Mapper address problem
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
udptest
udptest.c (text/plain), 1.51 KB, created by
Emmanuel Vadot
on 2023-12-15 12:25:16 UTC
(
hide
)
Description:
udptest
Filename:
MIME Type:
Creator:
Emmanuel Vadot
Created:
2023-12-15 12:25:16 UTC
Size:
1.51 KB
patch
obsolete
>#include <sys/types.h> >#include <sys/socket.h> >#include <netinet/in.h> >#include <arpa/inet.h> >#include <stdio.h> >#include <string.h> > >int >main(int argc, char *argv[]) { > struct sockaddr_in6 sa6 = { 0 }; > struct sockaddr_in6 sa6recv; > int optval = 0; > int sock; > char buffer[20] = { 0 }; > socklen_t len = sizeof(sa6recv); > const char msg1[] = "abcd"; > const char msg2[] = "efgh"; > char *dest_addr; > int n; > > if (argc != 2) > return (1); > sa6.sin6_family = AF_INET6; > sa6.sin6_port = htons(1234); > sock = socket(PF_INET6, SOCK_DGRAM, 0); > > setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof(optval)); > > inet_pton(AF_INET6, "::ffff:127.0.0.1", &(sa6.sin6_addr)); > sendto(sock, msg1, sizeof(msg1) - 1, 0, (struct sockaddr*)&sa6, sizeof(sa6)); > n = recvfrom(sock, (char*)buffer, sizeof(buffer), MSG_WAITALL, (struct sockaddr*)&sa6recv, &len); > if (n <= 0 || strcmp(buffer, msg1) != 0) > { > printf("incorrect message 1\n"); > return -1; > } > > asprintf(&dest_addr, "::ffff:%s", argv[1]); > inet_pton(AF_INET6, dest_addr, &(sa6.sin6_addr)); > sendto(sock, msg2, sizeof(msg2) - 1, 0, (struct sockaddr*)&sa6, sizeof(sa6)); > n = recvfrom(sock, (char*)buffer, sizeof(buffer), MSG_WAITALL, (struct sockaddr*)&sa6recv, &len); > if (n <= 0 || strcmp(buffer, msg2) != 0) > { > printf("incorrect message 2\n"); > return -1; > } > printf("succeeded\n"); > return 0; >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 275774
: 247054 |
247055
|
247056