nss-myhostname.c revision ab1ecd3c9a303765f5158a9d4692f6fcbea02540
/*-*- Mode: C; c-basic-offset: 8 -*-*/
/***
This file is part of nss-myhostname.
Copyright 2008 Lennart Poettering
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation, either version 2.1
of the License, or (at your option) any later version.
nss-myhostname is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with nss-myhostname. If not, If not, see
***/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <limits.h>
#include <nss.h>
#include <netdb.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
/* We use 127.0.0.2 as IPv4 address. This has the advantage over
* 127.0.0.1 that it can be translated back to the local hostname. For
* IPv6 we use ::1 which unfortunately will not translate back to the
* hostname but instead something like "localhost6" or so. */
#define LOCALADDRESS_IPV6 &in6addr_loopback
#define LOOPBACK_INTERFACE "lo"
#define ALIGN(a) (((a+sizeof(void*)-1)/sizeof(void*))*sizeof(void*))
const char *name,
struct gaih_addrtuple **pat,
unsigned ifi;
char *r_name;
*h_errnop = NO_RECOVERY;
return NSS_STATUS_UNAVAIL;
}
return NSS_STATUS_NOTFOUND;
}
/* If this call fails we fill in 0 as scope. Which is fine */
*h_errnop = NO_RECOVERY;
return NSS_STATUS_TRYAGAIN;
}
/* First, fill in hostname */
/* Second, fill in IPv4 tuple */
/* Third, fill in IPv6 tuple */
/* Verify the size matches */
if (ttlp)
*ttlp = 0;
return NSS_STATUS_SUCCESS;
}
static enum nss_status fill_in_hostent(
const char *hn,
int af,
char **canonp) {
*h_errnop = NO_RECOVERY;
return NSS_STATUS_TRYAGAIN;
}
/* First, fill in hostname */
/* Second, create aliases array */
idx += sizeof(char*);
/* Third, add address */
else
/* Fourth, add address pointer array */
((char**) r_addr_list)[0] = r_addr;
idx += sizeof(char*)*2;
/* Verify the size matches */
if (ttlp)
*ttlp = 0;
if (canonp)
return NSS_STATUS_SUCCESS;
}
const char *name,
int af,
char **canonp) {
*errnop = EAFNOSUPPORT;
return NSS_STATUS_UNAVAIL;
}
*h_errnop = NO_RECOVERY;
return NSS_STATUS_UNAVAIL;
}
return NSS_STATUS_NOTFOUND;
}
}
const char *name,
int af,
return _nss_myhostname_gethostbyname3_r(
name,
af,
host,
NULL,
NULL);
}
const char *name,
return _nss_myhostname_gethostbyname3_r(
name,
host,
NULL,
NULL);
}
int af,
if (len != 4 ||
goto not_found;
if (len != 16 ||
goto not_found;
} else {
*errnop = EAFNOSUPPORT;
return NSS_STATUS_UNAVAIL;
}
*h_errnop = NO_RECOVERY;
return NSS_STATUS_UNAVAIL;
}
return NSS_STATUS_NOTFOUND;
}
int af,
return _nss_myhostname_gethostbyaddr2_r(
af,
host,
NULL);
}