diff options
| author | Robert Pluim | 2019-11-07 16:16:39 +0100 |
|---|---|---|
| committer | Robert Pluim | 2019-11-08 10:04:13 +0100 |
| commit | 063277c5ecd82551b2bf1409d1583edc7c0fcaad (patch) | |
| tree | 2c4669471723f2a63aeeed067575778bd5c3bbc8 /src | |
| parent | 82323253378c310c71cfea393d228321d1fc51f4 (diff) | |
| download | emacs-063277c5ecd82551b2bf1409d1583edc7c0fcaad.tar.gz emacs-063277c5ecd82551b2bf1409d1583edc7c0fcaad.zip | |
Ensure building and running on non-IPv6 capable hosts works
* src/process.c (Fmake_network_process) [AF_INET6]: Only build ::1
localhost when IPv6 is supported.
(Fnetwork_lookup_address_info) [AF_INET6]: Move check for Qipv6 inside
ifdef, since its definition depends on AF_INET6. Don't return IPv6
addresses when they're not supported.
* test/src/process-tests.el (lookup-family-specification,
lookup-google): Only do IPv6 lookup if IPv6 is supported.
Diffstat (limited to 'src')
| -rw-r--r-- | src/process.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/process.c b/src/process.c index 1f959e39607..8aa4811f7ed 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -4015,9 +4015,11 @@ usage: (make-network-process &rest ARGS) */) | |||
| 4015 | if (family != AF_LOCAL) | 4015 | if (family != AF_LOCAL) |
| 4016 | #endif | 4016 | #endif |
| 4017 | { | 4017 | { |
| 4018 | #ifdef AF_INET6 | ||
| 4018 | if (family == AF_INET6) | 4019 | if (family == AF_INET6) |
| 4019 | host = build_string ("::1"); | 4020 | host = build_string ("::1"); |
| 4020 | else | 4021 | else |
| 4022 | #endif | ||
| 4021 | host = build_string ("127.0.0.1"); | 4023 | host = build_string ("127.0.0.1"); |
| 4022 | } | 4024 | } |
| 4023 | } | 4025 | } |
| @@ -4027,9 +4029,11 @@ usage: (make-network-process &rest ARGS) */) | |||
| 4027 | { | 4029 | { |
| 4028 | /* Depending on setup, "localhost" may map to different IPv4 and/or | 4030 | /* Depending on setup, "localhost" may map to different IPv4 and/or |
| 4029 | IPv6 addresses, so it's better to be explicit (Bug#6781). */ | 4031 | IPv6 addresses, so it's better to be explicit (Bug#6781). */ |
| 4032 | #ifdef AF_INET6 | ||
| 4030 | if (family == AF_INET6) | 4033 | if (family == AF_INET6) |
| 4031 | host = build_string ("::1"); | 4034 | host = build_string ("::1"); |
| 4032 | else | 4035 | else |
| 4036 | #endif | ||
| 4033 | host = build_string ("127.0.0.1"); | 4037 | host = build_string ("127.0.0.1"); |
| 4034 | } | 4038 | } |
| 4035 | CHECK_STRING (host); | 4039 | CHECK_STRING (host); |
| @@ -4622,7 +4626,8 @@ DEFUN ("network-lookup-address-info", Fnetwork_lookup_address_info, | |||
| 4622 | Optional parameter FAMILY controls whether to look up IPv4 or IPv6 | 4626 | Optional parameter FAMILY controls whether to look up IPv4 or IPv6 |
| 4623 | addresses. The default of nil means both, symbol `ipv4' means IPv4 | 4627 | addresses. The default of nil means both, symbol `ipv4' means IPv4 |
| 4624 | only, symbol `ipv6' means IPv6 only. Returns a list of addresses, or | 4628 | only, symbol `ipv6' means IPv6 only. Returns a list of addresses, or |
| 4625 | nil if none were found. Each address is a vector of integers. */) | 4629 | nil if none were found. Each address is a vector of integers, as per |
| 4630 | the description of ADDRESS in `make-network-process'. */) | ||
| 4626 | (Lisp_Object name, Lisp_Object family) | 4631 | (Lisp_Object name, Lisp_Object family) |
| 4627 | { | 4632 | { |
| 4628 | Lisp_Object addresses = Qnil; | 4633 | Lisp_Object addresses = Qnil; |
| @@ -4636,12 +4641,9 @@ nil if none were found. Each address is a vector of integers. */) | |||
| 4636 | hints.ai_family = AF_UNSPEC; | 4641 | hints.ai_family = AF_UNSPEC; |
| 4637 | else if (EQ (family, Qipv4)) | 4642 | else if (EQ (family, Qipv4)) |
| 4638 | hints.ai_family = AF_INET; | 4643 | hints.ai_family = AF_INET; |
| 4639 | else if (EQ (family, Qipv6)) | ||
| 4640 | #ifdef AF_INET6 | 4644 | #ifdef AF_INET6 |
| 4645 | else if (EQ (family, Qipv6)) | ||
| 4641 | hints.ai_family = AF_INET6; | 4646 | hints.ai_family = AF_INET6; |
| 4642 | #else | ||
| 4643 | /* If we don't support IPv6, querying will never work anyway */ | ||
| 4644 | return addresses; | ||
| 4645 | #endif | 4647 | #endif |
| 4646 | else | 4648 | else |
| 4647 | error ("Unsupported lookup type"); | 4649 | error ("Unsupported lookup type"); |
| @@ -4653,9 +4655,15 @@ nil if none were found. Each address is a vector of integers. */) | |||
| 4653 | else | 4655 | else |
| 4654 | { | 4656 | { |
| 4655 | for (lres = res; lres; lres = lres->ai_next) | 4657 | for (lres = res; lres; lres = lres->ai_next) |
| 4656 | addresses = Fcons (conv_sockaddr_to_lisp (lres->ai_addr, | 4658 | { |
| 4657 | lres->ai_addrlen), | 4659 | #ifndef AF_INET6 |
| 4658 | addresses); | 4660 | if (lres->ai_family != AF_INET) |
| 4661 | continue; | ||
| 4662 | #endif | ||
| 4663 | addresses = Fcons (conv_sockaddr_to_lisp (lres->ai_addr, | ||
| 4664 | lres->ai_addrlen), | ||
| 4665 | addresses); | ||
| 4666 | } | ||
| 4659 | addresses = Fnreverse (addresses); | 4667 | addresses = Fnreverse (addresses); |
| 4660 | 4668 | ||
| 4661 | freeaddrinfo (res); | 4669 | freeaddrinfo (res); |