/*
* 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 <ctype.h>
#include <netdb.h>
#include "ns_internal.h"
#include "ldap_common.h"
/* protocols attributes filters */
#define _F_GETPROTOBYNUMBER \
"(&(objectClass=ipProtocol)(ipProtocolNumber=%d))"
#define _F_GETPROTOBYNUMBER_SSD \
"(&(%%s)(ipProtocolNumber=%d))"
static const char *protocols_attrs[] = {
(char *)NULL
};
typedef struct protocol_alias {
char *protocol;
char *alias;
{ "ip", "IP" },
{ "ipip", "IP-IP" },
{ "ipcomp", "IPComp" },
{ "ipv6", "IPv6" },
{ "ipv6-route", "IPv6-Route" },
{ "ipv6-frag", "IPv6-Frag" },
{ "ipv6-icmp", "IPv6-ICMP" },
{ "ipv6-nonxt", "IPv6-NoNxt" },
{ "ipv6-opts", "IPv6-Opts" },
};
/*
* When the data is imported by ldapaddent, it does not save the aliase in the
* "cn" that is same as the canonical name but only different in case.
* e.g.
* icmp 1 ICMP
*
* is saved as
*
* dn: cn=icmp, ...
* ...
* cn: icmp
* ...
*
* So it needs to replicate the canonical name as an alias of upper case.
* But some protocol does have different aliases.
*
* e.g.
* dn: cn=ospf, ...
* ...
* cn: ospf
* cn: OSPFIGP
* ...
*
* For many ip* protocols, the aliases are mixed cased. Maybe it's case
* insensitive. But this fucntion tries to restore the aliases to the original
* form as much as possible. If the alias can't be found in the aliases table,
* it assumes the alias is all upper case.
*
*/
static char *
int i;
char *cp;
return (ip_aliases[i].alias);
}
/*
* No aliase in the table. Return an all upper case aliase
*/
return (protocol);
} else {
/* Return an all upper case aliase */
return (protocol);
}
}
/*
* _nss_ldap_protocols2str is the data marshaling method for the protocols
* getXbyY * (e.g., getbyname(), getbynumber(), getent()) backend processes.
* This method is called after a successful ldap search has been performed.
* This method will parse the ldap search values into a file format.
* e.g.
* idrp 45 IDRP
* or
* ospf 89 OSPFIGP
*/
static int
{
uint_t i;
int nss_result;
return (NSS_STR_PARSE_PARSE);
goto result_pls2str;
}
} else
goto result_pls2str;
}
/* Get the canonical name */
goto result_pls2str;
}
goto result_pls2str;
}
/* Append aliases */
/* create an aliase from protocol name */
} else {
for (i = 0; i < names->value_count; i++) {
goto result_pls2str;
}
/* Skip the canonical name */
}
}
}
/* The front end marshaller doesn't need to copy trailing nulls */
return ((int)nss_result);
}
/*
* getbyname gets struct protoent values by protocol name. This
* function constructs an ldap search filter using the protocol
* name invocation parameter and the getprotobyname search filter
* defined. Once the filter is constructed, we search for a matching
* entry and marshal the data results into *proto = (struct *
* protoent *)argp->buf.result. The function _nss_ldap_protocols2ent
* performs the data marshaling.
*/
static nss_status_t
{
int ret;
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
}
/*
* getbynumber gets struct protoent values by protocol number. This
* function constructs an ldap search filter using the protocol
* name invocation parameter and the getprotobynumber search filter
* defined. Once the filter is constructed, we search for a matching
* entry and marshal the data results into *proto = (struct *
* protoent *)argp->buf.result. The function _nss_ldap_protocols2ent
* performs the data marshaling.
*/
static nss_status_t
{
int ret;
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
}
};
/*
* _nss_ldap_protocols_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)
{
}