[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#705900: check_ping fail if host do not have IPv6 address



Hi,

I got more information: If, in the attached example test.c, the
ai_family field of the hints argument to getaddrinfo is set to
"AF_UNSPEC", then I do get the correct scope id in the returned data
structure.

If the hint is set to AF_INET6, I don’t (but I also do not get the
debugging information that I put into libnss-myhostname, so I might just
not fully understand what’s going on here).

Greetings,
Joachim

-- 
Joachim "nomeata" Breitner
Debian Developer
  nomeata@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C
  JID: nomeata@joachim-breitner.de | http://people.debian.org/~nomeata

#include <stdio.h>
#include <string.h>
#include <linux/filter.h>
#include <stdlib.h>
#include <netinet/ip6.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>


int main(int argc, char *argv[])
{
	if (argc < 2) {
		printf("Usage: %s hostname\n", argv[0]);
		exit(1);
	}
	struct addrinfo hints, *ai;
	struct sockaddr_in6 *addr;

	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_INET6;

	getaddrinfo(argv[1], 0, &hints, &ai);
	addr = (struct sockaddr_in6 *)(ai->ai_addr);
	fprintf(stdout, "Scope id returned for %s: %d\n", argv[1], addr->sin6_scope_id);
	char foo[INET6_ADDRSTRLEN];
	fprintf(stdout, "Family returned for %s: %d (AF_INET6: %d)\n", argv[1], ai->ai_family, AF_INET6);
	fprintf(stdout, "Addr returned for %s: %s\n", argv[1], inet_ntop(AF_INET6, &(addr->sin6_addr), &(foo[0]), INET6_ADDRSTRLEN));
	return 0;
}
	

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: