chore: sdk compiles almost w/o warnings?

This commit is contained in:
2024-12-17 03:13:08 +06:00
parent 31efbc726f
commit 7c7b36a6b3
55 changed files with 658 additions and 514 deletions

View File

@@ -9,6 +9,7 @@
#include "utils/includes.h"
#include "utils/common.h"
#include "tls.h"
#include "wifi_eap_config.h"
#define DEBUG_LEVEL 0 // For debug: 5

View File

@@ -78,14 +78,14 @@ void judge_station_disconnect(void)
}
}
void eap_disconnected_hdl(char *buf, int buf_len, int flags, void* handler_user_data){
// printf("disconnected\n");
wifi_unreg_event_handler(WIFI_EVENT_EAPOL_RECVD, eap_eapol_recvd_hdl);
wifi_unreg_event_handler(WIFI_EVENT_DISCONNECT, eap_disconnected_hdl);
eap_peer_unregister_methods();
eap_sm_deinit();
//reset_config();
}
// void eap_disconnected_hdl(char *buf, int buf_len, int flags, void* handler_user_data){
// // printf("disconnected\n");
// wifi_unreg_event_handler(WIFI_EVENT_EAPOL_RECVD, eap_eapol_recvd_hdl);
// wifi_unreg_event_handler(WIFI_EVENT_DISCONNECT, eap_disconnected_hdl);
// eap_peer_unregister_methods();
// eap_sm_deinit();
// //reset_config();
// }
/*
void eap_config(void){

View File

@@ -0,0 +1,69 @@
#ifndef __WIFI_EAP_CONFIG_H
#define __WIFI_EAP_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "basic_types.h"
// Function declarations
/**
* @brief Set the EAP phase flag
* @param is_trigger_eap Flag value to set
*/
void set_eap_phase(unsigned char is_trigger_eap);
/**
* @brief Get the current EAP phase
* @return Current EAP phase value
*/
int get_eap_phase(void);
/**
* @brief Get the current EAP method
* @return Current EAP method value
*/
int get_eap_method(void);
/**
* @brief Reset all EAP configuration parameters to NULL
*/
void reset_config(void);
/**
* @brief Start the EAP authentication process
* @param method The EAP method to use ("peap", "tls", or "ttls")
* @return 0 on success, -1 on failure
*/
int eap_start(char *method);
/**
* @brief Handle auto-reconnection for EAP
* @param method_id The EAP method ID to use for reconnection
*/
void eap_autoreconnect_hdl(u8 method_id);
/**
* @brief Initialize EAP certificates
* @return 0 on success, -1 on failure
*/
int eap_cert_init(void);
/**
* @brief Free client certificate resources
*/
void eap_client_cert_free(void);
/**
* @brief Free server certificate resources
*/
void eap_server_cert_free(void);
#ifdef __cplusplus
}
#endif
#endif /* __WIFI_EAP_CONFIG_H */

View File

@@ -13,6 +13,8 @@
#include "tcpip.h"
#include <osdep_service.h>
#include <device_lock.h>
#include "wifi_promisc.h"
// #include "dhcp.h"
#if CONFIG_EXAMPLE_WLAN_FAST_CONNECT || CONFIG_JD_SMART
#include "wlan_fast_connect/example_wlan_fast_connect.h"
@@ -67,7 +69,7 @@ static unsigned char ap_bssid[6];
#if CONFIG_WIFI_IND_USE_THREAD
static void* disconnect_sema = NULL;
#endif
extern rtw_mode_t wifi_mode;
rtw_mode_t wifi_mode = RTW_MODE_STA;
static rtw_wpa_mode wifi_wpa_mode = WPA_AUTO_MODE;
int error_flag = RTW_UNKNOWN;
@@ -460,7 +462,7 @@ static void wifi_handshake_done_hdl( char* buf, int buf_len, int flags, void* us
if(join_user_data != NULL)
rtw_up_sema(&join_user_data->join_sema);
}
extern void dhcp_stop(struct netif *netif);
static void wifi_disconn_hdl( char* buf, int buf_len, int flags, void* userdata)
{
#define REASON_4WAY_HNDSHK_TIMEOUT 15
@@ -871,7 +873,7 @@ int wifi_connect(
error:
if(semaphore == NULL){
rtw_free_sema( &join_semaphore);
rtw_free_sema((_sema*)&join_semaphore);
}
join_user_data = NULL;
rtw_free((u8*)join_result);
@@ -1021,11 +1023,11 @@ int wifi_connect_bssid(
rtw_free(join_result->network_info.password);
}
rtw_free((u8*)join_result);
rtw_free_sema( &join_semaphore);
rtw_free_sema((_sema*)&join_semaphore);
result = RTW_TIMEOUT;
goto error;
} else {
rtw_free_sema( &join_semaphore );
rtw_free_sema((_sema*)&join_semaphore);
if(join_result->network_info.password_len) {
rtw_free(join_result->network_info.password);
}
@@ -1283,7 +1285,7 @@ int wifi_connect_concurrent(
error:
if(semaphore == NULL){
rtw_free_sema( &join_semaphore);
rtw_free_sema((_sema*)&join_semaphore);
}
join_user_data = NULL;
rtw_free((u8*)join_result);
@@ -1433,11 +1435,11 @@ int wifi_connect_bssid_concurrent(
rtw_free(join_result->network_info.password);
}
rtw_free((u8*)join_result);
rtw_free_sema( &join_semaphore);
rtw_free_sema((_sema*)&join_semaphore);
result = RTW_TIMEOUT;
goto error;
} else {
rtw_free_sema( &join_semaphore );
rtw_free_sema((_sema*)&join_semaphore);
if(join_result->network_info.password_len) {
rtw_free(join_result->network_info.password);
}
@@ -1681,6 +1683,7 @@ int wifi_get_channel_plan(uint8_t *channel_plan)
}
//----------------------------------------------------------------------------//
extern int rltk_wlan_get_sta_max_data_rate(u8 *inidata_rate);
int wifi_get_sta_max_data_rate(OUT u8 * inidata_rate)
{
return rltk_wlan_get_sta_max_data_rate(inidata_rate);
@@ -1995,7 +1998,7 @@ int wifi_set_power_mode(unsigned char ips_mode, unsigned char lps_mode)
int wifi_set_powersave_level(u8 level)
{
return rltk_set_lps_level(level);
// return rltk_set_lps_level(level);
}
int wifi_set_tdma_param(unsigned char slot_period, unsigned char rfon_period_len_1, unsigned char rfon_period_len_2, unsigned char rfon_period_len_3)
@@ -2017,7 +2020,7 @@ static void wifi_ap_sta_assoc_hdl( char* buf, int buf_len, int flags, void* user
{
#ifdef CONFIG_PLATFORM_8711B
if(enable_softap_adjust_phy){
softap_adjust_phy();
// softap_adjust_phy();
}
#endif
//USER TODO
@@ -2056,6 +2059,7 @@ int wifi_set_pmk_cache_enable(unsigned char value)
}
#endif
extern int set_hidden_ssid(const char *ifname, uint8_t value);
int wifi_start_ap(
char *ssid,
rtw_security_t security_type,
@@ -2154,7 +2158,7 @@ int wifi_start_ap(
// for adjust/recover phy parameters before/after link on softap mode
#ifdef CONFIG_PLATFORM_8711B
if(enable_softap_adjust_phy){
softap_adjust_phy();
// softap_adjust_phy();
}
#endif
@@ -2523,7 +2527,7 @@ int wifi_scan_networks_with_ssid_by_extended_security(int (results_handler)(char
return RTW_NOMEM;
}
rltk_wlan_enable_scan_with_ssid_by_extended_security(1);
// rltk_wlan_enable_scan_with_ssid_by_extended_security(1);
//set ssid
memset(scan_buf.buf, 0, scan_buf.buf_len);
@@ -2934,7 +2938,7 @@ int wifi_get_setting(const char *ifname, rtw_wifi_setting_t *pSetting)
int ret = 0;
int mode = 0;
unsigned short security = 0;
unsigned int auth_type = 0;
u32 auth_type = 0;
memset(pSetting, 0, sizeof(rtw_wifi_setting_t));
if(wext_get_mode(ifname, &mode) < 0)

View File

@@ -1,8 +1,8 @@
#include "FreeRTOS.h"
#include "wifi_promisc.h"
#include "task.h"
#include "main.h"
#include "tcpip.h"
#include "wifi/wifi_conf.h"
#ifndef CONFIG_WLAN
#define CONFIG_WLAN 1
@@ -11,6 +11,19 @@
#if CONFIG_WLAN
#include <platform/platform_stdlib.h>
#ifdef CONFIG_PROMISC
#define _adapter void
#define recv_frame void
extern void _promisc_deinit(void *padapter);
extern int _promisc_recv_func(void *padapter, void *rframe);
extern int _promisc_set(rtw_rcr_level_t enabled, void (*callback)(unsigned char*, unsigned int, void*), unsigned char len_used);
extern unsigned char _is_promisc_enabled(void);
extern int _promisc_get_fixed_channel(void * fixed_bssid, u8 *ssid, int * ssid_length);
extern void _promisc_filter_by_ap_and_phone_mac(u8 enable, void *ap_mac, void *phone_mac);
#endif
// Add extra interfaces to make release sdk able to determine promisc API linking
void promisc_deinit(void *padapter)
{
@@ -132,7 +145,6 @@ struct inic_eth_frame {
static struct inic_eth_frame *inic_frame, *inic_frame_tail = NULL;
static int inic_frame_cnt = 0;
#define MAX_INIC_FRAME_NUM 50 //maximum packets for each channel
extern void inic_c2h_msg(const char *atcmd, char status, char *msg, u16 msg_len);
#endif
@@ -144,8 +156,6 @@ struct eth_buffer {
static struct eth_buffer eth_buffer;
#ifdef CONFIG_PROMISC
#define MAX_PACKET_FILTER_INFO 5
#define FILTER_ID_INIT_VALUE 10
rtw_packet_filter_info_t paff_array[MAX_PACKET_FILTER_INFO]={0, 0, 0, 0, 0};
static u8 packet_filter_enable_num = 0;

View File

@@ -0,0 +1,53 @@
#ifndef WIFI_PROMISC_H
#define WIFI_PROMISC_H
#include <platform/platform_stdlib.h>
#include "FreeRTOS.h"
#include "wifi/wifi_conf.h"
#ifdef __cplusplus
extern "C" {
#endif
// Promisc mode function declarations
void promisc_deinit(void *padapter);
int promisc_recv_func(void *padapter, void *rframe);
int promisc_recv_lens_func(void *padapter, u8 *payload, u8 plen);
int promisc_filter_retransmit_pkt(u8 enable, u8 filter_interval_ms);
int promisc_filter_with_len(u16 len);
int promisc_set(rtw_rcr_level_t enabled,
void (*callback)(unsigned char *, unsigned int, void *),
unsigned char len_used);
unsigned char is_promisc_enabled(void);
int promisc_get_fixed_channel(void *fixed_bssid, u8 *ssid, int *ssid_length);
void promisc_filter_by_ap_and_phone_mac(u8 enable, void *ap_mac,
void *phone_mac);
// Packet filter functions
#ifdef CONFIG_PROMISC
void promisc_init_packet_filter(void);
int promisc_add_packet_filter(u8 filter_id, rtw_packet_filter_pattern_t *patt,
rtw_packet_filter_rule_t rule);
int promisc_enable_packet_filter(u8 filter_id);
int promisc_disable_packet_filter(u8 filter_id);
int promisc_remove_packet_filter(u8 filter_id);
#endif
// Command function
void cmd_promisc(int argc, char **argv);
// Constants
#define MAX_PACKET_FILTER_INFO 5
#define FILTER_ID_INIT_VALUE 10
#ifdef CONFIG_INIC_CMD_RSP
// maximum packets for each channel
#define MAX_INIC_FRAME_NUM 50
#endif
#ifdef __cplusplus
}
#endif
#endif /* WIFI_PROMISC_H */

View File

@@ -13,6 +13,7 @@
#include "wifi_simple_config.h"
#include "wifi_conf.h"
#include "wifi_util.h"
#include "wifi_promisc.h"
#if CONFIG_EXAMPLE_UART_ATCMD || CONFIG_EXAMPLE_SPI_ATCMD
#include "at_cmd/atcmd_wifi.h"
@@ -97,7 +98,7 @@ struct ack_msg {
PACK_STRUCT_FIELD(u16_t device_type);
PACK_STRUCT_FIELD(u32_t device_ip);
PACK_STRUCT_FIELD(u8_t device_name[64]);
};PACK_STRUCT_STRUCT;
} PACK_STRUCT_STRUCT;
PACK_STRUCT_END
#ifdef PACK_STRUCT_USE_INCLUDES
#include "arch/epstruct.h"
@@ -299,7 +300,7 @@ int SC_send_simple_config_ack(u8 round)
}
#endif
printf("\nSending simple config ack\n");
FD_ZERO(&to_addr);
memset(&to_addr, 0, sizeof(struct sockaddr_in));
to_addr.sin_family = AF_INET;
to_addr.sin_port = htons(8864);
to_addr.sin_addr.s_addr = (backup_sc_ctx->ip_addr);
@@ -1022,19 +1023,19 @@ extern void rtk_sc_deinit(void);
void init_simple_config_lib_config(struct simple_config_lib_config* config)
{
config->free = rtw_mfree;
config->malloc = rtw_malloc;
config->memcmp = _memcmp;
config->memcpy = _memcpy;
config->memset = _memset;
config->free = (simple_config_free_fn)rtw_mfree;
config->malloc = (simple_config_malloc_fn)rtw_malloc;
config->memcmp = (simple_config_memcmp_fn)_memcmp;
config->memcpy = (simple_config_memcpy_fn)_memcpy;
config->memset = (simple_config_memset_fn)_memset;
config->printf = (simple_config_printf_fn)printf;
config->strcpy = _strcpy;
config->strlen = _strlen;
config->zmalloc = rtw_zmalloc;
config->strcpy = (simple_config_strcpy_fn)_strcpy;
config->strlen = (simple_config_strlen_fn)_strlen;
config->zmalloc = (simple_config_zmalloc_fn)rtw_zmalloc;
#if CONFIG_LWIP_LAYER
config->_ntohl = lwip_ntohl;
config->_ntohl = (simple_config_ntohl_fn)lwip_ntohl;
#else
config->_ntohl = _ntohl;
config->_ntohl = (simple_config_ntohl_fn)_ntohl;
#endif
config->is_promisc_callback_unlock = &is_promisc_callback_unlock;
}
@@ -1342,6 +1343,8 @@ static void init_promisc_scan_channel(unsigned char softAP_ch)
return;
}
extern void dhcps_deinit(void);
extern void dhcps_init(struct netif * pnetif);
static int SimpleConfig_softAP_start(const char* ap_name, const char *ap_password)
{
int timeout = 20;

View File

@@ -1400,6 +1400,7 @@ void wext_set_low_power_mode(__u8 enable)
}
#endif
extern int rltk_get_auto_chl(const char *ifname, unsigned char *channel_set, unsigned char channel_num);
int wext_get_auto_chl(const char *ifname, unsigned char *channel_set, unsigned char channel_num)
{
int ret = -1;
@@ -1411,11 +1412,13 @@ int wext_get_auto_chl(const char *ifname, unsigned char *channel_set, unsigned c
return ret;
}
extern int rltk_set_sta_num(unsigned char ap_sta_num);
int wext_set_sta_num(unsigned char ap_sta_num)
{
return rltk_set_sta_num(ap_sta_num);
}
extern int rltk_del_station(const char *ifname, unsigned char* hwaddr);
int wext_del_station(const char *ifname, unsigned char* hwaddr)
{
return rltk_del_station(ifname, hwaddr);
@@ -1506,13 +1509,15 @@ void wext_set_indicate_mgnt(int enable)
void wext_set_sigstat_fast_enable(int enable)
{
rtw_set_sigstat_fast_enable(enable);
// TODO: doesn't exist in lib_wlan
// rtw_set_sigstat_fast_enable(enable);
return;
}
void wext_set_lowrssi_use_b(int enable,int rssi)
{
rtw_set_lowrssi_use_b(enable,rssi);
// TODO: doesn't exist in lib_wlan
// rtw_set_lowrssi_use_b(enable,rssi);
return ;
}
#ifdef CONFIG_AP_MODE
@@ -1533,14 +1538,17 @@ void wext_suspend_softap_beacon(const char *ifname)
}
void wext_resume_softap(const char *ifname)
{
rltk_resume_softap(ifname);
// TODO: doesn't exist in lib_wlan
// rltk_resume_softap(ifname);
}
// extern int rtw_ap_switch_chl_and_inform(unsigned char new_channel);
int wext_ap_switch_chl_and_inform(unsigned char new_channel)
{
if(rtw_ap_switch_chl_and_inform(new_channel))
// TODO: doesn't exist in lib_wlan
// if(rtw_ap_switch_chl_and_inform(new_channel))
return RTW_SUCCESS;
else
return RTW_ERROR;
// else
// return RTW_ERROR;
}
#endif

View File

@@ -84,7 +84,15 @@ int wext_del_custom_ie(const char *ifname);
int wext_send_mgnt(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
int wext_send_eapol(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
int wext_set_gen_ie(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
int wext_get_drv_ability(const char *ifname, __u32 *ability);
int wext_enable_forwarding(const char *ifname);
int wext_disable_forwarding(const char *ifname);
int wext_set_ch_deauth(const char *ifname, __u8 enable);
void wext_set_sigstat_fast_enable(int enable);
void wext_stop_softap(const char *ifname);
void wext_suspend_softap(const char *ifname);
void wext_suspend_softap_beacon(const char *ifname);
void wext_resume_softap(const char *ifname);
int wext_ap_switch_chl_and_inform(unsigned char new_channel);
int wext_get_nhm_ratio_level(const char *ifname, __u32 *level);
int wext_get_retry_drop_num(const char *ifname, rtw_fw_retry_drop_t * retry);
@@ -107,6 +115,9 @@ __u8 wext_get_adaptivity_enable(const char *ifname);
int wext_set_adaptivity_mode(const char *ifname, __u8 mode);
__u8 wext_get_adaptivity_mode(const char *ifname);
__u8 wext_get_channel_plan(const char *ifname);
int wext_get_bcn_rssi(const char *ifname, int *rssi);
#ifdef __cplusplus
}
#endif