pcmattman wrote:My mistake, it's actually not the TTL that made the difference. Turning off the firewall did. Sometimes the firewall just decides to block the ping, other times it decides to let it through.
Disabling the firewall always works.
And I plan to do a lot of reading soon. I have been doing a lot of reading.
Code: Select all
296 void neIrqHandler( struct regs* r )
297 {
298 struct ne2000_t* ne = neDevs[0];
299 uint8_t status;
300 packet_t *p;
301 while(1)
302 {
303 status = inportb(ne->ioAddress + INTERRUPTSTATUS);
304 outportb(ne->ioAddress + INTERRUPTSTATUS, status);
305
306 if(status & 0x1)
307 {
308 //kprintf( "NE2000: Packet Recieved\n" );
309 p = readPacket(ne);
310 handleEthernet(ne->eth, p);
311 }
312 else if(status & 0xa)
313 {
314 //kprintf( "NE2000: Packet Transmitted\n" );
315 }
316 else
317 {
318 break;
319 }
320 }
321 }
That won't work reliably. My code looked like that initially, but there's a race: if you don't handle a packet before another arrives (say you've got interrupts disabled too long) it'll queue another packet, but when you clear the ISR bit for receive it will NOT automatically set the bit again simply because you have more packets to be read. It'll only set it once the next packet arrives, which means you'll go out of sync.
The only reliable solution I've found is to do the following, in order:
1. check ISR, if says no packets received, we're done
2. reset the ISR bit about packets received
3. read CURRENT pointer from Page1.
4. read packets until "next packet" of the last packet = CURRENT value that was read at step 3
5. Goto 1 (in case we got more packets while reading)
Also notice that you can't actually have BOUNDARY=CURRENT since at least QEMU would think the NIC memory is full. So you must leave one unused page in between, complicating the logic a bit. National datasheet actually recommends doing this, so I guess there's also hardware that requires it, but said datasheet also shows how to do it.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.