SlideShare a Scribd company logo
Wpa_supplicant
Introduction
shengjhih@gmail.com
2016/03/20
Outline
● Wha is Wpa_supplicant
● Usage
● Initialization Flow
● cfg80211 and libnl
● Layer 2 Packet Sniffing
● Event Loop
What is Wpa_supplicant
● From Wiki page: wpa_supplicant
● wpa_supplicant is widely used in Linux distributions and Android!
● These slides are based on 2.6-devel
wpa_supplicant is a free software implementation of an IEEE 802.11i supplicant for Linux,
FreeBSD, NetBSD, QNX, AROS, Microsoft Windows, Solaris, OS/2 (including eComStation) and
Haiku. In addition to being a fully featured WPA2 supplicant, it also implements WPA and older
wireless LAN security protocols. Features include:
● WPA and full IEEE 802.11i/RSN/WPA2
● WPA-PSK and WPA2-PSK ("WPA-Personal", pre-shared key)
● WPA with EAP ("WPA-Enterprise", for example with RADIUS authentication server)
● key management for CCMP, TKIP, WEP (both 104/128- and 40/64-bit)
● RSN: PMKSA caching, pre-authentication
● IEEE 802.11r
● IEEE 802.11w
● Wi-Fi Protected Setup (WPS)
Usage
● wpa_supplicant
○ -D: driver type, cfg80211 or wext
○ -B: run as a daemon
○ -b: the bridge interface
○ -c: configure file path
○ -C: control interface
○ -d: decrease debug level (show more log)
○ -e: entropy file
○ -f: debug log file
○ -g: global control interface (ctrl_interface)
○ -G: the ctrl_interface will set to be owned by the specified group
○ -h: show usage
○ -i: interface
○ -I: another configuration file
○ -K: show key in debug log
Usage
● wpa_supplicant
○ -L: show license
○ -m: p2p device configuration file
○ -o: override driver option
○ -O: override control interface option
○ -p: driver parameter
○ -P: PID file
○ -q: increase debug level (show less log)
○ -s: use syslog
○ -T: use Linux Tracing
○ -t: add timestamp in debug log
○ -u: dbus control interface
○ -v: show wpa_supplicant version
○ -W: defer the main event loop until first external program attaches wpa_supplicant
○ -N: combine multiple interface parameters
cfg80211
wpa_supplicant, hostapd, iw,
...
nl80211
libnl, libnl-genl
mac80211
User Space
Kernel Space
wireless driver
wireless device
Physical HW
Architechture
Initialization Flow
1. wpa_supplicant_init()
2. Add each interface via wpa_supplicant_add_iface()
3. Run event loop via wpa_supplicant_run()
Init Step 1: wpa_supplicant_init()
1. Init debug log setting
a. If specified to dump log to file via -f parameter, then initialize the output file via
wpa_debug_open_file(). Otherwise, initialize the standard output for debug log via
wpa_debug_setup_stdout()
b. If specified to dump log to syslog via -s parameter, then initialize syslog setting via
wpa_debug_open_syslog()
c. If specified to dump log by Linux Tracing via -T parameter, then initialize the setting via
wpa_debug_open_linux_tracing()
2. Initialize EAP methods via eap_register_methods()
3. Initialize global ctrl_interface via wpa_supplicant_global_ctrl_iface_init()
a. Open socket for the ctrl_interface
b. Set the group permission if the group is specified by -G parameters
c. Register ctrl_interface reader socket via eloop_register_read_sock()
Init Step 1: wpa_supplicant_init()
4. Initialize dbus via wpas_notify_supplicant_initialized()
5. Check global driver list wpa_drivers
6. Register a period timeout (10s) function wpas_periodic to:
a. P2P: check whether P2P peers expired via p2p_expire_peers()
b. STA: flush expired bss via wpa_bss_flush_by_age()
c. AP: check whether the acl is expired via ap_periodic()
Init Step 2: wpa_supplicant_add_iface()
1. Allocate wpa_supplicant structure fo each interface
2. If the override driver option is set by -o parameter, override the driver
specified by -D parameter
3. If the override ctrl_interface option is set by -O parameter, override the
ctrl_interface specified by -C parameter
4. wpa_supplicant_init_iface()
a. Read configuration file via wpa_config_read if the file is specified by -c parameter; if not
specified, make default configrations
b. Read another configuration file vi wpa_config_read if the file is specified by -I parameter
c. If ctrl_interface and driver_param are specified by configuration file and comman line
parameter, use the one specified by command line
Init Step 2: wpa_supplicant_add_iface()
5. wpas_init_driver()
a. Set the driver (e.g. cfg80211 driver)
b. Initialize driver via wpa_drv_init()
c. Setup driver parameter via wpa_drv_set_param() if specified by -p parameter
d. Add the interface into the wpa_s->radio_list via radio_add_interface()
6. Initialize wpa context via wpa_supplicant_init_wpa()
7. Initialize hw feature to wpa_s->hw.modes via
wpa_drv_get_hw_feature_data()
8. Get and setup driver capability via wpa_drv_get_capa()
9. etup bridge or trigger scan via wpa_supplicant_driver_init()
10. If the interface is not P2P device, initialize TDLS via wpa_tdls_init()
11. Set country via wpa_drv_set_country()
Init Step 2: wpa_supplicant_add_iface()
12. Initialize WPS via wpas_wps_init()
13. Initialize EAPOL via wpa_supplicant_init_eapol()
14. Initialize the ctrl_iface of the interface via wpa_supplicant_ctrl_iface_init()
15. Initialize GAS query via gas_query_init()
16. Initialize P2P via wpas_p2p_init(), if the interface support P2P devic
operations
17. Set WOW settings via wpas_set_wowlan_triggers()
18. If support P2P device, try to add P2P device interface via
wpas_p2p_add_p2pdev_interface()
Init Step 3: wpa_supplicant_run()
1. If -B parameter is assigned, run wpa_supplicant as daemon via
wpa_supplicant_daemon
2. If -W parameter is assigned, start the event loop after external program
starting to attach wpa_supplicant via wpa_supplicant_ctrl_iface_wait()
3. Register terminal signal SIGINT and SIGTERM handler via
eloop_register_signal_terminate
4. Register SIGHUP as reconfig signal via eloop_register_signal_reconfig()
5. Start event loop via eloop_run()
cfg80211 and libnl
What is cfg80211 and libnl
● cfg80211 is a configuration system in Linux kernel for manipulating
802.11 devices
● libnl is the bridge for user space and kernel space to interact with each
other during manipulating 802.11 devices
● nl80211 in kernel registers the generic netlink(nl) family “nl80211”
● wpa_supplicant in userspace calls libnl APIs to communicate with kernel
generic nl family “nl80211”
Wpa_supplicant to kernel cf80211 via linbl
1. Initialize netlink connection via netlink_init()
2. Initialize the connection to kernel nl80211 via
wpa_driver_nl80211_init_nl_global()
a. Allocate nl handler via global->nl = nl_create_handle(global->nl_cb, "nl");
b. Resolve nl80211 via global->nl80211_id = genl_ctrl_resolve(global->nl, "nl80211");
c. Allocate event handler via global->nl_event = nl_create_handle(global->nl_cb, "event");
d. Add global->nl_event to “mlme”, “scan”, “regulatory”, “vendor” groups via:
i. ret = nl_get_multicast_id(global, "nl80211", "mlme");
ii. ret = nl_socket_add_membership(global->nl_event, ret);
e. Assign the global event handler via:
i. nl_cb_set(global->nl_cb, NL_CB_VALID, NL_CB_CUSTOM, process_global_event,
global);
f. Assign “mlme”, “scan”, “regulatory”, “vendor” event handler via:
i. nl80211_register_eloop_read(&global->nl_event, wpa_driver_nl80211_event_receive,
Layer 2 Packet Sniffing
Why Need to Access Layer 2 Packets
● To maintain the state machine of specified functions (e.g. TDLS),
wpa_supplicant needs to access layer 2(l2) packets
○ e.g. TDLS, many action frames are encapulated in layer 2 packets
Take TDLS as Example
1. wpa_supplicant calls l2_packet_init() to initialize the connection to l2 and
monitor the specified l2 packets
a. Assign the rx_callback (wpa_supplicant_rx_tdls())function for specified protocol
b. Assign the rx handle function l2_packet_receive() which will invoke the rx_callback
int wpa_tdls_init(struct wpa_sm *sm)
{
if (sm == NULL)
return -1;
sm->l2_tdls = l2_packet_init(sm->bridge_ifname ? sm->bridge_ifname :
sm->ifname,
sm->own_addr,
ETH_P_80211_ENCAP, wpa_supplicant_rx_tdls,
sm, 0);
if (sm->l2_tdls == NULL) {
wpa_printf(MSG_ERROR, "TDLS: Failed to open l2_packet "
"connection");
return -1;
}
...
Event Loop
eloop_init()
● Initialize eloop.timeout list
● Initialize eloop.reader, eloop.writer, eloop.exception
eloop_run()
● eloop keeps running is eloop.terminate is not set or any count of eloop.
reader, eloop.writer, eloop.exception is not zero
● During the while loop
○ Get first timout event in eloop.timeout list and calculate the remianing time to reach the
timeout
○ Call select() to wait for coming reader, writer, exception events
○ Call eloop_process_pending_signals() to process pending signal by calling their handlers
○ Get first timout event in eloop.timeout list, if the timeout fired, call the handler to process
the timeout event
○ If reader, writer, exception socekts are changed, skip previous select() results
○ Call eloop_sock_table_dispatch() to handle all the set reader, writer, exceptions events
Reader, Writer, Exceptions Event Sources
● Reader event source
○ ctrl_iface connection
○ netlink connection between wpa_supplicant and nl80211
○ EAPOL Tx status in wpa_driver_nl80211_drv_init()
○ EAPOL socket in i802_init()
○ Socket for Monitor mode
○ …
● Writer event source
○ Dbus watch
○ http client
● Exception event source
○ Dbus watch
Reference
● https://en.wikipedia.org/wiki/Wpa_supplicant
● https://w1.fi/wpa_supplicant/
● https://w1.fi/wpa_supplicant/devel/
● https://wireless.wiki.kernel.org/
● http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git
● https://www.infradead.org/~tgr/libnl/

More Related Content

What's hot

Cilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDPCilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDP
Thomas Graf
 
VLANs in the Linux Kernel
VLANs in the Linux KernelVLANs in the Linux Kernel
VLANs in the Linux Kernel
Kernel TLV
 
OpenVirtex (OVX) Tutorial
OpenVirtex (OVX) TutorialOpenVirtex (OVX) Tutorial
OpenVirtex (OVX) Tutorial
동호 손
 
OpenWrt From Top to Bottom
OpenWrt From Top to BottomOpenWrt From Top to Bottom
OpenWrt From Top to Bottom
Kernel TLV
 
ACI MultiPod Config Guide
ACI MultiPod Config GuideACI MultiPod Config Guide
ACI MultiPod Config Guide
Woo Hyung Choi
 
Project calico - introduction
Project calico - introductionProject calico - introduction
Project calico - introduction
Hazzim Anaya
 
Integration of OVS in OpenWrt wireless network and investigation of SDWMN
Integration of OVS in OpenWrt wireless network and investigation of SDWMNIntegration of OVS in OpenWrt wireless network and investigation of SDWMN
Integration of OVS in OpenWrt wireless network and investigation of SDWMN
Nazmul Hossain Rakib
 
Faster packet processing in Linux: XDP
Faster packet processing in Linux: XDPFaster packet processing in Linux: XDP
Faster packet processing in Linux: XDP
Daniel T. Lee
 
Next Generation Nexus 9000 Architecture
Next Generation Nexus 9000 ArchitectureNext Generation Nexus 9000 Architecture
Next Generation Nexus 9000 Architecture
Cisco Canada
 
Mikrotik Bridge Deep Dive
Mikrotik Bridge Deep DiveMikrotik Bridge Deep Dive
Mikrotik Bridge Deep Dive
GLC Networks
 
LTE: X2 interface
LTE: X2 interfaceLTE: X2 interface
LTE: X2 interface
Schwannden Kuo
 
Accelerating Envoy and Istio with Cilium and the Linux Kernel
Accelerating Envoy and Istio with Cilium and the Linux KernelAccelerating Envoy and Istio with Cilium and the Linux Kernel
Accelerating Envoy and Istio with Cilium and the Linux Kernel
Thomas Graf
 
SRAN18 configurations.pdf
SRAN18 configurations.pdfSRAN18 configurations.pdf
SRAN18 configurations.pdf
VSBunroath
 
DevConf 2014 Kernel Networking Walkthrough
DevConf 2014   Kernel Networking WalkthroughDevConf 2014   Kernel Networking Walkthrough
DevConf 2014 Kernel Networking Walkthrough
Thomas Graf
 
6lowpan 110828234426-phpapp01
6lowpan 110828234426-phpapp016lowpan 110828234426-phpapp01
6lowpan 110828234426-phpapp01
mrmr2010i
 
Campus_Network_Design_with_ArubaOS-CX_-_Leading_Practices
Campus_Network_Design_with_ArubaOS-CX_-_Leading_PracticesCampus_Network_Design_with_ArubaOS-CX_-_Leading_Practices
Campus_Network_Design_with_ArubaOS-CX_-_Leading_Practices
RoanVillalobos1
 
Linux Internals - Part II
Linux Internals - Part IILinux Internals - Part II
Linux Internals - Part II
Emertxe Information Technologies Pvt Ltd
 
MTCNA
MTCNAMTCNA
Docker Networking: Control plane and Data plane
Docker Networking: Control plane and Data planeDocker Networking: Control plane and Data plane
Docker Networking: Control plane and Data plane
Docker, Inc.
 
Linux Linux Traffic Control
Linux Linux Traffic ControlLinux Linux Traffic Control
Linux Linux Traffic Control
SUSE Labs Taipei
 

What's hot (20)

Cilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDPCilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDP
 
VLANs in the Linux Kernel
VLANs in the Linux KernelVLANs in the Linux Kernel
VLANs in the Linux Kernel
 
OpenVirtex (OVX) Tutorial
OpenVirtex (OVX) TutorialOpenVirtex (OVX) Tutorial
OpenVirtex (OVX) Tutorial
 
OpenWrt From Top to Bottom
OpenWrt From Top to BottomOpenWrt From Top to Bottom
OpenWrt From Top to Bottom
 
ACI MultiPod Config Guide
ACI MultiPod Config GuideACI MultiPod Config Guide
ACI MultiPod Config Guide
 
Project calico - introduction
Project calico - introductionProject calico - introduction
Project calico - introduction
 
Integration of OVS in OpenWrt wireless network and investigation of SDWMN
Integration of OVS in OpenWrt wireless network and investigation of SDWMNIntegration of OVS in OpenWrt wireless network and investigation of SDWMN
Integration of OVS in OpenWrt wireless network and investigation of SDWMN
 
Faster packet processing in Linux: XDP
Faster packet processing in Linux: XDPFaster packet processing in Linux: XDP
Faster packet processing in Linux: XDP
 
Next Generation Nexus 9000 Architecture
Next Generation Nexus 9000 ArchitectureNext Generation Nexus 9000 Architecture
Next Generation Nexus 9000 Architecture
 
Mikrotik Bridge Deep Dive
Mikrotik Bridge Deep DiveMikrotik Bridge Deep Dive
Mikrotik Bridge Deep Dive
 
LTE: X2 interface
LTE: X2 interfaceLTE: X2 interface
LTE: X2 interface
 
Accelerating Envoy and Istio with Cilium and the Linux Kernel
Accelerating Envoy and Istio with Cilium and the Linux KernelAccelerating Envoy and Istio with Cilium and the Linux Kernel
Accelerating Envoy and Istio with Cilium and the Linux Kernel
 
SRAN18 configurations.pdf
SRAN18 configurations.pdfSRAN18 configurations.pdf
SRAN18 configurations.pdf
 
DevConf 2014 Kernel Networking Walkthrough
DevConf 2014   Kernel Networking WalkthroughDevConf 2014   Kernel Networking Walkthrough
DevConf 2014 Kernel Networking Walkthrough
 
6lowpan 110828234426-phpapp01
6lowpan 110828234426-phpapp016lowpan 110828234426-phpapp01
6lowpan 110828234426-phpapp01
 
Campus_Network_Design_with_ArubaOS-CX_-_Leading_Practices
Campus_Network_Design_with_ArubaOS-CX_-_Leading_PracticesCampus_Network_Design_with_ArubaOS-CX_-_Leading_Practices
Campus_Network_Design_with_ArubaOS-CX_-_Leading_Practices
 
Linux Internals - Part II
Linux Internals - Part IILinux Internals - Part II
Linux Internals - Part II
 
MTCNA
MTCNAMTCNA
MTCNA
 
Docker Networking: Control plane and Data plane
Docker Networking: Control plane and Data planeDocker Networking: Control plane and Data plane
Docker Networking: Control plane and Data plane
 
Linux Linux Traffic Control
Linux Linux Traffic ControlLinux Linux Traffic Control
Linux Linux Traffic Control
 

Viewers also liked

Diving inside Android Wifi
Diving inside Android WifiDiving inside Android Wifi
Diving inside Android Wifi
Nanik Tolaram
 
Wpa too-hole196-defcon18-presentation
Wpa too-hole196-defcon18-presentationWpa too-hole196-defcon18-presentation
Wpa too-hole196-defcon18-presentation
Md Sohail Ahmad
 
2.4G Radio Transceiver for IEEE802.15.4 and ZigBee Applications
2.4G Radio Transceiver for IEEE802.15.4 and ZigBee Applications2.4G Radio Transceiver for IEEE802.15.4 and ZigBee Applications
2.4G Radio Transceiver for IEEE802.15.4 and ZigBee Applications
Premier Farnell
 
WORK EXPERIENCE - Linked In
WORK EXPERIENCE - Linked InWORK EXPERIENCE - Linked In
WORK EXPERIENCE - Linked InDavid Vest
 
Wi Max Ecosystem And Devices V0.3
Wi Max Ecosystem And Devices V0.3Wi Max Ecosystem And Devices V0.3
Wi Max Ecosystem And Devices V0.3Deepak Sharma
 
Internet of things
Internet of thingsInternet of things
Internet of things
Alok Ranjan
 
WEP
WEPWEP
Wireless networking
Wireless networkingWireless networking
Wireless networking
Online
 

Viewers also liked (8)

Diving inside Android Wifi
Diving inside Android WifiDiving inside Android Wifi
Diving inside Android Wifi
 
Wpa too-hole196-defcon18-presentation
Wpa too-hole196-defcon18-presentationWpa too-hole196-defcon18-presentation
Wpa too-hole196-defcon18-presentation
 
2.4G Radio Transceiver for IEEE802.15.4 and ZigBee Applications
2.4G Radio Transceiver for IEEE802.15.4 and ZigBee Applications2.4G Radio Transceiver for IEEE802.15.4 and ZigBee Applications
2.4G Radio Transceiver for IEEE802.15.4 and ZigBee Applications
 
WORK EXPERIENCE - Linked In
WORK EXPERIENCE - Linked InWORK EXPERIENCE - Linked In
WORK EXPERIENCE - Linked In
 
Wi Max Ecosystem And Devices V0.3
Wi Max Ecosystem And Devices V0.3Wi Max Ecosystem And Devices V0.3
Wi Max Ecosystem And Devices V0.3
 
Internet of things
Internet of thingsInternet of things
Internet of things
 
WEP
WEPWEP
WEP
 
Wireless networking
Wireless networkingWireless networking
Wireless networking
 

Similar to Wpa supplicant introduction

How can you configure Wireshark to always recognize port 444 as an S.pdf
How can you configure Wireshark to always recognize port 444 as an S.pdfHow can you configure Wireshark to always recognize port 444 as an S.pdf
How can you configure Wireshark to always recognize port 444 as an S.pdf
arkleatheray
 
7 hands on
7 hands on7 hands on
7 hands on
videos
 
BKK16-312 Integrating and controlling embedded devices in LAVA
BKK16-312 Integrating and controlling embedded devices in LAVABKK16-312 Integrating and controlling embedded devices in LAVA
BKK16-312 Integrating and controlling embedded devices in LAVA
Linaro
 
Didactum SNMP Manual
Didactum SNMP ManualDidactum SNMP Manual
Didactum SNMP Manual
Didactum
 
DPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet ProcessingDPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet Processing
Michelle Holley
 
Positive Hack Days. Pavlov. Network Infrastructure Security Assessment
Positive Hack Days. Pavlov. Network Infrastructure Security AssessmentPositive Hack Days. Pavlov. Network Infrastructure Security Assessment
Positive Hack Days. Pavlov. Network Infrastructure Security Assessment
Positive Hack Days
 
DCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystem
DCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystemDCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystem
DCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystem
rudndccn
 
9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training
videos
 
AIX Advanced Administration Knowledge Share
AIX Advanced Administration Knowledge ShareAIX Advanced Administration Knowledge Share
AIX Advanced Administration Knowledge Share
.Gastón. .Bx.
 
Linux internet server security and configuration tutorial
Linux internet server security and configuration tutorialLinux internet server security and configuration tutorial
Linux internet server security and configuration tutorial
annik147
 
Open Dayligth usando SDN-NFV
Open Dayligth usando SDN-NFVOpen Dayligth usando SDN-NFV
Open Dayligth usando SDN-NFV
Open Networking Perú (Opennetsoft)
 
Ccna Imp Guide
Ccna Imp GuideCcna Imp Guide
Ccna Imp Guide
abhijitgnbbl
 
Geep networking stack-linuxkernel
Geep networking stack-linuxkernelGeep networking stack-linuxkernel
Geep networking stack-linuxkernel
Kiran Divekar
 
In depth understanding network security
In depth understanding network securityIn depth understanding network security
In depth understanding network securityThanawan Tuamyim
 
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-BaljevicHow to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
Circling Cycle
 
03 linuxfirewall1
03 linuxfirewall103 linuxfirewall1
03 linuxfirewall1
Iwan Threads
 
Important cisco-chow-commands
Important cisco-chow-commandsImportant cisco-chow-commands
Important cisco-chow-commands
ssusere31b5c
 
Perf stat windows
Perf stat windowsPerf stat windows
Perf stat windowsAccenture
 

Similar to Wpa supplicant introduction (20)

How can you configure Wireshark to always recognize port 444 as an S.pdf
How can you configure Wireshark to always recognize port 444 as an S.pdfHow can you configure Wireshark to always recognize port 444 as an S.pdf
How can you configure Wireshark to always recognize port 444 as an S.pdf
 
7 hands on
7 hands on7 hands on
7 hands on
 
BKK16-312 Integrating and controlling embedded devices in LAVA
BKK16-312 Integrating and controlling embedded devices in LAVABKK16-312 Integrating and controlling embedded devices in LAVA
BKK16-312 Integrating and controlling embedded devices in LAVA
 
Didactum SNMP Manual
Didactum SNMP ManualDidactum SNMP Manual
Didactum SNMP Manual
 
DPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet ProcessingDPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet Processing
 
Positive Hack Days. Pavlov. Network Infrastructure Security Assessment
Positive Hack Days. Pavlov. Network Infrastructure Security AssessmentPositive Hack Days. Pavlov. Network Infrastructure Security Assessment
Positive Hack Days. Pavlov. Network Infrastructure Security Assessment
 
Yum (Linux)
Yum (Linux) Yum (Linux)
Yum (Linux)
 
DCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystem
DCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystemDCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystem
DCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystem
 
9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training
 
AIX Advanced Administration Knowledge Share
AIX Advanced Administration Knowledge ShareAIX Advanced Administration Knowledge Share
AIX Advanced Administration Knowledge Share
 
Vt6655 linux user_guide
Vt6655 linux user_guideVt6655 linux user_guide
Vt6655 linux user_guide
 
Linux internet server security and configuration tutorial
Linux internet server security and configuration tutorialLinux internet server security and configuration tutorial
Linux internet server security and configuration tutorial
 
Open Dayligth usando SDN-NFV
Open Dayligth usando SDN-NFVOpen Dayligth usando SDN-NFV
Open Dayligth usando SDN-NFV
 
Ccna Imp Guide
Ccna Imp GuideCcna Imp Guide
Ccna Imp Guide
 
Geep networking stack-linuxkernel
Geep networking stack-linuxkernelGeep networking stack-linuxkernel
Geep networking stack-linuxkernel
 
In depth understanding network security
In depth understanding network securityIn depth understanding network security
In depth understanding network security
 
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-BaljevicHow to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
 
03 linuxfirewall1
03 linuxfirewall103 linuxfirewall1
03 linuxfirewall1
 
Important cisco-chow-commands
Important cisco-chow-commandsImportant cisco-chow-commands
Important cisco-chow-commands
 
Perf stat windows
Perf stat windowsPerf stat windows
Perf stat windows
 

Recently uploaded

2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
NaapbooksPrivateLimi
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
XfilesPro
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 

Recently uploaded (20)

2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 

Wpa supplicant introduction

  • 2. Outline ● Wha is Wpa_supplicant ● Usage ● Initialization Flow ● cfg80211 and libnl ● Layer 2 Packet Sniffing ● Event Loop
  • 3. What is Wpa_supplicant ● From Wiki page: wpa_supplicant ● wpa_supplicant is widely used in Linux distributions and Android! ● These slides are based on 2.6-devel wpa_supplicant is a free software implementation of an IEEE 802.11i supplicant for Linux, FreeBSD, NetBSD, QNX, AROS, Microsoft Windows, Solaris, OS/2 (including eComStation) and Haiku. In addition to being a fully featured WPA2 supplicant, it also implements WPA and older wireless LAN security protocols. Features include: ● WPA and full IEEE 802.11i/RSN/WPA2 ● WPA-PSK and WPA2-PSK ("WPA-Personal", pre-shared key) ● WPA with EAP ("WPA-Enterprise", for example with RADIUS authentication server) ● key management for CCMP, TKIP, WEP (both 104/128- and 40/64-bit) ● RSN: PMKSA caching, pre-authentication ● IEEE 802.11r ● IEEE 802.11w ● Wi-Fi Protected Setup (WPS)
  • 4. Usage ● wpa_supplicant ○ -D: driver type, cfg80211 or wext ○ -B: run as a daemon ○ -b: the bridge interface ○ -c: configure file path ○ -C: control interface ○ -d: decrease debug level (show more log) ○ -e: entropy file ○ -f: debug log file ○ -g: global control interface (ctrl_interface) ○ -G: the ctrl_interface will set to be owned by the specified group ○ -h: show usage ○ -i: interface ○ -I: another configuration file ○ -K: show key in debug log
  • 5. Usage ● wpa_supplicant ○ -L: show license ○ -m: p2p device configuration file ○ -o: override driver option ○ -O: override control interface option ○ -p: driver parameter ○ -P: PID file ○ -q: increase debug level (show less log) ○ -s: use syslog ○ -T: use Linux Tracing ○ -t: add timestamp in debug log ○ -u: dbus control interface ○ -v: show wpa_supplicant version ○ -W: defer the main event loop until first external program attaches wpa_supplicant ○ -N: combine multiple interface parameters
  • 6. cfg80211 wpa_supplicant, hostapd, iw, ... nl80211 libnl, libnl-genl mac80211 User Space Kernel Space wireless driver wireless device Physical HW Architechture
  • 7. Initialization Flow 1. wpa_supplicant_init() 2. Add each interface via wpa_supplicant_add_iface() 3. Run event loop via wpa_supplicant_run()
  • 8. Init Step 1: wpa_supplicant_init() 1. Init debug log setting a. If specified to dump log to file via -f parameter, then initialize the output file via wpa_debug_open_file(). Otherwise, initialize the standard output for debug log via wpa_debug_setup_stdout() b. If specified to dump log to syslog via -s parameter, then initialize syslog setting via wpa_debug_open_syslog() c. If specified to dump log by Linux Tracing via -T parameter, then initialize the setting via wpa_debug_open_linux_tracing() 2. Initialize EAP methods via eap_register_methods() 3. Initialize global ctrl_interface via wpa_supplicant_global_ctrl_iface_init() a. Open socket for the ctrl_interface b. Set the group permission if the group is specified by -G parameters c. Register ctrl_interface reader socket via eloop_register_read_sock()
  • 9. Init Step 1: wpa_supplicant_init() 4. Initialize dbus via wpas_notify_supplicant_initialized() 5. Check global driver list wpa_drivers 6. Register a period timeout (10s) function wpas_periodic to: a. P2P: check whether P2P peers expired via p2p_expire_peers() b. STA: flush expired bss via wpa_bss_flush_by_age() c. AP: check whether the acl is expired via ap_periodic()
  • 10. Init Step 2: wpa_supplicant_add_iface() 1. Allocate wpa_supplicant structure fo each interface 2. If the override driver option is set by -o parameter, override the driver specified by -D parameter 3. If the override ctrl_interface option is set by -O parameter, override the ctrl_interface specified by -C parameter 4. wpa_supplicant_init_iface() a. Read configuration file via wpa_config_read if the file is specified by -c parameter; if not specified, make default configrations b. Read another configuration file vi wpa_config_read if the file is specified by -I parameter c. If ctrl_interface and driver_param are specified by configuration file and comman line parameter, use the one specified by command line
  • 11. Init Step 2: wpa_supplicant_add_iface() 5. wpas_init_driver() a. Set the driver (e.g. cfg80211 driver) b. Initialize driver via wpa_drv_init() c. Setup driver parameter via wpa_drv_set_param() if specified by -p parameter d. Add the interface into the wpa_s->radio_list via radio_add_interface() 6. Initialize wpa context via wpa_supplicant_init_wpa() 7. Initialize hw feature to wpa_s->hw.modes via wpa_drv_get_hw_feature_data() 8. Get and setup driver capability via wpa_drv_get_capa() 9. etup bridge or trigger scan via wpa_supplicant_driver_init() 10. If the interface is not P2P device, initialize TDLS via wpa_tdls_init() 11. Set country via wpa_drv_set_country()
  • 12. Init Step 2: wpa_supplicant_add_iface() 12. Initialize WPS via wpas_wps_init() 13. Initialize EAPOL via wpa_supplicant_init_eapol() 14. Initialize the ctrl_iface of the interface via wpa_supplicant_ctrl_iface_init() 15. Initialize GAS query via gas_query_init() 16. Initialize P2P via wpas_p2p_init(), if the interface support P2P devic operations 17. Set WOW settings via wpas_set_wowlan_triggers() 18. If support P2P device, try to add P2P device interface via wpas_p2p_add_p2pdev_interface()
  • 13. Init Step 3: wpa_supplicant_run() 1. If -B parameter is assigned, run wpa_supplicant as daemon via wpa_supplicant_daemon 2. If -W parameter is assigned, start the event loop after external program starting to attach wpa_supplicant via wpa_supplicant_ctrl_iface_wait() 3. Register terminal signal SIGINT and SIGTERM handler via eloop_register_signal_terminate 4. Register SIGHUP as reconfig signal via eloop_register_signal_reconfig() 5. Start event loop via eloop_run()
  • 15. What is cfg80211 and libnl ● cfg80211 is a configuration system in Linux kernel for manipulating 802.11 devices ● libnl is the bridge for user space and kernel space to interact with each other during manipulating 802.11 devices ● nl80211 in kernel registers the generic netlink(nl) family “nl80211” ● wpa_supplicant in userspace calls libnl APIs to communicate with kernel generic nl family “nl80211”
  • 16. Wpa_supplicant to kernel cf80211 via linbl 1. Initialize netlink connection via netlink_init() 2. Initialize the connection to kernel nl80211 via wpa_driver_nl80211_init_nl_global() a. Allocate nl handler via global->nl = nl_create_handle(global->nl_cb, "nl"); b. Resolve nl80211 via global->nl80211_id = genl_ctrl_resolve(global->nl, "nl80211"); c. Allocate event handler via global->nl_event = nl_create_handle(global->nl_cb, "event"); d. Add global->nl_event to “mlme”, “scan”, “regulatory”, “vendor” groups via: i. ret = nl_get_multicast_id(global, "nl80211", "mlme"); ii. ret = nl_socket_add_membership(global->nl_event, ret); e. Assign the global event handler via: i. nl_cb_set(global->nl_cb, NL_CB_VALID, NL_CB_CUSTOM, process_global_event, global); f. Assign “mlme”, “scan”, “regulatory”, “vendor” event handler via: i. nl80211_register_eloop_read(&global->nl_event, wpa_driver_nl80211_event_receive,
  • 17. Layer 2 Packet Sniffing
  • 18. Why Need to Access Layer 2 Packets ● To maintain the state machine of specified functions (e.g. TDLS), wpa_supplicant needs to access layer 2(l2) packets ○ e.g. TDLS, many action frames are encapulated in layer 2 packets
  • 19. Take TDLS as Example 1. wpa_supplicant calls l2_packet_init() to initialize the connection to l2 and monitor the specified l2 packets a. Assign the rx_callback (wpa_supplicant_rx_tdls())function for specified protocol b. Assign the rx handle function l2_packet_receive() which will invoke the rx_callback int wpa_tdls_init(struct wpa_sm *sm) { if (sm == NULL) return -1; sm->l2_tdls = l2_packet_init(sm->bridge_ifname ? sm->bridge_ifname : sm->ifname, sm->own_addr, ETH_P_80211_ENCAP, wpa_supplicant_rx_tdls, sm, 0); if (sm->l2_tdls == NULL) { wpa_printf(MSG_ERROR, "TDLS: Failed to open l2_packet " "connection"); return -1; } ...
  • 21. eloop_init() ● Initialize eloop.timeout list ● Initialize eloop.reader, eloop.writer, eloop.exception
  • 22. eloop_run() ● eloop keeps running is eloop.terminate is not set or any count of eloop. reader, eloop.writer, eloop.exception is not zero ● During the while loop ○ Get first timout event in eloop.timeout list and calculate the remianing time to reach the timeout ○ Call select() to wait for coming reader, writer, exception events ○ Call eloop_process_pending_signals() to process pending signal by calling their handlers ○ Get first timout event in eloop.timeout list, if the timeout fired, call the handler to process the timeout event ○ If reader, writer, exception socekts are changed, skip previous select() results ○ Call eloop_sock_table_dispatch() to handle all the set reader, writer, exceptions events
  • 23. Reader, Writer, Exceptions Event Sources ● Reader event source ○ ctrl_iface connection ○ netlink connection between wpa_supplicant and nl80211 ○ EAPOL Tx status in wpa_driver_nl80211_drv_init() ○ EAPOL socket in i802_init() ○ Socket for Monitor mode ○ … ● Writer event source ○ Dbus watch ○ http client ● Exception event source ○ Dbus watch
  • 24. Reference ● https://en.wikipedia.org/wiki/Wpa_supplicant ● https://w1.fi/wpa_supplicant/ ● https://w1.fi/wpa_supplicant/devel/ ● https://wireless.wiki.kernel.org/ ● http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git ● https://www.infradead.org/~tgr/libnl/