📄 porting.doxygen
字号:
/**\page porting Porting to different target boards and operating systems%wpa_supplicant was designed to be easily portable to differenthardware (board, CPU) and software (OS, drivers) targets. It isalready used with number of operating systems and numerous wirelesscard models and drivers. The main %wpa_supplicant repository includessupport for Linux, FreeBSD, and Windows. In addition, at least VxWorksand PalmOS are supported in separate repositories. On the hardwareside, %wpa_supplicant is used on various systems: desktops, laptops,PDAs, and embedded devices with CPUs including x86, PowerPC,arm/xscale, and MIPS. Both big and little endian configurations aresupported.\section driver_iface_porting Driver interfaceUnless the target OS and driver is already supported, most portingprojects have to implement a driver wrapper. This may be done byadding a new driver interface module or modifying an existing module(driver_*.c) if the new target is similar to one of them. \refdriver_wrapper "Driver wrapper implementation" describes the detailsof the driver interface and discusses the tasks involved in portingthis part of %wpa_supplicant.\section l2_packet_porting l2_packet (link layer access)%wpa_supplicant needs to have access to sending and receiving layer 2(link layer) packets with two Ethertypes: EAP-over-LAN (EAPOL) 0x888eand RSN pre-authentication 0x88c7. l2_packet.h defines the interfacesused for this in the core %wpa_supplicant implementation.If the target operating system supports a generic mechanism for linklayer access, that is likely the best mechanism for providing theneeded functionality for %wpa_supplicant. Linux packet socket is anexample of such a generic mechanism. If this is not available, aseparate interface may need to be implemented to the network stack ordriver. This is usually an intermediate or protocol driver that isoperating between the device driver and the OS network stack. If sucha mechanism is not feasible, the interface can also be implementeddirectly in the device driver.The main %wpa_supplicant repository includes l2_packet implementationsfor Linux using packet sockets (l2_packet_linux.c), more portableversion using libpcap/libdnet libraries (l2_packet_pcap.c; thissupports WinPcap, too), and FreeBSD specific version of libpcapinterface (l2_packet_freebsd.c).If the target operating system is supported by libpcap (receiving) andlibdnet (sending), l2_packet_pcap.c can likely be used with minimal orno changes. If this is not a case or a proprietary interface for linklayer is required, a new l2_packet module may need to beadded. Alternatively, struct wpa_driver_ops::send_eapol() handler canbe used to override the l2_packet library if the link layer access isintegrated with the driver interface implementation.\section eloop_porting Event loop%wpa_supplicant uses a single process/thread model and an event loopto provide callbacks on events (registered timeout, received packet,signal). eloop.h defines the event loop interface. eloop.c is animplementation of such an event loop using select() and sockets. Thisis suitable for most UNIX/POSIX systems. When porting to otheroperating systems, it may be necessary to replace that implementationwith OS specific mechanisms that provide similar functionality.\section ctrl_iface_porting Control interface%wpa_supplicant uses a \ref ctrl_iface_page "control interface"to allow external processedto get status information and to control the operations. Currently,this is implemented with socket based communication; both UNIX domainsockets and UDP sockets are supported. If the target OS does notsupport sockets, this interface will likely need to be modified to useanother mechanism like message queues. The control interface isoptional component, so it is also possible to run %wpa_supplicantwithout porting this part.The %wpa_supplicant side of the control interface is implemented inctrl_iface.c. Matching client side is implemented as a controlinterface library in wpa_ctrl.c.\section entry_point Program entry point%wpa_supplicant defines a set of functions that can be used toinitialize main supplicant processing. Each operating system has amechanism for starting new processing or threads. This is usually afunction with a specific set of arguments and calling convention. Thisfunction is responsible on initializing %wpa_supplicant.main.c includes an entry point for UNIX-like operating system, i.e.,main() function that uses command line arguments for settingparameters for %wpa_supplicant. When porting to other operatingsystems, similar OS-specific entry point implementation is needed. Itcan be implemented in a new file that is then linked with%wpa_supplicant instead of main.o. main.c is also a good example onhow the initialization process should be done.The supplicant initialization functions are defined inwpa_supplicant_i.h. In most cases, the entry point function shouldstart by fetching configuration parameters. After this, a global%wpa_supplicant context is initialized with a call towpa_supplicant_init(). After this, existing network interfaces can beadded with wpa_supplicant_add_iface(). wpa_supplicant_run() is thenused to start the main event loop. Once this returns at programtermination time, wpa_supplicant_deinit() is used to release globalcontext data.wpa_supplicant_add_iface() and wpa_supplicant_remove_iface() can beused dynamically to add and remove interfaces based on when%wpa_supplicant processing is needed for them. This can be done, e.g.,when hotplug network adapters are being inserted and ejected. It isalso possible to do this when a network interface is beingenabled/disabled if it is desirable that %wpa_supplicant processingfor the interface is fully enabled/disabled at the same time.*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -