1N/A/*
1N/A * CDDL HEADER START
1N/A *
1N/A * The contents of this file are subject to the terms of the
1N/A * Common Development and Distribution License, Version 1.0 only
1N/A * (the "License"). You may not use this file except in compliance
1N/A * with the License.
1N/A *
1N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1N/A * or http://www.opensolaris.org/os/licensing.
1N/A * See the License for the specific language governing permissions
1N/A * and limitations under the License.
1N/A *
1N/A * When distributing Covered Code, include this CDDL HEADER in each
1N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1N/A * If applicable, add the following below this CDDL HEADER, with the
1N/A * fields enclosed by brackets "[]" replaced with your own identifying
1N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1N/A *
1N/A * CDDL HEADER END
1N/A */
1N/A/*
1N/A * Copyright 1994,2002 Sun Microsystems, Inc. All rights reserved.
1N/A * Use is subject to license terms.
1N/A */
1N/A
1N/A#pragma ident "%Z%%M% %I% %E% SMI"
1N/A
1N/A#include <stdio.h>
1N/A#include <stdlib.h>
1N/A#include <netdb.h>
1N/A#include <sys/types.h>
1N/A#include <sys/socket.h>
1N/A#include <net/if.h>
1N/A#include <netinet/in.h>
1N/A#include <netinet/if_ether.h>
1N/A#include "getent.h"
1N/A
1N/Astatic int
1N/Aputethers(const char *hostname, const struct ether_addr *e, FILE *fp)
1N/A{
1N/A if (hostname == NULL || e == NULL)
1N/A return (EXC_SYNTAX);
1N/A
1N/A if (fprintf(fp, "%-20s %s\n", hostname, ether_ntoa(e)) == EOF)
1N/A return (EXC_SYNTAX); /* for lack of a better error code */
1N/A return (EXC_SUCCESS);
1N/A}
1N/A
1N/A/*
1N/A * ether_ntohost/hostton - get entries from ethers database
1N/A */
1N/Aint
1N/Adogetethers(const char **list)
1N/A{
1N/A int rc = EXC_SUCCESS;
1N/A
1N/A if (list == NULL || *list == NULL) {
1N/A rc = EXC_ENUM_NOT_SUPPORTED;
1N/A } else {
1N/A for (; *list != NULL; list++) {
1N/A struct ether_addr ea;
1N/A struct ether_addr *e;
1N/A char hostname[MAXHOSTNAMELEN + 1];
1N/A char *hp;
1N/A int retval;
1N/A
1N/A if ((e = ether_aton(*list)) != NULL) {
1N/A hp = hostname;
1N/A retval = ether_ntohost(hp, e);
1N/A } else {
1N/A hp = (char *)*list;
1N/A e = &ea;
1N/A retval = ether_hostton(hp, e);
1N/A }
1N/A if (retval != 0)
1N/A rc = EXC_NAME_NOT_FOUND;
1N/A else
1N/A rc = putethers(hp, e, stdout);
1N/A }
1N/A }
1N/A
1N/A return (rc);
1N/A}
1N/A