01 // vim: set ft=c: 02 03 U0 HandleNetFifoEntry(CNetFifoEntry* e) { 04 CEthFrame l2_frame; 05 06 if (EthernetFrameParse(&l2_frame, e->frame, e->length) < 0) 07 return; 08 09 //"NetFifoEntry %04X\n", l2_frame.ethertype; 10 11 CL3Protocol* l3 = l3_protocols; 12 13 while (l3) { 14 if (l3->ethertype == l2_frame.ethertype) { 15 l3->handler(&l2_frame); 16 break; 17 } 18 l3 = l3->next; 19 } 20 } 21 22 U0 NetHandlerTask(I64) { 23 EthernetInit(); 24 25 while (1) { 26 CNetFifoEntry* e = NetFifoPull(); 27 28 if (e) { 29 HandleNetFifoEntry(e); 30 } 31 else { 32 LBts(&Fs->task_flags, TASKf_IDLE); 33 Yield; 34 } 35 } 36 } 37 38 netfifo_handler_task = Spawn(&NetHandlerTask, NULL, "NetHandler");