shithub: riscv

Download patch

ref: 2a29b497f215f91d05b6718a0e852e8a9b6ce6da
parent: 6b38e52e4b38370d3097a32550ba9cace6782888
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Oct 8 06:33:21 EDT 2022

devip: use port/netif.h constants for ethermedium

--- a/sys/src/9/ip/ethermedium.c
+++ b/sys/src/9/ip/ethermedium.c
@@ -9,11 +9,6 @@
 #include "ip.h"
 #include "ipv6.h"
 
-enum {
-	EHSIZE = 14,
-	EMINTU = 60,
-};
-
 typedef struct Etherhdr Etherhdr;
 struct Etherhdr
 {
@@ -40,9 +35,9 @@
 Medium ethermedium =
 {
 .name=		"ether",
-.hsize=		EHSIZE,
-.mintu=		EMINTU,
-.maxtu=		1514,
+.hsize=		ETHERHDRSIZE,
+.mintu=		ETHERMINTU,
+.maxtu=		ETHERHDRSIZE+1500,
 .maclen=	6,
 .bind=		etherbind,
 .unbind=	etherunbind,
@@ -56,9 +51,9 @@
 Medium gbemedium =
 {
 .name=		"gbe",
-.hsize=		EHSIZE,
-.mintu=		EMINTU,
-.maxtu=		9014,
+.hsize=		ETHERHDRSIZE,
+.mintu=		ETHERMINTU,
+.maxtu=		ETHERHDRSIZE+9000,
 .maclen=	6,
 .bind=		etherbind,
 .unbind=	etherunbind,
@@ -285,9 +280,9 @@
 	assert(bp->list == nil);
 
 	/* make it a single block with space for the ether header */
-	bp = padblock(bp, EHSIZE);
-	if(BLEN(bp) < EMINTU)
-		bp = adjustblock(bp, EMINTU);
+	bp = padblock(bp, ETHERHDRSIZE);
+	if(BLEN(bp) < ETHERMINTU)
+		bp = adjustblock(bp, ETHERMINTU);
 	eh = (Etherhdr*)bp->rp;
 
 	/* copy in mac addresses and ether type */
@@ -336,10 +331,10 @@
 			nexterror();
 		}
 		ifc->in++;
-		if(ifc->lifc == nil || BLEN(bp) <= EHSIZE)
+		if(ifc->lifc == nil || BLEN(bp) <= ETHERHDRSIZE)
 			freeb(bp);
 		else {
-			bp->rp += EHSIZE;
+			bp->rp += ETHERHDRSIZE;
 			ipiput4(er->f, ifc, bp);
 		}
 		runlock(ifc);
@@ -374,10 +369,10 @@
 			nexterror();
 		}
 		ifc->in++;
-		if(ifc->lifc == nil || BLEN(bp) <= EHSIZE)
+		if(ifc->lifc == nil || BLEN(bp) <= ETHERHDRSIZE)
 			freeb(bp);
 		else {
-			bp->rp += EHSIZE;
+			bp->rp += ETHERHDRSIZE;
 			ipiput6(er->f, ifc, bp);
 		}
 		runlock(ifc);
@@ -436,9 +431,9 @@
 {
 	Block *bp;
 
-	bp = allocb(EMINTU);
-	bp->wp += EMINTU;
-	memset(bp->rp, 0, EMINTU);
+	bp = allocb(ETHERMINTU);
+	bp->wp += ETHERMINTU;
+	memset(bp->rp, 0, ETHERMINTU);
 	return bp;
 }