Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 44ddbde

Browse files
committed
Remove INET6 define. Use ENABLE_IPV6 instead.
1 parent 080d5b3 commit 44ddbde

5 files changed

Lines changed: 236 additions & 248 deletions

File tree

Modules/getaddrinfo.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
#include "addrinfo.h"
5858
#endif
5959

60-
#if defined(__KAME__) && defined(INET6)
60+
#if defined(__KAME__) && defined(ENABLE_IPV6)
6161
# define FAITH
6262
#endif
6363

@@ -94,7 +94,7 @@ static struct gai_afd {
9494
const char *a_addrany;
9595
const char *a_loopback;
9696
} gai_afdl [] = {
97-
#ifdef INET6
97+
#ifdef ENABLE_IPV6
9898
#define N_INET6 0
9999
{PF_INET6, sizeof(struct in6_addr),
100100
sizeof(struct sockaddr_in6),
@@ -111,7 +111,7 @@ static struct gai_afd {
111111
{0, 0, 0, 0, NULL, NULL},
112112
};
113113

114-
#ifdef INET6
114+
#ifdef ENABLE_IPV6
115115
#define PTON_MAX 16
116116
#else
117117
#define PTON_MAX 4
@@ -288,7 +288,7 @@ getaddrinfo(const char*hostname, const char*servname,
288288
switch (hints->ai_family) {
289289
case PF_UNSPEC:
290290
case PF_INET:
291-
#ifdef INET6
291+
#ifdef ENABLE_IPV6
292292
case PF_INET6:
293293
#endif
294294
break;
@@ -417,7 +417,7 @@ getaddrinfo(const char*hostname, const char*servname,
417417
for (i = 0; gai_afdl[i].a_af; i++) {
418418
if (inet_pton(gai_afdl[i].a_af, hostname, pton)) {
419419
u_long v4a;
420-
#ifdef INET6
420+
#ifdef ENABLE_IPV6
421421
u_char pfx;
422422
#endif
423423

@@ -430,7 +430,7 @@ getaddrinfo(const char*hostname, const char*servname,
430430
if (v4a == 0 || v4a == IN_LOOPBACKNET)
431431
pai->ai_flags &= ~AI_CANONNAME;
432432
break;
433-
#ifdef INET6
433+
#ifdef ENABLE_IPV6
434434
case AF_INET6:
435435
pfx = ((struct in6_addr *)pton)->s6_addr8[0];
436436
if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
@@ -495,11 +495,11 @@ get_name(addr, gai_afd, res, numaddr, pai, port0)
495495
struct hostent *hp;
496496
struct addrinfo *cur;
497497
int error = 0;
498-
#ifdef INET6
498+
#ifdef ENABLE_IPV6
499499
int h_error;
500500
#endif
501501

502-
#ifdef INET6
502+
#ifdef ENABLE_IPV6
503503
hp = getipnodebyaddr(addr, gai_afd->a_addrlen, gai_afd->a_af, &h_error);
504504
#else
505505
hp = gethostbyaddr(addr, gai_afd->a_addrlen, AF_INET);
@@ -510,7 +510,7 @@ get_name(addr, gai_afd, res, numaddr, pai, port0)
510510
} else
511511
GET_AI(cur, gai_afd, numaddr, port);
512512

513-
#ifdef INET6
513+
#ifdef ENABLE_IPV6
514514
if (hp)
515515
freehostent(hp);
516516
#endif
@@ -519,7 +519,7 @@ get_name(addr, gai_afd, res, numaddr, pai, port0)
519519
free:
520520
if (cur)
521521
freeaddrinfo(cur);
522-
#ifdef INET6
522+
#ifdef ENABLE_IPV6
523523
if (hp)
524524
freehostent(hp);
525525
#endif
@@ -547,7 +547,7 @@ get_addr(hostname, af, res, pai, port0)
547547
top = NULL;
548548
sentinel.ai_next = NULL;
549549
cur = &sentinel;
550-
#ifdef INET6
550+
#ifdef ENABLE_IPV6
551551
if (af == AF_UNSPEC) {
552552
hp = getipnodebyname(hostname, AF_INET6,
553553
AI_ADDRCONFIG|AI_ALL|AI_V4MAPPED, &h_error);
@@ -582,18 +582,18 @@ get_addr(hostname, af, res, pai, port0)
582582

583583
for (i = 0; (ap = hp->h_addr_list[i]) != NULL; i++) {
584584
switch (af) {
585-
#ifdef INET6
585+
#ifdef ENABLE_IPV6
586586
case AF_INET6:
587587
gai_afd = &gai_afdl[N_INET6];
588588
break;
589589
#endif
590-
#ifndef INET6
590+
#ifndef ENABLE_IPV6
591591
default: /* AF_UNSPEC */
592592
#endif
593593
case AF_INET:
594594
gai_afd = &gai_afdl[N_INET];
595595
break;
596-
#ifdef INET6
596+
#ifdef ENABLE_IPV6
597597
default: /* AF_UNSPEC */
598598
if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {
599599
ap += sizeof(struct in6_addr) -
@@ -622,15 +622,15 @@ get_addr(hostname, af, res, pai, port0)
622622
}
623623
cur = cur->ai_next;
624624
}
625-
#ifdef INET6
625+
#ifdef ENABLE_IPV6
626626
freehostent(hp);
627627
#endif
628628
*res = top;
629629
return SUCCESS;
630630
free:
631631
if (top)
632632
freeaddrinfo(top);
633-
#ifdef INET6
633+
#ifdef ENABLE_IPV6
634634
if (hp)
635635
freehostent(hp);
636636
#endif

Modules/getnameinfo.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static struct gni_afd {
5858
int a_socklen;
5959
int a_off;
6060
} gni_afdl [] = {
61-
#ifdef INET6
61+
#ifdef ENABLE_IPV6
6262
{PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
6363
offsetof(struct sockaddr_in6, sin6_addr)},
6464
#endif
@@ -102,7 +102,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
102102
int family, len, i;
103103
char *addr, *p;
104104
u_long v4a;
105-
#ifdef INET6
105+
#ifdef ENABLE_IPV6
106106
u_char pfx;
107107
#endif
108108
int h_error;
@@ -159,7 +159,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
159159
if (v4a == 0 || v4a == IN_LOOPBACKNET)
160160
flags |= NI_NUMERICHOST;
161161
break;
162-
#ifdef INET6
162+
#ifdef ENABLE_IPV6
163163
case AF_INET6:
164164
pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr8[0];
165165
if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
@@ -177,7 +177,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
177177
return ENI_MEMORY;
178178
strcpy(host, numaddr);
179179
} else {
180-
#ifdef INET6
180+
#ifdef ENABLE_IPV6
181181
hp = getipnodebyaddr(addr, gni_afd->a_addrlen, gni_afd->a_af, &h_error);
182182
#else
183183
hp = gethostbyaddr(addr, gni_afd->a_addrlen, gni_afd->a_af);
@@ -190,13 +190,13 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
190190
if (p) *p = '\0';
191191
}
192192
if (strlen(hp->h_name) > hostlen) {
193-
#ifdef INET6
193+
#ifdef ENABLE_IPV6
194194
freehostent(hp);
195195
#endif
196196
return ENI_MEMORY;
197197
}
198198
strcpy(host, hp->h_name);
199-
#ifdef INET6
199+
#ifdef ENABLE_IPV6
200200
freehostent(hp);
201201
#endif
202202
} else {

Modules/socketmodule.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ typedef struct {
479479
#ifdef AF_UNIX
480480
struct sockaddr_un un;
481481
#endif
482-
#ifdef INET6
482+
#ifdef ENABLE_IPV6
483483
struct sockaddr_in6 in6;
484484
struct sockaddr_storage storage;
485485
#endif
@@ -594,7 +594,7 @@ setipaddr(char* name, struct sockaddr * addr_ret, int af)
594594
case AF_INET:
595595
siz = 4;
596596
break;
597-
#ifdef INET6
597+
#ifdef ENABLE_IPV6
598598
case AF_INET6:
599599
siz = 16;
600600
break;
@@ -651,7 +651,7 @@ setipaddr(char* name, struct sockaddr * addr_ret, int af)
651651
switch (addr_ret->sa_family) {
652652
case AF_INET:
653653
return 4;
654-
#ifdef INET6
654+
#ifdef ENABLE_IPV6
655655
case AF_INET6:
656656
return 16;
657657
#endif
@@ -725,7 +725,7 @@ makesockaddr(int sockfd, struct sockaddr *addr, int addrlen)
725725
}
726726
#endif /* AF_UNIX */
727727

728-
#ifdef INET6
728+
#ifdef ENABLE_IPV6
729729
case AF_INET6:
730730
{
731731
struct sockaddr_in6 *a;
@@ -830,7 +830,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
830830
return 1;
831831
}
832832

833-
#ifdef INET6
833+
#ifdef ENABLE_IPV6
834834
case AF_INET6:
835835
{
836836
struct sockaddr_in6* addr;
@@ -919,7 +919,7 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
919919
return 1;
920920
}
921921

922-
#ifdef INET6
922+
#ifdef ENABLE_IPV6
923923
case AF_INET6:
924924
{
925925
*len_ret = sizeof (struct sockaddr_in6);
@@ -1993,7 +1993,7 @@ gethost_common(struct hostent *h, struct sockaddr *addr, int alen, int af)
19931993
if (alen < sizeof(struct sockaddr_in))
19941994
return NULL;
19951995
break;
1996-
#ifdef INET6
1996+
#ifdef ENABLE_IPV6
19971997
case AF_INET6:
19981998
if (alen < sizeof(struct sockaddr_in6))
19991999
return NULL;
@@ -2031,7 +2031,7 @@ gethost_common(struct hostent *h, struct sockaddr *addr, int alen, int af)
20312031
memcpy((char *) addr, &sin, sizeof(sin));
20322032
break;
20332033
}
2034-
#ifdef INET6
2034+
#ifdef ENABLE_IPV6
20352035
case AF_INET6:
20362036
{
20372037
struct sockaddr_in6 sin6;
@@ -2138,7 +2138,7 @@ for a host. The host argument is a string giving a host name or IP number.";
21382138
static PyObject *
21392139
PySocket_gethostbyaddr(PyObject *self, PyObject *args)
21402140
{
2141-
#ifdef INET6
2141+
#ifdef ENABLE_IPV6
21422142
struct sockaddr_storage addr;
21432143
#else
21442144
struct sockaddr_in addr;
@@ -2177,7 +2177,7 @@ PySocket_gethostbyaddr(PyObject *self, PyObject *args)
21772177
ap = (char *)&((struct sockaddr_in *)sa)->sin_addr;
21782178
al = sizeof(((struct sockaddr_in *)sa)->sin_addr);
21792179
break;
2180-
#ifdef INET6
2180+
#ifdef ENABLE_IPV6
21812181
case AF_INET6:
21822182
ap = (char *)&((struct sockaddr_in6 *)sa)->sin6_addr;
21832183
al = sizeof(((struct sockaddr_in6 *)sa)->sin6_addr);
@@ -2588,7 +2588,7 @@ PySocket_getnameinfo(PyObject *self, PyObject *args)
25882588
}
25892589
break;
25902590
}
2591-
#ifdef INET6
2591+
#ifdef ENABLE_IPV6
25922592
case AF_INET6:
25932593
{
25942594
struct sockaddr_in6 *sin6;

0 commit comments

Comments
 (0)