[問題] linux取得ssid

看板C_and_CPP (C/C++)作者 (臨界點)時間15年前 (2011/03/11 12:20), 編輯推噓1(102)
留言3則, 1人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) linux 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 如何用c/c++取得ssid的資訊 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) 補充說明(Supplement): 類似像取得ip address一樣,可以利用ioctl取得 struct ifreq ifr; ioctl(s, SIOCGIFADDR, (char *)&ifr) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.120.158.204

03/11 12:54, , 1F
你可以翻 iw 的source code ... 基本上是靠 libnl
03/11 12:54, 1F

03/11 12:55, , 2F
如果你不介意用 popen 去抓外部程式的 stdout 的話
03/11 12:55, 2F

03/11 12:56, , 3F
iw dev wlan0 link 的輸出結果比較省事 XDD
03/11 12:56, 3F
我本來想說,如果沒有現成的ioctl的話,就真的要靠stdout來做了 不過後來有在網路上找到get ssid的code http://www.vi1129.com/tag/ioctl/ 但我是include <iwlib.h>,謝謝~ ※ 編輯: watershed 來自: 59.120.158.204 (03/11 16:10) 如果沒有這份檔的話,還可以使用 #include <sys/ioctl.h> #include <sys/socket.h> #include <linux/wireless.h> ※ 編輯: watershed 來自: 59.120.158.204 (03/11 18:29)
文章代碼(AID): #1DUQCWCJ (C_and_CPP)
文章代碼(AID): #1DUQCWCJ (C_and_CPP)