浏览代码

net: Define IP flag field values

These defines were pulled from the "Add simple
IP/UDP fragmentation support" patch from Frank
Haverkamp <haver@vnet.ibm.com>.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
Peter Tyser 16 年之前
父节点
当前提交
e0c07b868c
共有 2 个文件被更改,包括 9 次插入3 次删除
  1. 6 0
      include/net.h
  2. 3 3
      net/net.c

+ 6 - 0
include/net.h

@@ -200,6 +200,12 @@ typedef struct {
 	ushort		udp_xsum;	/* Checksum			*/
 	ushort		udp_xsum;	/* Checksum			*/
 } IP_t;
 } IP_t;
 
 
+#define IP_OFFS		0x1fff /* ip offset *= 8 */
+#define IP_FLAGS	0xe000 /* first 3 bits */
+#define IP_FLAGS_RES	0x8000 /* reserved */
+#define IP_FLAGS_DFRAG	0x4000 /* don't fragments */
+#define IP_FLAGS_MFRAG	0x2000 /* more fragments */
+
 #define IP_HDR_SIZE_NO_UDP	(sizeof (IP_t) - 8)
 #define IP_HDR_SIZE_NO_UDP	(sizeof (IP_t) - 8)
 #define IP_HDR_SIZE		(sizeof (IP_t))
 #define IP_HDR_SIZE		(sizeof (IP_t))
 
 

+ 3 - 3
net/net.c

@@ -735,7 +735,7 @@ int PingSend(void)
 	ip->ip_tos   = 0;
 	ip->ip_tos   = 0;
 	ip->ip_len   = htons(IP_HDR_SIZE_NO_UDP + 8);
 	ip->ip_len   = htons(IP_HDR_SIZE_NO_UDP + 8);
 	ip->ip_id    = htons(NetIPID++);
 	ip->ip_id    = htons(NetIPID++);
-	ip->ip_off   = htons(0x4000);	/* No fragmentation */
+	ip->ip_off   = htons(IP_FLAGS_DFRAG);	/* Don't fragment */
 	ip->ip_ttl   = 255;
 	ip->ip_ttl   = 255;
 	ip->ip_p     = 0x01;		/* ICMP */
 	ip->ip_p     = 0x01;		/* ICMP */
 	ip->ip_sum   = 0;
 	ip->ip_sum   = 0;
@@ -1399,7 +1399,7 @@ NetReceive(volatile uchar * inpkt, int len)
 		if ((ip->ip_hl_v & 0xf0) != 0x40) {
 		if ((ip->ip_hl_v & 0xf0) != 0x40) {
 			return;
 			return;
 		}
 		}
-		if (ip->ip_off & htons(0x1fff)) { /* Can't deal w/ fragments */
+		if (ip->ip_off & htons(IP_OFFS)) { /* Can't deal w/ fragments */
 			return;
 			return;
 		}
 		}
 		/* can't deal with headers > 20 bytes */
 		/* can't deal with headers > 20 bytes */
@@ -1698,7 +1698,7 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
 	ip->ip_tos   = 0;
 	ip->ip_tos   = 0;
 	ip->ip_len   = htons(IP_HDR_SIZE + len);
 	ip->ip_len   = htons(IP_HDR_SIZE + len);
 	ip->ip_id    = htons(NetIPID++);
 	ip->ip_id    = htons(NetIPID++);
-	ip->ip_off   = htons(0x4000);	/* No fragmentation */
+	ip->ip_off   = htons(IP_FLAGS_DFRAG);	/* Don't fragment */
 	ip->ip_ttl   = 255;
 	ip->ip_ttl   = 255;
 	ip->ip_p     = 17;		/* UDP */
 	ip->ip_p     = 17;		/* UDP */
 	ip->ip_sum   = 0;
 	ip->ip_sum   = 0;