resolved: introduce common macro for 127.0.0.2 IP address
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "local-addresses.h"
|
||||
#include "macro.h"
|
||||
#include "nss-util.h"
|
||||
#include "resolve-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "string-util.h"
|
||||
@@ -21,7 +22,7 @@
|
||||
* IPv6 we use ::1 which unfortunately will not translate back to the
|
||||
* hostname but instead something like "localhost" or so. */
|
||||
|
||||
#define LOCALADDRESS_IPV4 (htobe32(0x7F000002))
|
||||
#define LOCALADDRESS_IPV4 (htobe32(INADDR_LOCALADDRESS))
|
||||
#define LOCALADDRESS_IPV6 &in6addr_loopback
|
||||
|
||||
NSS_GETHOSTBYNAME_PROTOTYPES(myhostname);
|
||||
|
||||
@@ -217,7 +217,7 @@ static int synthesize_system_hostname_rr(Manager *m, const DnsResourceKey *key,
|
||||
buffer[n++] = (struct local_address) {
|
||||
.family = AF_INET,
|
||||
.ifindex = LOOPBACK_IFINDEX,
|
||||
.address.in.s_addr = htobe32(0x7F000002),
|
||||
.address.in.s_addr = htobe32(INADDR_LOCALADDRESS),
|
||||
};
|
||||
|
||||
if (IN_SET(af, AF_INET6, AF_UNSPEC) && socket_ipv6_is_enabled())
|
||||
@@ -245,7 +245,7 @@ static int synthesize_system_hostname_ptr(Manager *m, int af, const union in_add
|
||||
assert(address);
|
||||
assert(answer);
|
||||
|
||||
if (af == AF_INET && address->in.s_addr == htobe32(0x7F000002)) {
|
||||
if (af == AF_INET && address->in.s_addr == htobe32(INADDR_LOCALADDRESS)) {
|
||||
|
||||
/* Always map the IPv4 address 127.0.0.2 to the local hostname, in addition to "localhost": */
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
/* 127.0.0.54 in native endian (The IP address we listen on we only implement "proxy" mode) */
|
||||
#define INADDR_DNS_PROXY_STUB ((in_addr_t) 0x7f000036U)
|
||||
|
||||
/* 127.0.0.2 is an address we always map to the local hostname. This is different from 127.0.0.1 which maps to "localhost" */
|
||||
#define INADDR_LOCALADDRESS ((in_addr_t) 0x7f000002U)
|
||||
|
||||
typedef enum DnsCacheMode DnsCacheMode;
|
||||
|
||||
enum DnsCacheMode {
|
||||
|
||||
Reference in New Issue
Block a user