Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/nss/ethers.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2006-11-16 13:50:27 +0100
committerArthur de Jong <arthur@arthurdejong.org>2006-11-16 13:50:27 +0100
commit4bbb60e380e068cf4bd49e8468957c55a5199259 (patch)
tree6c121042348f99ee3392c56c1e3ff72a2f3efe7f /nss/ethers.c
parentfc0578b5d55645ad060f3a64697a2ed79e88e8e6 (diff)
switch to a simpler and more compact framework to generate methods (one reader function to deserialize a struct from the stream and auto-generated functions)
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/libnss_ldapd@92 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nss/ethers.c')
-rw-r--r--nss/ethers.c56
1 files changed, 14 insertions, 42 deletions
diff --git a/nss/ethers.c b/nss/ethers.c
index 6a475cf..13443f7 100644
--- a/nss/ethers.c
+++ b/nss/ethers.c
@@ -36,48 +36,32 @@
#define ETHER_NAME result->e_name
#define ETHER_ADDR result->e_addr
-/* map a hostname to the corresponding ethernet address */
-enum nss_status _nss_ldap_gethostton_r(
- const char *name,struct etherent *result,
+static enum nss_status read_etherent(
+ FILE *fp,struct etherent *result,
char *buffer,size_t buflen,int *errnop)
{
- FILE *fp;
int32_t tmpint32;
size_t bufptr=0;
- /* open socket and write request */
- OPEN_SOCK(fp);
- WRITE_REQUEST(fp,NSLCD_ACTION_ETHER_BYNAME);
- WRITE_STRING(fp,name);
- WRITE_FLUSH(fp);
- /* read response */
- READ_RESPONSEHEADER(fp,NSLCD_ACTION_ETHER_BYNAME);
- READ_RESPONSE_CODE(fp);
+ /* auto-genereted read code */
LDF_ETHER;
- /* close socket and we're done */
- fclose(fp);
+ /* we're done */
return NSS_STATUS_SUCCESS;
}
+/* map a hostname to the corresponding ethernet address */
+enum nss_status _nss_ldap_gethostton_r(
+ const char *name,struct etherent *result,
+ char *buffer,size_t buflen,int *errnop)
+{
+ NSS_BYNAME(NSLCD_ACTION_ETHER_BYNAME,name,read_etherent);
+}
+
/* map an ethernet address to the corresponding hostname */
enum nss_status _nss_ldap_getntohost_r(
const struct ether_addr *addr,struct etherent *result,
char *buffer,size_t buflen,int *errnop)
{
- FILE *fp;
- int32_t tmpint32;
- size_t bufptr=0;
- /* open socket and write request */
- OPEN_SOCK(fp);
- WRITE_REQUEST(fp,NSLCD_ACTION_ETHER_BYNAME);
- WRITE_TYPE(fp,addr,u_int8_t[6]);
- WRITE_FLUSH(fp);
- /* read response */
- READ_RESPONSEHEADER(fp,NSLCD_ACTION_ETHER_BYNAME);
- READ_RESPONSE_CODE(fp);
- LDF_ETHER;
- /* close socket and we're done */
- fclose(fp);
- return NSS_STATUS_SUCCESS;
+ NSS_BYTYPE(NSLCD_ACTION_ETHER_BYETHER,addr,u_int8_t[6],read_etherent);
}
/* thread-local file pointer to an ongoing request */
@@ -93,19 +77,7 @@ enum nss_status _nss_ldap_getetherent_r(
struct etherent *result,
char *buffer,size_t buflen,int *errnop)
{
- int32_t tmpint32;
- size_t bufptr=0;
- /* check that we have a valid file descriptor */
- if (fp==NULL)
- {
- *errnop=ENOENT;
- return NSS_STATUS_UNAVAIL;
- }
- /* read a response */
- READ_RESPONSE_CODE(fp);
- LDF_ETHER;
- /* return result code */
- return NSS_STATUS_SUCCESS;
+ NSS_GETENT(read_etherent);
}
enum nss_status _nss_ldap_endetherent(void)