yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame^] | 1 | /*
|
| 2 | Wifi Ä£¿é¹«¹²¹¤¾ßÍ·Îļþ
|
| 3 | */
|
| 4 |
|
| 5 | #ifndef WIFI_UTIL_H
|
| 6 | #define WIFI_UTIL_H
|
| 7 |
|
| 8 | #include <stdio.h>
|
| 9 | #include <errno.h>
|
| 10 | #include <string.h>
|
| 11 | #include <stdlib.h>
|
| 12 | #include <stdarg.h>
|
| 13 | #include <sys/types.h>
|
| 14 | #include <sys/ioctl.h>
|
| 15 | #include <sys/prctl.h>
|
| 16 | #include <pthread.h>
|
| 17 | #include <linux/netlink.h>
|
| 18 | #include <sys/inotify.h>
|
| 19 | #include <linux/rtc.h>
|
| 20 | #include <sys/stat.h>
|
| 21 | #include <fcntl.h>
|
| 22 | #include <netinet/in.h>
|
| 23 | #include <unistd.h>
|
| 24 | #include <sys/ipc.h>
|
| 25 | #include <sys/msg.h>
|
| 26 | #include <syslog.h>
|
| 27 | #include <signal.h>
|
| 28 | #include <sys/time.h>
|
| 29 | #include <time.h>
|
| 30 | #include "softap_api.h"
|
| 31 | #include "netotherapi.h"
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 | #define CASE_RETURN_STR(x) case x: return #x;
|
| 36 | // Useful macros..
|
| 37 | #define MIN( a, b ) ((a) < (b) ? (a) : (b))
|
| 38 | #define MAX( a, b ) ((a) < (b) ? (b) : (a))
|
| 39 | #define safe_free(x) do { if(x) {free(x); x=NULL;} } while(0)
|
| 40 | #define itoa(i,a,b) (((b) == 16) ? sprintf((a), "%x", (i)) : sprintf((a), "%d", (i)))
|
| 41 |
|
| 42 |
|
| 43 | enum {
|
| 44 | WIFI_CFG_OPEN, //´ò¿ªwifi
|
| 45 | WIFI_CFG_CLOSE, //¹Ø±Õwifi
|
| 46 | WIFI_CFG_OPEN_MSSID, //´ò¿ª¸±ssid
|
| 47 | WIFI_CFG_CLOSE_MSSID, //¹Ø±Õ¸±ssid
|
| 48 | WIFI_CFG_OPEN_VA0_VA1, //´ò¿ªÖ÷¸±ssid
|
| 49 | WIFI_CFG_RF, //ÅäÖÃÉ䯵²ÎÊý
|
| 50 | WIFI_CFG_AP, //ÅäÖÃAP
|
| 51 | WIFI_CFG_MSSID, //ÅäÖø±ssid
|
| 52 | WIFI_CFG_RESTART_APSTATION, //ÖØÆôap station
|
| 53 | WIFI_CFG_RESTART_AP, //ÖØÆôap
|
| 54 | WIFI_CFG_CLOSESTA_OPENMSSID, //¹Ø±Õstation£¬´ò¿ª¸±ssid
|
| 55 | WIFI_CFG_FORCE_RESTART, //Ç¿ÖÆÖØÆôwifi
|
| 56 | WIFI_CFG_SLEEP, //˯Ãß
|
| 57 | WIFI_CFG_CHANNEL_FOLLOW, //APÐŵÀ¸úËæSTA
|
| 58 | WIFI_CFG_APSTA_OPEN_AP, //apstaÁ¬½Ó³É¹¦´ò¿ªap
|
| 59 | };
|
| 60 |
|
| 61 | void wf_write_file (char* file, char* status);
|
| 62 | int wf_get_msg_qid (int module_id);
|
| 63 | int wf_create_msg_id (int module_id);
|
| 64 | void wf_ms_sleep (unsigned long mSec);
|
| 65 | int find_substr_num (char* str, char substr);
|
| 66 | int find_substr_num_for_acl (char* str, char substr);
|
| 67 | void write_status (char* file, const char* status);
|
| 68 | void wlan_write_file (char* file_path, char* param);
|
| 69 | int wf_create_msg_qid (int module_id);
|
| 70 | void wf_create_thread (void *thread_name, void * (*thread_loop) (void*));
|
| 71 | #define wf_err(fmt, args...) \
|
| 72 | do {slog(WIFI_PRINT,SLOG_ERR, "[wlan][%s-%d]: " fmt"\n", __FUNCTION__, __LINE__, ## args);} while (0)
|
| 73 |
|
| 74 |
|
| 75 | #define wf_log(fmt, args...) \
|
| 76 | do {slog(WIFI_PRINT,SLOG_ERR, "[wlan][%s-%d]: " fmt"\n", __FUNCTION__, __LINE__, ## args);} while (0)
|
| 77 |
|
| 78 | // do {wlog("[wlan][%s]: " fmt"\n", __FUNCTION__, ## args);} while (0)
|
| 79 | unsigned int deleteCharFromStr (char c, char* instr, char* outstr);
|
| 80 | void* safe_malloc (int size, unsigned char is_assert);
|
| 81 | void safe_strcpy (char* dest, char* source, int size);
|
| 82 | int wlan_readfile (const char *path, char * buf, int len);
|
| 83 | int wfsystem(const char * cmd);
|
| 84 | unsigned char s2x (char *s);
|
| 85 |
|
| 86 | int ensure_config_dir_exist(char * dir);
|
| 87 | int get_file_size (char * file);
|
| 88 |
|
| 89 | int ensure_file_exist(char * file);
|
| 90 | void write_lockfile (char *filepath, char *setbuf);
|
| 91 |
|
| 92 |
|
| 93 | int wf_msg_to_zcore(unsigned short msg_cmd, unsigned short datalen, unsigned char *pData);
|
| 94 | int wf_msg_to_mmi(unsigned short msg_cmd, unsigned short datalen, unsigned char *pData);
|
| 95 | int wf_msg_to_self(unsigned short msg_cmd, unsigned short datalen, unsigned char *pData);
|
| 96 | #ifdef __AP_FUNC__
|
| 97 | int wifi_aes_init_key(void);
|
| 98 | int wifi_encrypt_code(void);
|
| 99 | int wifi_decrypt_code(void);
|
| 100 | int wifi_decode_b2s(void);
|
| 101 | #endif
|
| 102 |
|
| 103 | #endif
|