* Init variables
*/
memset(&hint, 0, sizeof(hint));
- hint.ai_family = PF_UNSPEC;
+ hint.ai_family = AF_UNSPEC;
/*
* Input section: decode command line parameters
* Use getopt function
case 'v': /* set address type */
j = strtol(optarg, NULL, 10);
if (j == 4) {
- hint.ai_family = PF_INET;
+ hint.ai_family = AF_INET;
break;
}
if (j == 6) {
- hint.ai_family = PF_INET6;
+ hint.ai_family = AF_INET6;
break;
}
printf("Wrong IP protocol version, use 4 o 6\n\n");
ptr = res; /* init list pointer */
printf("Canonical name %s\n", ptr->ai_canonname); /* print cname */
while (ptr != NULL) { /* loop on list */
- if (ptr->ai_family == PF_INET) { /* if IPv4 */
+ if (ptr->ai_family == AF_INET) { /* if IPv4 */
printf("IPv4 address: \n");
addr = (struct sockaddr_in *) ptr->ai_addr; /* address */
port = ntohs(addr->sin_port); /* port */
string = inet_ntop(addr->sin_family, &addr->sin_addr,
buffer, sizeof(buffer));
- } else if (ptr->ai_family == PF_INET6) { /* if IPv6 */
+ } else if (ptr->ai_family == AF_INET6) { /* if IPv6 */
printf("IPv6 address: \n");
addr6 = (struct sockaddr_in6 *) ptr->ai_addr; /* address */
port = ntohs(addr6->sin6_port); /* port */