현재 커밋된 WIFI API 리스트와 동작 방식에 대해 상세히 서술했다.
Version | Date | Comment | Author |
1.0 | 2013-6-11 | 최초 작성 | 시스템 소프트웨어3팀 김우종 선임연구원 |
1.1 | 2013-9-2 | 업데이트(수정된 함수 코드 반영 및 세부 동작 기술 추가) | 시스템 소프트웨어3팀 김우종 선임연구원 |
1.2 | 2013-10-29 | 업데이트(내용추가) | 시스템 소프트웨어3팀 김우종 선임연구원 |
본 문서는 IP 카메라 상에서 WIFI 기능을 사용하기 위해서 알아야 할 WIFI 동작과 이 때 실행되는 API 에 대한 설명을 기술하고 있다. 이 문서를 통해 WIFI 의 동작을 좀더 쉽게 이해할 수 있고 나아가서는 디버깅 및 기능 개선 하는데 소요되는 시간을 줄일 수 있을 것이라 기대한다.
소스코드와 API 함수 표기는 굴림 글꼴로 표시한다. 이 문서에 언급한 API 는 SVN 상의 최신 소스코드에 반영되어 있다.
내용 중 알아두면 편리한 참고 사항과 반드시 알아야 하는 중요 사항을 다음과 같이 표시한다.
<Note> | 내용 중 알아두면 편리한 각종 참고 사항 |
<Caution> | 내용 중 반드시 알아야 하는 중요한 사항 |
본 문서는 다음과 같은 약어를 사용한다.
Acronym | Description |
WIFI | Wi-Fi (Wireless Fidelity) is a trademark of the Wi-Fi Alliance that manufacturers may use to brand certified products that belong to a class of wireless local area network (WLAN) devices based on the IEEE 802.11 standards, which is by far the most widespread WLAN class today. |
SSID | Service Set Identifier. 무선랜을 통해 전송되는 패킷들의 각 헤더에 덧붙여지는 32 바이트 길이의 고유 식별자로서, 무선 장치들이 BSS(basic service set)에 접속할 때 인증키로 사용된다. SSID는 하나의 무선 랜을 다른 무선랜으로부터 구분해 주므로, 특정 무선랜에 접속하려는 모든 AP나 무선 장치들은 반드시 동일한 SSID를 사용해야만 한다. 특정 BSS의 고유한 SSID를 알지 못하는 그 어떠한 장치도 그 BSS 에 접속할 수 없다. SSID는 패킷 상에 포함된 평범한 텍스트 데이터이고, 충분히 스니핑 당할 가능성이 있기 때문에, 네트워크에 대해 어떠한 보증도 하지 않는다. |
RSSI | Received Signal Strength Indication. AP 에서부터 WIFI 칩셋까지의 라디오 주파수 신호세기를 의미한다. |
BSS | The basic service set (BSS) is a set of all stations that can communicate with each other. There are two types of BSS: Independent BSS (also referred to as IBSS), and infrastructure BSS. Every BSS has an identification (ID) called the BSSID, which is the MAC address of the access point servicing the BSS. An independent BSS (IBSS) is an ad-hoc network that contains no access points, which means they can not connect to any other basic service set. An infrastructure can communicate with other stations not in the same basic service set by communicating through access points. |
WEP | Wired Equivalent Privacy. 개인적인 데이터 프레임을 암호화하기 위한 표준이며, 최소한의 정보 보호를 제공하기 위해 만들어졌고 어느 정도 성공하고 있다. 하지만, 2001년 8월 공개적으로 해킹되어 더 이상 안전하지 않다. |
WPA | WIFI Protected Access. WIFI Alliance 의 감독하에 수행하는 인증 프로그램으로, WIFI Alliance 가 책정한 보안 프로토콜 네트워크 장비가 준수하고 있음을 나타내는 보안 프로토콜이다. WEP 의 취약점 때문에 대안으로 나왔다. |
WPA2 | 2세대 WPA 로서 보안 기능이 개선되었으며 AES 암호화, 사전 인증 및 PMKID 캐시로 구성된다. |
VID | Vendor ID. 제조 회사를 나타내며, 동일한 회사에서 나오는 디바이스들은 모두 동일한 VID 를 가진다. |
PID | Product ID. 각 제품별로 다른 PID 를 가진다. 다른 제품들과 겹치면 안되기 때문에 별도의 관리가 필요하다. 따라서 벤더마다 PID 규칙을 지정해서 사용한다. |
AP | Access Point. 흔히 유무선 공유기라도 불리며, 요즘에는 공유기 기능 외에 라우터, 방화벽 등의 기능도 함께 제공한다. 일반적으로 WIFI 는 하나의 AP 에 접속하여 외부와의 통신을 할 수 있다. |
TKIP | Temporal Key Integrity Protocol. 해싱 알고리즘을 사용하여 데이터 암호화 성능을 개선하고 키 재설정 방법을 포함하여 데이터 암호화 방법이 크게 개선되었다. |
AES | Advanced Encryption Standard. WPA, WPA2 의 필수 프로토콜인 TKIP 을 대체하기 위해 만들어진 IEEE 802.11i 암호화 프로토콜. WPA2 표준의 필수요소이며, WPA 표준의 선택적 요소이고, RSN 을 따르는 네트워크에 대해 요구되는 옵션이다. |
PSK | Pre Shared Key. 인증을 위해 서버를 사용하는 방식이 아닌, 클라이언트와 AP 간에 인증하는 방식이다. |
WPS | WIFI Protected Setup. 사용자가 일일이 비밀번호를 입력하는 번거로움 없이 AP에 접속할 수 있는 방법으로 AP의 버튼을 누르는 PBC 모드와 WIFI Dongle 의 PIN 숫자를 입력하는 PIN 모드가 있다. |
PBC | Push Button Configuration. WPS 접속 방식의 하나로, AP 에 붙어있는 버튼과 WIFI Dongle 에 달린 버튼을 누름으로써 이들 기기끼리 자동으로 접속되는 방법이다. |
Soft AP | 타겟이 AP에 접속하는 Station 으로 동작하는 것이 아니라, 마치 AP 처럼 주변의 다른 Station 에게 주기적으로 Beacon 메세지를 보내고, 그들이 타겟에 접속할 수도 있는 모드이다. |
DHCP | 접속한 AP 로부터 IP 주소를 포함한 네트워크 정보를 받기위해 사용하는 프로토콜. 받은 정보를 네트워크 인터페이스에 할당하고, 이를 바탕으로 외부와의 통신을 시도하게 된다. |
wpa_supplicant | 무선 인터페이스를 관리하는 미들웨어로서, WiFi 지원하는 거의 모든 기능을 이 프로그램을 통해 실행할 수 있다. Application layer 에서는 wpa_supplicant 을 통해, driver layer 의 정보를 주고 받을 수 있다. |
hostapd | Soft AP 모드로 동작 시, 이를 관리하는 미들웨어로서, Broadcom 모듈의 경우, 자체 미들웨어를 사용하지만, Realtek 모듈의 경우, 이를 사용한다. |
IP 카메라(S1 무선/지능형 카메라 기준)에서 요구되는 Spec 은 다음과 같다.
WiFi 는 크게 두가지 목적으로 사용된다.
첫번째, Setup(설치) 용도로 사용되는 데(즉, Factory 모드에서 실행), 이 경우, 일반적인 Station 모드가 아닌 Soft AP 로 동작하게 된다.
두번째, A/V 스트리밍 용도로 사용된다. 이때는 AP 에 접속하여 다른 디바이스(예를 들면 NVR 또는 PC)에 A/V 데이터를 전송한다.
카메라가 부팅하면, RC 스크립트(insmod.sh)에 의해 자동으로 WiFi 관련 커널 모듈이 로딩된다. Main Application(nmdhost) 이 실행하면서, Soft AP 모드 여부를 체크한다.
만일 Soft AP 모드이면, 'factory_mode.sh' 파일을 실행한다. Soft AP 모드가 아니면(즉 Station 모드이면), 'normal_mode.sh' 파일을 실행한다. 참고로 이 파일들은 파일시스템(/srv/wifi) 아래에 있다.
WiFi 모듈이 Broadcom 또는 Realtek 에 따라 동작 시퀀스가 약간 달라진다.
실행순서 | 시퀀스 | 설명 |
1 | insmod.sh 실행 | WiFi 드라이버 로딩 및 드라이버 설정 |
2 | factory_mode.sh 실행 | Soft AP 설정 및 동작 실행(wlarm), DHCP server 실행(dnsmasq), wpa_supplicant 실행 |
실행순서 | 시퀀스 | 설명 |
1 | normal_mode.sh 실행 | insmod.sh 실행, wpa_supplicant 실행 |
realtek 은 Soft AP 모드만 지원한다.
실행순서 | 시퀀스 | 설명 |
1 | insmod.sh 실행 | WiFi 드라이버 로딩 및 드라이버 설정 |
2 | factory_mode.sh 실행 | DHCP server 실행(dnsmasq), hostapd 실행 |
Station 모드이든, Soft AP 모드이든 위의 초기화 과정이 완료되면, API 를 호출하여 WIFI 기능을 사용할 수 있다.
wpa_supplicant 는 주기적으로 백그라운드 상태로 AP scan 을 하고, 이에 대한 결과값을 버퍼에 저장한다. 매번 스캔을 할때마다 버퍼는 갱신되고, 일정 시간이 지나면, 만료된다.
자동으로 bg(백그라운드) 스캔을 수행하기 때문에 AP scan 에 대한 오버헤드를 상당히 줄일 수 있다. 실제 Application layer 에서 스캔 실행 명령을 내리지 않더라도, 버퍼에 있는 결과값을 바로 반환해주면 되기 때문이다.
Application layer 로부터 접속할 AP 에 대한 정보를 입력받아, 접속을 시도한다. 이때 사용하는 API 는 암호 및 인증 방법과 비밀번호에 따라 구분하여 접속을 시도한다. 최종적으로는 wpa_supplication 에 접속 명령을 내림으로서 접속을 시도하게 된다.
접속시도를 한 뒤에 제대로 접속이 되었는지 여부를 확인한다. wpa_supplicant 가 가지고 있는 정보를 확인하여, 현재 접속 상태를 알 수 있다. 접속 여부에 따라, 이후 각각 서로 다른 동작을 하게 된다.
접속을 끊는다. 현재 접속된 상태에서 강제로 접속을 끊는다. wpa_supplication 에 접속 끊음 명령을 내린다.
API 와 그에 사용되는 Structure 에 대한 설명을 한다.
WIFI API 를 실행한 후 결과값을 저장하는 구조체. 이 값을 통해 원하는 대로 API 가 실행되었는지 여부를 판단한다.
typedef enum { WIFI_OK = 0, // 성공 WIFI_FAIL = -1 // 실패 }WIFI_STATUS_T;
AP 스캔의 결과값을 저장하는 구조체. Application layer 에서는 이 구조체를 이용해서 화면에 AP 리스트를 출력한다.
typedef struct { char ssid[APSCAN_NUM][64]; // SSID int rssi[APSCAN_NUM]; // 신호세기 char security[APSCAN_NUM][64]; // 보안 설정 int total_apnum; // 검색된 AP 갯수 }SCAN_AP_RESULT_T;
접속 상태 여부를 저장하는 구조체. 현재 접속 상태 정보를 알 수 있다.
typedef struct { int status; // 접속 상태 여부 char ssid[64]; // 접속한 AP 의 SSID int rssi; // 접속한 AP 의 신호세기 }WIFI_STATUS_INFO_T;
Description | AP Scan 결과값을 가져온다. 이때 숨겨진(Hidden) SSID 와 Ad-hoc 은 제외한다 |
Syntax | WIFI_STATUS_T WIFI_GetScanResult(SCAN_AP_RESULT_T *ap_scan_result) |
Parameters | ap_scan_result(OUT) - Copy to structure about AP Scan result |
Return Value | If the function succeeds, the return value is WIFI_OK. |
If the function fails, the return is WIFI_FAIL. | |
Remarks | WIFI 가 Initialization 된 이후에 호출가능하다. 저장되는 구조체에는 SSID, 보안인증 방식, 신호세기가 포함된다 |
See Also | |
Details | 호출되면, wpa_supplicant 가 가지고 있는 스캔 리스트를 파일에 저장한다. 이를 파싱하여 구조체에 복사하고, Application 쪽으로 넘겨준다 |
#define SCAN_FILE "/tmp/scan" #define APSCAN_NUM 32 WIFI_STATUS_T WIFI_GetScanResult(SCAN_AP_RESULT_T *ap_scan_result) { char *pointer; char *line; char tmp[256] = {0,}; int count = 0; int s_count = 0; int print_count = 0; int ret; char buf[256]; FILE *file; SCAN_AP_RESULT_T _g_ap_result; memset(&_g_ap_result, 0, sizeof(_g_ap_result)); memcpy(&_g_ap_result, ap_scan_result, sizeof(SCAN_AP_RESULT_T)); sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && /srv/wifi/bcm/supplicant/wpa_cli -i eth1 scan_result > %s", SCAN_FILE); ret = proxy_시스템(tmp, PROXY_TYPE_SYSTEM, 10); // 한글 주의 if(ret != 0) { printf("\nWIFI_GetScanResult error code : %d\n", WEXITSTATUS(ret)); return WIFI_FAIL; } file = fopen(SCAN_FILE, "r"); if (file == NULL) { printf("Can`t open scan file!\n"); return WIFI_FAIL; } line = fgets(buf, sizeof(buf), file); if(line == NULL) { printf("Scan_Fail!\n"); return WIFI_FAIL; } if (strncmp(line, "FAIL-BUSY", 9) == 0) { printf("Scan busy!!\n"); return WIFI_FAIL; } fclose(file); file = fopen(SCAN_FILE, "r"); if (file == NULL) { printf("Can`t open scan file!\n"); return WIFI_FAIL; } for (line = fgets(buf, sizeof(buf), file); line != NULL; line = fgets(buf, sizeof(buf), file)) { pointer = (char *)strtok(line, "\t"); if(strncmp(pointer, "-", 1) == 0) { continue; } strcpy(_g_ap_result.ssid[count], pointer); while ((pointer = (char *)strtok(NULL, "\t")) != NULL) { if (s_count == 0) { _g_ap_result.rssi[count] = atoi(pointer); } if (s_count == 1) { if(strstr(pointer, "WPA")) { strcpy(_g_ap_result.security[count], "WPA"); if(strstr(pointer, "WPA2")) { strcpy(_g_ap_result.security[count], "WPA/WPA2"); } } else if(strstr(pointer, "WEP")) { strcpy(_g_ap_result.security[count], "WEP"); } else { strcpy(_g_ap_result.security[count], "None"); } } s_count++; } s_count = 0; count++; if(count == APSCAN_NUM) break; } _g_ap_result.total_apnum = count; fclose(file); memcpy(ap_scan_result, &_g_ap_result, sizeof(SCAN_AP_RESULT_T)); return WIFI_OK; }
int ret=0; SCAN_AP_RESULT_T web_result; SCAN_AP_RESULT_T result; memset(&web_result, 0, sizeof(web_result)); ret = WIFI_GetScanResult(&web_result); if( ret < 0 ) { printf("ERR WIFI_GetScanResult fail!!!\n"); return WEBBASE_ERR_RET_INTERNAL; } result[0].apcnt = web_result.total_apnum;
Description | 현재 WiFi 접속 상태를 알고 싶을 때, 사용한다 |
Syntax | WIFI_STATUS_T WIFI_GetStatus(WIFI_STATUS_INFO_T *status) |
Parameters | status(OUT) - structure for WiFi status infomation |
Return Value | If the function succeeds, the return value is WIFI_OK. |
If the function fails, the return is WIFI_FAIL. | |
Remarks | WIFI Driver 가 Initial 된 이후에 호출가능하며, 상태 정보(AP 접속여부, 접속된 AP 의 SSID, 접속된 AP 와의 RSSI)를 반환해준다 |
See Also | |
Details | wpa_supplicant 에 접속 상태 결과를 파일에 저장한다. 이를 파싱하여 구조체에 복사하고, 접속되어 있는 경우, wlarm 에 신호세기 값을 파일에 저장하고, 이를 파싱하여 구조체에 복사하고, Application 으로 넘긴다 |
#define STATUS_FILE "/tmp/status" #define RSSI_FILE "/tmp/rssi" WIFI_STATUS_T WIFI_GetStatus(WIFI_STATUS_INFO_T *status) { char buf[256]; char buf2[256]; char tmp[256] = {0,}; char * line; char * line2; int ret; FILE *file; FILE *file2; WIFI_STATUS_INFO_T t_status; memset(&t_status, 0, sizeof(t_status)); memcpy(&t_status, status, sizeof(WIFI_STATUS_INFO_T)); sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && /srv/wifi/bcm/supplicant/wpa_cli -i eth1 status > %s", STATUS_FILE); ret = proxy_시스템(tmp, PROXY_TYPE_SYSTEM, 10); // 한글 주의 if(ret != 0) { printf("\nWIFI_GetStatus error code : %d\n", WEXITSTATUS(ret)); return WIFI_FAIL; } file = fopen(STATUS_FILE, "r"); if (file == NULL) { printf("Can`t open status file!\n"); return WIFI_FAIL; } line = fgets(buf, sizeof(buf), file); if (line == NULL) { printf("Read fail status file!\n"); return WIFI_FAIL; } if (strncmp(line, "COMPLETED", 9) == 0) { t_status.status = 1; //printf("Connection!!\n"); line = fgets(buf, sizeof(buf), file); //printf("SSID = %s\n", line); memcpy(t_status.ssid, line, sizeof(t_status.ssid)); sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && /srv/wifi/bcm/wlarm rssi > %s", RSSI_FILE); ret = proxy_시스템(tmp, PROXY_TYPE_SYSTEM, 10); // 한글 주의 if(ret != 0) { printf("\nWIFI_GetStatus error code : %d\n", WEXITSTATUS(ret)); fclose(file); return WIFI_FAIL; } file2 = fopen(RSSI_FILE, "r"); if (file2 == NULL) { printf("Can`t open rssi file!\n"); fclose(file); return WIFI_FAIL; } line2 = fgets(buf2, sizeof(buf2), file2); if (line2 == NULL) { printf("Read fail rssi file!\n"); return WIFI_FAIL; } t_status.rssi = atoi(line2); fclose(file2); } else { printf("Not Connection!!\r\n"); t_status.status = 0; } fclose(file); memcpy(status, &t_status, sizeof(WIFI_STATUS_INFO_T)); return WIFI_OK; }
WIFI_STATUS_INFO_T web_status_info; memset(&web_status_info, 0, sizeof(web_status_info)); ret = WIFI_GetStatus(&web_status_info); if( ret < 0 ) { return WEBBASE_ERR_RET_INTERNAL; } strncpy(result.ssid, web_status_info.ssid, sizeof(web_status_info.ssid)); result.status = web_status_info.status; result.rssi = web_status_info.rssi;
항목 | 설명 | 비고 |
Description | 특수문자가 들어있는 SSID 와 패스워드를 파싱하여 처리한다 | |
Syntax | gint WIFI_CheckInfo(char* ssid, char* key) | |
Parameters | ssid(IN) - SSID of connect AP`s | 최대 32 글자(영어,숫자,한글) |
key(IN) - password of connect AP`s | 최대 64 글자(영어,숫자,한글) | |
Return Value | 특수문자의 포함여부를 판단하는 check 변수의 값을 반환한다 | |
Remarks | “ 나 ` 나 $ 가 포함된 문자열의 경우, 차후 별도의 처리를 위해 check 변수에 1을 저장한다 | |
See Also | ||
Details | 특수문자가 들어있는 SSID 와 패스워드의 경우, 차후 별도의 처리를 위해 이를 구분한다 |
gint WIFI_CheckInfo(char* ssid, char* key) { int check = 0; if(strstr(ssid, "\"")) { // printf("special info\n"); check = 1; return check; } else { if(strstr(key, "\"")) { // printf("special info\n"); check = 1; return check; } // printf("this no have \"\n"); } if(strstr(ssid, "`")) { // printf("special info\n"); check = 1; return check; } else { if(strstr(key, "`")) { // printf("special info\n"); check = 1; return check; } // printf("this no have `\n"); } if(strstr(ssid, "$")) { // printf("special info\n"); check = 1; return check; } else { if(strstr(key, "$")) { // printf("special info\n"); check = 1; return check; } // printf("this no have $\n"); } return check; }
char tmp[256] = {0,}; int ret=0; int special=0; if(wifion == 0) return WIFI_FAIL; special = WIFI_CheckInfo(ssid, key); // 호출 if(auth == 0) // NONE { printf("\n!!!!!!!!! NONE !!!!!!!!!!\n"); if(special == 1) { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && echo \'\"%s\"\' > /tmp/.1st && /srv/wifi/bcm/supplicant/s-none", ssid); } else { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && /srv/wifi/bcm/supplicant/w-none \"%s\"", ssid); } ret = proxy_시스템(tmp, PROXY_TYPE_SYSTEM, 10); // 한글주의 } ...
항목 | 설명 | 비고 | |
Description | 입력받은 인자를 이용해서 AP 접속을 시도한다 | ||
Syntax | WIFI_STATUS_T WIFI_SetConnection(int wifion, char* ssid, int auth, char* key, int wep_encrypt, int wep_input, int wep_keynum) | ||
Parameters | wifion(IN) - enable or disable WiFi function | 1(=enable), 0(=disable) | |
ssid(IN) - SSID of connect AP`s | 최대 32 글자(영어,숫자,한글) | ||
auth(IN) - security of connect AP`s | 0(=none), 1(=wep-open), 2(=wep-shared), 3(=wpa | wpa2) | |
key(IN) - password of connect AP`s | 최대 64 글자(영어,숫자,한글) | ||
wep_encrypt(IN) - encryption in WEP of connect AP`s | |||
wep_input(IN) - input type in WEP of connect AP`s | 0(=string), 1(=hex) | ||
wep_keynum(IN) - key number in WEP of connect AP`s | 0~3 | ||
Return Value | If the function succeeds, the return value is WIFI_OK. | ||
If the function fails, the return is WIFI_FAIL. | |||
Remarks | 보안 인증 방식에 따라 서로다른 스크립트를 실행한다 | ||
See Also | |||
Details | 인증 방식에 따라, 다른 명령어로 wpa_supplicant 에 명령을 내린다. 특수 문자가 포함된 SSID 의 경우, 별도의 처리를 가한 후 명령을 내리게 된다 |
입력되는 인자들은 사전에 정의된 DB 에 저장된 값들인데, 아래와 같이 사전 정의되어 있다. 파일은 include/nf_sysdb_convert_table.h 이다.
{"net.wifi.apmode" , SYSDB_TYPE_BOOL, 0, 0}, {"net.wifi.wifion" , SYSDB_TYPE_BOOL, 0, 0}, {"net.wifi.ssid" , SYSDB_TYPE_STRING, 0, 0}, {"net.wifi.auth" , SYSDB_TYPE_UINT, 0, 0}, {"net.wifi.key" , SYSDB_TYPE_STRING, 0, 0}, {"net.wifi.wep_encrypt" , SYSDB_TYPE_UINT, 0, 0}, {"net.wifi.wep_input" , SYSDB_TYPE_UINT, 0, 0}, {"net.wifi.wep_keynum" , SYSDB_TYPE_UINT, 0, 0}, {"net.wifi.wep_key1" , SYSDB_TYPE_STRING, 0, 0}, {"net.wifi.wep_key2" , SYSDB_TYPE_STRING, 0, 0}, {"net.wifi.wep_key3" , SYSDB_TYPE_STRING, 0, 0}, {"net.wifi.wep_key4" , SYSDB_TYPE_STRING, 0, 0}, // 항목이름, 데이터 타입, 초기값, 인덱스값, 길이
WIFI_STATUS_T WIFI_SetConnection(int wifion, char* ssid, int auth, char* key, int wep_encrypt, int wep_input, int wep_keynum) { char tmp[256] = {0,}; int ret=0; int special=0; if(wifion == 0) return WIFI_FAIL; special = WIFI_CheckInfo(ssid, key); if(auth == 0) // NONE { printf("\n!!!!!!!!! NONE !!!!!!!!!!\n"); if(special == 1) { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && echo \'\"%s\"\' > /tmp/.1st && /srv/wifi/bcm/supplicant/s-none", ssid); } else { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && /srv/wifi/bcm/supplicant/w-none \"%s\"", ssid); } ret = proxy_시스템(tmp, PROXY_TYPE_SYSTEM, 10); // 한글 주의 } else if(auth == 1) // WEP-OPEN { if(wep_input == 0 ) // String { printf("\n!!!!!!!!! WEP-OPEN-STRING !!!!!!!!!! [%s] [%s] [%d] \n", ssid, key, wep_keynum); if(special == 1) { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && echo \'\"%s\"\' \'\"%s\"\' %d > /tmp/.1st && /srv/wifi/bcm/supplicant/s-wep-open-string", ssid, key, wep_keynum); } else { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && /srv/wifi/bcm/supplicant/w-wep-open-string \"%s\" \"%s\" %d", ssid, key, wep_keynum); } } else if(wep_input == 1) // HEX { printf("\n!!!!!!!!! WEP-OPEN-HEX !!!!!!!!!! [%s] [%s] [%d] \n", ssid, key, wep_keynum); if(special == 1) { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && echo \'\"%s\"\' \'\"%s\"\' %d > /tmp/.1st && /srv/wifi/bcm/supplicant/s-wep-open-hex", ssid, key, wep_keynum); } else { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && /srv/wifi/bcm/supplicant/w-wep-open-hex \"%s\" \"%s\" %d", ssid, key, wep_keynum); } } ret = proxy_시스템(tmp, PROXY_TYPE_SYSTEM, 10); // 한글 주의 } else if(auth == 2) // WEP-SHARED { if(wep_input == 0) // String { printf("\n!!!!!!!!! WEP-SHARED-STRING !!!!!!!!!!\n"); if(special == 1) { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && echo \'\"%s\"\' \'\"%s\"\' %d > /tmp/.1st && /srv/wifi/bcm/supplicant/s-wep-shared-string", ssid, key, wep_keynum); } else { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && /srv/wifi/bcm/supplicant/w-wep-shared-string \"%s\" \"%s\" %d", ssid, key, wep_keynum); } } else if(wep_input == 1) // HEX { printf("\n!!!!!!!!! WEP-SHARED-HEX !!!!!!!!!!\n"); if(special == 1) { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && echo \'\"%s\"\' \'\"%s\"\' %d > /tmp/.1st && /srv/wifi/bcm/supplicant/s-wep-shared-hex", ssid, key, wep_keynum); } else { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && /srv/wifi/bcm/supplicant/w-wep-shared-hex \"%s\" \"%s\" %d", ssid, key, wep_keynum); } } ret = proxy_시스템(tmp, PROXY_TYPE_SYSTEM, 10); // 한글 주의 } else if(auth > 2) // WPA, WPA2 { printf("\n!!!!!!!!! WPA/WPA2 !!!!!!!!!!\n"); if(special == 1) { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && echo \'\"%s\"\' \'\"%s\"\' > /tmp/.1st && /srv/wifi/bcm/supplicant/s-wpa", ssid, key); } else { sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && /srv/wifi/bcm/supplicant/w-wpa \"%s\" \"%s\"", ssid, key); } ret = proxy_시스템(tmp, PROXY_TYPE_SYSTEM, 10); // 한글 주의 } if(ret != 0) { printf("\nWIFI_SetConnection error code : %d\n", WEXITSTATUS(ret)); return WIFI_FAIL; } first_led_set_wifi = 1; nf_set_net_stat_led(NET_STAT_WIFI_CONNECTING); return WIFI_OK; }
wifion = 1; ssid = "itx"; auth = 1; key = "xxxxx"; wep_encrypt = 0; wep_input = 0; wep_keynum = 0; ret = WIFI_SetConnection(wifion, ssid, auth, key, wep_encrypt, wep_input, wep_keynum); if( ret < 0 ) { return WEBBASE_ERR_RET_INTERNAL; }
Description | AP 접속을 해제한다 |
Syntax | WIFI_STATUS_T WIFI_DisConnection(void) |
Parameters | None |
Return Value | If the function succeeds, the return value is WIFI_OK. |
If the function fails, the return is WIFI_FAIL. | |
Remarks | 연결된 AP 접속을 해제한다 |
See Also |
WIFI_STATUS_T WIFI_DisConnection(void) { char tmp[256] = {0,}; int ret; sprintf(tmp, "/sbin/ifconfig eth1 > /dev/null && /srv/wifi/bcm/supplicant/wpa_cli disconnect"); ret = proxy_시스템(tmp, PROXY_TYPE_SYSTEM, CMD_RUN); // 한글 주의 if(ret != 0) { printf("\nWIFI_DisConnection error code : %d\n", WEXITSTATUS(ret)); return WIFI_FAIL; } return WIFI_OK; }
int ret=0; ret = WIFI_DisConnection(); if( ret < 0 ) { return WEBBASE_ERR_RET_INTERNAL; }
Description | WPS 접속을 시도한다 |
Syntax | WIFI_STATUS_T WIFI_WPS_Connection(void) |
Parameters | None |
Return Value | If the function succeeds, the return value is WIFI_OK. |
If the function fails, the return is WIFI_FAIL. | |
Remarks | 일정한 기간(2분)동안 WPS 접속을 시도한다. 별도의 프로세스로 동작하며, 동작 후, 자동으로 종료된다 |
See Also |
WIFI_STATUS_T WIFI_WPS_Connection(void) { char tmp[256] = {0,}; int ret; sprintf(tmp, "/srv/wifi/bcm/wpsenr -if eth1 -pb &"); ret = proxy_시스템(tmp, PROXY_TYPE_SYSTEM, CMD_RUN); // 한글 주의 if(ret != 0) { printf("\nWIFI_WPS_Connection error code : %d\n", WEXITSTATUS(ret)); return WIFI_FAIL; } return WIFI_OK; }
int ret=0; ret = WIFI_WPS_Connection(); if( ret < 0 ) { return WEBBASE_ERR_RET_INTERNAL; }
Description | WPS 접속 정보를 얻는다 |
Syntax | WIFI_STATUS_T WIFI_WPS_ConnectionInfo(WIFI_WPS_INFO_T *wpsinfo) |
Parameters | wpsinfo(OUT) - copy to structure about WPS connect information |
Return Value | If the function succeeds, the return value is WIFI_OK. |
If the function fails, the return is WIFI_FAIL. | |
Remarks | WPS 로 접속 후에 호출된다. 접속된 정보(SSID, 암호, 보안)를 얻어 DB 에 저장한다 |
See Also |
WIFI_STATUS_T WIFI_WPS_ConnectionInfo(WIFI_WPS_INFO_T *wpsinfo) { char buf[256]; char *line; char *token; int count = 0; FILE *file; WIFI_WPS_INFO_T test; memset(&test, 0, sizeof(test)); memcpy(&test, wpsinfo, sizeof(WIFI_WPS_INFO_T)); file = fopen("/tmp/wpsinfo", "r"); if(file == NULL) { printf("can not read file!!\n"); } line = fgets(buf, sizeof(buf), file); fclose(file); token = (char *)strtok(line, " "); test.auth = atoi(token); while((token = (char *)strtok(NULL, " ")) != NULL) { if(count == 0) { strcpy(test.ssid, token); } if(count == 1) { if(test.auth == 1) break; strcpy(test.key, token); } count++; } memcpy(wpsinfo, &test, sizeof(WIFI_WPS_INFO_T)); }
int ret = 0; WIFI_WPS_Connection(); WIFI_WPS_INFO_T aaa; memset(&aaa, 0, sizeof(aaa)); ret = WIFI_WPS_ConnectionInfo(&aaa); if( ret < 0 ) { return WEBBASE_ERR_RET_INTERNAL; } printf("SSID : %s\n Security : %d\n KEY : %s\n", aaa.ssid, aaa.auth, aaa.key);
현재 주석처리되어 있다. 사용하기 위해서는 nmd_host/include/nf_util_netif.h 과 nmd_host/sysman/nf_util_netif.c 의 해당 부분을 주석해제하면 된다.