当前位置: 动力学知识库 > 问答 > 编程问答 >

c - how hostapd signals receive frame/DHCP packets

问题描述:

Can someone please explain to me how hostPd (wired driver implementation) signals the receive function (wired_driver.c = static void handle_dhcp(int sock, void *eloop_ctx, void *sock_ctx)).

I have studied the code very closely and this is how I understand it works (up to the point I am stuck).

  1. During the interface/driver initialisation, the receive function (handle_dhcp) is registered as a call back function in the eloop readers table.
  2. The interface socket is opened and bound to; using the 'bind' system call.
  3. After all initialisation is completed, eloop runs indefinitely. This involves dispatching all readers/writers/exception handler functions. If any function does not have any data to be dispatched, it is not called back. This loops every time the timeout expires.
  4. When a DHCP packet is received on the socket, the eloop_sock_table_dispatch() (in eloop.c) function calls back the registered function in step 1. above, which then reads the data from the socket, and all is in business (authentication proceeds).

Now, when the DHCP packet becomes availabe for reading in step 4. above, I cannot just work out how the linux kernel notifies the hostAPd daemon that data is available for reading on the socket. I fairly know its done within eloop, but how the signal is transfered is what I am asking about!

Now, I know (after extensive debugging) that hostAPd registers some signals (1/10/2/15 : SIGHUP/SIGBUS/SIGINT/SIGTERM via the system 'signal()' function call: {}. Now, as far as I am aware, none of these actually handles the receipt of data on a socket: which is handled by SIGIO.

I have debugged the signal handler function and in fact, it is not called upon receive of the DHCP packet on the socket (which confirms? my hunch above).

So the question here is how does the kernel signal hostAPd, which then invokes the callback function, which then reads the data off the socket?

I hope there are some hostAPd experts in here!

Thanks!

分享给朋友:
您可能感兴趣的文章:
随机阅读: