Loading src/its_bridge_server.c +6 −3 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ int main(const int32_t p_argc, char* const p_argv[]) { fprintf(stderr, "Failed to parse command line arguments: MAC address of the OBU missing, exit.\n"); return -1; } hex2bin(mac_address, 6, mac_address, 12); if (udp_nic == NULL) { fprintf(stderr, "Failed to parse command line arguments: NIC UDP missing, exit.\n"); return -1; Loading Loading @@ -224,13 +225,15 @@ int main(const int32_t p_argc, char* const p_argv[]) { fprintf(stderr, "'recvfrom' operation failure: %s, state=%d.\n", strerror(errno), state); continue; } printf("Received UDP broadcast:%s:%u.\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); // Inject the packet struct ether_header* eth_header = (struct ether_header*)buffer; char eth_src[10]; bin2hex(eth_src, 10, (const uint8_t*)(eth_header->ether_shost), 6); if (strcmp(eth_src, mac_address) != 0) { /* do not inject our own packet - Should never be the case */ // bin2hex(eth_src, 10, (const uint8_t*)(eth_header->ether_shost), 6); if (memcmp(eth_header->ether_shost, mac_address, 6) != 0) { /* do not inject our own packet - Should never be the case */ printf("Forward UDP packet:%s:%u.\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); pcap_sendpacket(device, buffer, result); }else{ printf("Skip UDP packet:%s:%u.\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); } } /* End of 'while' statement */ Loading Loading
src/its_bridge_server.c +6 −3 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ int main(const int32_t p_argc, char* const p_argv[]) { fprintf(stderr, "Failed to parse command line arguments: MAC address of the OBU missing, exit.\n"); return -1; } hex2bin(mac_address, 6, mac_address, 12); if (udp_nic == NULL) { fprintf(stderr, "Failed to parse command line arguments: NIC UDP missing, exit.\n"); return -1; Loading Loading @@ -224,13 +225,15 @@ int main(const int32_t p_argc, char* const p_argv[]) { fprintf(stderr, "'recvfrom' operation failure: %s, state=%d.\n", strerror(errno), state); continue; } printf("Received UDP broadcast:%s:%u.\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); // Inject the packet struct ether_header* eth_header = (struct ether_header*)buffer; char eth_src[10]; bin2hex(eth_src, 10, (const uint8_t*)(eth_header->ether_shost), 6); if (strcmp(eth_src, mac_address) != 0) { /* do not inject our own packet - Should never be the case */ // bin2hex(eth_src, 10, (const uint8_t*)(eth_header->ether_shost), 6); if (memcmp(eth_header->ether_shost, mac_address, 6) != 0) { /* do not inject our own packet - Should never be the case */ printf("Forward UDP packet:%s:%u.\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); pcap_sendpacket(device, buffer, result); }else{ printf("Skip UDP packet:%s:%u.\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); } } /* End of 'while' statement */ Loading