diff options
Diffstat (limited to 'usr/src/cmd/cmd-inet/usr.lib/wpad')
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c | 7 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h | 3 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c | 47 |
3 files changed, 26 insertions, 31 deletions
diff --git a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c index 999e80cfb1..75fff828e2 100644 --- a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c +++ b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c @@ -32,8 +32,7 @@ static void pmksa_cache_set_expiration(struct wpa_supplicant *); * IEEE 802.11i/D3.0 */ static const int WPA_SELECTOR_LEN = 4; -static const uint8_t WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 }; -static const uint16_t WPA_VERSION = 1; +static const uint8_t WPA_OUI_AND_TYPE[] = { 0x00, 0x50, 0xf2, 1 }; static const uint8_t WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x50, 0xf2, 1 }; static const uint8_t @@ -361,7 +360,7 @@ wpa_parse_wpa_ie_wpa(struct wpa_supplicant *wpa_s, uint8_t *wpa_ie, if (hdr->elem_id != GENERIC_INFO_ELEM || hdr->len != wpa_ie_len - 2 || - memcmp(&hdr->oui, WPA_OUI_TYPE, WPA_SELECTOR_LEN) != 0 || + memcmp(&hdr->oui, WPA_OUI_AND_TYPE, WPA_SELECTOR_LEN) != 0 || LE_16(hdr->version) != WPA_VERSION) { wpa_printf(MSG_DEBUG, "%s: malformed ie or unknown version", "wpa_parse_wpa_ie_wpa"); @@ -570,7 +569,7 @@ wpa_gen_wpa_ie_wpa(struct wpa_supplicant *wpa_s, uint8_t *wpa_ie) hdr = (struct wpa_ie_hdr *)wpa_ie; hdr->elem_id = GENERIC_INFO_ELEM; - (void) memcpy(&hdr->oui, WPA_OUI_TYPE, WPA_SELECTOR_LEN); + (void) memcpy(&hdr->oui, WPA_OUI_AND_TYPE, WPA_SELECTOR_LEN); hdr->version = LE_16(WPA_VERSION); pos = (uint8_t *)(hdr + 1); diff --git a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h index 7745ec1c7f..2e043e6a37 100644 --- a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h +++ b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h @@ -15,6 +15,7 @@ #include <net/wpa.h> #include <libdladm.h> +#include <libdllink.h> #ifdef __cplusplus extern "C" { @@ -166,7 +167,7 @@ struct wpa_supplicant { unsigned char own_addr[IEEE80211_ADDR_LEN]; datalink_id_t linkid; - char kname[WPA_STRSIZE]; + char kname[DLADM_SECOBJ_NAME_MAX]; uint8_t pmk[PMK_LEN]; diff --git a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c index 06663383f7..889d671b48 100644 --- a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c +++ b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c @@ -22,6 +22,7 @@ #include <signal.h> #include <fcntl.h> #include <door.h> +#include <libscf.h> #include <libdladm.h> #include <libdllink.h> #include <sys/ethernet.h> @@ -32,9 +33,6 @@ #include "eloop.h" #include "l2_packet.h" -static const char *wpa_supplicant_version = -"wpa_supplicant v1.0"; - extern struct wpa_driver_ops wpa_driver_wifi_ops; int wpa_debug_level = MSG_ERROR; @@ -799,16 +797,16 @@ daemon(boolean_t nochdir, boolean_t noclose) return (0); } -static void -usage(void) +/* + * make sure wpad is running under SMF context. + */ +static boolean_t +is_smf_context(void) { - (void) printf("%s\n\n" - "usage:\n" - " wpa_supplicant [-hv] -i<ifname> -k<keyname>\n" - "options:\n" - " -h = show this help text\n" - " -v = show version\n", - wpa_supplicant_version); + char *fmri; + + return (((fmri = getenv("SMF_FMRI")) != NULL) && + (strstr(fmri, SERVICE_NAME) != NULL)); } int @@ -822,31 +820,28 @@ main(int argc, char *argv[]) dladm_phys_attr_t dpa; int c; int exitcode; - char door_file[WPA_STRSIZE]; + char door_file[MAXPATHLEN]; + + if (!is_smf_context()) { + (void) fprintf(stderr, + "wpad is an smf(5) managed service and cannot be run from " + "the command line; please use dladm(1M).\n"); + return (SMF_EXIT_ERR_NOSMF); + } for (;;) { - c = getopt(argc, argv, "Dk:hi:v"); + c = getopt(argc, argv, "i:k:"); if (c < 0) break; switch (c) { - case 'D': - wpa_debug_level = MSG_DEBUG; - break; - case 'h': - usage(); - return (-1); case 'i': link = optarg; break; case 'k': key = optarg; break; - case 'v': - (void) printf("%s\n", wpa_supplicant_version); - return (-1); default: - usage(); - return (-1); + return (SMF_EXIT_ERR_CONFIG); } } @@ -895,7 +890,7 @@ main(int argc, char *argv[]) dlpi_close(dh); return (-1); } - (void) snprintf(door_file, WPA_STRSIZE, "%s_%s", WPA_DOOR, dpa.dp_dev); + (void) snprintf(door_file, MAXPATHLEN, "%s_%s", WPA_DOOR, dpa.dp_dev); (void) memset(&wpa_s, 0, sizeof (wpa_s)); wpa_s.driver = &wpa_driver_wifi_ops; |