6 * You may not use this file except in compliance with the License.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <stddef.h>
31 #include <errno.h>
32 #include <ctype.h>
33 #include <stdarg.h>
34 #include <fcntl.h>
35 #include <unistd.h>
36 #include <net/if.h>
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <sys/wait.h>
40 #include <sys/ipc.h>
41 #include <sys/ddi.h>
42 #include <stropts.h>
43 #include <assert.h>
44 #include <termios.h>
45 #include <time.h>
46 #include <string.h>
2734
2735 PRTDBG(("do_rmprefer(%d, 0x%x)\n", argc, argv));
2736 if (argc <= 0) {
2737 do_print_usage();
2738 exit(WIFI_IMPROPER_USE);
2739 }
2740
2741 /*
2742 * if a "all" is inputted, all the items in the preference
2743 * list will be deleted.
2744 */
2745 if (strcasecmp(argv[0], "all") == 0) {
2746 p_section = find_section(gp_config_file, WIFI_PREFER);
2747 if (p_section != NULL)
2748 plist = p_section->list;
2749
2750 if ((p_section == NULL) || (plist == NULL))
2751 return (B_FALSE);
2752 pae = plist->ael_head;
2753 while (pae != NULL) {
2754 free(pae);
2755 pae = pae->ae_next;
2756 }
2757 plist->ael_head = plist->ael_tail = NULL;
2758 plist->ael_argc = 0;
2759 } else if (gp_config_file != NULL) {
2760 for (i = 0; i < argc; i++) {
2761 if (del_prefer(gp_config_file, argv[i], B_TRUE)
2762 == B_FALSE) {
2763 return (B_FALSE);
2764 }
2765 }
2766 }
2767 return (B_TRUE);
2768 }
2769
2770 static boolean_t
2771 is_prefer_rank_valid(const char *pbuf)
2772 {
2773 int i;
2774 boolean_t ret = B_FALSE;
2775
|
6 * You may not use this file except in compliance with the License.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * Copyright (c) 2018, Joyent, Inc.
28 */
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <stddef.h>
33 #include <errno.h>
34 #include <ctype.h>
35 #include <stdarg.h>
36 #include <fcntl.h>
37 #include <unistd.h>
38 #include <net/if.h>
39 #include <sys/types.h>
40 #include <sys/stat.h>
41 #include <sys/wait.h>
42 #include <sys/ipc.h>
43 #include <sys/ddi.h>
44 #include <stropts.h>
45 #include <assert.h>
46 #include <termios.h>
47 #include <time.h>
48 #include <string.h>
2736
2737 PRTDBG(("do_rmprefer(%d, 0x%x)\n", argc, argv));
2738 if (argc <= 0) {
2739 do_print_usage();
2740 exit(WIFI_IMPROPER_USE);
2741 }
2742
2743 /*
2744 * if a "all" is inputted, all the items in the preference
2745 * list will be deleted.
2746 */
2747 if (strcasecmp(argv[0], "all") == 0) {
2748 p_section = find_section(gp_config_file, WIFI_PREFER);
2749 if (p_section != NULL)
2750 plist = p_section->list;
2751
2752 if ((p_section == NULL) || (plist == NULL))
2753 return (B_FALSE);
2754 pae = plist->ael_head;
2755 while (pae != NULL) {
2756 ae_t *next = pae->ae_next;
2757 free(pae);
2758 pae = next;
2759 }
2760 plist->ael_head = plist->ael_tail = NULL;
2761 plist->ael_argc = 0;
2762 } else if (gp_config_file != NULL) {
2763 for (i = 0; i < argc; i++) {
2764 if (del_prefer(gp_config_file, argv[i], B_TRUE)
2765 == B_FALSE) {
2766 return (B_FALSE);
2767 }
2768 }
2769 }
2770 return (B_TRUE);
2771 }
2772
2773 static boolean_t
2774 is_prefer_rank_valid(const char *pbuf)
2775 {
2776 int i;
2777 boolean_t ret = B_FALSE;
2778
|