diff --git a/src/ckernelwifi.cc b/src/ckernelwifi.cc index 02dc469..cf83af3 100644 --- a/src/ckernelwifi.cc +++ b/src/ckernelwifi.cc @@ -179,8 +179,10 @@ int CKernelWifi::process_messages(struct nl_msg *msg) } int value=_SendSignal(&power, (char*)nlh, msg_len); - if( value == SOCKET_ERROR ) + if( value == SOCKET_ERROR ) { + printf("Error sending to server\n"); manage_server_crash(); + } // Send also on the others interfaces on the same VM : // -------------------> @@ -449,8 +451,10 @@ void CKernelWifi::recv_from_server(){ return ; TPower power; - if( _RecvSignal(&power, &dropped, &Buffer) == SOCKET_ERROR ) + if( _RecvSignal(&power, &dropped, &Buffer) == SOCKET_ERROR ) { + printf("Error receiving from server\n"); manage_server_crash(); + } int signal = power ; @@ -539,6 +543,7 @@ void CKernelWifi::recv_from_server(){ if (!dropped) flags |= HWSIM_TX_STAT_ACK; +#if 0 struct nl_msg *tx_info = build_tx_info(&framesrc, flags, (int)signal, tx_rates, @@ -549,8 +554,11 @@ void CKernelWifi::recv_from_server(){ int value=_SendSignal(&power, (char*)hdr, hdr->nlmsg_len); nlmsg_free(tx_info); - if( value == SOCKET_ERROR ) + if( value == SOCKET_ERROR ) { + printf("Error sending tx info to server\n"); manage_server_crash(); + } +#endif if (dropped) return; @@ -926,6 +934,7 @@ bool CKernelWifi::is_connected_to_server(){ void CKernelWifi::manage_server_crash(){ + printf("MANAGE SERVER CRASH"); connected_to_server(false) ; } diff --git a/src/csocket.cc b/src/csocket.cc index 423662c..b40fc58 100644 --- a/src/csocket.cc +++ b/src/csocket.cc @@ -53,8 +53,10 @@ ssize_t CSocket::SendBigData(TDescriptor descriptor, const char* data, TMinimalS ssize_t CSocket::Read(TDescriptor descriptor, char* data, ssize_t sizeOfData) { ssize_t ret = recv(descriptor , data, sizeOfData, 0); - if ( ret <= 0 ) + if ( ret <= 0 ) { + printf("Recv failed with %ld\n", errno); return SOCKET_ERROR ; + } return ret; } diff --git a/src/cwifi.cc b/src/cwifi.cc index 02775b7..bb2d780 100644 --- a/src/cwifi.cc +++ b/src/cwifi.cc @@ -15,7 +15,7 @@ const double ConstanteC=92.45; const TFrequency DEFAULT_FREQUENCY=2412; // Hz -const int MTU=1640; // Maximum Transmission Unit : 1640 is an experimental value +const int MTU=4096; // Maximum Transmission Unit : 1640 is an experimental value TFrequency CWifi::GetFrequency(struct nlmsghdr* nlh) { @@ -83,24 +83,32 @@ ssize_t CWifi::RecvSignalWithSocket(CSocket* socket, TDescriptor descriptor, TPo // read the power valread = socket->Read(descriptor, (char*)power, sizeof(TPower)); - if ( valread <= 0 ) + if ( valread <= 0 ) { + printf("cannot read power %d\n", valread); return valread; + } // read dropped valread = socket->Read(descriptor, (char*)dropped, sizeof(uint8_t)); - if ( valread <= 0 ) + if ( valread <= 0 ) { + printf("cannot read dropped %d\n", valread); return valread; + } // read the signal // "nlmsg_len" (type "uint32_t") is the first attribut of the "struct nlmsghdr" in "libnl3/netlink/netlink-kernel.h" ssize_t sizeRead = socket->ReadEqualSize(descriptor, buffer, 0, sizeof(struct nlmsghdr)); - if( sizeRead == SOCKET_ERROR ) + if( sizeRead == SOCKET_ERROR ) { + printf("Cannot read nlmsg_len\n"); return SOCKET_ERROR; + } int sizeTotal=((struct nlmsghdr *)(buffer->GetBuffer()))->nlmsg_len; - if( sizeTotal > MTU ) // to avoid that a error packet overfulls the memory + if( sizeTotal > MTU ) { // to avoid that a error packet overfulls the memory + printf("Size greater than MTU %d\n", sizeTotal); return SOCKET_ERROR; + } return socket->ReadEqualSize(descriptor, buffer, sizeRead, sizeTotal); }