On 12/16/2011 09:40 AM, Rich Burridge wrote:
On 12/16/2011 09:07 AM, Danek Duvall wrote:
...
When I try to run them on my system (stard.us.oracle.com), I get:
$ sudo ./old_icmp6_echoreq
libnet 1.1 echo request ICMP6[raw]
libnet_init() failed:
$ sudo ./new_icmp6_echoreq
libnet 1.1 echo request ICMP6[raw]
libnet_init() failed:
I get a usage message when setting LD_LIBRARY_PATH to your proto area.
Even when I try to follow what the usage message says (using -t ::1
-a 1),
I still get the usage message.
And stard has ipv6 loopback, so you should be able to use ::1. I don't
know why you're getting that message.
Okay, I'll dig deeper.
I got a little further on this. Simplifying the problem, the following
program:
$ cat init4.c
/*
* Compile with:
*
* $ gcc -ggdb -Wall init4.c -o init4 -lnet -lsocket -lnsl
*/
#include <stdio.h>
#include <stdlib.h>
#include <libnet.h>
int main() {
libnet_t *l; /* the libnet context */
char errbuf[LIBNET_ERRBUF_SIZE];
l = libnet_init(LIBNET_RAW4, NULL, errbuf);
if ( l == NULL ) {
fprintf(stderr, "libnet_init() failed: %s\n", errbuf);
exit(EXIT_FAILURE);
}
libnet_destroy(l);
return 0;
}
works just fine, but if I just s/LIBNET_RAW4/LIBNET_RAW6/ and have:
/*
* Compile with:
*
* $ gcc -ggdb -Wall init6.c -o init6 -lnet -lsocket -lnsl
*/
#include <stdio.h>
#include <stdlib.h>
#include <libnet.h>
int main() {
libnet_t *l; /* the libnet context */
char errbuf[LIBNET_ERRBUF_SIZE];
l = libnet_init(LIBNET_RAW6, NULL, errbuf);
if ( l == NULL ) {
fprintf(stderr, "libnet_init() failed: %s\n", errbuf);
exit(EXIT_FAILURE);
}
libnet_destroy(l);
return 0;
}
it failed in libnet_init(). I need to now start debugging that code.
Using the addr6.c example in the libnet tutorial at:
https://repolinux.wordpress.com/2011/09/18/libnet-1-1-tutorial/
(see attached), I was able to show on my Ubuntu machine at home,
that it works just fine with the loopback address.
$ sudo ./addr6
[sudo] password for richb:
Enter an IPv6 address: ::1
libnet_name2addr6() returned: 0000:0000:0000:0000:0000:0000:0000:0001
libnet_addr2name6() says it's: ::1
$
I noticed that we have a specific patch that we are applying to the
libnet component in Userland to work with the new network vanity naming.
I wonder if it needs to be tweaked for IPV6...
Anyhoo, that's something to investigate further next week.
#include <stdio.h>
#include <stdlib.h>
#include <libnet.h>
#include <stdint.h>
#define BYTES_IN_IPV6_ADDR 16
#define MAX_CHARS_IN_IPV6_ADDR 39
int libnet_in6_addr_cmp(struct libnet_in6_addr addr1, \
struct libnet_in6_addr addr2) {
/* Returns != 0 if addresses are equal, 0 otherwise. */
uint32_t *p1 = (uint32_t*)&addr1.__u6_addr, \
*p2 = (uint32_t*)&addr2.__u6_addr;
return ((p1[0] == p2[0]) && (p1[1] == p2[1]) && \
(p1[2] == p2[2]) && (p1[3] == p2[3]));
}
int main() {
libnet_t *l; /* the libnet context */
char errbuf[LIBNET_ERRBUF_SIZE];
int i;
char ipv6_addr_str[MAX_CHARS_IN_IPV6_ADDR+1];
struct libnet_in6_addr ipv6_addr;
u_int8_t *ipv6_addr_p;
l = libnet_init(LIBNET_RAW6, NULL, errbuf);
if ( l == NULL ) {
fprintf(stderr, "libnet_init() failed: %s\n", errbuf);
exit(EXIT_FAILURE);
}
printf("Enter an IPv6 address: ");
/* too lazy not to hardcode this: */
scanf("%39s",ipv6_addr_str);
ipv6_addr = libnet_name2addr6(l, ipv6_addr_str, \
LIBNET_DONT_RESOLVE);
if (libnet_in6_addr_cmp(ipv6_addr, in6addr_error) != 0) {
fprintf(stderr, "Error converting IPv6 address.\n");
libnet_destroy(l);
exit(EXIT_FAILURE);
}
ipv6_addr_p = (u_int8_t*)&ipv6_addr.__u6_addr;
printf("libnet_name2addr6() returned: ");
for ( i=0; i < BYTES_IN_IPV6_ADDR; i++) {
printf("%02x", ipv6_addr_p[i]);
if ((i % 2 == 1) && i < BYTES_IN_IPV6_ADDR -1)
printf(":");
}
printf("\n");
ipv6_addr_str[0] = '\0';
libnet_addr2name6_r(ipv6_addr, LIBNET_DONT_RESOLVE, \
ipv6_addr_str, MAX_CHARS_IN_IPV6_ADDR);
printf("libnet_addr2name6() says it's: %s\n", \
ipv6_addr_str);
libnet_destroy(l);
return 0;
}
_______________________________________________
userland-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/userland-discuss