getether.c revision cb5caa98562cf06753163f558cbcfe30b8f4673a
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <netinet/if_ether.h>
#include "ldap_common.h"
/* ether attributes filters */
#define _E_HOSTNAME "cn"
#define _E_MACADDRESS "macaddress"
#define _F_GETETHERBYHOST "(&(objectClass=ieee802Device)(cn=%s))"
#define _F_GETETHERBYHOST_SSD "(&(%%s)(cn=%s))"
#define _F_GETETHERBYETHER "(&(objectClass=ieee802Device)(macAddress=%s))"
#define _F_GETETHERBYETHER_SSD "(&(%%s)(macAddress=%s))"
static const char *ethers_attrs[] = {
(char *)NULL
};
/*
* _nss_ldap_ethers2str is the data marshaling method for the ethers
* ether_hostton/ether_ntohost backend processes.
* This method is called after a successful ldap search has been performed.
* This method will parse the ldap search values into the file format.
* e.g.
*
* 8:0:20:8e:eb:8a8 borealis
*
* The front end marshaller str2ether uses argp->buf.result for a different
* purpose so a flag be->db_type is set to work around this oddity.
*
*/
/*ARGSUSED0*/
static int
{
int nss_result;
char **host, **macaddress;
return (NSS_STR_PARSE_PARSE);
goto result_ea2str;
}
goto result_ea2str;
}
/* Add a trailing null for easy debug */
goto result_ea2str;
}
macaddress[0], host[0]);
return (nss_result);
}
/*
* getbyhost gets an ethernet address by hostname. This function
* constructs an ldap search filter using the hostname invocation
* parameter and the getetherbyhost search filter defined. Once
* the filter is constructed, we search for a matching entry and
* marshal the data results into uchar_t *ether for the frontend
* process. The function _nss_ldap_ethers2ent performs the data
* marshaling.
*
* RFC 2307, An Approach for Using LDAP as a Network Information Service,
* indicates that dn's be fully qualified. Host name searches will be on
* fully qualified host names (e.g., foo.bar.sun.com).
*/
static nss_status_t
{
char searchfilter[SEARCHFILTERLEN];
char userdata[SEARCHFILTERLEN];
int ret;
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
return (rc);
}
/*
* getbyether gets an ethernet address by ethernet address. This
* function constructs an ldap search filter using the ASCII
* ethernet address invocation parameter and the getetherbyether
* search filter defined. Once the filter is constructed, we
* search for a matching entry and marshal the data results into
* uchar_t *ether for the frontend process. The function
* _nss_ldap_ethers2ent performs the data marshaling.
*/
static nss_status_t
{
char etherstr[18];
char searchfilter[SEARCHFILTERLEN];
char userdata[SEARCHFILTERLEN];
int ret;
*e, *(e + 1), *(e + 2), *(e + 3), *(e + 4), *(e + 5));
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
}
static ldap_backend_op_t ethers_ops[] = {
};
/*
* _nss_ldap_ethers_constr is where life begins. This function calls the
* generic ldap constructor function to define and build the abstract
* data types required to support ldap operations.
*/
/*ARGSUSED0*/
const char *dummy3)
{
}