diff --git a/kernel/src/arp_layer.cpp b/kernel/src/arp_layer.cpp index 1e22e3fa..426a5241 100644 --- a/kernel/src/arp_layer.cpp +++ b/kernel/src/arp_layer.cpp @@ -48,43 +48,48 @@ void network::arp::decode(network::ethernet::packet& packet){ return; } + if (operation != 0x1 && operation != 0x2) { + logging::logf(logging::log_level::TRACE, "arp: Unhandled operation %h\n", size_t(operation)); + return;J + } + + size_t source_hw = 0; + size_t target_hw = 0; + + for(size_t i = 0; i < 3; ++i){ + source_hw |= uint64_t(switch_endian_16(arp_header->source_hw_addr[i])) << ((3 - i) * 16); + target_hw |= uint64_t(switch_endian_16(arp_header->target_hw_addr[i])) << ((3 - i) * 16); + } + + logging::logf(logging::log_level::TRACE, "arp: Source HW Address %h \n", source_hw); + logging::logf(logging::log_level::TRACE, "arp: Target HW Address %h \n", target_hw); + + uint8_t source_prot[4]; + uint8_t target_prot[4]; + + for(size_t i = 0; i < 2; ++i){ + auto source = switch_endian_16(arp_header->source_protocol_addr[i]); + auto target = switch_endian_16(arp_header->target_protocol_addr[i]); + + source_prot[2*i] = source >> 8; + source_prot[2*i+1] = source; + + target_prot[2*i] = target >> 8; + target_prot[2*i+1] = target; + } + + logging::logf(logging::log_level::TRACE, "arp: Source Protocol Address %u.%u.%u.%u \n", + uint64_t(source_prot[0]), uint64_t(source_prot[1]), uint64_t(source_prot[2]), uint64_t(source_prot[3])); + logging::logf(logging::log_level::TRACE, "arp: Target Protocol Address %u.%u.%u.%u \n", + uint64_t(target_prot[0]), uint64_t(target_prot[1]), uint64_t(target_prot[2]), uint64_t(target_prot[3])); + if(operation == 0x1){ logging::logf(logging::log_level::TRACE, "arp: Handle Request\n"); - size_t source_hw = 0; - size_t target_hw = 0; - - for(size_t i = 0; i < 3; ++i){ - source_hw |= uint64_t(switch_endian_16(arp_header->source_hw_addr[i])) << ((3 - i) * 16); - target_hw |= uint64_t(switch_endian_16(arp_header->target_hw_addr[i])) << ((3 - i) * 16); - } - - logging::logf(logging::log_level::TRACE, "arp: Source HW Address %h \n", source_hw); - logging::logf(logging::log_level::TRACE, "arp: Target HW Address %h \n", target_hw); - - uint8_t source_prot[4]; - uint8_t target_prot[4]; - - for(size_t i = 0; i < 2; ++i){ - auto source = switch_endian_16(arp_header->source_protocol_addr[i]); - auto target = switch_endian_16(arp_header->target_protocol_addr[i]); - - source_prot[2*i] = source >> 8; - source_prot[2*i+1] = source; - - target_prot[2*i] = target >> 8; - target_prot[2*i+1] = target; - } - - logging::logf(logging::log_level::TRACE, "arp: Source Protocol Address %u.%u.%u.%u \n", - uint64_t(source_prot[0]), uint64_t(source_prot[1]), uint64_t(source_prot[2]), uint64_t(source_prot[3])); - logging::logf(logging::log_level::TRACE, "arp: Target Protocol Address %u.%u.%u.%u \n", - uint64_t(target_prot[0]), uint64_t(target_prot[1]), uint64_t(target_prot[2]), uint64_t(target_prot[3])); - + //TODO } else if(operation == 0x2){ logging::logf(logging::log_level::TRACE, "arp: Handle Query\n"); - } else { - logging::logf(logging::log_level::TRACE, "arp: Unhandled operation %h\n", size_t(operation)); + //TODO } }