From 49f933fbc3a55071e1cac362f7e1b5f2fd41b657 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 19 Apr 2006 01:52:41 +0000 Subject: Moved if_ether.h and if_arp.h to include/gpxe, for consistency with Linux kernel. Removed obsolete struct arprequest from if_arp.h and put it in nic.c so that nic.c will still compile. ARP will very shortly be handled by net/arp.c instead. --- src/core/nic.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/nic.c b/src/core/nic.c index be6eb7bc4..04d48a115 100644 --- a/src/core/nic.c +++ b/src/core/nic.c @@ -24,6 +24,18 @@ Literature dealing with the network protocols: #include "background.h" #include "elf.h" /* FOR EM_CURRENT */ +struct arprequest { + uint16_t hwtype; + uint16_t protocol; + uint8_t hwlen; + uint8_t protolen; + uint16_t opcode; + uint8_t shwaddr[6]; + uint8_t sipaddr[4]; + uint8_t thwaddr[6]; + uint8_t tipaddr[4]; +} PACKED; + struct arptable_t arptable[MAX_ARP]; /* Put rom_info in .nocompress section so romprefix.S can write to it */ struct rom_info rom __attribute__ ((section (".text16.nocompress"))) = {0,0}; @@ -427,7 +439,7 @@ static int await_arp(int ival, void *ptr, return 0; arpreply = (struct arprequest *)&nic.packet[ETH_HLEN]; - if (arpreply->opcode != htons(ARP_REPLY)) + if (arpreply->opcode != htons(ARPOP_REPLY)) return 0; if (memcmp(arpreply->sipaddr, ptr, sizeof(in_addr)) != 0) return 0; @@ -474,10 +486,10 @@ int ip_transmit(int len, const void *buf) break; if (i == ETH_ALEN) { /* Need to do arp request */ arpreq.hwtype = htons(1); - arpreq.protocol = htons(IP); + arpreq.protocol = htons(ETH_P_IP); arpreq.hwlen = ETH_ALEN; arpreq.protolen = 4; - arpreq.opcode = htons(ARP_REQUEST); + arpreq.opcode = htons(ARPOP_REQUEST); memcpy(arpreq.shwaddr, arptable[ARP_CLIENT].node, ETH_ALEN); memcpy(arpreq.sipaddr, &arptable[ARP_CLIENT].ipaddr, sizeof(in_addr)); memset(arpreq.thwaddr, 0, ETH_ALEN); @@ -974,9 +986,9 @@ int await_reply(reply_t reply, int ival, void *ptr, long timeout) arpreply = (struct arprequest *)&nic.packet[ETH_HLEN]; memcpy(&tmp, arpreply->tipaddr, sizeof(in_addr)); - if ((arpreply->opcode == htons(ARP_REQUEST)) && + if ((arpreply->opcode == htons(ARPOP_REQUEST)) && (tmp == arptable[ARP_CLIENT].ipaddr.s_addr)) { - arpreply->opcode = htons(ARP_REPLY); + arpreply->opcode = htons(ARPOP_REPLY); memcpy(arpreply->tipaddr, arpreply->sipaddr, sizeof(in_addr)); memcpy(arpreply->thwaddr, arpreply->shwaddr, ETH_ALEN); memcpy(arpreply->sipaddr, &arptable[ARP_CLIENT].ipaddr, sizeof(in_addr)); -- cgit v1.2.3-55-g7522