aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/ctrl_iface_unix.c
Commit message (Collapse)AuthorAgeFilesLines
* hostapd: Add wpa_msg_ctrl() to report Probe Request frames from STAbhagavathi perumal s2017-11-231-1/+1
| | | | | | | | | This allows external applications to get event indication for Probe Request frames. Extend ctrl iface cmd "ATTACH" to enable this event on per-request basis. For example, user has to send ctrl iface cmd "ATTACH probe_rx_events=1" to enable the Probe Request frame events. Signed-off-by: bhagavathi perumal s <bperumal@qti.qualcomm.com>
* Use TIOCOUTQ instead of SIOCOUTQ to avoid need for linux/sockios.hJouni Malinen2016-03-261-3/+2
| | | | | | | | All that the kernel header was doing here is defining SIOCOUTQ to be TIOCOUTQ. Instead of pulling in the header, we might as well use TIOCOUTQ directly. Signed-off-by: Jouni Malinen <j@w1.fi>
* ctrl_iface_common: Use sockaddr_storage instead of sockaddr_unJanusz Dziedzic2016-03-051-17/+15
| | | | | | | This is a step towards allowing UDP sockets to be used with the common implementation. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
* wpa_supplicant: Use common functions for ctrl_ifaceJanusz Dziedzic2016-03-051-71/+4
| | | | | | Use the common functions, structures when UNIX socket ctrl_iface used. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
* Do not wait for monitor to attach if no control interfaceIlan Peer2015-12-281-0/+3
| | | | | | | | In case an interface has started without a control interface initialized, skip waiting for monitor to attach at the start of wpa_supplicant (-W). Signed-off-by: Ilan Peer <ilan.peer@intel.com>
* Add forgotten list entry removal for control interface deinitJouni Malinen2015-10-041-2/+6
| | | | | | | | dl_list_del() must be called before freeing the list entries. Neither of these cases caused problems because the full list data structure was freed, but still, it is better to do this properly. Signed-off-by: Jouni Malinen <j@w1.fi>
* Throttle control interface event message burstsJouni Malinen2015-10-041-11/+226
| | | | | | | | | | | | | | | | | Some operations like a new scan result processing can result in large number of wpa_supplicant control interface messages being generated. Especially with multiple control interface monitors, this could result in hitting the output queue length maximum and event messages getting dropped. In worst case, that could even result in hitting ten consecutive sendto() errors which could result in an attached monitor socket getting detached. Avoid this type of issues by throttling monitor event transmission based on the output queue length. If more than half of the maximum send buffer is used, postpone sending of following event messages until the pending output queue has dropped below the limit. Signed-off-by: Jouni Malinen <j@w1.fi>
* Android: Avoid same per-iface and global ctrl socketSunil Dutt2015-09-241-0/+47
| | | | | | | | | | | | | | | | | | Android platform assigns the same socket id if the socket identifier in conf->ctrl_interface and global->params.ctrl_interface (parameter for android_get_control_socket) point to the same Android specific control socket. This ends up having two eloop socket handlers registered for the same file descriptor and thus, two attempt to receive and process each command. This can result in unexpected failure, e.g., the prefix IFNAME= for any command is valid for global socket handler, but results in UNKNOWN COMMAND response from the per-interface ctrl socket handler). Since it might be possible to end up with this type of invalid configuration in OTA upgrade, compare the socket identifiers and do not open the ctrl socket on the respective interface if both point to same. This allows the Wi-Fi framework to use the global control interface. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* Drop some control interface debug print verbosity for send operationsJouni Malinen2015-09-101-2/+3
| | | | | | | | | | These prints were at DEBUG level (-d), but they can be very frequent, so drop them to MSGDUMP (-dd). This allows the prints to be suppressed in common debugging cases while still leaving them easily enablable to debug control interface issues without having to enable excessive debugging. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* Add debug prints for wpa_supplicant ctrl_iface socket send operationsJouni Malinen2015-08-141-0/+35
| | | | | | | | This makes it easier to track the output queue state on a control interface socket and determine what could be causing issues with running out of space in the buffer. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* hostapd: Global control interface notificationsAnton Nayshtut2015-07-161-2/+3
| | | | | | | | | | This commit implements hostapd global control interface notifications infrastructure. hostapd global control interface clients issue ATTACH/DETACH commands to register and deregister with hostapd correspondingly - the same way as for any other hostapd/wpa_supplicant control interface. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* Clear control interface command explicitly from stackJouni Malinen2015-06-171-0/+14
| | | | | | | | The control interface commands may include passwords or other private key material, so clear it explicitly from memory as soon as the temporary buffer is not needed anymore. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* Document the wpa_msg_cb "global" parameterJouni Malinen2015-06-101-8/+8
| | | | | | | | Instead of an int variable with magic values 0, 1, 2, use an enum that gives clearer meaning to the values now that the original boolean type global argument is not really a boolean anymore. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* Print in debug log whether attached monitor is for global interfaceJouni Malinen2015-01-181-5/+7
| | | | | | | | | It is easier to debug issues related to the wpa_supplicant control interfaces being left behind in attached state when the debug log file can be used to determine whether a specific monitor socket was a global or per-interface one. Signed-off-by: Jouni Malinen <j@w1.fi>
* Check os_snprintf() result more consistently - automatic 1Jouni Malinen2014-12-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This converts os_snprintf() result validation cases to use os_snprintf_error() where the exact rule used in os_snprintf_error() was used. These changes were done automatically with spatch using the following semantic patch: @@ identifier E1; expression E2,E3,E4,E5,E6; statement S1; @@ ( E1 = os_snprintf(E2, E3, ...); | int E1 = os_snprintf(E2, E3, ...); | if (E5) E1 = os_snprintf(E2, E3, ...); else E1 = os_snprintf(E2, E3, ...); | if (E5) E1 = os_snprintf(E2, E3, ...); else if (E6) E1 = os_snprintf(E2, E3, ...); else E1 = 0; | if (E5) { ... E1 = os_snprintf(E2, E3, ...); } else { ... return -1; } | if (E5) { ... E1 = os_snprintf(E2, E3, ...); } else if (E6) { ... E1 = os_snprintf(E2, E3, ...); } else { ... return -1; } | if (E5) { ... E1 = os_snprintf(E2, E3, ...); } else { ... E1 = os_snprintf(E2, E3, ...); } ) ? os_free(E4); - if (E1 < 0 || \( E1 >= E3 \| (size_t) E1 >= E3 \| (unsigned int) E1 >= E3 \| E1 >= (int) E3 \)) + if (os_snprintf_error(E3, E1)) ( S1 | { ... } ) Signed-off-by: Jouni Malinen <j@w1.fi>
* Do not re-open Android control socketsNeelansh Mittal2014-11-251-1/+27
| | | | | | | | | | | | On Android, the control socket being used may be the socket that is created when wpa_supplicant is started as a /init.*.rc service. Such a socket is maintained as a key-value pair in Android's environment. Closing this control socket would leave wpa_supplicant in a bad state. When wpa_supplicant re-opens the ctrl_iface socket, it will query the Android's environment, and will be returned with the same socket descriptor that has already been closed. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* Note chmod() failure in debug log even in ignore case (CID 62843)Jouni Malinen2014-06-141-1/+7
| | | | | | | | | If this chmod() call fails, the global control interface is allowed to be used since there was no change to its group. Anyway, it can be helpful to note the error case in debug log instead of silently ignoring it. Signed-off-by: Jouni Malinen <j@w1.fi>
* Remove unused gid_str pointer updateJouni Malinen2014-03-021-8/+6
| | | | | | | | The group name is not used on these paths, so just remove it from the directory name without updating gid_str to point to the unused group name. Signed-off-by: Jouni Malinen <j@w1.fi>
* Increase global ctrl_iface buffer to same size as per-interfaceJouni Malinen2014-01-231-1/+1
| | | | | | | | | | Since the global ctrl_iface can be used with IFNAME= prefix to send commands to be processed by per-interface code, it should have the same (well, close to same since the prefix takes some space) limits on command length as the per-interface ctrl_iface. Increase the buffer from 256 to 4096 to achieve this. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
* Clean up ctrl_iface debug prints for monitor eventsJouni Malinen2014-01-051-21/+29
| | | | Signed-hostap: Jouni Malinen <j@w1.fi>
* Stop ctrl_iface monitor send loop on reinit failureJouni Malinen2013-10-261-0/+1
| | | | | | | There is no point trying to continue sending messages with sendmsg() if socket reinitialization fails. Signed-hostap: Jouni Malinen <j@w1.fi>
* Add no_ctrl_interface config param to clear ctrl_interfaceJouni Malinen2013-09-271-0/+2
| | | | | | | | | | | | | | | | | | | | This can be used to override previously set ctrl_interface value in a way that clears the variable to NULL instead of empty string. The only real use case for this is to disable per-interface ctrl_interface from the additional control file (-I<file>) in case ctrl_interface was set in the main configuration file. It should be noted that zero-length ctrl_interface parameter can be used to initiate some control interface backends, so simpler designs were not available for this. The format of the new parameter is not exactly cleanest due to configuration file parsing assumptions. For example: ctrl_interface=.... no_ctrl_interface= would end up with ctrl_interface=NULL. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
* Register wpa_msg callback even if only global ctrl_iface is usedJouni Malinen2013-09-251-0/+2
| | | | | | | | | | | | Previously, wpa_msg_register_cb() was called only from successful completion of per-interface control interface initialization. This would leave the callback unregistered in case only the global control interface is used which would result in not delivering control interface events on the global interface. Fix this by registering the callback handler also from successful initialization of the global control interface. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
* Re-open ctrl_iface socket on some failure cases as a workaroundJouni Malinen2013-09-251-67/+189
| | | | | | | | | | | | | | | | If wpa_supplicant ctrl_iface clients are misbehaving and refusing to read replies or event messages from wpa_supplicant, the single socket used in wpa_supplicant to send messages can reach the maximum send buffer limit. When that happens, no more responses to any client can be sent. Work around this by closed and reopening the socket in case such a failure state is detected. This is obviously not desirable since it breaks existing connected sockets, but is needed to avoid leaving wpa_supplicant completely unable to respond to any client. Cleaner fix for this may require more considerable changes in the ctrl_iface design to move to connection oriented design to allow each client to be handled separately and unreachability to be detected more reliably. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
* Simplify ctrl_iface sendto() useJouni Malinen2013-09-231-34/+26
| | | | | | | | Prepare reply buffer first for all cases and then use a single sendto() call instead of three calls depending on reply type. This allows simpler error handling for control interface send operations. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
* Print ctrl_iface sendto() failures into debug logJouni Malinen2013-09-141-17/+51
| | | | | | | This makes it easier to debug issues with control interface operations failing. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
* Replace perror() with wpa_printf(strerror) in ctrl_iface callsJouni Malinen2013-08-261-27/+43
| | | | | | | | | This replaces number of perror() calls with wpa_printf() to get the error messages embedded within rest of the debug messages in the same stream instead of pushing these to stderr which may get directed to another location. Signed-hostap: Jouni Malinen <j@w1.fi>
* wpa_supplicant: Reduce wait time for control interfacesIlan Peer2013-08-251-2/+2
| | | | | | | | Reduce the wait time for the monitor control interfaces to get messages on wpa_supplicant de-init etc., as this significantly delays the shutdown of the wpa_supplicant. Signed-hostap: Ilan Peer <ilan.peer@intel.com>
* Fix DETACH command debug prints to avoid use of freed memoryJouni Malinen2013-08-241-2/+2
| | | | | | | | | | In case a control interface socket is detached because of sendmsg() failing for the socket, function call to detach the socket uses a pointer to the socket information in the structure to be freed. Reorder code to print socket info before freeing the data to avoid use of freed memory in case debug prints are enabled. Signed-hostap: Jouni Malinen <j@w1.fi>
* Make global UNIX socket non-blocking for ctrl_ifaceJouni Malinen2013-08-241-0/+15
| | | | | | | | | This keeps wpa_supplicant from hanging forever if the other end of the socket dies. This is similar to the earlier commit 4fdc8def8855ce9b90ffbbdc47152ce46ccdcb1e to make the global control interface befave in the same way. Signed-hostap: Jouni Malinen <j@w1.fi>
* Do not block on ctrl_iface monitor eventsJouni Malinen2013-07-111-1/+1
| | | | | | | | | | It looks like some of the global control interface cases ended up blocking in sendmsg() when trying to send an event. Since this can block all wpa_supplicant processing for multiple seconds, this is very undesirable. Avoid this by requesting sendmsg() to return an error rather than waiting for the message to be sent. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
* P2P: No duplicate AP-STA-CONNECTED/DISCONNECTED as global eventJouni Malinen2013-05-181-1/+1
| | | | | | | | | | These events are sent as a special case to both the group interface and "parent interface" (i.e., the interface that was used for managing P2P negotiation). The latter is not really correct event, so get rid of it with the new global control interface design where there is no need to support legacy upper layer implementations. Signed-hostap: Jouni Malinen <j@w1.fi>
* Add wpa_msg_global() for global eventsJouni Malinen2013-05-181-2/+3
| | | | | | | This function can be used instead of wpa_msg() and wpa_msg_ctrl() to indicate that an event is not specific to a network interface. Signed-hostap: Jouni Malinen <j@w1.fi>
* Allow global ctrl_iface monitorsJouni Malinen2013-05-181-35/+94
| | | | | | | | | | The ATTACH/DETACH mechanism to request event messages from wpa_supplicant can now be used through the global control interface, too. This results in events from all interfaces being delivered through a single monitor socket. "IFNAME=<ifname> " prefix is used on events that are specific to an interface. Signed-hostap: Jouni Malinen <j@w1.fi>
* Abstract and Android sockets for global ctrl_ifaceJouni Malinen2013-05-181-17/+56
| | | | | | | | | The wpa_supplicant global control interface parameter can now be used to explicitly specify an abstract UNIX domain socket (Linux specific extension) with "@abstract:" prefix and an Android control socket with "@android:" prefix. Signed-hostap: Jouni Malinen <j@w1.fi>
* wpa_supplicant: Add -G argument to specify global ctrl groupJouni Malinen2013-05-181-1/+36
| | | | | | | The optional -G<group> command line argument can be used to specify the group that can access the global control interface. Signed-hostap: Jouni Malinen <j@w1.fi>
* Android: Force group access to ctrl_iface directoryJouni Malinen2012-11-231-0/+16
| | | | | | | | | | | | | | | | | | | wpa_supplicant is started from /init.*.rc on Android and that seems to be using umask 0077 which would leave the control interface directory without group access. This breaks things since Wi-Fi framework assumes that this directory can be accessed by other applications in the wifi group. Fix this by adding group access even if umask value would prevent this. In most cases, this issue was not hit since the control interface directory is normally created by that same init.*.rc file with suitable mode and wpa_supplicant is killed in the way that does not allow it to remove the file. However, if wpa_supplicant is allowed stop cleanly, it will remove the directory and the next start could result with the Wi-Fi framework not being able to use Wi-Fi (and GUI not showing Wi-Fi getting enabled). Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
* Make UNIX socket non-blocking for ctrl_ifaceBen Greear2012-08-041-0/+17
| | | | | | | This keeps wpa_cli from hanging forever if the other end of the socket dies. Signed-hostap: Ben Greear <greearb@candelatech.com>
* Make bind failure messages uniqueBen Greear2012-04-061-3/+4
| | | | | | This helps someone know which part of the code is complaining. Signed-hostap: Ben Greear <greearb@candelatech.com>
* Remove the GPL notification from files contributed by Jouni MalinenJouni Malinen2012-02-111-8/+2
| | | | | | | Remove the GPL notification text from the files that were initially contributed by myself. Signed-hostap: Jouni Malinen <j@w1.fi>
* Use Android reserved namespace for control interfaceDmitry Shmidt2011-02-271-0/+22
| | | | | On Android, use a special reserved namespace for the UNIX domain socket.
* P2P: Add control interface commands for P2PJouni Malinen2010-09-091-1/+1
|
* Avoid dropping ctrl_iface on ENOBUFS error burstJouni Malinen2010-04-111-1/+3
| | | | | | These bursts can result in control interface monitors being detached even if the external program is still working properly. Use much larger error threshold for ENOBUFS to avoid this.
* wpa_supplicant: fix FTBFS on Debian GNU/kFreeBSDKel Modderman2010-03-061-2/+2
| | | | | | | | This patch allows wpa_supplicant to compile on Debian's kfreebsd architectures. Patch by Stefan Lippers-Hollmann based on work done by Petr Salinger and Emmanuel Bouthenot for 0.6.X (http://bugs.debian.org/480572).
* Convert to use struct dl_listJouni Malinen2009-12-231-32/+20
|
* wpa_supplicant: Fix ctrl_interface group permissions to allow read/executeAnders Aspegren S√łndergaard2009-11-161-0/+8
| | | | | | | | When using umask 0077, the control interface directory was left without group read/execute permissions even if the configuration file explicitly asked for the group to be allowed to access the control interface. Fix this by adding read/execute permissions for group if a specific group is defined in the configuration. [Bug 199]
* Fix UNIX domain socket address handling to be more portableSam Leffler2009-03-211-6/+18
| | | | | | Removing just sun_family is not portable since some systems (e.g., FreeBSD) include an additional sun_len field. Using offsetof should be portable. In addition, set sun_ken for FreeBSD.
* Detach ctrl_iface monitor if the client socket is removedJouni Malinen2009-03-171-2/+5
| | | | | No need to wait for 10 errors when using UNIX domain socket; we can detach the client immediately on ENOENT.
* Make the "invalid group" error show up with default verbosity levelJouni Malinen2008-03-061-1/+1
|
* Re-initialize hostapd/wpa_supplicant git repository based on 0.6.3 releaseJouni Malinen2008-02-281-0/+699