2017-05-06 19:28:56 +02:00
|
|
|
/****************************************************************************
|
2019-04-29 18:22:56 +02:00
|
|
|
* apps/netutils/netinit/netinit_associate.c
|
2017-05-06 19:28:56 +02:00
|
|
|
*
|
2021-06-11 06:22:42 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2017-05-06 19:28:56 +02:00
|
|
|
*
|
2021-06-11 06:22:42 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2017-05-06 19:28:56 +02:00
|
|
|
*
|
2021-06-11 06:22:42 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2017-05-06 19:28:56 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
2020-04-03 07:30:45 +02:00
|
|
|
#include <errno.h>
|
2017-05-06 19:28:56 +02:00
|
|
|
|
|
|
|
#include <nuttx/wireless/wireless.h>
|
|
|
|
|
|
|
|
#include "wireless/wapi.h"
|
2019-04-29 18:22:56 +02:00
|
|
|
#include "netutils/netinit.h"
|
2017-05-06 19:28:56 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_WIRELESS_WAPI
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2019-04-29 18:22:56 +02:00
|
|
|
* Name: netinit_associate
|
2017-05-06 19:28:56 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2019-04-29 18:22:56 +02:00
|
|
|
int netinit_associate(FAR const char *ifname)
|
2017-05-06 19:28:56 +02:00
|
|
|
{
|
2020-02-24 04:31:38 +01:00
|
|
|
struct wpa_wconfig_s conf;
|
2020-04-03 07:30:45 +02:00
|
|
|
int ret = -EINVAL;
|
2020-02-24 04:31:38 +01:00
|
|
|
FAR void *load;
|
2017-05-06 19:28:56 +02:00
|
|
|
|
2020-02-24 04:31:38 +01:00
|
|
|
load = wapi_load_config(ifname, NULL, &conf);
|
|
|
|
if (!load)
|
|
|
|
{
|
|
|
|
conf.ifname = ifname;
|
|
|
|
conf.sta_mode = CONFIG_NETINIT_WAPI_STAMODE;
|
|
|
|
conf.auth_wpa = CONFIG_NETINIT_WAPI_AUTHWPA;
|
|
|
|
conf.cipher_mode = CONFIG_NETINIT_WAPI_CIPHERMODE;
|
|
|
|
conf.alg = CONFIG_NETINIT_WAPI_ALG;
|
|
|
|
conf.ssid = CONFIG_NETINIT_WAPI_SSID;
|
|
|
|
conf.passphrase = CONFIG_NETINIT_WAPI_PASSPHRASE;
|
|
|
|
conf.ssidlen = strlen(conf.ssid);
|
|
|
|
conf.phraselen = strlen(conf.passphrase);
|
2020-09-02 04:49:52 +02:00
|
|
|
conf.bssid = NULL;
|
2020-02-24 04:31:38 +01:00
|
|
|
}
|
2017-05-06 19:28:56 +02:00
|
|
|
|
2020-04-03 07:30:45 +02:00
|
|
|
if (conf.ssidlen > 0)
|
|
|
|
{
|
|
|
|
ret = wpa_driver_wext_associate(&conf);
|
|
|
|
}
|
2017-05-06 19:28:56 +02:00
|
|
|
|
2020-02-24 04:31:38 +01:00
|
|
|
wapi_unload_config(load);
|
2017-05-06 19:28:56 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_WIRELESS_WAPI */
|