wpa_cli
두 가지 방법을 사용할 수 있습니다. 여기
는
대화 모드 :
$ wpa_cli -i wlan0
wpa_cli v2.1
Copyright (c) 2004-2014, Jouni Malinen <[email protected]> and contributors
This software may be distributed under the terms of the BSD license.
See README for more details.
Interactive mode
> status
wpa_state=INACTIVE
address=98:fc:11:d1:89:68
uuid=0cb62eb3-776e-55d2-a4f9-983cdd3e48d2
그리고 비 대화 형 모드 :
$ wpa_cli -i wlan0 status
wpa_state=INACTIVE
address=98:fc:11:d1:89:68
uuid=0cb62eb3-776e-55d2-a4f9-983cdd3e48d2
것 같다 당신은 대화 형 모드를 사용하는 경우, wpa_cli
ctrl_conn
및 mon_conn
을 모두 사용하십시오. ctrl_conn
은 명령을 전송하는 데 사용되며 mon_conn
은 이벤트를 가져 오는 데 사용됩니다 (즉, wpa_ctrl_attach()
을 통해 연결되는 이벤트).
비대화 형 모드를 사용하는 경우 wpa_cli
은 이벤트가 반환되지 않기 때문에 ctrl_conn
만 사용하십시오. 하나는이 질문에 대답 할 수있는 방법
/**
* wpa_ctrl_request - Send a command to wpa_supplicant/hostapd
* @ctrl: Control interface data from wpa_ctrl_open()
* @cmd: Command; usually, ASCII text, e.g., "PING"
* @cmd_len: Length of the cmd in bytes
* @reply: Buffer for the response
* @reply_len: Reply buffer length
* @msg_cb: Callback function for unsolicited messages or %NULL if not used
* Returns: 0 on success, -1 on error (send or receive failed), -2 on timeout
*
* This function is used to send commands to wpa_supplicant/hostapd. Received
* response will be written to reply and reply_len is set to the actual length
* of the reply. This function will block for up to two seconds while waiting
* for the reply. If unsolicited messages are received, the blocking time may
* be longer.
*
* msg_cb can be used to register a callback function that will be called for
* unsolicited messages received while waiting for the command response. These
* messages may be received if wpa_ctrl_request() is called at the same time as
* wpa_supplicant/hostapd is sending such a message. This can happen only if
* the program has used wpa_ctrl_attach() to register itself as a monitor for
* event messages. Alternatively to msg_cb, programs can register two control
* interface connections and use one of them for commands and the other one for
* receiving event messages, in other words, call wpa_ctrl_attach() only for
* the control interface connection that will be used for event messages.
*/
int wpa_ctrl_request(struct wpa_ctrl *ctrl, const char *cmd, size_t cmd_len,
char *reply, size_t *reply_len,
void (*msg_cb)(char *msg, size_t len));
출처
2014-09-25 10:50:52
jml
: 당신은 (그리고 나는 당신이 희망)을
wpa_supplicant
이벤트를 사용할 경우, 나는
wpa_ctrl_request()
comments concerning the msg_cb argument에서 설명한 바와 같이 두 개의 서로 다른 연결을 사용하는 것이 좋습니다 생각 ? http://stackoverflow.com/help/how-to-ask – Mali제목이 수정되었습니다. –