summaryrefslogtreecommitdiffstats
path: root/sys/i386/boot
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1996-08-06 21:14:36 +0000
committerphk <phk@FreeBSD.org>1996-08-06 21:14:36 +0000
commit5ac19ff3ee101aa4e4a4b1116882a4b5e5a11161 (patch)
treef630f4ed06a1ba25dccda323532d5e93e6a9d6f3 /sys/i386/boot
parent954270700febe9302cf12727a332d854d9b4188e (diff)
downloadFreeBSD-src-5ac19ff3ee101aa4e4a4b1116882a4b5e5a11161.zip
FreeBSD-src-5ac19ff3ee101aa4e4a4b1116882a4b5e5a11161.tar.gz
Megacommit to straigthen out ETHER_ mess.
I'm pretty convinced after looking at this that the majority of our drivers are confused about the in/exclusion of ETHER_CRC_LEN :-(
Diffstat (limited to 'sys/i386/boot')
-rw-r--r--sys/i386/boot/netboot/3c509.c8
-rw-r--r--sys/i386/boot/netboot/3c509.h5
-rw-r--r--sys/i386/boot/netboot/main.c38
-rw-r--r--sys/i386/boot/netboot/netboot.h6
-rw-r--r--sys/i386/boot/netboot/ns8390.c10
-rw-r--r--sys/i386/boot/netboot/rpc.c8
6 files changed, 33 insertions, 42 deletions
diff --git a/sys/i386/boot/netboot/3c509.c b/sys/i386/boot/netboot/3c509.c
index 9ebfe5d..50b41c0 100644
--- a/sys/i386/boot/netboot/3c509.c
+++ b/sys/i386/boot/netboot/3c509.c
@@ -18,7 +18,7 @@ Author: Martin Renters.
3c509 support added by Serge Babkin (babkin@hq.icb.chel.su)
-$Id: 3c509.c,v 1.1 1995/04/12 20:14:56 martin Exp $
+$Id: 3c509.c,v 1.2 1995/05/30 07:58:52 rgrimes Exp $
***************************************************************************/
@@ -48,7 +48,7 @@ static get_e();
/**************************************************************************
The following two variables are used externally
***************************************************************************/
-char packet[ETH_MAX_PACKET];
+char packet[ETHER_MAX_LEN];
int packetlen;
/*********************** Name of driver *********************************/
@@ -480,7 +480,7 @@ eth_poll()
struct arprequest *arpreq;
unsigned long reqip;
- arpreq = (struct arprequest *)&packet[ETHER_HDR_SIZE];
+ arpreq = (struct arprequest *)&packet[ETHER_HDR_LEN];
#ifdef EDEBUG
printf("(ARP %I->%I)",ntohl(*(int*)arpreq->sipaddr),
@@ -502,7 +502,7 @@ eth_poll()
} else if(type==IP) {
struct iphdr *iph;
- iph = (struct iphdr *)&packet[ETHER_HDR_SIZE];
+ iph = (struct iphdr *)&packet[ETHER_HDR_LEN];
#ifdef EDEBUG
printf("(IP %I-%d->%I)",ntohl(*(int*)iph->src),
ntohs(iph->protocol),ntohl(*(int*)iph->dest));
diff --git a/sys/i386/boot/netboot/3c509.h b/sys/i386/boot/netboot/3c509.h
index 8bfa368..f0e3bcb 100644
--- a/sys/i386/boot/netboot/3c509.h
+++ b/sys/i386/boot/netboot/3c509.h
@@ -37,9 +37,6 @@
/*
* Some global constants
*/
-#define ETHER_MIN_LEN 64
-#define ETHER_MAX_LEN 1518
-#define ETHER_ADDR_LEN 6
#define TX_INIT_RATE 16
#define TX_INIT_MAX_RATE 64
@@ -379,8 +376,6 @@
#define BNC 0x2
#define UTP 0x4
-#define ETHER_ADDR_LEN 6
-#define ETHER_MAX 1536
#define RX_BYTES_MASK (u_short) (0x07ff)
/* EISA support */
diff --git a/sys/i386/boot/netboot/main.c b/sys/i386/boot/netboot/main.c
index daa42e7..6b429a4 100644
--- a/sys/i386/boot/netboot/main.c
+++ b/sys/i386/boot/netboot/main.c
@@ -389,19 +389,19 @@ udp_transmit(destip, srcsock, destsock, len, buf)
printf("%I is not in my arp table!\n");
return(0);
}
- for (i = 0; i<ETHER_ADDR_SIZE; i++)
+ for (i = 0; i<ETHER_ADDR_LEN; i++)
if (arptable[arpentry].node[i]) break;
- if (i == ETHER_ADDR_SIZE) { /* Need to do arp request */
+ if (i == ETHER_ADDR_LEN) { /* Need to do arp request */
arpreq.hwtype = htons(1);
arpreq.protocol = htons(IP);
- arpreq.hwlen = ETHER_ADDR_SIZE;
+ arpreq.hwlen = ETHER_ADDR_LEN;
arpreq.protolen = 4;
arpreq.opcode = htons(ARP_REQUEST);
bcopy(arptable[ARP_CLIENT].node, arpreq.shwaddr,
- ETHER_ADDR_SIZE);
+ ETHER_ADDR_LEN);
convert_ipaddr(arpreq.sipaddr,
&arptable[ARP_CLIENT].ipaddr);
- bzero(arpreq.thwaddr, ETHER_ADDR_SIZE);
+ bzero(arpreq.thwaddr, ETHER_ADDR_LEN);
convert_ipaddr(arpreq.tipaddr, &destip);
while (retry--) {
eth_transmit(broadcast, ARP, sizeof(arpreq),
@@ -438,7 +438,7 @@ tftp(name)
if (!udp_transmit(arptable[ARP_SERVER].ipaddr, isocket, osocket,
len, &tp)) return(0);
if (await_reply(AWAIT_TFTP, isocket, NULL)) {
- tr = (struct tftp_t *)&packet[ETHER_HDR_SIZE];
+ tr = (struct tftp_t *)&packet[ETHER_HDR_LEN];
if (tr->opcode == ntohs(TFTP_ERROR)) {
printf("TFTP error %d (%s)\r\n",
ntohs(tr->u.err.errcode),
@@ -476,9 +476,9 @@ bootp()
bzero(&bp, sizeof(struct bootp_t));
bp.bp_op = BOOTP_REQUEST;
bp.bp_htype = 1;
- bp.bp_hlen = ETHER_ADDR_SIZE;
+ bp.bp_hlen = ETHER_ADDR_LEN;
bp.bp_xid = starttime = currticks();
- bcopy(arptable[ARP_CLIENT].node, bp.bp_hwaddr, ETHER_ADDR_SIZE);
+ bcopy(arptable[ARP_CLIENT].node, bp.bp_hwaddr, ETHER_ADDR_LEN);
while(retry--) {
udp_transmit(IP_BROADCAST, 0, BOOTP_SERVER,
sizeof(struct bootp_t), &bp);
@@ -504,7 +504,7 @@ await_reply(type, ival, ptr)
struct bootp_t *bootpreply;
struct rpc_t *rpc;
- int protohdrlen = ETHER_HDR_SIZE + sizeof(struct iphdr) +
+ int protohdrlen = ETHER_HDR_LEN + sizeof(struct iphdr) +
sizeof(struct udphdr);
time = currticks() + TIMEOUT;
while(time > currticks()) {
@@ -512,16 +512,16 @@ await_reply(type, ival, ptr)
if (eth_poll()) { /* We have something! */
/* Check for ARP - No IP hdr */
if ((type == AWAIT_ARP) &&
- (packetlen >= ETHER_HDR_SIZE +
+ (packetlen >= ETHER_HDR_LEN +
sizeof(struct arprequest)) &&
(((packet[12] << 8) | packet[13]) == ARP)) {
arpreply = (struct arprequest *)
- &packet[ETHER_HDR_SIZE];
+ &packet[ETHER_HDR_LEN];
if ((arpreply->opcode == ntohs(ARP_REPLY)) &&
bcompare(arpreply->sipaddr, ptr, 4)) {
bcopy(arpreply->shwaddr,
arptable[ival].node,
- ETHER_ADDR_SIZE);
+ ETHER_ADDR_LEN);
return(1);
}
continue;
@@ -530,17 +530,17 @@ await_reply(type, ival, ptr)
/* Anything else has IP header */
if ((packetlen < protohdrlen) ||
(((packet[12] << 8) | packet[13]) != IP)) continue;
- ip = (struct iphdr *)&packet[ETHER_HDR_SIZE];
+ ip = (struct iphdr *)&packet[ETHER_HDR_LEN];
if ((ip->verhdrlen != 0x45) ||
ipchksum(ip, sizeof(struct iphdr)) ||
(ip->protocol != IP_UDP)) continue;
- udp = (struct udphdr *)&packet[ETHER_HDR_SIZE +
+ udp = (struct udphdr *)&packet[ETHER_HDR_LEN +
sizeof(struct iphdr)];
/* BOOTP ? */
- bootpreply = (struct bootp_t *)&packet[ETHER_HDR_SIZE];
+ bootpreply = (struct bootp_t *)&packet[ETHER_HDR_LEN];
if ((type == AWAIT_BOOTP) &&
- (packetlen >= (ETHER_HDR_SIZE +
+ (packetlen >= (ETHER_HDR_LEN +
sizeof(struct bootp_t))) &&
(ntohs(udp->dest) == BOOTP_CLIENT) &&
(bootpreply->bp_op == BOOTP_REPLY)) {
@@ -550,11 +550,11 @@ await_reply(type, ival, ptr)
convert_ipaddr(&arptable[ARP_SERVER].ipaddr,
bootpreply->bp_siaddr);
bzero(arptable[ARP_SERVER].node,
- ETHER_ADDR_SIZE); /* Kill arp */
+ ETHER_ADDR_LEN); /* Kill arp */
convert_ipaddr(&arptable[ARP_GATEWAY].ipaddr,
bootpreply->bp_giaddr);
bzero(arptable[ARP_GATEWAY].node,
- ETHER_ADDR_SIZE); /* Kill arp */
+ ETHER_ADDR_LEN); /* Kill arp */
if (bootpreply->bp_file[0]) {
bcopy(bootpreply->bp_file,
kernel_buf, 128);
@@ -569,7 +569,7 @@ await_reply(type, ival, ptr)
(ntohs(udp->dest) == ival)) return(1);
/* RPC */
- rpc = (struct rpc_t *)&packet[ETHER_HDR_SIZE];
+ rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
if ((type == AWAIT_RPC) &&
(ntohs(udp->dest) == RPC_SOCKET) &&
(ntohl(rpc->u.reply.id) == ival) &&
diff --git a/sys/i386/boot/netboot/netboot.h b/sys/i386/boot/netboot/netboot.h
index 7f724e6..f762e0d 100644
--- a/sys/i386/boot/netboot/netboot.h
+++ b/sys/i386/boot/netboot/netboot.h
@@ -13,6 +13,7 @@ Author: Martin Renters
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/mount.h>
+#include <net/ethernet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <nfs/nfsv2.h>
@@ -53,11 +54,6 @@ Author: Martin Renters
#define TRUE 1
#define FALSE 0
-#define ETHER_ADDR_SIZE 6 /* Size of Ethernet address */
-#define ETHER_HDR_SIZE 14 /* Size of ethernet header */
-#define ETH_MIN_PACKET 64
-#define ETH_MAX_PACKET 1518
-
#define VENDOR_NONE 0
#define VENDOR_WD 1
#define VENDOR_NOVELL 2
diff --git a/sys/i386/boot/netboot/ns8390.c b/sys/i386/boot/netboot/ns8390.c
index e0875e2..f1a2f28 100644
--- a/sys/i386/boot/netboot/ns8390.c
+++ b/sys/i386/boot/netboot/ns8390.c
@@ -43,7 +43,7 @@ unsigned char *eth_node_addr;
The following two variables are used externally
**************************************************************************/
char eth_driver[] = "ed0";
-char packet[ETH_MAX_PACKET];
+char packet[ETHER_MAX_LEN];
int packetlen;
#ifdef INCLUDE_NE
@@ -418,7 +418,7 @@ eth_transmit(d,t,s,p)
*(eth_bmem+13) = t;
bcopy(p, eth_bmem+14, s);
s += 14;
- while (s < ETH_MIN_PACKET) *(eth_bmem+(s++)) = 0;
+ while (s < ETHER_MIN_LAN) *(eth_bmem+(s++)) = 0;
}
#endif
#ifdef INCLUDE_WD
@@ -438,7 +438,7 @@ eth_transmit(d,t,s,p)
*(eth_bmem+13) = t;
bcopy(p, eth_bmem+14, s);
s += 14;
- while (s < ETH_MIN_PACKET) *(eth_bmem+(s++)) = 0;
+ while (s < ETHER_MIN_LAN) *(eth_bmem+(s++)) = 0;
if (eth_flags & FLAG_790) {
outb(eth_asic_base + WD_MSR, 0);
inb(0x84);
@@ -458,7 +458,7 @@ eth_transmit(d,t,s,p)
eth_pio_write(&type, (eth_tx_start<<8)+12, 2);
eth_pio_write(p, (eth_tx_start<<8)+14, s);
s += 14;
- if (s < ETH_MIN_PACKET) s = ETH_MIN_PACKET;
+ if (s < ETHER_MIN_LEN) s = ETHER_MIN_LEN;
}
#endif
twiddle();
@@ -565,7 +565,7 @@ eth_poll()
if (ret && (type == ARP)) {
struct arprequest *arpreq;
unsigned long reqip;
- arpreq = (struct arprequest *)&packet[ETHER_HDR_SIZE];
+ arpreq = (struct arprequest *)&packet[ETHER_HDR_LEN];
convert_ipaddr(&reqip, arpreq->tipaddr);
if ((ntohs(arpreq->opcode) == ARP_REQUEST) &&
(reqip == arptable[ARP_CLIENT].ipaddr)) {
diff --git a/sys/i386/boot/netboot/rpc.c b/sys/i386/boot/netboot/rpc.c
index f035248..134667d 100644
--- a/sys/i386/boot/netboot/rpc.c
+++ b/sys/i386/boot/netboot/rpc.c
@@ -31,7 +31,7 @@ rpclookup(addr, prog, ver)
udp_transmit(arptable[addr].ipaddr, RPC_SOCKET,
SUNRPC, rpcptr - (char *)&buf, &buf);
if (await_reply(AWAIT_RPC, rpc_id, NULL)) {
- rpc = (struct rpc_t *)&packet[ETHER_HDR_SIZE];
+ rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
if (rpc->u.reply.rstatus == rpc->u.reply.verifier ==
rpc->u.reply.astatus == 0)
return(ntohl(rpc->u.reply.data[0]));
@@ -66,7 +66,7 @@ nfs_mount(server, port, path, fh)
udp_transmit(arptable[server].ipaddr, RPC_SOCKET,
port, rpcptr - (char *)&buf, &buf);
if (await_reply(AWAIT_RPC, rpc_id, NULL)) {
- rpc = (struct rpc_t *)&packet[ETHER_HDR_SIZE];
+ rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
if (rpc->u.reply.rstatus || rpc->u.reply.verifier ||
rpc->u.reply.astatus || rpc->u.reply.data[0]) {
rpc_err(rpc);
@@ -104,7 +104,7 @@ nfs_lookup(server, port, fh, path, file_fh)
udp_transmit(arptable[server].ipaddr, RPC_SOCKET,
port, rpcptr - (char *)&buf, &buf);
if (await_reply(AWAIT_RPC, rpc_id, NULL)) {
- rpc = (struct rpc_t *)&packet[ETHER_HDR_SIZE];
+ rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
if (rpc->u.reply.rstatus || rpc->u.reply.verifier ||
rpc->u.reply.astatus || rpc->u.reply.data[0]) {
rpc_err(rpc);
@@ -143,7 +143,7 @@ nfs_read(server, port, fh, offset, len, buffer)
udp_transmit(arptable[server].ipaddr, RPC_SOCKET,
port, rpcptr - (char *)&buf, &buf);
if (await_reply(AWAIT_RPC, rpc_id, NULL)) {
- rpc = (struct rpc_t *)&packet[ETHER_HDR_SIZE];
+ rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
if (rpc->u.reply.rstatus || rpc->u.reply.verifier ||
rpc->u.reply.astatus || rpc->u.reply.data[0]) {
rpc_err(rpc);
OpenPOWER on IntegriCloud