[U-Boot-Users] question about net/net.c

I had a question about the latest version of net/net.c
scenario is as follows.
1. u-boot initiates a tftp transfer 2. u-boot sets a flag "NetArpWaitPacketMAC = 1" 3. u-boot sends ARP Request on network to find the MAC address of tftp server 4. server is a little slow, and u-boot has not yet received the ARP so, u-boot sends ARP Request on network to find the MAC address of tftp server 5. tftp server responds back to first request with it's MAC address, and u-boot sees this, and accepts it. 6. u-boot sets the flag "NetArpWaitPacketMAC = 0" as it got the ARP reply 7. tftp server responds back to second request with it's MAC address, and u-boot sees this, and accepts it.
At this point as u-boot is not waiting (NetArpWaitPacketMAC is 0) for ARP reply breaks out of the switch that handles ARP reply. But this break is not to return from the complete handler and thus falls into RARP handler code.
8. u-boot prints out "invalid RARP header".
This can be observed in net\net.c "NetReceive" function.
===============================================
void NetReceive(volatile uchar * inpkt, int len) {
[snip/snip]
switch (x) {
case PROT_ARP: switch (ntohs(arp->ar_op)) { case ARPOP_REQUEST: /* reply with our IP address */ return;
case ARPOP_REPLY: /* arp reply */ /* are we waiting for a reply */ if (!NetArpWaitPacketIP || !NetArpWaitPacketMAC) break; return; default: return; }
case PROT_RARP: break;
================================================== am I missing something or shouldn't there be a break; above the 'case PROT_RARP:' to handle this?
Thanks -Robin

In message 6.1.1.1.0.20041021094242.01deca40@wheresmymailserver.com you wrote:
am I missing something or shouldn't there be a break; above the 'case PROT_RARP:' to handle this?
Can you please re-send this question in form of a (suggested / potential) patch? That would be much more readable.
Thanks.
Best regards,
Wolfgang Denk

Pseudo patch...
On Thursday 21 October 2004 18.43, Robin Getz wrote:
void NetReceive(volatile uchar * inpkt, int len) {
[snip/snip]
switch (x) { // 1:st switch case PROT_ARP: switch (ntohs(arp->ar_op)) { // 2:nd switch case ARPOP_REQUEST: /* reply with our IP
address */ return;
case ARPOP_REPLY: /* arp reply */ /* are we waiting for a reply */ if (!NetArpWaitPacketIP || !NetArpWaitPacketMAC)
- break; // (current) breaks 2:nd switch + return; //
return; default:
return; }
// We end up here after break with ARPOP_REPLY and not waiting + break; or + /* no break, fall through */ // (current)
case PROT_RARP: break;
My guess is that break should be replaced with return. But the second break would be nice too...
/RogerL
Optronic dp AB
participants (3)
-
Robin Getz
-
Roger Larsson
-
Wolfgang Denk