iplib: Add protocol constants to iplib.h
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 6 Jan 2017 21:29:42 +0000 (16:29 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 10 Jan 2017 00:01:40 +0000 (19:01 -0500)
A few of these were in ipconfig.  Likewise, dial.c was manually defining a
constant from iplib.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tools/apps/ipconfig/ipconfig.h
user/iplib/dial.c
user/iplib/include/iplib/iplib.h

index 996f246..f34620d 100644 (file)
@@ -174,10 +174,6 @@ enum {
 
        IP_HOPBYHOP = 0,
        ICMPv4 = 1,
-       IP_IGMPPROTO = 2,
-       IP_TCPPROTO = 6,
-       IP_UDPPROTO = 17,
-       IP_ILPROTO = 40,
        IP_v6ROUTE = 43,
        IP_v6FRAG = 44,
        IP_IPsecESP = 50,
index 9c36050..b38c441 100644 (file)
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <iplib/iplib.h>
 
 #define NAMELEN 28
-#define NETPATHLEN 40
+
 static int isdigit(int c)
 {
        return ((c >= '0' && c <= '9'));
index 5ee67ca..94cdabc 100644 (file)
@@ -14,6 +14,63 @@ __BEGIN_DECLS
 
 enum 
 {
+       ETH_HDR_LEN                     = 14,
+       ETH_OFF_DST                     = 0,
+       ETH_OFF_SRC                     = 6,
+       ETH_OFF_ETYPE           = 12,
+
+       ETH_ADDR_LEN            = 6,
+       ETH_TYPE_IPV4           = 0x0800,
+       ETH_TYPE_ARP            = 0x0806,
+       ETH_TYPE_IPV6           = 0x86dd,
+       ETH_HTYPE_ETH           = 1,
+
+       IPV4_HDR_LEN            = 20,
+       IPV4_OFF_LEN            = 2,
+       IPV4_OFF_ID                     = 4,
+       IPV4_OFF_TTL            = 8,
+       IPV4_OFF_PROTO          = 9,
+       IPV4_OFF_XSUM           = 10,
+       IPV4_OFF_SRC            = 12,
+       IPV4_OFF_DST            = 16,
+
+       IPV4_ADDR_LEN           = 4,
+       IP_ICMPPROTO            = 1,
+       IP_IGMPPROTO            = 2,
+       IP_TCPPROTO                     = 6,
+       IP_UDPPROTO                     = 17,
+       IP_ILPROTO                      = 40,
+
+       UDP_HDR_LEN                     = 8,
+       UDP_OFF_SRC_PORT        = 0,
+       UDP_OFF_DST_PORT        = 2,
+       UDP_OFF_LEN                     = 4,
+       UDP_OFF_XSUM            = 6,
+
+       TCP_HDR_LEN                     = 20,
+       TCP_OFF_SRC_PORT        = 0,
+       TCP_OFF_DST_PORT        = 2,
+       TCP_OFF_SEQ                     = 4,
+       TCP_OFF_ACK                     = 8,
+       TCP_OFF_DATA            = 12,
+       TCP_OFF_FL                      = 12,
+       TCP_OFF_WIN                     = 14,
+       TCP_OFF_XSUM            = 16,
+
+       ARP_PKT_LEN                     = 28,
+       ARP_OFF_HTYPE           = 0,
+       ARP_OFF_PTYPE           = 2,
+       ARP_OFF_HLEN            = 4,
+       ARP_OFF_PLEN            = 5,
+       ARP_OFF_OP                      = 6,
+       ARP_OFF_SHA                     = 8,
+       ARP_OFF_SPA                     = 14,
+       ARP_OFF_THA                     = 18,
+       ARP_OFF_TPA                     = 24,
+
+       ARP_OP_REQ                      = 1,
+       ARP_OP_RSP                      = 2,
+
        IPaddrlen=      16,
        IPv4addrlen=    4,
        IPv4off=        12,