ether_addr.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* nisplus/ether_addr.c -- "nisplus" backend for nsswitch "ethers" database
*
* Copyright 1988-1992,2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* All routines necessary to deal with the ethers NIS+ table. The table
* contains mapping between 48 bit ethernet addresses and their corresponding
* hosts name. The addresses have an ascii representation of the form
* "x:x:x:x:x:x" where x is a hex number between 0x00 and 0xff; the
* bytes are always in network order.
*/
#include <netinet/if_ether.h>
#include <strings.h>
#include <nss_dbdefs.h>
#include "nisplus_common.h"
#include "nisplus_tables.h"
static nss_status_t
void *a;
{
}
static nss_status_t
getbyether(be, a)
void *a;
{
char etherstr[18];
*e, *(e + 1), *(e + 2), *(e + 3), *(e + 4), *(e + 5));
etherstr));
}
/*
* Place the resulting struct ether_addr from the nis_object structure into
* argp->buf.result only if argp->buf.result is initialized (not NULL).
* I.e. it happens for the call ether_hostton.
*
* Place the resulting hostname into argp->buf.buffer only if
* argp->buf.buffer is initialized. I.e. it happens for the call
* ether_ntohost.
*
* Returns NSS_STR_PARSE_{SUCCESS, ERANGE, PARSE}
*/
/*ARGSUSED*/
static int
int nobj;
{
char *val;
int len;
/*
* argp->buf.buflen does not make sense for ethers. It
* is always set to 0 by the frontend. The caller only
* passes a hostname pointer in case of ether_ntohost,
* that is assumed to be big enough. For ether_hostton,
* the struct ether_addr passed is a fixed size.
*
* If we got more than one nis_object, we just ignore it.
* Although it should never have happened.
*
* ASSUMPTION: All the columns in the NIS+ tables are
* null terminated.
*/
return (NSS_STR_PARSE_PARSE);
}
/*
* get ether addr
*
* ether_hostton
*/
if (ether) {
int i;
unsigned int t[6];
if (len < 2)
return (NSS_STR_PARSE_PARSE);
&t[0], &t[1], &t[2], &t[3], &t[4], &t[5]);
if (i != ETHERADDRL)
return (NSS_STR_PARSE_PARSE);
for (i = 0; i < ETHERADDRL; i++)
/*
* get hostname
*
* ether_ntohost
*/
} else if (host) {
if (len < 2)
return (NSS_STR_PARSE_PARSE);
/*
* The interface does not let the caller specify how long is
* the buffer pointed by host. We make a safe assumption that
* the callers will always give MAXHOSTNAMELEN. In any case,
* it is the only finite number we can lay our hands on in
* case of runaway strings, memory corruption etc.
*/
if (len > MAXHOSTNAMELEN)
return (NSS_STR_PARSE_ERANGE);
}
return (NSS_STR_PARSE_SUCCESS);
}
static nisplus_backend_op_t ethers_ops[] = {
};
/*ARGSUSED*/
{
return (_nss_nisplus_constr(ethers_ops,
sizeof (ethers_ops) / sizeof (ethers_ops[0]),
}