diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-12-18 01:44:34 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-12-19 02:07:42 +0100 |
commit | b7d131939347fee0f1af7a288052a3dffb5a6763 (patch) | |
tree | 55afcf11e48665155eb74cb81877fa07c3214e49 /src | |
parent | c853953658865ec3b3487e3f1eb2cc0516320bf3 (diff) |
nss-myhostname: introduce is_gateway() similar to the existing is_hostname()
Diffstat (limited to 'src')
-rw-r--r-- | src/nss-myhostname/nss-myhostname.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c index 2f768603b0..dcf7c1f5de 100644 --- a/src/nss-myhostname/nss-myhostname.c +++ b/src/nss-myhostname/nss-myhostname.c @@ -47,6 +47,13 @@ NSS_GETHOSTBYNAME_PROTOTYPES(myhostname); NSS_GETHOSTBYADDR_PROTOTYPES(myhostname); +static bool is_gateway(const char *hostname) { + assert(hostname); + + return streq(hostname, "gateway") || + streq(hostname, "gateway."); +} + enum nss_status _nss_myhostname_gethostbyname4_r( const char *name, struct gaih_addrtuple **pat, @@ -78,7 +85,7 @@ enum nss_status _nss_myhostname_gethostbyname4_r( canonical = "localhost"; local_address_ipv4 = htonl(INADDR_LOOPBACK); - } else if (streq(name, "gateway") || streq(name, "gateway.")) { + } else if (is_gateway(name)) { n_addresses = local_gateways(NULL, 0, AF_UNSPEC, &addresses); if (n_addresses <= 0) { @@ -348,7 +355,7 @@ enum nss_status _nss_myhostname_gethostbyname3_r( canonical = "localhost"; local_address_ipv4 = htonl(INADDR_LOOPBACK); - } else if (streq(name, "gateway") || streq(name, "gateway.")) { + } else if (is_gateway(name)) { n_addresses = local_gateways(NULL, 0, af, &addresses); if (n_addresses <= 0) { |