MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / OnReceiveIPv4

Function OnReceiveIPv4

Kernel/src/net/interface.cpp:43–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41 }
42
43 void OnReceiveIPv4(void* data, size_t length){
44 if(length < sizeof(IPv4Header)){
45 Log::Warning("[Network] [IPv4] Discarding packet (too short)");
46 return;
47 }
48
49 IPv4Header* header = (IPv4Header*)data;
50
51 if(header->version != 4){
52 Log::Warning("[Network] [IPv4] Discarding packet (invalid version)");
53 return;
54 }
55
56 switch(header->protocol){
57 case IPv4ProtocolICMP:
58 OnReceiveICMP(header->data, length - sizeof(IPv4Header));
59 break;
60 case IPv4ProtocolUDP:
61 OnReceiveUDP(*header, header->data, length - sizeof(IPv4Header));
62 break;
63 case IPv4ProtocolTCP:
64 default:
65 Log::Warning("[Network] [IPv4] Discarding packet (invalid protocol %x)", header->protocol);
66 break;
67 }
68 }
69
70 [[noreturn]] void InterfaceThread(){
71 Log::Info("[Network] Initializing network interface layer...");

Callers 1

InterfaceThreadFunction · 0.85

Calls 3

WarningFunction · 0.85
OnReceiveICMPFunction · 0.85
OnReceiveUDPFunction · 0.85

Tested by

no test coverage detected