16ba597c5SAnurag S. Maskey /*
26ba597c5SAnurag S. Maskey  * CDDL HEADER START
36ba597c5SAnurag S. Maskey  *
46ba597c5SAnurag S. Maskey  * The contents of this file are subject to the terms of the
56ba597c5SAnurag S. Maskey  * Common Development and Distribution License (the "License").
66ba597c5SAnurag S. Maskey  * You may not use this file except in compliance with the License.
76ba597c5SAnurag S. Maskey  *
86ba597c5SAnurag S. Maskey  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96ba597c5SAnurag S. Maskey  * or http://www.opensolaris.org/os/licensing.
106ba597c5SAnurag S. Maskey  * See the License for the specific language governing permissions
116ba597c5SAnurag S. Maskey  * and limitations under the License.
126ba597c5SAnurag S. Maskey  *
136ba597c5SAnurag S. Maskey  * When distributing Covered Code, include this CDDL HEADER in each
146ba597c5SAnurag S. Maskey  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156ba597c5SAnurag S. Maskey  * If applicable, add the following below this CDDL HEADER, with the
166ba597c5SAnurag S. Maskey  * fields enclosed by brackets "[]" replaced with your own identifying
176ba597c5SAnurag S. Maskey  * information: Portions Copyright [yyyy] [name of copyright owner]
186ba597c5SAnurag S. Maskey  *
196ba597c5SAnurag S. Maskey  * CDDL HEADER END
206ba597c5SAnurag S. Maskey  */
216ba597c5SAnurag S. Maskey 
226ba597c5SAnurag S. Maskey /*
23f6da83d4SAnurag S. Maskey  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
246ba597c5SAnurag S. Maskey  */
256ba597c5SAnurag S. Maskey 
266ba597c5SAnurag S. Maskey #include <arpa/inet.h>
276ba597c5SAnurag S. Maskey #include <ctype.h>
286ba597c5SAnurag S. Maskey #include <errno.h>
296ba597c5SAnurag S. Maskey #include <inet/ip.h>
306ba597c5SAnurag S. Maskey #include <libdladm.h>
316ba597c5SAnurag S. Maskey #include <libdllink.h>
326ba597c5SAnurag S. Maskey #include <libdlwlan.h>
336ba597c5SAnurag S. Maskey #include <netdb.h>
346ba597c5SAnurag S. Maskey #include <stdio.h>
356ba597c5SAnurag S. Maskey #include <stdlib.h>
366ba597c5SAnurag S. Maskey #include <string.h>
376ba597c5SAnurag S. Maskey 
386ba597c5SAnurag S. Maskey #include <libnwam.h>
396ba597c5SAnurag S. Maskey #include "conditions.h"
406ba597c5SAnurag S. Maskey #include "ncu.h"
416ba597c5SAnurag S. Maskey #include "objects.h"
426ba597c5SAnurag S. Maskey #include "util.h"
436ba597c5SAnurag S. Maskey 
446ba597c5SAnurag S. Maskey /*
456ba597c5SAnurag S. Maskey  * conditions.c - contains routines which check state to see if activation
466ba597c5SAnurag S. Maskey  * conditions for NWAM objects are satisfied and rates activation conditions to
476ba597c5SAnurag S. Maskey  * help determine which is most specific.
486ba597c5SAnurag S. Maskey  *
496ba597c5SAnurag S. Maskey  * If the activation-mode is CONDITIONAL_ANY or CONDITIONAL_ALL, the conditions
506ba597c5SAnurag S. Maskey  * property is set to a string made up of conditional expressions. Each
516ba597c5SAnurag S. Maskey  * expression is made up of a condition that can be assigned a boolean value,
526ba597c5SAnurag S. Maskey  * e.g. "system-domain is sun.com" or "ncu ip:bge0 is-not active". If the
536ba597c5SAnurag S. Maskey  * activation-mode is CONDITIONAL_ANY, the condition will be satisfied if any
546ba597c5SAnurag S. Maskey  * one of the conditions is true; if the activation-mode is CONDITIONAL_ALL,
556ba597c5SAnurag S. Maskey  * the condition is satisfied only if all of the conditions are true.
566ba597c5SAnurag S. Maskey  */
576ba597c5SAnurag S. Maskey 
586ba597c5SAnurag S. Maskey uint64_t condition_check_interval = CONDITION_CHECK_INTERVAL_DEFAULT;
596ba597c5SAnurag S. Maskey 
606ba597c5SAnurag S. Maskey extern int getdomainname(char *, int);
616ba597c5SAnurag S. Maskey 
626ba597c5SAnurag S. Maskey /* NCP, NCU, ENM and location conditions */
636ba597c5SAnurag S. Maskey static boolean_t test_condition_ncp(nwam_condition_t condition,
646ba597c5SAnurag S. Maskey     const char *ncp_name);
656ba597c5SAnurag S. Maskey static boolean_t test_condition_ncu(nwam_condition_t condition,
666ba597c5SAnurag S. Maskey     const char *ncu_name);
676ba597c5SAnurag S. Maskey static boolean_t test_condition_enm(nwam_condition_t condition,
686ba597c5SAnurag S. Maskey     const char *enm_name);
696ba597c5SAnurag S. Maskey static boolean_t test_condition_loc(nwam_condition_t condition,
706ba597c5SAnurag S. Maskey     const char *loc_name);
716ba597c5SAnurag S. Maskey 
726ba597c5SAnurag S. Maskey /* IP address conditions */
736ba597c5SAnurag S. Maskey static boolean_t test_condition_ip_address(nwam_condition_t condition,
746ba597c5SAnurag S. Maskey     const char *ip_address);
756ba597c5SAnurag S. Maskey 
766ba597c5SAnurag S. Maskey /* domainname conditions */
776ba597c5SAnurag S. Maskey static boolean_t test_condition_sys_domain(nwam_condition_t condition,
786ba597c5SAnurag S. Maskey     const char *domainname);
796ba597c5SAnurag S. Maskey static boolean_t test_condition_adv_domain(nwam_condition_t condition,
806ba597c5SAnurag S. Maskey     const char *domainname);
816ba597c5SAnurag S. Maskey 
826ba597c5SAnurag S. Maskey /*  WLAN conditions */
836ba597c5SAnurag S. Maskey static boolean_t test_condition_wireless_essid(nwam_condition_t condition,
846ba597c5SAnurag S. Maskey     const char *essid);
856ba597c5SAnurag S. Maskey static boolean_t test_condition_wireless_bssid(nwam_condition_t condition,
866ba597c5SAnurag S. Maskey     const char *essid);
876ba597c5SAnurag S. Maskey 
886ba597c5SAnurag S. Maskey struct nwamd_condition_map {
896ba597c5SAnurag S. Maskey 	nwam_condition_object_type_t object_type;
906ba597c5SAnurag S. Maskey 	boolean_t (*condition_func)(nwam_condition_t, const char *);
916ba597c5SAnurag S. Maskey } condition_map[] =
926ba597c5SAnurag S. Maskey {
936ba597c5SAnurag S. Maskey 	{ NWAM_CONDITION_OBJECT_TYPE_NCP, test_condition_ncp },
946ba597c5SAnurag S. Maskey 	{ NWAM_CONDITION_OBJECT_TYPE_NCU, test_condition_ncu },
956ba597c5SAnurag S. Maskey 	{ NWAM_CONDITION_OBJECT_TYPE_ENM, test_condition_enm },
966ba597c5SAnurag S. Maskey 	{ NWAM_CONDITION_OBJECT_TYPE_LOC, test_condition_loc },
976ba597c5SAnurag S. Maskey 	{ NWAM_CONDITION_OBJECT_TYPE_IP_ADDRESS, test_condition_ip_address },
986ba597c5SAnurag S. Maskey 	{ NWAM_CONDITION_OBJECT_TYPE_SYS_DOMAIN, test_condition_sys_domain },
996ba597c5SAnurag S. Maskey 	{ NWAM_CONDITION_OBJECT_TYPE_ADV_DOMAIN, test_condition_adv_domain },
1006ba597c5SAnurag S. Maskey 	{ NWAM_CONDITION_OBJECT_TYPE_ESSID, test_condition_wireless_essid },
1016ba597c5SAnurag S. Maskey 	{ NWAM_CONDITION_OBJECT_TYPE_BSSID, test_condition_wireless_bssid }
1026ba597c5SAnurag S. Maskey };
1036ba597c5SAnurag S. Maskey 
1046ba597c5SAnurag S. Maskey /*
1056ba597c5SAnurag S. Maskey  * This function takes which kind of conditions (is or is not) we are testing
1066ba597c5SAnurag S. Maskey  * the object against and an object and applies the conditon to the object.
1076ba597c5SAnurag S. Maskey  */
1086ba597c5SAnurag S. Maskey static boolean_t
test_condition_object_state(nwam_condition_t condition,nwam_object_type_t object_type,const char * object_name)1096ba597c5SAnurag S. Maskey test_condition_object_state(nwam_condition_t condition,
1106ba597c5SAnurag S. Maskey     nwam_object_type_t object_type, const char *object_name)
1116ba597c5SAnurag S. Maskey {
1126ba597c5SAnurag S. Maskey 	nwamd_object_t object;
1136ba597c5SAnurag S. Maskey 	nwam_state_t state;
1146ba597c5SAnurag S. Maskey 
1156ba597c5SAnurag S. Maskey 	object = nwamd_object_find(object_type, object_name);
1166ba597c5SAnurag S. Maskey 	if (object == NULL)
1176ba597c5SAnurag S. Maskey 		return (B_FALSE);
1186ba597c5SAnurag S. Maskey 
1196ba597c5SAnurag S. Maskey 	state = object->nwamd_object_state;
1206ba597c5SAnurag S. Maskey 	nwamd_object_release(object);
1216ba597c5SAnurag S. Maskey 
1226ba597c5SAnurag S. Maskey 	switch (condition) {
1236ba597c5SAnurag S. Maskey 	case NWAM_CONDITION_IS:
1246ba597c5SAnurag S. Maskey 		return (state == NWAM_STATE_ONLINE);
1256ba597c5SAnurag S. Maskey 	case NWAM_CONDITION_IS_NOT:
1266ba597c5SAnurag S. Maskey 		return (state != NWAM_STATE_ONLINE);
1276ba597c5SAnurag S. Maskey 	default:
1286ba597c5SAnurag S. Maskey 		return (B_FALSE);
1296ba597c5SAnurag S. Maskey 	}
1306ba597c5SAnurag S. Maskey }
1316ba597c5SAnurag S. Maskey 
1326ba597c5SAnurag S. Maskey static boolean_t
test_condition_ncp(nwam_condition_t condition,const char * name)1336ba597c5SAnurag S. Maskey test_condition_ncp(nwam_condition_t condition, const char *name)
1346ba597c5SAnurag S. Maskey {
1356ba597c5SAnurag S. Maskey 	boolean_t active;
1366ba597c5SAnurag S. Maskey 
1376ba597c5SAnurag S. Maskey 	(void) pthread_mutex_lock(&active_ncp_mutex);
1386ba597c5SAnurag S. Maskey 	active = (strcasecmp(active_ncp, name) == 0);
1396ba597c5SAnurag S. Maskey 	(void) pthread_mutex_unlock(&active_ncp_mutex);
1406ba597c5SAnurag S. Maskey 
1416ba597c5SAnurag S. Maskey 	switch (condition) {
1426ba597c5SAnurag S. Maskey 	case NWAM_CONDITION_IS:
1436ba597c5SAnurag S. Maskey 		return (active);
1446ba597c5SAnurag S. Maskey 	case NWAM_CONDITION_IS_NOT:
1456ba597c5SAnurag S. Maskey 		return (active != B_TRUE);
1466ba597c5SAnurag S. Maskey 	default:
1476ba597c5SAnurag S. Maskey 		return (B_FALSE);
1486ba597c5SAnurag S. Maskey 	}
1496ba597c5SAnurag S. Maskey }
1506ba597c5SAnurag S. Maskey 
1516ba597c5SAnurag S. Maskey static boolean_t
test_condition_ncu(nwam_condition_t condition,const char * name)1526ba597c5SAnurag S. Maskey test_condition_ncu(nwam_condition_t condition, const char *name)
1536ba597c5SAnurag S. Maskey {
1546ba597c5SAnurag S. Maskey 	char *real_name, *ncu_name;
1556ba597c5SAnurag S. Maskey 	nwam_ncu_handle_t ncuh;
1566ba597c5SAnurag S. Maskey 	nwam_ncu_type_t ncu_type;
1576ba597c5SAnurag S. Maskey 	boolean_t rv;
1586ba597c5SAnurag S. Maskey 
1596ba597c5SAnurag S. Maskey 	/* names are case-insensitive, so get real name from libnwam */
1606ba597c5SAnurag S. Maskey 	if (nwam_ncu_read(active_ncph, name, NWAM_NCU_TYPE_INTERFACE, 0, &ncuh)
1616ba597c5SAnurag S. Maskey 	    == NWAM_SUCCESS) {
1626ba597c5SAnurag S. Maskey 		ncu_type = NWAM_NCU_TYPE_INTERFACE;
1636ba597c5SAnurag S. Maskey 	} else if (nwam_ncu_read(active_ncph, name, NWAM_NCU_TYPE_LINK, 0,
1646ba597c5SAnurag S. Maskey 	    &ncuh) == NWAM_SUCCESS) {
1656ba597c5SAnurag S. Maskey 		ncu_type = NWAM_NCU_TYPE_LINK;
1666ba597c5SAnurag S. Maskey 	} else {
1676ba597c5SAnurag S. Maskey 		return (B_FALSE);
1686ba597c5SAnurag S. Maskey 	}
1696ba597c5SAnurag S. Maskey 	if (nwam_ncu_get_name(ncuh, &real_name) != NWAM_SUCCESS) {
1706ba597c5SAnurag S. Maskey 		nwam_ncu_free(ncuh);
1716ba597c5SAnurag S. Maskey 		return (B_FALSE);
1726ba597c5SAnurag S. Maskey 	}
1736ba597c5SAnurag S. Maskey 	nwam_ncu_free(ncuh);
1746ba597c5SAnurag S. Maskey 
1756ba597c5SAnurag S. Maskey 	/*
1766ba597c5SAnurag S. Maskey 	 * Name may be either unqualified or qualified by NCU type
1776ba597c5SAnurag S. Maskey 	 * (interface:/link:).  Need to translate unqualified names
1786ba597c5SAnurag S. Maskey 	 * to qualified, specifying interface:name if an interface
1796ba597c5SAnurag S. Maskey 	 * NCU is present, otherwise link:ncu.
1806ba597c5SAnurag S. Maskey 	 */
1816ba597c5SAnurag S. Maskey 	if (nwam_ncu_name_to_typed_name(real_name, ncu_type, &ncu_name)
1826ba597c5SAnurag S. Maskey 	    != NWAM_SUCCESS) {
1836ba597c5SAnurag S. Maskey 		free(real_name);
1846ba597c5SAnurag S. Maskey 		return (B_FALSE);
1856ba597c5SAnurag S. Maskey 	}
1866ba597c5SAnurag S. Maskey 	free(real_name);
1876ba597c5SAnurag S. Maskey 
1886ba597c5SAnurag S. Maskey 	rv = test_condition_object_state(condition, NWAM_OBJECT_TYPE_NCU,
1896ba597c5SAnurag S. Maskey 	    ncu_name);
1906ba597c5SAnurag S. Maskey 	free(ncu_name);
1916ba597c5SAnurag S. Maskey 	return (rv);
1926ba597c5SAnurag S. Maskey }
1936ba597c5SAnurag S. Maskey 
1946ba597c5SAnurag S. Maskey static boolean_t
test_condition_enm(nwam_condition_t condition,const char * enm_name)1956ba597c5SAnurag S. Maskey test_condition_enm(nwam_condition_t condition, const char *enm_name)
1966ba597c5SAnurag S. Maskey {
1976ba597c5SAnurag S. Maskey 	nwam_enm_handle_t enmh;
1986ba597c5SAnurag S. Maskey 	char *real_name;
1996ba597c5SAnurag S. Maskey 	boolean_t rv;
2006ba597c5SAnurag S. Maskey 
2016ba597c5SAnurag S. Maskey 	/* names are case-insensitive, so get real name from libnwam */
2026ba597c5SAnurag S. Maskey 	if (nwam_enm_read(enm_name, 0, &enmh) != NWAM_SUCCESS)
2036ba597c5SAnurag S. Maskey 		return (B_FALSE);
2046ba597c5SAnurag S. Maskey 	if (nwam_enm_get_name(enmh, &real_name) != NWAM_SUCCESS) {
2056ba597c5SAnurag S. Maskey 		nwam_enm_free(enmh);
2066ba597c5SAnurag S. Maskey 		return (B_FALSE);
2076ba597c5SAnurag S. Maskey 	}
2086ba597c5SAnurag S. Maskey 	nwam_enm_free(enmh);
2096ba597c5SAnurag S. Maskey 
2106ba597c5SAnurag S. Maskey 	rv = test_condition_object_state(condition, NWAM_OBJECT_TYPE_ENM,
2116ba597c5SAnurag S. Maskey 	    real_name);
2126ba597c5SAnurag S. Maskey 	free(real_name);
2136ba597c5SAnurag S. Maskey 	return (rv);
2146ba597c5SAnurag S. Maskey }
2156ba597c5SAnurag S. Maskey 
2166ba597c5SAnurag S. Maskey static boolean_t
test_condition_loc(nwam_condition_t condition,const char * loc_name)2176ba597c5SAnurag S. Maskey test_condition_loc(nwam_condition_t condition, const char *loc_name)
2186ba597c5SAnurag S. Maskey {
2196ba597c5SAnurag S. Maskey 	nwam_loc_handle_t loch;
2206ba597c5SAnurag S. Maskey 	char *real_name;
2216ba597c5SAnurag S. Maskey 	boolean_t rv;
2226ba597c5SAnurag S. Maskey 
2236ba597c5SAnurag S. Maskey 	/* names are case-insensitive, so get real name from libnwam */
2246ba597c5SAnurag S. Maskey 	if (nwam_loc_read(loc_name, 0, &loch) != NWAM_SUCCESS)
2256ba597c5SAnurag S. Maskey 		return (B_FALSE);
2266ba597c5SAnurag S. Maskey 	if (nwam_loc_get_name(loch, &real_name) != NWAM_SUCCESS) {
2276ba597c5SAnurag S. Maskey 		nwam_loc_free(loch);
2286ba597c5SAnurag S. Maskey 		return (B_FALSE);
2296ba597c5SAnurag S. Maskey 	}
2306ba597c5SAnurag S. Maskey 	nwam_loc_free(loch);
2316ba597c5SAnurag S. Maskey 
2326ba597c5SAnurag S. Maskey 	rv = test_condition_object_state(condition, NWAM_OBJECT_TYPE_LOC,
2336ba597c5SAnurag S. Maskey 	    real_name);
2346ba597c5SAnurag S. Maskey 	free(real_name);
2356ba597c5SAnurag S. Maskey 	return (rv);
2366ba597c5SAnurag S. Maskey }
2376ba597c5SAnurag S. Maskey 
2386ba597c5SAnurag S. Maskey static boolean_t
test_condition_domain(nwam_condition_t condition,const char * target_domain,const char * found_domain)2396ba597c5SAnurag S. Maskey test_condition_domain(nwam_condition_t condition, const char *target_domain,
2406ba597c5SAnurag S. Maskey     const char *found_domain)
2416ba597c5SAnurag S. Maskey {
2426ba597c5SAnurag S. Maskey 	int i, len_t, len_f;
2436ba597c5SAnurag S. Maskey 	char target[MAXHOSTNAMELEN], found[MAXHOSTNAMELEN];
2446ba597c5SAnurag S. Maskey 
2456ba597c5SAnurag S. Maskey 	len_t = target_domain == NULL ? 0 : strlen(target_domain);
2466ba597c5SAnurag S. Maskey 	len_f = found_domain == NULL ? 0 : strlen(found_domain);
2476ba597c5SAnurag S. Maskey 
2486ba597c5SAnurag S. Maskey 	/* convert target_domain and found_domain to lowercase for strstr() */
2496ba597c5SAnurag S. Maskey 	for (i = 0; i < len_t; i++)
2506ba597c5SAnurag S. Maskey 		target[i] = tolower(target_domain[i]);
2516ba597c5SAnurag S. Maskey 	target[len_t] = '\0';
2526ba597c5SAnurag S. Maskey 
2536ba597c5SAnurag S. Maskey 	for (i = 0; i < len_f; i++)
2546ba597c5SAnurag S. Maskey 		found[i] = tolower(found_domain[i]);
2556ba597c5SAnurag S. Maskey 	found[len_f] = '\0';
2566ba597c5SAnurag S. Maskey 
2576ba597c5SAnurag S. Maskey 	switch (condition) {
2586ba597c5SAnurag S. Maskey 	case NWAM_CONDITION_IS:
2596ba597c5SAnurag S. Maskey 		return (found_domain != NULL && strcmp(found, target) == 0);
2606ba597c5SAnurag S. Maskey 	case NWAM_CONDITION_IS_NOT:
2616ba597c5SAnurag S. Maskey 		return (found_domain == NULL || strcmp(found, target) != 0);
2626ba597c5SAnurag S. Maskey 	case NWAM_CONDITION_CONTAINS:
2636ba597c5SAnurag S. Maskey 		return (found_domain != NULL && strstr(found, target) != NULL);
2646ba597c5SAnurag S. Maskey 	case NWAM_CONDITION_DOES_NOT_CONTAIN:
2656ba597c5SAnurag S. Maskey 		return (found_domain == NULL || strstr(found, target) == NULL);
2666ba597c5SAnurag S. Maskey 	default:
2676ba597c5SAnurag S. Maskey 		return (B_FALSE);
2686ba597c5SAnurag S. Maskey 	}
2696ba597c5SAnurag S. Maskey }
2706ba597c5SAnurag S. Maskey 
2716ba597c5SAnurag S. Maskey struct ncu_adv_domains {
2726ba597c5SAnurag S. Maskey 	struct ncu_adv_domains *next;
2736ba597c5SAnurag S. Maskey 	char *dns_domain;
2746ba597c5SAnurag S. Maskey 	char *nis_domain;
2756ba597c5SAnurag S. Maskey };
2766ba597c5SAnurag S. Maskey 
2776ba597c5SAnurag S. Maskey static int
get_adv_domains(nwamd_object_t obj,void * arg)2786ba597c5SAnurag S. Maskey get_adv_domains(nwamd_object_t obj, void *arg)
2796ba597c5SAnurag S. Maskey {
2806ba597c5SAnurag S. Maskey 	nwamd_ncu_t *ncu = (nwamd_ncu_t *)obj->nwamd_object_data;
2816ba597c5SAnurag S. Maskey 	struct ncu_adv_domains **headpp = (struct ncu_adv_domains **)arg;
2826ba597c5SAnurag S. Maskey 	struct ncu_adv_domains *adp;
2836ba597c5SAnurag S. Maskey 	char *dns, *nis;
2846ba597c5SAnurag S. Maskey 
2856ba597c5SAnurag S. Maskey 	if (ncu->ncu_type != NWAM_NCU_TYPE_INTERFACE)
2866ba597c5SAnurag S. Maskey 		return (0);
2876ba597c5SAnurag S. Maskey 
2886ba597c5SAnurag S. Maskey 	dns = nwamd_get_dhcpinfo_data("DNSdmain", ncu->ncu_name);
2896ba597c5SAnurag S. Maskey 	nis = nwamd_get_dhcpinfo_data("NISdmain", ncu->ncu_name);
2906ba597c5SAnurag S. Maskey 
2916ba597c5SAnurag S. Maskey 	if (dns != NULL || nis != NULL) {
2926ba597c5SAnurag S. Maskey 		adp = (struct ncu_adv_domains *)malloc(sizeof (*adp));
2936ba597c5SAnurag S. Maskey 		if (adp == NULL)
2946ba597c5SAnurag S. Maskey 			return (1);
2956ba597c5SAnurag S. Maskey 		adp->dns_domain = dns;
2966ba597c5SAnurag S. Maskey 		adp->nis_domain = nis;
2976ba597c5SAnurag S. Maskey 		adp->next = *headpp;
2986ba597c5SAnurag S. Maskey 		*headpp = adp;
2996ba597c5SAnurag S. Maskey 	}
3006ba597c5SAnurag S. Maskey 
3016ba597c5SAnurag S. Maskey 	return (0);
3026ba597c5SAnurag S. Maskey }
3036ba597c5SAnurag S. Maskey 
3046ba597c5SAnurag S. Maskey static boolean_t
test_condition_sys_domain(nwam_condition_t condition,const char * domainname)3056ba597c5SAnurag S. Maskey test_condition_sys_domain(nwam_condition_t condition, const char *domainname)
3066ba597c5SAnurag S. Maskey {
3076ba597c5SAnurag S. Maskey 	char cur_domainname[MAXHOSTNAMELEN];
3086ba597c5SAnurag S. Maskey 
3096ba597c5SAnurag S. Maskey 	if (getdomainname(cur_domainname, MAXHOSTNAMELEN) != 0)
3106ba597c5SAnurag S. Maskey 		return (B_FALSE);
3116ba597c5SAnurag S. Maskey 
3126ba597c5SAnurag S. Maskey 	return (test_condition_domain(condition, domainname, cur_domainname));
3136ba597c5SAnurag S. Maskey }
3146ba597c5SAnurag S. Maskey 
3156ba597c5SAnurag S. Maskey static boolean_t
test_condition_adv_domain(nwam_condition_t condition,const char * domainname)3166ba597c5SAnurag S. Maskey test_condition_adv_domain(nwam_condition_t condition, const char *domainname)
3176ba597c5SAnurag S. Maskey {
3186ba597c5SAnurag S. Maskey 	struct ncu_adv_domains *adv_domains = NULL;
3196ba597c5SAnurag S. Maskey 	struct ncu_adv_domains *adp, *prev;
3206ba597c5SAnurag S. Maskey 	boolean_t positive, rtn;
3216ba597c5SAnurag S. Maskey