4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
27 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
35 * This module contains miscellaneous library functions.
43 #include <rpcsvc/nis.h>
46 #include <netinet/in.h>
51 * In the pre-IPv6 code, secure RPC has a bug such that it doesn't look
52 * at the endpoint 'family' field when selecting an endpoint to use for
53 * time synchronization. In order to protect that broken code from itself,
54 * we set the endpoint 'proto' to 'nc_netid' (i.e., "udp6" or "tcp6")
55 * rather than 'nc_proto' ("udp"/"tcp") if 'nc_family' is "inet6".
57 * The __nis_netconfig2ep() and __nis_netconfig_matches_ep() service
58 * functions below simplify endpoint manipulation by implementing the
63 __nis_netconfig2ep(struct netconfig
*nc
, endpoint
*ep
) {
65 if (nc
== 0 || ep
== 0)
68 ep
->family
= strdup(nc
->nc_protofmly
);
70 if (strcmp(ep
->family
, "inet6") == 0) {
71 ep
->proto
= strdup(nc
->nc_netid
);
73 ep
->proto
= strdup(nc
->nc_proto
);
78 __nis_netconfig_matches_ep(struct netconfig
*nc
, endpoint
*ep
) {
80 if (nc
== 0 || ep
== 0)
83 if (strcmp(nc
->nc_protofmly
, ep
->family
) != 0)
86 if (strcmp(ep
->family
, "inet6") == 0)
87 return (strcmp(nc
->nc_netid
, ep
->proto
) == 0 ||
88 strcmp(nc
->nc_proto
, ep
->proto
) == 0);
90 return (strcmp(nc
->nc_proto
, ep
->proto
) == 0);