summaryrefslogtreecommitdiff
path: root/testnss.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2006-11-10 13:08:48 +0000
committerArthur de Jong <arthur@arthurdejong.org>2006-11-10 13:08:48 +0000
commitb279ad846720add3b262db9e5b10c96390393a44 (patch)
tree2a25cf3b47982aa448f267ca291927fe7adf15c2 /testnss.c
parent58a82990fc8284539113f0b4b05002a434eeeb59 (diff)
implement NSS-side ethers database lookups plus test code
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/libnss_ldapd@79 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'testnss.c')
-rw-r--r--testnss.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/testnss.c b/testnss.c
index 1481d34..8b2986a 100644
--- a/testnss.c
+++ b/testnss.c
@@ -124,6 +124,15 @@ static void printhost(struct hostent *host)
printf(" h_addr_list[%d]=NULL\n",i);
}
+static void printether(struct etherent *ether)
+{
+ printf("struct etherent {\n"
+ " e_name=\"%s\",\n"
+ " e_addr=%s\n"
+ "}\n",
+ ether->e_name,ether_ntoa(&(ether->e_addr)));
+}
+
/* the main program... */
int main(int argc,char *argv[])
{
@@ -131,6 +140,7 @@ int main(int argc,char *argv[])
struct aliasent aliasresult;
struct group groupresult;
struct hostent hostresult;
+ struct etherent etherresult;
char buffer[1024];
enum nss_status res;
int errnocp,h_errnocp;
@@ -349,5 +359,46 @@ int main(int argc,char *argv[])
res=_nss_ldap_endhostent();
printf("status=%s\n",nssstatus(res));
+ /* test ether_hostton() */
+ printf("\nTEST ether_hostton()\n");
+ res=_nss_ldap_gethostton_r("appelscha",&etherresult,buffer,1024,&errnocp);
+ printf("status=%s\n",nssstatus(res));
+ if (res==NSS_STATUS_SUCCESS)
+ printether(&etherresult);
+ else
+ {
+ printf("errno=%d:%s\n",(int)errno,strerror(errno));
+ printf("errnocp=%d:%s\n",(int)errnocp,strerror(errnocp));
+ }
+
+ /* test ether_ntohost() */
+ printf("\nTEST ether_ntohost()\n");
+ res=_nss_ldap_getntohost_r(ether_aton("0:13:72:a4:39:c7"),
+ &etherresult,buffer,1024,&errnocp);
+ printf("status=%s\n",nssstatus(res));
+ if (res==NSS_STATUS_SUCCESS)
+ printether(&etherresult);
+ else
+ {
+ printf("errno=%d:%s\n",(int)errno,strerror(errno));
+ printf("errnocp=%d:%s\n",(int)errnocp,strerror(errnocp));
+ }
+
+
+ /* test {set,get,end}etherent() */
+ printf("\nTEST {set,get,end}etherent()\n");
+ res=_nss_ldap_setetherent(1);
+ printf("status=%s\n",nssstatus(res));
+ while ((res=_nss_ldap_getetherent_r(&etherresult,buffer,1024,&errnocp))==NSS_STATUS_SUCCESS)
+ {
+ printf("status=%s\n",nssstatus(res));
+ printether(&etherresult);
+ }
+ printf("status=%s\n",nssstatus(res));
+ printf("errno=%d:%s\n",(int)errno,strerror(errno));
+ printf("errnocp=%d:%s\n",(int)errnocp,strerror(errnocp));
+ res=_nss_ldap_endetherent();
+ printf("status=%s\n",nssstatus(res));
+
return 0;
}