516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * CDDL HEADER START
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * The contents of this file are subject to the terms of the
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff * Common Development and Distribution License (the "License").
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff * You may not use this file except in compliance with the License.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * See the License for the specific language governing permissions
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * and limitations under the License.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * When distributing Covered Code, include this CDDL HEADER in each
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * If applicable, add the following below this CDDL HEADER, with the
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * fields enclosed by brackets "[]" replaced with your own identifying
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * information: Portions Copyright [yyyy] [name of copyright owner]
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * CDDL HEADER END
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Use is subject to license terms.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx#pragma ident "%Z%%M% %I% %E% SMI"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Debug information
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx#define PRTDBG(msg) if (wifi_debug > 1) wifi_dbgprintf msg
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx#else /* DEBUG */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx#endif /* DEBUG */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Wificonfig exit status
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxtypedef enum {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxtypedef enum {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * config_file_t is an abstract of configration file,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * either/etc/inet/wifi/wifi.<interface> or /etc/inet/secret/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * wifi/wifiwepkey.<interface>
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic char *p_file_wifiwepkey = "/etc/inet/secret/wifiwepkey";
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxtypedef enum {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * gbuf: is a global buf, which is used to communicate between the user and
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * the driver
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx const char *format, ...);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void new_section(config_file_t *p_config_file, aelist_t *p_list,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx const char *section_id);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t fprint_config_file(config_file_t *p_config_file,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx const char *file_name);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic section_t *find_section(config_file_t *p_config_file,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx const char *section_id);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void update_aelist(aelist_t *plist, const char *arg);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic char *find_active_profile(int);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t call_ioctl(int, int, uint32_t, uint32_t);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t del_prefer(config_file_t *p_config_file, const char *prefer,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t del_section(config_file_t *p_config_file, char *section_id);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t set_prefer(config_file_t *p_config_file, const char *prefer,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void heuristic_load(int fd, uint32_t ess_num, wl_ess_conf_t **);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic char *select_profile(int fd, int readonly, int timeout);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t items_in_profile(aelist_t *, aelist_t *, int, char **);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic char *get_commit_key(int, int, char **);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void print_wepkey_info(const char *id, const char *wepkeyn);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void do_print_usage();
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_autoconf(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_startconf(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_loadpf(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_disconnect(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_printpf(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_restoredef(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_history(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_deletepf(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_wepkey(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_setprefer(int fd, int argc, char **arg);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_rmprefer(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_lsprefer(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_wlanlist(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_showstatus(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_getprofparam(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_setprofparam(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_setprofwepkey(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t is_rates_support(int fd, int num, uint8_t *rates);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_set_powermode(int fd, const char *arg);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_set_createibss(int fd, const char *arg);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_set_wepkeyid(int fd, const char *arg);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_set_encryption(int fd, const char *arg);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_set_authmode(int fd, const char *arg);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t do_createprofile(int fd, int argc, char **argv);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic boolean_t value_is_valid(config_item_t item, const char *value);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx boolean_t b_fileonly; /* operation only on the config file */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx boolean_t b_readonly; /* only read from the card or config file */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "autoconf",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "startconf",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "connect",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "disconnect",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "showprofile",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "deleteprofile",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "history",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "listprefer",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "removeprefer",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "setprefer",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "setwepkey",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "restoredef",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "getparam",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "setparam",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "createprofile",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "showstatus",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "setprofileparam",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "getprofileparam",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "setprofilewepkey",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx {BSSTYPE, "bsstype", do_get_bsstype, do_set_bsstype, RW},
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx {CREATEIBSS, "createibss", do_get_createibss, do_set_createibss, RW},
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx {CHANNEL, "channel", do_get_channel, do_set_channel, RW},
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx {POWERMODE, "powermode", do_get_powermode, do_set_powermode, RW},
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx {AUTHMODE, "authmode", do_get_authmode, do_set_authmode, RW},
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx {ENCRYPTION, "encryption", do_get_encryption, do_set_encryption, RW},
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx {WEPKEYID, "wepkeyindex", do_get_wepkeyid, do_set_wepkeyid, RW},
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * valid rate value
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * the rates value is in increments of 500kb/s.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * according to the 802.11 a/b/g specs(IEEE):
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * 802.11b(IEEE Std 802.11b-1999) page35, rates should be:
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * X02, X04, X0b, X16
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * 802.11a(IEEE Std 802.11a-1999) page47, rates should be:
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * 6,9,12,18,24,36,48,54 Mb/s
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * 802.11g(IEEE Std 802.11g-2003) page44, rates should be:
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * 1,2,5.5,11,6,9,12,18,22,24,33,36,48,54 Mb/s
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/* print the error message on why set or get ioctl command failed. */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void *
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void *
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic char *
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (p == NULL) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (p);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * new_ae: Add an element with content pointed by arg to the list *ael.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * new_ael: Create a new aelist with list_type "type"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * and return the list pointer.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * new_config_file: Creates a new config_file_t struct which is counterpart of
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * of the configration file, and return the pointer.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx p_config_file->section_head = p_config_file->section_tail = NULL;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * new_section: Add a list pointed by "p_list", with identity "section_id" to
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * the config_file_t struct pointed by "p_config_file"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxnew_section(config_file_t *p_config_file, aelist_t *p_list,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx const char *section_id)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx PRTDBG(("new_section(0x%x, 0x%x, \"%s\")\n", p_config_file, p_list,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * destroy_config:Destroy the config_file struct
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * parse_file: Parse each section of the configration file
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * and construct the config_file_t structure.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Example:
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * A config file has contents below:
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * {preferrence}
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * essid=ap7-3
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * essid=linksys
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * {history}
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * essid=ap7-3
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * essid=ap7-2
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * essid=ap7-3
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * wepkeyid=3
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * channel=11
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * rates=1,2
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * [linksys]
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * essid=linksys
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * createibss=BSS
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * authmode=OPENSYSTEM
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * wepkeyid=1
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * then its config_file_t structure will be:
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * config_file_t
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * |~~~~~~~~~~~~~~~~~~~~~~~~~~|
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * | section_argc=5 |
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * |~~~~~~~~~~~~T~~~~~~~~~~~~~|
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * /| *head | *tail |\
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * / ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * section_t V section_t V section_t
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * |~~~~~~~~~~~~~~~|~~| |~~~~~~~~~~~~~~~|~~| |~~~~~~~~~~~~~~|~~|
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * |"{preferrence}"| | | "{history}" | | | "[linksys]" | |
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * |~~~~~~~~~~~~~~~| -+---->|~~~~~~~~~~~~~~~| -+->..->|~~~~~~~~~~~~~~| -+->NULL
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * | *list | | | *list | | | *list | |
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * ~~T~~~~~~~~~~~~~~~~~ ~~~T~~~~~~~~~~~~~~~~ ~~~T~~~~~~~~~~~~~~~
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * V aelist_t V aelist_t V aelist_t
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * |~~~~~~~~~~~~~| |~~~~~~~~~~~~~| |~~~~~~~~~~~~~|
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * | argc=2 | | argc=3 | | argc=4 |
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * |~~~~~~~~~~~~~| |~~~~~~~~~~~~~| |~~~~~~~~~~~~~|
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * |PREFFERRENCE | | HISTORY | | PROFILE |
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * |~~~~~~T~~~~~~| |~~~~~~T~~~~~~| |~~~~~~T~~~~~~|
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * |*head |*tail |\ |*head |*tail |\ |*head |*tail |
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * ~~T~~~~~~~~~~~~ \ ~~T~~~~~~~~~~~~ \ /~~~~~~~~~~~~~~~\
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * | \ V V / \
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * | \ ... ... / \
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * V ae_t V ae_t ae_t V ae_t V
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * |~~~~~~~~~T~~| |~~~~~~~~~T~~| |~~~~~~~~~T~~| |~~~~~~~~~T~~|
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * |"essid= | -+->|"essid= | -+->NULL |"essid= | -+->..->|"wepkeyid| -+->NULL
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * | ap7-3" | | | linksys"| | | linksys"| | | =1" | |
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * The files /etc/inet/wifi and /etc/inet/secret/wifiwepkey should
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * be opened with "r" attribute. If these two files do not exist,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * create them here.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (fd < 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx while (fgets(buf_line, sizeof (buf_line), file) != NULL) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx /* replace the old '\n' to '\0' */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "%s : duplicated %s section\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "%s : duplicated %s section\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "%s : duplicated %s section\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx PRTDBG(("parse_file(\"%s\")=0x%x\n", pfile, p_config_file));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * construct an argument vector from an aelist
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic char **
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (argc = 0, ae = ael->ael_head; ae; ae = ae->ae_next) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx /* skip bssid since it can not be set */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (strncmp(ae->ae_arg, "bssid=", strlen("bssid=")) == 0)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * archived contents into a file
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxfprint_config_file(config_file_t *p_config_file, const char *file_name)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx PRTDBG(("fprint_config_file(0x%x, \"%s\")\n", p_config_file,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx assert((p_config_file != NULL)&&(strcmp(file_name, "") != 0));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (fd < 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: failed to open %s\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (len < 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "failed to update %s: %s\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (len < 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "update %s: %s\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * The attribute of the file /etc/inet/wifi and
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * /etc/inet/security/wifiwepkey should be retained.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * if those file do not exist, set default file mode.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "file %s stat: %s\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: failed to update %s: %s"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * append_pa: Each section holds a section_id which identifies a section
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * a profile uses its essid appending "[]" to denote its section_id.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * note: new memory is allocated, remember to free.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic char *
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * find a section by section_id from p_config_file,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * return the section pointer.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxfind_section(config_file_t *p_config_file, const char *section_id)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx PRTDBG(("find_section(0x%x, \"%s\")\n", p_config_file, section_id));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * get_value: Get rid of "parameter=" from a "parameter=value", for example:
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * when we read an line from file, we gets "essid=ap7-2", this function
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * returns the pointer to string "ap7-2";
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic const char *
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (p + 1);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * search /dev/wifi to see which interface is available
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Try to return the first found wifi interface.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * If no wifi interface is available, return B_FALSE
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx PRTDBG(("failed to find available wireless interface\n"));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * open_dev: Open the driver.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * if the 'devname' has format like 'ath0', we should add the path to that
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * device(/dev/ath0) and open it; if the 'devname' has format like
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * '/dev/wifi/ath0', we open it directly.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * If the devname is got from the user input, we
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * add '/dev/' to that relative devname. If it
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * is got from the 'search interface', it is an
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * absolute path.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (strncmp(devname, "/dev/wifi/", strlen("/dev/wifi/")) == 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: failed to open '%s': %s"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (-1);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "not a stream device\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (-1);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (fd);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * call_ioctl: Fill strioctl structure and issue an ioctl system call
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxcall_ioctl(int fd, int cmd, uint32_t params, uint32_t buf_len)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx switch (cmd) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * del_prefer: Delete an item from the {preferrence} list, the idea is
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * simply free the ae_t element, and set ae_arg to NULL, then when archive
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * the config_file_t struct to the file, it will be delete.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * The last flag is used to identify whether this function is invoked due to
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * the 'removeprefer' subcommand or due to 'deleteprofile' subcommand.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxdel_prefer(config_file_t *p_config_file, const char *prefer, boolean_t rflag)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx PRTDBG(("del_prefer(0x%x, \"%s\")\n", p_config_file, prefer));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "no such profile: '%s' in the preference list\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * del_section: Delete an section from p_config_file, the idea is
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * simply free the aelist_t struct and set it to NULL, when archiving
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * config_file_t struct to the file, we will find section list is NULL,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * and will not write it to file, so it will be deleted.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxdel_section(config_file_t *p_config_file, char *section_id)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx PRTDBG(("del_section(0x%x, \"%s\")\n", p_config_file, section_id));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * set_prefer: Reorder the preferrence list.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxset_prefer(config_file_t *p_config_file, const char *prefer, int rank)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx PRTDBG(("set_prefer(0x%x, \"%s\", %d)\n", p_config_file, prefer, rank));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "no such profile: '%s'\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx PRTDBG(("set_prefer: %d Profiles in prefer list\n", plist->ael_argc));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * If number of prefer list items is larger than the MAX_PREFERENCE_NUM
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * delete those items whose No is larger than MAX_PREFERENCE_NUM.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx PRTDBG(("set_prefer: %d Profiles in prefer list\n", plist->ael_argc));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * add_to_history: Save the scanlist argv into history section
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxadd_to_history(config_file_t *p_config_file, int argc, char **argv)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx PRTDBG(("add_to_history(0x%x, %d, 0x%x)\n", p_config_file, argc, argv));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < argc; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * add time stamp to the history record
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("\t%s [-R root_path][-i interface]"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("\t%s [-R root_path][-i interface]"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("\t%s [-R root_path][-i interface]"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("\t%s [-R root_path][-i interface]"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("\t%s [-R root_path][-i interface]"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("\t%s [-R root_path][-i interface]"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\tparameters:\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\tbssid\t\t - read only: 6 byte mac address of "
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "base station\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\tessid\t\t - name of the network, a string of up "
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "to 32 chars\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\tbsstype\t\t - bss(ap, infrastructure), ibss(ad-hoc)"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff " or auto\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\tcreateibss\t - flag to identify whether a ibss is to be\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\t\t\t created when the network to connect is\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\t\t\t not available, yes or no\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\tchannel\t\t - channel(used only when creating an ibss)\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\t\t\t valid value:\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\t\t\t\t 802.11a: 0-99\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\t\t\t\t 802.11b: 1-14\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\t\t\t\t 802.11g: 1-14\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\trates\t\t - set of rates, seperated by ',' valid rates:\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\t\t\t 1,2,5.5,6,9,11,12,18,22,24,33,36,48 and 54\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\tpowermode\t - off, mps or fast\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\tauthmode\t - opensystem or shared_key\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\tencryption\t - none or wep\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\twepkey|1-4\t - write only:\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\t\t\t 5 chars or 10 hex digits for 40bit wepkey;\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\t\t\t 13 chars or 26 hex digits for 128bit wepkey\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\twepkeyindex\t - an integer within the range 1-4\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\tsignal\t\t - read only: signal strength from 0 to 15\n"
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "\t\tradio\t\t - on or off\n"));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("\t%s [-R root_path][-i interface]"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("\t%s [-R root_path][-i interface]"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("\t%s [-R root_path][-i interface]"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("\t%s [-R root_path][-i interface]"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx " createprofile profile parameter=value [...]\n"), gExecName);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx " deleteprofile profile1 [profile2 [...]]\n"), gExecName);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx " getprofileparam profile [parameter [...]]\n"), gExecName);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx " setprofileparam profile [parameter=value [...]]\n"), gExecName);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_print_support_params: Query interface which cmd is supported
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0, n = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < N_GS_FUNC; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * check_authority: Check if command is permitted.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (chkauthattr(p_auth_string[type], pw->pw_name) == 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "privilege '%s' is required for setting "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "privilege '%s' is required.\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * construct the 'history' and 'scan' output format
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * memory allocated. need to free after the function is invoked.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic char *
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < nt; i++)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return ("\t\t\t\t");
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * find the essid of the named profile.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * gp_config_file is golable, so the return is gloable too.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic const char *
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (strncmp(pae->ae_arg, "essid=", strlen("essid=")) == 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * If we don't know which profile is our favorate in 'autoconf',
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * we select the wifi network based on the following heuristic
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * 1. the network without wep.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * 2. the network with the strongst signal.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * 3. the network with the faster speed(not implemented since signal affects
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * the speed in some degree).
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxheuristic_load(int fd, uint32_t ess_num, wl_ess_conf_t **p_ess_conf)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) call_ioctl(fd, WLAN_COMMAND, WL_LOAD_DEFAULTS, 0);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < ess_num; i++) { /* extract none-wep network */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * if all the wlans are weped, we select the one with strongest signal
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * in all of them, otherwise we just select in the none weped ones.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < ess_num; i++) { /* extract the strongest signal ones */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < ess_num; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx /* select one in all the networks which meet the preceding stardands */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx " failed to connect to any essid\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) strlcpy(essid, ((wl_essid_t *)(gbuf->wldp_buf))->wl_essid_essid,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx sizeof (essid));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) printf(gettext("%s: autoconf: essid '%s' is selected%s\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "access point");
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx while (timeout > 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (*(wl_linkstatus_t *)(gbuf->wldp_buf) == WL_CONNECTED)) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: failed to connect to "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Called in autoconf and startconf to find which 'profile' is selected.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * The process is: check profile names in the prefer list item by item,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * if the essid of the profile is in the scan list, then it is the wanted.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * readonly: 1 for startconf
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * 0 for autoconf
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * for autoconf, the scan result will be recorded in the history list.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic char *
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if ((call_ioctl(fd, WLAN_COMMAND, WL_SCAN, 0) == B_FALSE) ||
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx ess_num = ((wl_ess_list_t *)(gbuf->wldp_buf))->wl_ess_list_num;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx p_ess_conf = safe_calloc(sizeof (wl_ess_list_t *), ess_num);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < ess_num; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (readonly == 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "%s%c%02x:%02x:%02x:%02x:%02x:%02x%c%s",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (readonly == 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < ess_num; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (nprefer == 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < ess_num; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < ess_num; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (i == -1)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_autoconf: First scan the wlanlist, and select one essid from scan result
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * by the order in {preferrence} list. If no match, then heuristic_load;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc > 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "invalid value %s for 'wait'\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "useless tokens after '%s'\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc > 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc > 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_startconf: almost the same as the do_autoconf, except that doesn't
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * write file.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) call_ioctl(fd, WLAN_COMMAND, WL_LOAD_DEFAULTS, 0);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < ael_num; i++)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic char *
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) strlcpy(essid, ((wl_essid_t *)(gbuf->wldp_buf))->wl_essid_essid,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx sizeof (essid));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx safe_snprintf(bssid, sizeof (bssid), "%02x:%02x:%02x:%02x:%02x:%02x",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx activep_section = find_section(gp_config_file, WIFI_ACTIVEP);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_loadpf: load a profile, set related parameters both in wifi
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * and in wifiwepkey, if network name is not exist in the
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * configration files, then we clean all parameters and set essid only
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc == 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "invalid value %s for 'wait'\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "useless tokens after '%s'\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) call_ioctl(fd, WLAN_COMMAND, WL_LOAD_DEFAULTS, 0);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * if there is no 'essid' item in argvnew, the profile
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * name(argv[0]) is treated as essid.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < ael_num; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < ael_num; i++)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * set flag in {active_profile} so that showprofile knows
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * which profile is active when more than one profiles are
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * created for the same WLAN.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (*(wl_linkstatus_t *)(gbuf->wldp_buf) == WL_CONNECTED)) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx /* record bssid in the profile */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "bssid=%02x:%02x:%02x:%02x:%02x:%02x",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: failed to connect to "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * if wepkey is set in the profile, display wepkey|n=*****
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * when showprofile and getprofilewepkey.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * if wepkeyn is NULL, all the wepkeys will be display,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * otherwise, just display the matching one.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_printpf: print each parameters of the profile, if no network name
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * assigned, then print all profile saved in configration file.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * if no profile name is inputted, all the profiles will be displayed.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc == 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * identify whether wepkey is set
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * in the profile
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < argc; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * identify whether wepkey is set
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * in the profile
0d2f4bc964616a7fec76406480264fcaa2cfbc14ff "no such profile: '%s'\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * find_ae: Find an ae by its contents, return its pointer.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * update_aelist: Update an aelist by arg, for example:
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * there are an item with content"essid=ap7-2",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * update_aelist(0x..., "essid=myssid2") will update it as "essid=myssid2"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_deletepf: delete a profile in configration files.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc <= 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * if a "all" is inputted, all the profiles will be deleted.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * remove the '[]' of the [section_id]
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < argc; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx ": no such profile: '%s'\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_history: Print the list in {history} section.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc > 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: trailing useless tokens "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * If history section is empty, directly return.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * construct the output format in terms of the
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * maxmium essid length
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "data format error\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx len = snprintf(format, sizeof (format), gettext("essid"));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx len += snprintf(format + len, sizeof (format) - len, "%s", ntstr);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) printf(gettext("essid\t\t\t\tbssid\t\t encryption"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "\tlast seen\n"));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * output the contents of the history section.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx /* display essid */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx /* display bssid */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx /* display wep */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx /* display time stamp */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_lsprefer: Print the list in {preferrence} section
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc > 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: trailing useless tokens "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_rmprefer: Remove an item in {preferrence} list
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc <= 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * if a "all" is inputted, all the items in the preference
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * list will be deleted.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < argc; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_setprefer: Set network preferrence
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc <= 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if ((i >= 0) && (i <= MAX_CHANNEL_NUM))
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx switch (length) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < length; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "wepkey should be:\n"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "\t 40bits: 5 char or 10 hex digits.\n"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "\t 128bits: 13 char or 26 hex digits.\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * get_valid_wepkey: get an valid wepkey from stdin
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic char *
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Because we need to get single char from terminal, so we need to
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * disable canonical mode and set buffer size to 1 tyte. And because
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * wepkey should not be see by others, so we disable echo too.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx /* Set new terminal attributes */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx while (((buf[i++] = getchar()) != '\n') && (i < MAX_KEY_LENGTH + 1)) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx /* Restore terminal attributes */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx /* Replace last char '\n' with '\0' */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_set_wepkey: Set parameters in wepkey, and call ioctl
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx char i = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx switch (length) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "wepkey should be:\n"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "\t 40bits: 5 char or 10 hex digits.\n"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "\t 128bits: 13 char or 26 hex digits.\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < MAX_NWEPKEYS; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "should be an integer within the range 1-4\n"), gExecName);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) memmove(gbuf->wldp_buf, &wepkey_tab, sizeof (wl_wep_key_tab_t));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * get the committed wepkey. the return form is like wepkey1=*****;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic char *
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "should be an integer within the range 1-4\n"), gExecName);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx free(wepkey_confirm); /* wepkey_confirm is no longer used */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx safe_snprintf(pbuf, len, "%s%d=%s", "wepkey", key, wepkey);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_wepkey: Get input from user, call do_set_wepkey
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc <= 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: trailing useless tokens "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if ((pbuf != NULL) && (do_set_wepkey(fd, pbuf) == B_TRUE)) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: trailing useless tokens "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "no such profile: '%s'\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_wlanlist: Scan for wlanlist
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc > 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: trailing useless tokens "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (call_ioctl(fd, WLAN_COMMAND, WL_SCAN, 0) == B_FALSE) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_showstatus: show the basic status of the interface, including
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * linkstauts, essid, encryption and signal strength.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc > 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: trailing useless tokens "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (*(wl_linkstatus_t *)(gbuf->wldp_buf) == WL_NOTCONNECTED) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_restoredef: Ask driver for loading default parameters
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc > 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: trailing useless tokens "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (call_ioctl(fd, WLAN_COMMAND, WL_LOAD_DEFAULTS, 0) == B_FALSE) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_disconnect: disconnect from the current connectted network
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc > 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: trailing useless tokens "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (call_ioctl(fd, WLAN_COMMAND, WL_DISASSOCIATE, 0) == B_FALSE) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * a trick here: clean the active_profile flag
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * in section{active_profile}
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) memmove(gbuf->wldp_buf, &essid, sizeof (wl_essid_t));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (call_ioctl(fd, WLAN_SET_PARAM, WL_ESSID, sizeof (wl_essid_t)));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "bss(ap,infrastructure) ibss(ad-hoc) or auto\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) memmove(gbuf->wldp_buf, &bsstype, sizeof (wl_bss_type_t));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "should be:\n"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "\t802.11a: 0-99\n"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "\t802.11b: 1-14\n"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx PRTDBG(("channel=%d\n", phy_conf.wl_phy_dsss_conf.wl_dsss_channel));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) memmove(gbuf->wldp_buf, &phy_conf, sizeof (wl_phy_conf_t));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * is_rates_support: Querying driver about supported rates.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0, j = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx PRTDBG(("is_rates_support(%d, %d, 0x%x)\n", fd, num, rates));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (call_ioctl(fd, WLAN_GET_PARAM, WL_SUPPORTED_RATES, 0)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx rates_num = ((wl_rates_t *)(gbuf->wldp_buf))->wl_rates_num;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < num; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (j = 0; j < rates_num; j++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (j == rates_num) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "rate 5.5M is not supported\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "rate %dM is not supported\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < WIFI_RATES_NUM; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * get_rates: convert string value arg into uint8_t array,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * array length will be save into *len[i].
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * for example:
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * arg = "1,2,5.5,11"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * then after call, rates[] = {2,4,11,22} will be returned.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * and *len will equal to 4
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 1, j = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < *len; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (j = 0; j < i; j++)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < num; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx num*sizeof (char)));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx switch (arg[0]) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) memmove(gbuf->wldp_buf, &ps_mode, sizeof (wl_ps_mode_t));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx /* Mark */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) memmove(gbuf->wldp_buf, &auth_mode, sizeof (wl_authmode_t));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) memmove(gbuf->wldp_buf, &encryption, sizeof (wl_encryption_t));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "should be an integer within the range 1-4\n"), gExecName);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) memmove(gbuf->wldp_buf, &wep_key_id, sizeof (wl_wep_key_id_t));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) memmove(gbuf->wldp_buf, &radio, sizeof (wl_radio_t));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (call_ioctl(fd, WLAN_SET_PARAM, WL_RADIO, sizeof (wl_radio_t)));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * print_gbuf: After each ioctl system call, gbuf will contain result, gbuf
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * contents's format varies from each kind of ioctl system call.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0, j = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx switch (index) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (memcmp((uint8_t *)gbuf->wldp_buf, bssid, sizeof (bssid))
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (memcmp((uint8_t *)gbuf->wldp_buf, bssid, sizeof (bssid))
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < 5; i++)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) printf("\tessid: %s\n", ((wl_essid_t *)(gbuf->wldp_buf))
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx subtype = ((wl_fhss_t *)(gbuf->wldp_buf))->wl_fhss_subtype;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx rates_num = ((wl_rates_t *)(gbuf->wldp_buf))->wl_rates_num;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < rates_num; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx default: /* Mark */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx default: /* Mark */
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx ess_num = ((wl_ess_list_t *)(gbuf->wldp_buf))->wl_ess_list_num;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx p_ess_conf = safe_calloc(sizeof (wl_ess_conf_t *), ess_num);
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < ess_num; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * construct the output format.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx len = snprintf(format, sizeof (format), gettext("essid"));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx len += snprintf(format + len, sizeof (format) - len, "%s",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "encryption\tsignallevel\n");
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < ess_num; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "%s%c%02x:%02x:%02x:%02x:%02x:%02x%c%s",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (j = 0; j < 5; j++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < ess_num; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_get_xxx: will send ioctl to driver, then the driver will fill gbuf
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * with related value. gbuf has a format of wldp_t structure.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (call_ioctl(fd, WLAN_GET_PARAM, WL_CREATE_IBSS, 0));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (call_ioctl(fd, WLAN_GET_PARAM, WL_PHY_CONFIG, 0));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (call_ioctl(fd, WLAN_GET_PARAM, WL_LINKSTATUS, 0));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (call_ioctl(fd, WLAN_GET_PARAM, WL_DESIRED_RATES, 0));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (call_ioctl(fd, WLAN_GET_PARAM, WL_POWER_MODE, 0));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (call_ioctl(fd, WLAN_GET_PARAM, WL_AUTH_MODE, 0));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (call_ioctl(fd, WLAN_GET_PARAM, WL_ENCRYPTION, 0));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (call_ioctl(fd, WLAN_GET_PARAM, WL_WEP_KEY_ID, 0));
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * param has two kinds of forms:
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * 'wepkeyn=*****' (when equalflag == B_TRUE),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * 'wepkeyn' (when equalflag == B_FALSE)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * update/add items in the profile
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxitems_in_profile(aelist_t *cplist, aelist_t *wplist, int argc, char **argv)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0, j = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < argc; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "invalid value '%s' for parameter "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "invalid argument '%s', use "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "parameter=value'\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (j = 0; j < N_GS_FUNC; j++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (j == N_GS_FUNC) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "unrecognized parameter '%s'\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "invalid value '%s' for parameter '%s'\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_createprofile: Called when create a profile off-line.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc <= 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * When creating a profile, if the profile name is not specified,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * the essid is selected as the profile name. the paramters are
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * saved into the section.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < argc; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (i == argc) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "essid required when creating profile\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "non-empty essid required\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * 'all', '{preference}', '{history}', '{active_profile}'
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * and any string with '[' as start and ']' as end should
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * not be a profile name
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "'%s' is an invalid profile name\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "profile '%s' already exists\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Save each parameters in the profile.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if ((psection_config == NULL) || (psection_wep == NULL)) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "profile '%s' doesn't exist\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * modify each parameters in the profile.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx/*ARGSUSED*/
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0, j = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "profile '%s' doesn't exist\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * If no specific parameter typed, we print out all parameters
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc == 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Match function with do_gs_func[] table, and print its result
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < argc; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (j = 0; j < N_GS_FUNC; j++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (j == N_GS_FUNC) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "parameter '%s' has not been set in profile %s\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Verify whether the value in the parameter=value pair is valid or not.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * For the channel, since we donot know what kind of wifi card(a,b,or g)
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * is in the system, so we just leave to verify the validity of the value
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * when the value is set to the card.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * The same goes for the rates.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx switch (item) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * do_set: Called when set a parameter, the format should be
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * parameter=value.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0, j = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc <= 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Set each parameters, if one failed, others behind it will
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * not be set
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < argc; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Separate param and its value, if the user types "param=",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * then value will be set to "";if the user types "param",
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * it is an error.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "'%s', use 'parameter=value'\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (j = 0; j < N_GS_FUNC; j++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Match each parameters with do_gs_func table,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (j == N_GS_FUNC) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "failed to set '%s' for "),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx int i = 0, j = 0, n = 0;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * If no specific parameter typed, we print out all parameters
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc <= 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < N_GS_FUNC; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Match function with do_gs_func[] table, and print its result
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < argc; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (j = 0; j < N_GS_FUNC; j++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (j == N_GS_FUNC) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "failed to read parameter '%s' : "),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * Only one wificonfig is running at one time.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * The following wificonfig which tries to be run will return error,
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * and the pid of the process will own the filelock will be printed out.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (fd0 < 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx (void) fprintf(stderr, gettext("%s: failed to open lockfile"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "enter_filelock:filelock is owned "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx return (getpid());
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx " exit_filelock: %s\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx extern char *optarg;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx extern int optind;
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if ((ppriv = priv_str_to_set("basic", ",", NULL)) == NULL) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "set priviledge to 'basic' error\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "set permitted priviledge: %s\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "set limit priviledge: %s\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "set inherit priviledge: %s\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "set effective priviledge: %s\n"),
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < argc; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx switch (c) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (argc <= 0) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx for (i = 0; i < N_FUNC; i++) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx if (i == N_FUNC) {
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx "failed to find the default wifi interface;"
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx " -i option should be used to specify the "
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * There is an occasion when more than one wificonfig processes
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * which attempt to write the <wifi> and <wifiwepkey> files are
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * running. We must be able to avoid this.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * We use file lock here to implement this.
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * can not write file when startconfing
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhx * during boot
516fc7f3e48e25d0375ea3f93ead33ec38bc597bhxstatic void