@@ -74,6 +74,7 @@ limitations under the License.
7474#include <assert.h>
7575#include <fcntl.h>
7676#include <poll.h>
77+ #include <time.h>
7778
7879#include <net/if.h>
7980#include <netinet/ether.h>
@@ -610,7 +611,7 @@ static const uc_nl_nested_spec_t nl80211_wiphy_bands_freqs_nla = {
610611 { NL80211_FREQUENCY_ATTR_NO_HT40_PLUS , "no_ht40_plus" , DT_FLAG , 0 , NULL },
611612 { NL80211_FREQUENCY_ATTR_NO_80MHZ , "no_80mhz" , DT_FLAG , 0 , NULL },
612613 { NL80211_FREQUENCY_ATTR_NO_160MHZ , "no_160mhz" , DT_FLAG , 0 , NULL },
613- { NL80211_FREQUENCY_ATTR_DFS_CAC_TIME , "dfs_cac_time" , DT_FLAG , 0 , NULL },
614+ { NL80211_FREQUENCY_ATTR_DFS_CAC_TIME , "dfs_cac_time" , DT_U32 , 0 , NULL },
614615 { NL80211_FREQUENCY_ATTR_INDOOR_ONLY , "indoor_only" , DT_FLAG , 0 , NULL },
615616 { NL80211_FREQUENCY_ATTR_IR_CONCURRENT , "ir_concurrent" , DT_FLAG , 0 , NULL },
616617 { NL80211_FREQUENCY_ATTR_NO_20MHZ , "no_20mhz" , DT_FLAG , 0 , NULL },
@@ -2557,6 +2558,19 @@ cb_listener_event(struct nl_msg *msg, void *arg)
25572558 return NL_SKIP ;
25582559}
25592560
2561+ static int
2562+ cb_evsock_msg (struct nl_msg * msg , void * arg )
2563+ {
2564+ struct nlmsghdr * hdr = nlmsg_hdr (msg );
2565+
2566+ if (hdr -> nlmsg_seq == 0 ) {
2567+ cb_listener_event (msg , NULL );
2568+ return NL_SKIP ;
2569+ }
2570+
2571+ return NL_OK ;
2572+ }
2573+
25602574static int
25612575cb_event (struct nl_msg * msg , void * arg )
25622576{
@@ -2572,10 +2586,11 @@ cb_event(struct nl_msg *msg, void *arg)
25722586 return NL_SKIP ;
25732587
25742588 o = uc_nl_prepare_event (s -> vm , msg );
2575- if (o )
2589+ if (o ) {
2590+ ucv_put (s -> res );
25762591 s -> res = o ;
2577-
2578- s -> cmd = gnlh -> cmd ;
2592+ s -> cmd = gnlh -> cmd ;
2593+ }
25792594
25802595 return NL_SKIP ;
25812596}
@@ -2699,9 +2714,24 @@ uc_nl_waitfor(uc_vm_t *vm, size_t nargs)
26992714
27002715 pfd .fd = nl_socket_get_fd (nl80211_conn .evsock );
27012716
2702- if (poll (& pfd , 1 , ms ) == 1 ) {
2703- while (err == 0 && ctx .cmd == 0 )
2704- nl_recvmsgs (nl80211_conn .evsock , cb );
2717+ while (err == 0 && ctx .cmd == 0 ) {
2718+ struct timespec start , end ;
2719+
2720+ if (ms > 0 )
2721+ clock_gettime (CLOCK_MONOTONIC , & start );
2722+
2723+ if (poll (& pfd , 1 , ms ) != 1 )
2724+ break ;
2725+
2726+ nl_recvmsgs (nl80211_conn .evsock , cb );
2727+
2728+ if (ms > 0 ) {
2729+ clock_gettime (CLOCK_MONOTONIC , & end );
2730+ ms -= (end .tv_sec - start .tv_sec ) * 1000 +
2731+ (end .tv_nsec - start .tv_nsec ) / 1000000 ;
2732+ if (ms <= 0 )
2733+ break ;
2734+ }
27052735 }
27062736
27072737 nl_cb_put (cb );
@@ -2799,6 +2829,11 @@ uc_nl_request_common(struct nl_sock *sock, uc_vm_t *vm, size_t nargs)
27992829 nl_cb_set (cb , NL_CB_ACK , NL_CB_CUSTOM , cb_done , & st );
28002830 nl_cb_err (cb , NL_CB_CUSTOM , cb_errno , & ret );
28012831
2832+ if (sock == nl80211_conn .evsock ) {
2833+ nl_cb_set (cb , NL_CB_SEQ_CHECK , NL_CB_CUSTOM , cb_seq , NULL );
2834+ nl_cb_set (cb , NL_CB_MSG_IN , NL_CB_CUSTOM , cb_evsock_msg , NULL );
2835+ }
2836+
28022837 nl_send_auto_complete (sock , msg );
28032838
28042839 while (ret > 0 && st .state < STATE_REPLIED )
0 commit comments