From time of last post there were big enough changes in code.
First of all, await functions support was implemented, so pxe_core_recv_packets() function now is hidden from user code even deeper.
Await functions are functions that are called back by pxe_await() during simple waiting mechanism. It seems in some modules it made code smaller in lines, but added wait_data structures, which stores current wait related variables. As for TCP module, it seems await function is not useful, but to be similar to all other modules – waiting during handshaking is done using tcp_await()
pxe_await() provides event, current try and wait related data when executes await callback function. So, all await functions are similar and are processing next try, new packets, start of try, end of try events.
DNS client was rewritten a little bit to use await functions mechanism, DHCP client was written to support it from the first lines of code.
After different issues with DHCP protocol simple client was produced to get nameserver, gateway and other useful as well as useless information from DHCP server. May be I need also to add project related DHCP-option, which will specify from which server to download files.
After implementing of major UDP services needed by project, finally TCP module got its first implementation.
As earlier in other protocols, main function for packet processing is callback named simply pxe_tcp_callback(). Main difference from other protocols, especialy UDP – that sockets and filters here firstly used separately and actual work is done in state handlers, not in main callback from start till end.
State handler functions registered now in compile time (and I believe never will be registered in run time, although it’s possible) in state_functions array and each function serves for one TCP connection state handling, if it’s NULL, state is ignored.
Connection is binded more to filter, than to socket structure. This is done to handle correctly TIME_WAIT state, when there is no actually any socket, but any lost packets must be got and forgot.
After testing in soft conditions of LAN it seems active establishing and active closing of connection is done correctly.
Next things to do:
1. resending of packets after timeouts. Adding max segment size option to tcp packet.
2. data send/recv using TCP sockets. Adding pxe_push() function to push data.
3. queueing of received not in correct sequential order packets. Now they are just dropped. It may be useful to move core_packets structure to TCP module for this purpose.