mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-15 15:37:51 -04:00
Refactor
This commit is contained in:
parent
234ea4f11a
commit
e91631b2f2
@ -48,43 +48,48 @@ void network::arp::decode(network::ethernet::packet& packet){
|
|||||||
return;
|
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){
|
if(operation == 0x1){
|
||||||
logging::logf(logging::log_level::TRACE, "arp: Handle Request\n");
|
logging::logf(logging::log_level::TRACE, "arp: Handle Request\n");
|
||||||
|
|
||||||
size_t source_hw = 0;
|
//TODO
|
||||||
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]));
|
|
||||||
|
|
||||||
} else if(operation == 0x2){
|
} else if(operation == 0x2){
|
||||||
logging::logf(logging::log_level::TRACE, "arp: Handle Query\n");
|
logging::logf(logging::log_level::TRACE, "arp: Handle Query\n");
|
||||||
|
|
||||||
} else {
|
//TODO
|
||||||
logging::logf(logging::log_level::TRACE, "arp: Unhandled operation %h\n", size_t(operation));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user