/*
Ethernet Frame:
min: 72 bytes	max: 1526 bytes
	Preamble   Destination	Source	   Type		Data		CRC
	 8 bytes     6 bytes	6 bytes	   2 bytes   46-1500 bytes	4 bytes
*/

#define EHLEN	14		/* Ethernet header length */
#define MINTRANSMIT 60		/* minimum Ethernet transmit size */

#define EP_RAW	0x0000		/* Raw packet */
#define EP_LOOP	0x0060		/* Loopback packet */
#define EP_ECHO 0x0200		/* Echo */
#define EP_PUP  0x0201		/* Xerox PUP */
#define EP_IP	0x0800		/* DARPA Internet protocol */
#define EP_ARP	0x0806		/* ARP packet */
#define EP_RARP	0x8035		/* reverse ARP packet */

typedef struct eheader {
	unsigned char rstatus;	/* Received packet status */
	unsigned char npp;	/* Next Packet Pointer */
	unsigned short int rbc;	/* Received Byte Count */
	char e_dest[6];		/* Destination address */
	char e_src[6];		/* Source address */
	short int e_ptype;	/* Ethernet packet type */
} eheader;

typedef struct epacket {
	struct eheader ep_hdr;	/* packet header */
	char ep_data[1500];	/* packet data */
} epacket;

#define AR_HRD	1		/* Ethernet hardware type code */
#define AR_PROT 0x0800		/* IP protocol address code */
#define AR_HLEN	6		/* Ethernet physical address length */
#define AR_PLEN 4		/* IP Protocol address length */
#define AR_TAB	6		/* size of IP to Ether addr. cache */
#define AR_TIME	60		/* time to wait for reply in 100 ms */
#define AR_RTRY	2		/* number of times to retry ARPs */

#define AR_REQ	1		/* arp request to resolve address */
#define AR_RPLY	2		/* reply to a resolve request */
#define AR_RREQ	3		/* reverse ARP request */
#define AR_RRLY	4		/* reply to a RARP */

typedef struct arppak {
    short ar_hrd;
    short ar_prot;
    char ar_hlen;
    char ar_plen;
    short ar_op;
    char ar_sha[6];
    long ar_spa;
    char ar_tha[6];
    long ar_tpa;
} arppak;

/*
IP Packet:
min: 46 bytes	max: 1500
Vers Len Type TLen ID Flags Frag Time Proto Chk Src Dst Opt Pad  Data
.5   .5   1    2    2  .5   1.5   1     1    2   4   4   0   0  26-1480
*/

#define IPTMASK	0300		/* Mask for IP type in top byte */
#define IPATYP	0000		/* IP Class A address */
#define IPBTYP	0200		/* IP Class B address */
#define IPCTYP	0300		/* IP Class C address */
#define IPHLEN	20		/* IP datagram header length */
#define IMAXLEN	1400		/* Max IP datagram */

#define IPRO_ICMP	1	/* Protocol type for ICMP */
#define IPRO_TCP	6	/* Protocol type for ICMP */
#define IPRO_UDP	17	/* Protocol type for UDP packets */
#define IVERLEN	0x45		/* current version length field */
#define	ISVCTYP	'\0'		/* Service type for normal service */
#define IFRAGOFF 0		/* Fragment offset (0 for no frag */
#define ITIM2LIV 10		/* Initial time-to-live */

#define MAXIPDATA 1480
typedef struct ip {
    char i_verlen;		/* IP version */
    char i_svctyp;		/* Service type */
    short i_paclen;		/* Packet length in bytes */
    short i_id;			/* datagram ID for fragmentation */
    short i_fragoff;		/* Fragment offset */
    char i_tim2liv;		/* time to live in gateway hops */
    char i_proto;		/* IP protocol */
    short i_cksum;		/* 1's compl. of sum of shorts (header) */
    long i_src;			/* IP address of source */
    long i_dest;		/* IP address of destination */
    char i_data[MAXIPDATA]		/* IP datagram data area */
}  ip;


#define MAXUDPDATA 1472
#define UDPHLEN 8
typedef struct iudp {
	unsigned short srcprt;	/* source port */
	unsigned short dstprt;	/* destination port */
	unsigned short length;	/* length */
	unsigned short cksum;	/* checksum */
	unsigned char data[MAXUDPDATA];	/* raw data */
}  iudp;

/*
 * debugger packet structure
 */

typedef struct dbugpkt {
	unsigned char seqno[4];
	unsigned char stx;
	unsigned char frameno;
	unsigned char len[2];
	unsigned char data[MAXUDPDATA-4];
}  dbugpkt;

/*
 * Connect command parameters
 */

typedef struct concmd {
	unsigned short  ec_monport;
	unsigned short  ec_hostport;
}  concmd;

