2183 lines
72 KiB
C
2183 lines
72 KiB
C
/* ipwps_cmd.c - IPWPS Command handlers */
|
|
|
|
/*
|
|
* Copyright (c) 2008 Wind River Systems, Inc.
|
|
*
|
|
* The right to copy, distribute, modify, or otherwise make use
|
|
* of this software may be licensed only pursuant to the terms
|
|
* of an applicable Wind River license agreement.
|
|
*
|
|
*/
|
|
|
|
/*
|
|
modification history
|
|
--------------------
|
|
01d,05may11,zan Fixing some typos
|
|
01c,08apr10,kxr Initialize variables to remove warnings
|
|
01b,05mar09,mry Add priliminary enrollee support
|
|
01a,24Dec08,mry Created
|
|
*/
|
|
|
|
/* DESCRIPTION:
|
|
* ===========
|
|
* Implements the IPWPS command handling.
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
#include "ipwps_config.h"
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#define IPCOM_USE_CLIB_PROTO
|
|
#include <ipcom_type.h>
|
|
#include <ipcom_cstyle.h>
|
|
#include <ipcom_clib.h>
|
|
#include <ipcom_err.h>
|
|
#include <ipcom_sock.h>
|
|
#include <ipcom_syslog.h>
|
|
#include <ipcom_sysvar.h>
|
|
#include <ipcom_errno.h>
|
|
#include <ipcom_err.h>
|
|
#include <ipcom_os.h>
|
|
#include <ipcom_ipd.h>
|
|
#include <ipcom_shell.h>
|
|
|
|
#include "ipwps_debug.h"
|
|
#include "ipwps_public.h"
|
|
|
|
#ifdef IPEAP
|
|
#include <ipeap.h>
|
|
#endif
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
#define IPWPS_CMD_USAGE_NOHELP IP_FALSE
|
|
#define IPWPS_CMD_USAGE_HELP IP_TRUE
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 5 TYPES
|
|
****************************************************************************
|
|
*/
|
|
typedef Ip_err (*Ipwps_cmd_fn)(int argc, char** argv, Ip_u32 cmd_index);
|
|
|
|
typedef struct Ipwps_cmd_st {
|
|
char *qualifier; /* optional */
|
|
char *cmd; /* mandatory */
|
|
char *args; /* optional */
|
|
char *help;
|
|
Ipwps_cmd_fn func;
|
|
} Ipwps_cmd;
|
|
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 EXTERN PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 7 LOCAL PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
IP_GLOBAL int ipwps_cmd_wps(int argc, char** argv);
|
|
IP_STATIC int ipwps_cmd_help(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_enable(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_disable(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_set(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_reconfig(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_show(int argc, char** argv, Ip_u32 cmd_index);
|
|
|
|
IP_STATIC int ipwps_cmd_devinfo_set(int argc, char** argv, Ip_u32 cmd_index);
|
|
|
|
IP_STATIC int ipwps_cmd_wpsproto_enable(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_wpsproto_disable(int argc, char** argv, Ip_u32 cmd_index);
|
|
|
|
IP_STATIC int ipwps_cmd_ap_enable(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_ap_disable(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_ap_set_uuid(int argc, char** argv, Ip_u32 cmd_index);
|
|
|
|
IP_STATIC int ipwps_cmd_enrollee_enable(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_enrollee_disable(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_enrollee_start(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_enrollee_stop(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_enrollee_set_uuid(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_enrollee_set_autoreg(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_enrollee_set_nonwps_drv(int argc, char** argv, Ip_u32 cmd_index);
|
|
#ifdef IPWPS_NOT_SUPPORTED
|
|
IP_STATIC int ipwps_cmd_enrollee_set_adhoc(int argc, char** argv, Ip_u32 cmd_index);
|
|
#endif
|
|
IP_STATIC int ipwps_cmd_registrar_enable(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_registrar_disable(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_registrar_set_reg_mode(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_registrar_set_offer_all_creds(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_registrar_set_uuid(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_registrar_start(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_registrar_stop(int argc, char** argv, Ip_u32 cmd_index);
|
|
|
|
IP_STATIC int ipwps_cmd_pbc_enable(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_pbc_disable(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_pbc_start(int argc, char** argv, Ip_u32 cmd_index);
|
|
|
|
IP_STATIC int ipwps_cmd_pin_enable(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_pin_disable(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_pin_set_cm(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_pin_set_mode(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_pin_new(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_pin_set(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_pin_show(int argc, char** argv, Ip_u32 cmd_index);
|
|
|
|
IP_STATIC int ipwps_cmd_cred_method(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_add(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_delete(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_new(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_autokeylen(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_autonetidx(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_autossid(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_auth(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_encr(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_key(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_keyidx(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_netidx(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_ssid(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_8021x(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_eapid(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_cred_eaptype(int argc, char** argv, Ip_u32 cmd_index);
|
|
#ifdef IPWPS_NOT_SUPPORTED
|
|
IP_STATIC int ipwps_cmd_unimplemented(int argc, char** argv, Ip_u32 cmd_index);
|
|
#endif
|
|
#ifdef IPWPS_DEBUG
|
|
IP_STATIC int ipwps_cmd_dbg_timers_show(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_dbg_ap_show(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_dbg_enrollee_show(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_dbg_registrar_show(int argc, char** argv, Ip_u32 cmd_index);
|
|
IP_STATIC int ipwps_cmd_dbg_wps_begin(int argc, char** argv, Ip_u32 cmd_index);
|
|
#endif
|
|
|
|
/*
|
|
*
|
|
****************************************************************************
|
|
* 8 DATA
|
|
****************************************************************************
|
|
*/
|
|
/* IMPORTANT: Make sure you group commands with the same qualifier together and the NULL qualifier group is ALWAYS 1st */
|
|
IP_STATIC Ipwps_cmd ipwps_supported_cmds[] = {
|
|
{IP_NULL, "commands", IP_NULL, "WPS list of commands",
|
|
IP_NULL},
|
|
{IP_NULL, "help", IP_NULL, "WPS command help",
|
|
ipwps_cmd_help},
|
|
{IP_NULL, "enable", IP_NULL, "Enable WPS",
|
|
ipwps_cmd_enable},
|
|
{IP_NULL, "disable", IP_NULL, "Disable WPS",
|
|
ipwps_cmd_disable},
|
|
{IP_NULL, "set", "wls_if <if_name>", "Set the active wireless interface for WPS\n"
|
|
" You need to call \"wps reconfig\" for the set to take effect.",
|
|
ipwps_cmd_set},
|
|
{IP_NULL, "reconfig", IP_NULL, "Reconfigure WPS with latest settings",
|
|
ipwps_cmd_reconfig},
|
|
{IP_NULL, "show", IP_NULL, "Display WPS status and statistics",
|
|
ipwps_cmd_show},
|
|
|
|
{"dev_info", "set", "<infotype> <val>", "Set one of the following WPS Common Device Info:\n"
|
|
" manufacturer <upto32chars>\n"
|
|
" modelname <upto32chars>\n"
|
|
" modelno <upto32digits>\n"
|
|
" serialno <upto32digits>\n"
|
|
" devicename <upto32chars>\n"
|
|
" catid <categoryIdValue>\n"
|
|
" oui <ouiHexValue>\n"
|
|
" subcatid <subCategoryIdValue>\n"
|
|
" You need to call \"wps reconfig\" for the set to take effect.",
|
|
ipwps_cmd_devinfo_set},
|
|
|
|
{"protocol", "enable", IP_NULL, "Enable WPS Protocol support",
|
|
ipwps_cmd_wpsproto_enable},
|
|
{"protocol", "disable", IP_NULL, "Disable WPS Protocol support",
|
|
ipwps_cmd_wpsproto_disable},
|
|
|
|
{"pbc", "enable", IP_NULL, "Enable WPS PBC Config Method\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_pbc_enable},
|
|
{"pbc", "disable", IP_NULL, "Disable WPS PBC Config Method\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_pbc_disable},
|
|
{"pbc", "start", IP_NULL, "Trigger a WPS PushButton event",
|
|
ipwps_cmd_pbc_start},
|
|
|
|
{"pin", "enable", IP_NULL, "Enable WPS PIN Config Method\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_pin_enable},
|
|
{"pin", "disable", IP_NULL, "Disable WPS PIN Config Method\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_pin_disable},
|
|
{"pin", "method", "<pin_method>", "Set the current WPS PIN config method to one of the following:\n"
|
|
" \"label\" # PIN retrieved from a label\n"
|
|
" \"display\" # PIN retrieved from a display \n"
|
|
" \"keypad\" # PIN entered via a keypad",
|
|
ipwps_cmd_pin_set_cm},
|
|
{"pin", "mode", "<pin_mode>", "Set WPS PIN mode to one of the following:\n"
|
|
" \"auto\" # Automatically generate a machine-specified PIN value\n"
|
|
" \"hard\" # Use the hardcoded PIN value (if one is programmed)\n"
|
|
" \"regs\" # Prompt for a registrar-specified PIN value (interactive mode)\n"
|
|
" \"user\" # Prompt for a user-specified PIN value (interactive mode)\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_pin_set_mode},
|
|
{"pin", "new", "<pin_value>", "Automatically generate a new WPS PIN value (Valid only in \"auto\" PIN mode)",
|
|
ipwps_cmd_pin_new},
|
|
{"pin", "set", "<pin_value>", "Set WPS PIN value",
|
|
ipwps_cmd_pin_set},
|
|
{"pin", "show", IP_NULL, "Display the current WPS PIN value (if available)",
|
|
ipwps_cmd_pin_show},
|
|
|
|
{"ap", "enable", IP_NULL, "Enable the WPS AP\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_ap_enable},
|
|
{"ap", "disable", IP_NULL, "Disable the WPS AP\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_ap_disable},
|
|
{"ap", "set_uuid", "<16byteUUID>", "Set the WPS AP UUID\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_ap_set_uuid},
|
|
|
|
{"enrollee", "enable", IP_NULL, "Enable the WPS Enrollee\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_enrollee_enable},
|
|
{"enrollee", "disable", IP_NULL, "Disable the WPS Enrollee\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_enrollee_disable},
|
|
#ifdef IPWPS_NOT_SUPPORTED
|
|
{"enrollee", "adhoc", "on|off", "Set Adhoc Registration mode support On/Off\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_enrollee_set_adhoc},
|
|
#endif
|
|
{"enrollee", "auto_reg", "on|off", "Set Automatic Registration Initiation On/Off\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_enrollee_set_autoreg},
|
|
{"enrollee", "non_wps_drv", "on|off", "Set Non-WPS-capable Driver support On/Off\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_enrollee_set_nonwps_drv},
|
|
{"enrollee", "set_uuid", "<16byteUUID>", "Set the WPS Enrollee UUID\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_enrollee_set_uuid},
|
|
{"enrollee", "start", IP_NULL, "Start the WPS Enrollee registration",
|
|
ipwps_cmd_enrollee_start},
|
|
{"enrollee", "stop", IP_NULL, "Stop the WPS Enrollee registration",
|
|
ipwps_cmd_enrollee_stop},
|
|
|
|
{"registrar", "enable", IP_NULL, "Enable the WPS Registrar\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_registrar_enable},
|
|
{"registrar", "disable", IP_NULL, "Disable the WPS Registrar\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_registrar_disable},
|
|
{"registrar", "reg_mode", "on|off", "Set the WPS Registrar Registration Mode On/Off\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_registrar_set_reg_mode},
|
|
{"registrar", "all_creds", "on|off", "Set the WPS Registrar All Credentials Offering On/Off\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_registrar_set_offer_all_creds},
|
|
{"registrar", "set_uuid", "<16byteUUID>", "Set the WPS Registrar UUID\n"
|
|
" You need to call \"wps reconfig\" for this operation to take effect.",
|
|
ipwps_cmd_registrar_set_uuid},
|
|
{"registrar", "start", IP_NULL, "Start the WPS Registrar registration",
|
|
ipwps_cmd_registrar_start},
|
|
{"registrar", "stop", IP_NULL, "Stop the WPS Registrar registration",
|
|
ipwps_cmd_registrar_stop},
|
|
|
|
{"credential", "method", "auto|default|interact", "Set the WPS Credentials configuration method to one of the following:\n"
|
|
" \"auto\" # Automatically generate WPS Credentials (valid for AP only)\n"
|
|
" \"default\" # Use the default configured WPS AP Credentials (if available)\n"
|
|
" \"interact\" # Interactively configure the WPS Credentials\n"
|
|
" Selecting \"default\" will cause existing credentials to be overwritten.\n"
|
|
" \"default\" and \"auto\" also update the 1st built-in registrar credential set.\n",
|
|
ipwps_cmd_cred_method},
|
|
{"credential", "add", "0..4", "Add the configured credential (if interactive config method is selected)\n"
|
|
" 0 to add an AP Credential to an AP or registrar\n"
|
|
" 1..4 to add an Enrollee Credential to a registrar",
|
|
ipwps_cmd_cred_add},
|
|
{"credential", "delete", "0..4", "Delete an existing credential (if interactive config method is selected)\n"
|
|
" 0 to delete the AP Credential from an AP or registrar\n"
|
|
" 1..4 to delete an Enrollee Credential from a registrar",
|
|
ipwps_cmd_cred_delete},
|
|
{"credential", "new", IP_NULL, "Auto-generate a new AP/built-in registrar credential set (if \"auto\" method is selected)\n"
|
|
" This will cause existing credentials to be overwritten.",
|
|
ipwps_cmd_cred_new},
|
|
{"credential", "autokeylen", "8..64", "Set the automatically generated Security Key Length\n"
|
|
" 8..63 for passphrase, 64 for hex key (PSK)",
|
|
ipwps_cmd_cred_autokeylen},
|
|
{"credential", "autonetidx", "1..255", "Set the Network Index for the automatically generated credentials",
|
|
ipwps_cmd_cred_autonetidx},
|
|
{"credential", "autossid", "<32charSSID>", "Set the SSID for the automatically generated credentials",
|
|
ipwps_cmd_cred_autossid},
|
|
{"credential", "auth", "wpa|wpa2|all|open", "Set the Authentication type to use\n"
|
|
" You need to call \"wps credential add\" for this value to be set.",
|
|
ipwps_cmd_cred_auth},
|
|
{"credential", "encr", "tkip|aes|all", "Set the Encryption method to use (not required if \"auth\" is set to \"open\")\n"
|
|
" You need to call \"wps credential add\" for this value to be set.",
|
|
ipwps_cmd_cred_encr},
|
|
{"credential", "key", "<passphrase>|<PSK>", "Set the Encryption passphrase or hex key to use\n"
|
|
" Use 8..63 printable ascii characters for a passphrase\n"
|
|
" Use exactly 64 hex characters for a PSK\n"
|
|
" You need to call \"wps credential add\" for this value to be set.",
|
|
ipwps_cmd_cred_key},
|
|
{"credential", "key_index", "1..255", "Set the Key Index for the specified key\n"
|
|
" You need to call \"wps credential add\" for this value to be set.",
|
|
ipwps_cmd_cred_keyidx},
|
|
{"credential", "net_index", "1..255", "Set the Network Index for the specified credential set\n"
|
|
" You need to call \"wps credential add\" for this value to be set.",
|
|
ipwps_cmd_cred_netidx},
|
|
{"credential", "ssid", "<32charSSID>", "Set the SSID to use\n"
|
|
" You need to call \"wps credential add\" for this value to be set.",
|
|
ipwps_cmd_cred_ssid},
|
|
{"credential", "8021x", "on|off", "Set 802.1X authentication ON (for WPA-enterprise) or OFF (for WPA-personal)\n"
|
|
" You need to call \"wps credential add\" for this value to be set.",
|
|
ipwps_cmd_cred_8021x},
|
|
{"credential", "eap_id", "<eap_identity>", "Set the EAP Identity to use for 802.1X authentication\n"
|
|
" You need to call \"wps credential add\" for this value to be set.",
|
|
ipwps_cmd_cred_eapid},
|
|
{"credential", "eap_type", "<1or8byteEAPtypeInHex>", "Set the EAP Type to use for 802.1X authentication (in hex format)\n"
|
|
" Example: \"0D\" for TLS or FE00000100000001 for an extended type\n"
|
|
" You need to call \"wps credential add\" for this value to be set.",
|
|
ipwps_cmd_cred_eaptype},
|
|
|
|
#ifdef IPWPS_DEBUG
|
|
/* These commands are for debugging only and are not part of the officially supported
|
|
* wps commands. Behavior when these commands are invoked is not guaranteed to be valid
|
|
* nor safe for normal operation.
|
|
*/
|
|
{"debug", "timers", "show", "DEBUG ONLY COMMAND: Show internal WPS timers details (using DEBUG2 level log messages).",
|
|
ipwps_cmd_dbg_timers_show},
|
|
{"debug", "ap", "show", "DEBUG ONLY COMMAND: Show internal AP state (using DEBUG2 level log messages).",
|
|
ipwps_cmd_dbg_ap_show},
|
|
{"debug", "enrollee", "show", "DEBUG ONLY COMMAND: Show internal Enrollee state (using DEBUG2 level log messages).",
|
|
ipwps_cmd_dbg_enrollee_show},
|
|
{"debug", "registrar", "show", "DEBUG ONLY COMMAND: Show internal Registrar state (using DEBUG2 level log messages).",
|
|
ipwps_cmd_dbg_registrar_show},
|
|
{"debug", "wps_begin", IP_NULL, "DEBUG ONLY COMMAND: Trigger a wps_begin event.",
|
|
ipwps_cmd_dbg_wps_begin},
|
|
#endif
|
|
|
|
{IP_NULL, IP_NULL, IP_NULL, IP_NULL, IP_NULL} /* Make sure this stays last */
|
|
};
|
|
|
|
IP_STATIC Ip_u32 ipwps_num_cmds = sizeof(ipwps_supported_cmds)/sizeof(ipwps_supported_cmds[0]);
|
|
|
|
IP_STATIC const char *ipwps_cmd_synopsis = "wps [<qualifier>] <cmd> [<args> ...]";
|
|
IP_STATIC const char *ipwps_cmd_discription = "Wi-Fi Protected Setup commands";
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 9 STATIC FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
IP_STATIC void ipwps_cmd_wps_usage(Ip_bool help);
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 10 GLOBAL FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_init
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipwps_cmd_init(void) {
|
|
ipcom_shell_add_cmd("wps", ipwps_cmd_synopsis, ipwps_cmd_discription, ipwps_cmd_wps,
|
|
IPCOM_PROC_PRIO_4, IPCOM_PROC_STACK_DEFAULT);
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_wps_usage_cmd
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC void ipwps_cmd_wps_usage_cmd(Ip_u32 cmd_index, Ip_bool help) {
|
|
|
|
if (cmd_index >= ipwps_num_cmds) {
|
|
ipcom_printf(" Invalid Command (id %d)\n", cmd_index);
|
|
return;
|
|
}
|
|
|
|
ipcom_printf(" wps");
|
|
if (ipwps_supported_cmds[cmd_index].qualifier)
|
|
ipcom_printf(" %s", ipwps_supported_cmds[cmd_index].qualifier);
|
|
if (ipwps_supported_cmds[cmd_index].cmd)
|
|
ipcom_printf(" %s", ipwps_supported_cmds[cmd_index].cmd);
|
|
if (ipwps_supported_cmds[cmd_index].args)
|
|
ipcom_printf(" %s", ipwps_supported_cmds[cmd_index].args);
|
|
ipcom_printf("\n");
|
|
if (ipwps_supported_cmds[cmd_index].help && help)
|
|
ipcom_printf(" %s\n", ipwps_supported_cmds[cmd_index].help);
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_wps_usage
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC void ipwps_cmd_wps_usage(Ip_bool help) {
|
|
int i;
|
|
ipcom_printf("IPWPS command shell\n");
|
|
ipcom_printf("Usage: %s\n", ipwps_cmd_synopsis);
|
|
|
|
for (i = 0; i < ipwps_num_cmds; i++) {
|
|
if (ipwps_supported_cmds[i].cmd)
|
|
ipwps_cmd_wps_usage_cmd(i, help);
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_wps
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL int ipwps_cmd_wps(int argc, char** argv) {
|
|
int i,j;
|
|
char *qualifier;
|
|
char *cmd = IP_NULL;
|
|
Ipwps_cmd_fn fn = IP_NULL;
|
|
int n_argc = 0;
|
|
char **n_argv = IP_NULL;
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
|
|
if (argc <= 1) {
|
|
ipwps_cmd_wps_usage(IPWPS_CMD_USAGE_NOHELP);
|
|
return 0;
|
|
}
|
|
|
|
/* find the start of the qualifier group */
|
|
qualifier = argv[1];
|
|
for (i=0; i < ipwps_num_cmds; i++) {
|
|
if (ipwps_supported_cmds[i].qualifier &&
|
|
(ipcom_strcmp(qualifier, ipwps_supported_cmds[i].qualifier) == 0)) {
|
|
if (argc <= 2) {
|
|
ipwps_cmd_wps_usage(IPWPS_CMD_USAGE_NOHELP);
|
|
return -1;
|
|
}
|
|
cmd = argv[2];
|
|
n_argc = argc-3;
|
|
n_argv = &argv[3];
|
|
break;
|
|
}
|
|
}
|
|
if (i == ipwps_num_cmds) {
|
|
/* If we are here this is either a non-qualified command or a bad command, assume the former for now */
|
|
i = 0;
|
|
qualifier = IP_NULL;
|
|
cmd = argv[1];
|
|
n_argc = argc-2;
|
|
n_argv = &argv[2];
|
|
}
|
|
|
|
/* Find a qualified or non-qualified command */
|
|
for (j=i; j < ipwps_num_cmds; j++) {
|
|
if (qualifier && (ipwps_supported_cmds[j].qualifier == IP_NULL))
|
|
break; /* We reached the end of the table */
|
|
|
|
if ((qualifier == IP_NULL) && (ipwps_supported_cmds[j].qualifier != IP_NULL))
|
|
break; /* negative scan result for whole unqualified command group ==> bad command */
|
|
|
|
if (qualifier && ipcom_strcmp(qualifier, ipwps_supported_cmds[j].qualifier))
|
|
break; /* negative scan result for whole qualified command group ==> bad command */
|
|
|
|
if (ipwps_supported_cmds[j].cmd == IP_NULL) {
|
|
/* Something is wrong with the Command Table, we should always have a command*/
|
|
IP_PANIC();
|
|
return -1;
|
|
}
|
|
|
|
if (ipcom_strcmp(cmd, ipwps_supported_cmds[j].cmd) == 0) {
|
|
/* found it */
|
|
fn = ipwps_supported_cmds[j].func;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (fn == IP_NULL) {
|
|
/* command not found */
|
|
ipwps_cmd_wps_usage(IPWPS_CMD_USAGE_NOHELP);
|
|
return -1;
|
|
}
|
|
|
|
rc = fn(n_argc, n_argv, j);
|
|
ipcom_printf(">>> wps command %s (%d: %s).\n", ((rc == IPCOM_SUCCESS) ? "Done" : "Failed"),
|
|
rc, ipcom_err_string(rc));
|
|
return ((rc == IPCOM_SUCCESS) ? 0 : -1);
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_help
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_help(int argc, char** argv, Ip_u32 cmd_index) {
|
|
ipwps_cmd_wps_usage(IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_SUCCESS;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_enable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_enable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
}
|
|
return ipwps_api_wps_enable(1);
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_disable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_disable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
}
|
|
return ipwps_api_wps_enable(0);
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_set
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_set(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
|
|
if (argc < 1)
|
|
goto fail;
|
|
|
|
if (ipcom_strcmp(argv[0], "wls_if") == 0) {
|
|
if (argc != 2)
|
|
goto fail;
|
|
rc = ipwps_api_wps_set_if(argv[1]);
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
fail:
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_reconfig
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_reconfig(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
}
|
|
return ipwps_api_wps_reconfig();
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_show
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_show(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
return ipwps_api_wps_show();
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_devinfo_set
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_devinfo_set(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_INVALID_ARG;
|
|
Ipwps_dev_info_type which_info;
|
|
|
|
if (argc != 2)
|
|
goto fail;
|
|
|
|
if (ipcom_strcmp(argv[0], "manufacturer") == 0) {
|
|
which_info = IPWPS_DEVINFO_MANUFACTURER;
|
|
} else if (ipcom_strcmp(argv[0], "modelname") == 0) {
|
|
which_info = IPWPS_DEVINFO_MODELNAME;
|
|
} else if (ipcom_strcmp(argv[0], "modelno") == 0) {
|
|
which_info = IPWPS_DEVINFO_MODELNO;
|
|
} else if (ipcom_strcmp(argv[0], "serialno") == 0) {
|
|
which_info = IPWPS_DEVINFO_SERIALNO;
|
|
} else if (ipcom_strcmp(argv[0], "devicename") == 0) {
|
|
which_info = IPWPS_DEVINFO_DEVNAME;
|
|
} else if (ipcom_strcmp(argv[0], "catid") == 0) {
|
|
which_info = IPWPS_DEVINFO_CATID;
|
|
} else if (ipcom_strcmp(argv[0], "oui") == 0) {
|
|
which_info = IPWPS_DEVINFO_OUI;
|
|
} else if (ipcom_strcmp(argv[0], "subcatid") == 0) {
|
|
which_info = IPWPS_DEVINFO_SUBCATID;
|
|
} else {
|
|
goto fail;
|
|
}
|
|
rc = ipwps_api_wps_set_commondevinfo(which_info, argv[1]);
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
|
|
fail:
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_wpsproto_enable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_wpsproto_enable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
return ipwps_api_wpsproto_enable(1);
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_wpsproto_disable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_wpsproto_disable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
return ipwps_api_wpsproto_enable(0);
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_ap_enable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_ap_enable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
rc = ipwps_api_ap_enable(1);
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_ap_disable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_ap_disable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
rc = ipwps_api_ap_enable(0);
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_ap_set_uuid
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_ap_set_uuid(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if ((argc != 1) || (strlen(argv[0]) != (2*IPWPS_UUID_SIZE))) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
#ifdef IPWPS_USE_WPS_AP
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_AP_UUID, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_AP_UUID);
|
|
return IPCOM_ERR_FAILED;
|
|
}
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return IPCOM_SUCCESS;
|
|
#else
|
|
IPCOM_LOG0(ERR, "ipwps_cmd_ap_set_uuid :: Cannot set AP UUID because WPS AP support is not present.");
|
|
return IPCOM_ERR_NOT_SUPPORTED;
|
|
#endif
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_enrollee_enable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_enrollee_enable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
rc = ipwps_api_enrollee_enable(1);
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_enrollee_disable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_enrollee_disable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
rc = ipwps_api_enrollee_enable(0);
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_enrollee_start
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_enrollee_start(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
return ipwps_api_enrollee_start();
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_enrollee_stop
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_enrollee_stop(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
return ipwps_api_enrollee_stop();
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_enrollee_set_uuid
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_enrollee_set_uuid(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if ((argc != 1) || (strlen(argv[0]) != (2*IPWPS_UUID_SIZE))) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
#ifdef IPWPS_USE_WPS_ENROLLEE
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_ENROLLEE_UUID, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_ENROLLEE_UUID);
|
|
return IPCOM_ERR_FAILED;
|
|
}
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return IPCOM_SUCCESS;
|
|
#else
|
|
IPCOM_LOG0(ERR, "ipwps_cmd_enrollee_set_uuid :: Cannot set Enrollee UUID because WPS Enrollee support is not present.");
|
|
return IPCOM_ERR_NOT_SUPPORTED;
|
|
#endif
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_enrollee_set_autoreg
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_enrollee_set_autoreg(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 1) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
if (ipcom_strcmp(argv[0], "on") == 0) {
|
|
rc = ipwps_api_enrollee_autoreg(1);
|
|
} else if (ipcom_strcmp(argv[0], "off") == 0) {
|
|
rc = ipwps_api_enrollee_autoreg(0);
|
|
} else {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_enrollee_set_nonwps_drv
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_enrollee_set_nonwps_drv(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 1) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
if (ipcom_strcmp(argv[0], "on") == 0) {
|
|
rc = ipwps_api_enrollee_nonwps_drv(1);
|
|
} else if (ipcom_strcmp(argv[0], "off") == 0) {
|
|
rc = ipwps_api_enrollee_nonwps_drv(0);
|
|
} else {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
#ifdef IPWPS_NOT_SUPPORTED
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_enrollee_set_adhoc
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_enrollee_set_adhoc(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 1) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
if (ipcom_strcmp(argv[0], "on") == 0) {
|
|
rc = ipwps_api_enrollee_adhoc(1);
|
|
} else if (ipcom_strcmp(argv[0], "off") == 0) {
|
|
rc = ipwps_api_enrollee_adhoc(0);
|
|
} else {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
#endif
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_registrar_enable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_registrar_enable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
rc = ipwps_api_registrar_enable(1);
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_registrar_disable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_registrar_disable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
rc = ipwps_api_registrar_enable(0);
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_registrar_start
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_registrar_start(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
return ipwps_api_registrar_start();
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_registrar_stop
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_registrar_stop(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
return ipwps_api_registrar_stop();
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_registrar_set_reg_mode
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_registrar_set_reg_mode(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 1) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
if (ipcom_strcmp(argv[0], "on") == 0) {
|
|
rc = ipwps_api_registrar_reg_mode(1);
|
|
} else if (ipcom_strcmp(argv[0], "off") == 0) {
|
|
rc = ipwps_api_registrar_reg_mode(0);
|
|
} else {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_registrar_set_offer_all_creds
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_registrar_set_offer_all_creds(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 1) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
if (ipcom_strcmp(argv[0], "on") == 0) {
|
|
rc = ipwps_api_registrar_offer_all_creds(1);
|
|
} else if (ipcom_strcmp(argv[0], "off") == 0) {
|
|
rc = ipwps_api_registrar_offer_all_creds(0);
|
|
} else {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_registrar_set_uuid
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_registrar_set_uuid(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if ((argc != 1) || (strlen(argv[0]) != (2*IPWPS_UUID_SIZE))) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
#ifdef IPWPS_USE_WPS_REGISTRAR
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_REGISTRAR_UUID, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_REGISTRAR_UUID);
|
|
return IPCOM_ERR_FAILED;
|
|
}
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return IPCOM_SUCCESS;
|
|
#else
|
|
IPCOM_LOG0(ERR, "ipwps_cmd_registrar_set_uuid :: Cannot set Registrar UUID because WPS Enrollee support is not present.");
|
|
return IPCOM_ERR_NOT_SUPPORTED;
|
|
#endif
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_pbc_enable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_pbc_enable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
rc = ipwps_api_pbc_enable(1);
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_pbc_disable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_pbc_disable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
rc = ipwps_api_pbc_enable(0);
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_pbc_start
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_pbc_start(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
return ipwps_api_pbc_start();
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_pin_enable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_pin_enable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
rc = ipwps_api_pin_enable(1);
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_pin_disable
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_pin_disable(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_ERR_FAILED;
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
rc = ipwps_api_pin_enable(0);
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_pin_set_cm
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_pin_set_cm(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_u16 config_method;
|
|
Ip_err rc;
|
|
|
|
if (argc != 1) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
if (ipcom_strcmp(argv[0], "label") == 0) {
|
|
config_method = IPWPS_CONFIG_METHOD_LABEL;
|
|
} else if (ipcom_strcmp(argv[0], "display") == 0) {
|
|
config_method = IPWPS_CONFIG_METHOD_DISPLAY;
|
|
} else if (ipcom_strcmp(argv[0], "keypad") == 0) {
|
|
config_method = IPWPS_CONFIG_METHOD_KEYPAD;
|
|
} else {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
|
|
rc = ipwps_api_pin_set_cm(config_method);
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_pin_set_mode
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_pin_set_mode(int argc, char** argv, Ip_u32 cmd_index) {
|
|
ipwps_pin_mode pin_mode;
|
|
Ip_err rc;
|
|
|
|
if (argc != 1) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
if (ipcom_strcmp(argv[0], "auto") == 0) {
|
|
pin_mode = IPWPS_PINMODE_VAL_AUTO;
|
|
} else if (ipcom_strcmp(argv[0], "hard") == 0) {
|
|
pin_mode = IPWPS_PINMODE_VAL_HARDCODE;
|
|
} else if (ipcom_strcmp(argv[0], "regs") == 0) {
|
|
pin_mode = IPWPS_PINMODE_VAL_INTERACT_REGS;
|
|
} else if (ipcom_strcmp(argv[0], "user") == 0) {
|
|
pin_mode = IPWPS_PINMODE_VAL_INTERACT_USER;
|
|
} else {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
rc = ipwps_api_pin_set_mode(pin_mode);
|
|
if (rc == IPCOM_SUCCESS)
|
|
ipcom_printf(" Issue the \"wps reconfig\" command for the change to take effect\n");
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_pin_new
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_pin_new(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_u8 new_pin[IPWPS_PIN_MAXLEN+1];
|
|
Ip_err rc;
|
|
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
|
|
rc = ipwps_api_pin_new(new_pin, sizeof(new_pin));
|
|
if (rc == IPCOM_SUCCESS) {
|
|
ipcom_printf("NEW IPWPS PIN = \"%s\"\n", new_pin);
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_pin_set
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_pin_set(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 1) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
return ipwps_api_pin_set((Ip_u8 *)argv[0]);
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_pin_show
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_pin_show(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_u8 pin[IPWPS_PIN_MAXLEN+1];
|
|
Ip_err rc;
|
|
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
rc = ipwps_api_pin_get(pin, sizeof(pin));
|
|
if (rc == IPCOM_SUCCESS) {
|
|
ipcom_printf("IPWPS PIN = \"%s\"\n", pin);
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_method
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_cred_method(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ipwps_credential_method cred_method;
|
|
|
|
if (argc != 1) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
if (ipcom_strcmp(argv[0], IPWPS_CRED_CONFIG_METHOD_AUTO) == 0) {
|
|
cred_method = IPWPS_CERDENTIAL_METHOD_AUTO;
|
|
} else if (ipcom_strcmp(argv[0], IPWPS_CRED_CONFIG_METHOD_DEFAULT) == 0) {
|
|
cred_method = IPWPS_CERDENTIAL_METHOD_DEFAULT;
|
|
} else if (ipcom_strcmp(argv[0], IPWPS_CRED_CONFIG_METHOD_INTERACT) == 0) {
|
|
cred_method = IPWPS_CERDENTIAL_METHOD_INTERACTIVE;
|
|
} else {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
return ipwps_api_credential_set_method(cred_method);
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_add
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_cred_add(int argc, char** argv, Ip_u32 cmd_index) {
|
|
int i;
|
|
if (argc != 1) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
for (i=0; i < ipcom_strlen(argv[0]); i++) {
|
|
if (!isdigit(argv[0][i])) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
}
|
|
return ipwps_api_credential_add(ipcom_atoi(argv[0]));
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_delete
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_cred_delete(int argc, char** argv, Ip_u32 cmd_index) {
|
|
int i;
|
|
if (argc != 1) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
for (i=0; i < ipcom_strlen(argv[0]); i++) {
|
|
if (!isdigit(argv[0][i])) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
}
|
|
return ipwps_api_credential_delete(ipcom_atoi(argv[0]));
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_new
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_cred_new(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
return ipwps_api_credential_new();
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_autokeylen
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_cred_autokeylen(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_u8 val;
|
|
int i;
|
|
Ip_err rc = IPCOM_SUCCESS;
|
|
|
|
if (argc != 1) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_autokeylen_done;
|
|
}
|
|
for (i=0; i < ipcom_strlen(argv[0]); i++) {
|
|
if (!ipcom_isdigit(argv[0][i])) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_autokeylen_done;
|
|
}
|
|
}
|
|
val = ipcom_atoi(argv[0]);
|
|
if ((val < IPWPS_PASSPHRASE_MINLEN) || (val > IPWPS_PROTO_NETWORK_KEY_MAXLEN)) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_autokeylen_done;
|
|
}
|
|
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_CREDENTIAL_AUTO_KEYLEN, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_CREDENTIAL_AUTO_KEYLEN);
|
|
rc = IPCOM_ERR_FAILED;
|
|
}
|
|
|
|
cred_autokeylen_done:
|
|
if (rc != IPCOM_SUCCESS) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_autonetidx
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_cred_autonetidx(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_u32 val;
|
|
int i;
|
|
Ip_err rc = IPCOM_SUCCESS;
|
|
|
|
if (argc != 1) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_autonetidx_done;
|
|
}
|
|
for (i=0; i < ipcom_strlen(argv[0]); i++) {
|
|
if (!ipcom_isdigit(argv[0][i])) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_autonetidx_done;
|
|
}
|
|
}
|
|
val = ipcom_atoi(argv[0]);
|
|
if ((val < IPWPS_NETINDEX_MIN) || (val > IPWPS_NETINDEX_MAX)) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_autonetidx_done;
|
|
}
|
|
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_CREDENTIAL_AUTO_NETINDEX, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_CREDENTIAL_AUTO_NETINDEX);
|
|
rc = IPCOM_ERR_FAILED;
|
|
}
|
|
|
|
cred_autonetidx_done:
|
|
if (rc != IPCOM_SUCCESS) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_autossid
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_cred_autossid(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_SUCCESS;
|
|
Ip_u32 len;
|
|
int i;
|
|
|
|
if (argc != 1) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_autossid_done;
|
|
}
|
|
len = ipcom_strlen(argv[0]);
|
|
if (len > IPWPS_SSID_MAXLEN) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_autossid_done;
|
|
}
|
|
for (i=0; i < len; i++) {
|
|
if (!ipcom_isascii(argv[0][i])) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_autossid_done;
|
|
}
|
|
}
|
|
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_CREDENTIAL_AUTO_SSID, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_CREDENTIAL_AUTO_SSID);
|
|
rc = IPCOM_ERR_FAILED;
|
|
}
|
|
|
|
cred_autossid_done:
|
|
if (rc != IPCOM_SUCCESS) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_auth
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
|
|
IP_STATIC int ipwps_cmd_cred_auth(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_SUCCESS;
|
|
|
|
if (argc != 1) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_auth_done;
|
|
}
|
|
if ((ipcom_strcmp(argv[0], IPWPS_CRED_AUTH_OPEN) != 0) &&
|
|
(ipcom_strcmp(argv[0], IPWPS_CRED_AUTH_WPA) != 0) &&
|
|
(ipcom_strcmp(argv[0], IPWPS_CRED_AUTH_WPA2) != 0) &&
|
|
(ipcom_strcmp(argv[0], IPWPS_CRED_AUTH_ALL) != 0)) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_auth_done;
|
|
}
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_CREDENTIAL_AUTH, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_CREDENTIAL_AUTH);
|
|
rc = IPCOM_ERR_FAILED;
|
|
}
|
|
cred_auth_done:
|
|
if (rc != IPCOM_SUCCESS) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
} else {
|
|
ipcom_printf(" Use \"wps credential add\" for this value to be set.\n");
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_encr
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
|
|
IP_STATIC int ipwps_cmd_cred_encr(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_SUCCESS;
|
|
|
|
if (argc != 1) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_encr_done;
|
|
}
|
|
if ((ipcom_strcmp(argv[0], IPWPS_CRED_ENCR_TKIP) != 0) &&
|
|
(ipcom_strcmp(argv[0], IPWPS_CRED_ENCR_AES) != 0) &&
|
|
(ipcom_strcmp(argv[0], IPWPS_CRED_ENCR_ALL) != 0)) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_encr_done;
|
|
}
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_CREDENTIAL_ENCR, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_CREDENTIAL_ENCR);
|
|
rc = IPCOM_ERR_FAILED;
|
|
}
|
|
cred_encr_done:
|
|
if (rc != IPCOM_SUCCESS) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
} else {
|
|
ipcom_printf(" Use \"wps credential add\" for this value to be set.\n");
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_key
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
|
|
IP_STATIC int ipwps_cmd_cred_key(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_SUCCESS;
|
|
Ip_u32 len;
|
|
int i;
|
|
|
|
if (argc != 1) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_key_done;
|
|
}
|
|
len = ipcom_strlen(argv[0]);
|
|
if ((len < IPWPS_PASSPHRASE_MINLEN) || (len > IPWPS_PROTO_NETWORK_KEY_MAXLEN)) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_key_done;
|
|
}
|
|
for (i=0; i < len; i++) {
|
|
if (((len == 64) && (!ipcom_isxdigit(argv[0][i]))) ||
|
|
(!ipcom_isascii(argv[0][i]))) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_key_done;
|
|
}
|
|
}
|
|
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_CREDENTIAL_KEY, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_CREDENTIAL_KEY);
|
|
rc = IPCOM_ERR_FAILED;
|
|
}
|
|
|
|
cred_key_done:
|
|
if (rc != IPCOM_SUCCESS) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
} else {
|
|
ipcom_printf(" Use \"wps credential add\" for this value to be set.\n");
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_keyidx
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_cred_keyidx(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_u32 val;
|
|
int i;
|
|
Ip_err rc = IPCOM_SUCCESS;
|
|
|
|
if (argc != 1) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_keyidx_done;
|
|
}
|
|
for (i=0; i < ipcom_strlen(argv[0]); i++) {
|
|
if (!ipcom_isdigit(argv[0][i])) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_keyidx_done;
|
|
}
|
|
}
|
|
val = ipcom_atoi(argv[0]);
|
|
if ((val < IPWPS_KEYINDEX_MIN) || (val > IPWPS_KEYINDEX_MAX)) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_keyidx_done;
|
|
}
|
|
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_CREDENTIAL_KEYINDEX, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_CREDENTIAL_KEYINDEX);
|
|
rc = IPCOM_ERR_FAILED;
|
|
}
|
|
|
|
cred_keyidx_done:
|
|
if (rc != IPCOM_SUCCESS) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
} else {
|
|
ipcom_printf(" Use \"wps credential add\" for this value to be set.\n");
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_netidx
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_cred_netidx(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_u32 val;
|
|
int i;
|
|
Ip_err rc = IPCOM_SUCCESS;
|
|
|
|
if (argc != 1) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_netidx_done;
|
|
}
|
|
for (i=0; i < ipcom_strlen(argv[0]); i++) {
|
|
if (!ipcom_isdigit(argv[0][i])) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_netidx_done;
|
|
}
|
|
}
|
|
val = ipcom_atoi(argv[0]);
|
|
if ((val < IPWPS_NETINDEX_MIN) || (val > IPWPS_NETINDEX_MAX)) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_netidx_done;
|
|
}
|
|
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_CREDENTIAL_NETINDEX, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_CREDENTIAL_NETINDEX);
|
|
rc = IPCOM_ERR_FAILED;
|
|
}
|
|
|
|
cred_netidx_done:
|
|
if (rc != IPCOM_SUCCESS) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
} else {
|
|
ipcom_printf(" Use \"wps credential add\" for this value to be set.\n");
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_ssid
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
|
|
IP_STATIC int ipwps_cmd_cred_ssid(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_SUCCESS;
|
|
Ip_u32 len;
|
|
int i;
|
|
|
|
if (argc != 1) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_ssid_done;
|
|
}
|
|
len = ipcom_strlen(argv[0]);
|
|
if (len > IPWPS_SSID_MAXLEN) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_ssid_done;
|
|
}
|
|
for (i=0; i < len; i++) {
|
|
if (!ipcom_isascii(argv[0][i])) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_ssid_done;
|
|
}
|
|
}
|
|
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_CREDENTIAL_SSID, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_CREDENTIAL_SSID);
|
|
rc = IPCOM_ERR_FAILED;
|
|
}
|
|
|
|
cred_ssid_done:
|
|
if (rc != IPCOM_SUCCESS) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
} else {
|
|
ipcom_printf(" Use \"wps credential add\" for this value to be set.\n");
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_8021x
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
|
|
IP_STATIC int ipwps_cmd_cred_8021x(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_SUCCESS;
|
|
char *val;
|
|
|
|
if (argc != 1) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_8021x_done;
|
|
}
|
|
if (ipcom_strcmp(argv[0], "on") == 0) {
|
|
val = "1";
|
|
} else if (ipcom_strcmp(argv[0], "off") == 0) {
|
|
val = "0";
|
|
} else {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_8021x_done;
|
|
}
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_CREDENTIAL_8021X, val, IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_CREDENTIAL_8021X);
|
|
rc = IPCOM_ERR_FAILED;
|
|
}
|
|
cred_8021x_done:
|
|
if (rc != IPCOM_SUCCESS) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
} else {
|
|
ipcom_printf(" Use \"wps credential add\" for this value to be set.\n");
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_eapid
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
|
|
IP_STATIC int ipwps_cmd_cred_eapid(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_SUCCESS;
|
|
Ip_u32 len;
|
|
int i;
|
|
|
|
if (argc != 1) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_eapid_done;
|
|
}
|
|
len = ipcom_strlen(argv[0]);
|
|
for (i=0; i < len; i++) {
|
|
if (!ipcom_isascii(argv[0][i])) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_eapid_done;
|
|
}
|
|
}
|
|
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_CREDENTIAL_EAP_ID, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_CREDENTIAL_EAP_ID);
|
|
rc = IPCOM_ERR_FAILED;
|
|
}
|
|
|
|
cred_eapid_done:
|
|
if (rc != IPCOM_SUCCESS) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
} else {
|
|
ipcom_printf(" Use \"wps credential add\" for this value to be set.\n");
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_cred_eaptype
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
|
|
IP_STATIC int ipwps_cmd_cred_eaptype(int argc, char** argv, Ip_u32 cmd_index) {
|
|
Ip_err rc = IPCOM_SUCCESS;
|
|
Ip_u32 len;
|
|
int i;
|
|
|
|
if (argc != 1) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_eaptype_done;
|
|
}
|
|
len = ipcom_strlen(argv[0]);
|
|
if (!len || (len != 2 && len != 16)) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_eaptype_done;
|
|
}
|
|
for (i=0; i < len; i++) {
|
|
if (!ipcom_isxdigit(argv[0][i])) {
|
|
rc = IPCOM_ERR_INVALID_ARG;
|
|
goto cred_eaptype_done;
|
|
}
|
|
}
|
|
|
|
if (ipcom_sysvar_set(IPWPS_SYSVAR_CREDENTIAL_EAP_TYPE, argv[0], IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
|
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", IPWPS_SYSVAR_CREDENTIAL_EAP_TYPE);
|
|
rc = IPCOM_ERR_FAILED;
|
|
}
|
|
|
|
cred_eaptype_done:
|
|
if (rc != IPCOM_SUCCESS) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
} else {
|
|
ipcom_printf(" Use \"wps credential add\" for this value to be set.\n");
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
#ifdef IPWPS_NOT_SUPPORTED
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_unimplemented
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_unimplemented(int argc, char** argv, Ip_u32 cmd_index) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
ipcom_printf("*** Command not yet implemented ***\n");
|
|
return IPCOM_ERR_NOT_SUPPORTED;
|
|
}
|
|
#endif
|
|
|
|
#ifdef IPWPS_DEBUG
|
|
/* These commands are for debugging only and are not part of the officially supported
|
|
* wps commands. Behavior when these commands are invoked is not guaranteed to be valid
|
|
* nor safe for normal operation.
|
|
*/
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_dbg_timers_show
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_dbg_timers_show(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc < 1)
|
|
goto fail;
|
|
|
|
if (ipcom_strcmp(argv[0], "show") == 0) {
|
|
return ipwps_dbg_timers_show();
|
|
} else {
|
|
goto fail;
|
|
}
|
|
|
|
fail:
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_dbg_ap_show
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_dbg_ap_show(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc < 1)
|
|
goto fail;
|
|
|
|
if (ipcom_strcmp(argv[0], "show") == 0) {
|
|
return ipwps_dbg_ap_show();
|
|
} else {
|
|
goto fail;
|
|
}
|
|
|
|
fail:
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_dbg_enrollee_show
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_dbg_enrollee_show(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc < 1)
|
|
goto fail;
|
|
|
|
if (ipcom_strcmp(argv[0], "show") == 0) {
|
|
return ipwps_dbg_enrollee_show();
|
|
} else {
|
|
goto fail;
|
|
}
|
|
|
|
fail:
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_dbg_registrar_show
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_dbg_registrar_show(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc < 1)
|
|
goto fail;
|
|
|
|
if (ipcom_strcmp(argv[0], "show") == 0) {
|
|
return ipwps_dbg_registrar_show();
|
|
} else {
|
|
goto fail;
|
|
}
|
|
|
|
fail:
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
return IPCOM_ERR_INVALID_ARG;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_cmd_dbg_wps_begin
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC int ipwps_cmd_dbg_wps_begin(int argc, char** argv, Ip_u32 cmd_index) {
|
|
if (argc != 0) {
|
|
ipcom_printf("Cmd usage: \n");
|
|
ipwps_cmd_wps_usage_cmd(cmd_index, IPWPS_CMD_USAGE_HELP);
|
|
}
|
|
return ipwps_dbg_wps_begin();
|
|
}
|
|
#endif
|