RealtimeCompLab2
Dependencies: mbed
Fork of PPP-Blinky by
Diff: PPP-Blinky/ppp-blinky.h
- Revision:
- 159:4d1bf96a59cd
- Parent:
- 156:163c23249731
- Child:
- 160:bd701ad564cb
--- a/PPP-Blinky/ppp-blinky.h Sat Sep 02 01:55:19 2017 +0000 +++ b/PPP-Blinky/ppp-blinky.h Sat Sep 02 07:48:53 2017 +0000 @@ -10,14 +10,14 @@ void waitForPppFrame(); void determinePacketType(); -/// structure of a PPP header +/// PPP header typedef struct { // [ff 03 00 21] unsigned int pppAddress : 8; // always 0xff unsigned int pppControl : 8; // always 03 unsigned int pppProtocol : 16; // 2100 for IP (byte reversed, should be 0021) } pppHeaderType; -/// structure of an IP header for little-endian devices +/// IP header typedef struct { unsigned int headerLength : 4; // ip headerlength / 4 unsigned int version : 4; // ip version number @@ -37,10 +37,22 @@ unsigned int dstAdrR; // destination IP address } ipHeaderType; -/// structure of TCP header +/// IP pseudoheader typedef struct { - unsigned int srcAdrR : 16; // byte reversed - unsigned int dstAdrR : 16; // byte reversed + union { + unsigned char start [0]; + unsigned int srcAdrR; // source IP address + }; + unsigned int dstAdrR; // destination IP address + unsigned int zero : 8; + unsigned int protocol : 8; + unsigned int lengthR : 16; // byte reversed +} pseudoIpHeaderType; + +/// TCP header +typedef struct { + unsigned int srcPortR : 16; // byte reversed + unsigned int dstPortR : 16; // byte reversed unsigned int seqTcpR; // byte reversed unsigned int ackTcpR; // byte reversed unsigned int resvd1 : 4; // reserved @@ -63,3 +75,4 @@ unsigned int urgentPointerR : 16; // byte reversed; unsigned int tcpOptions[10]; // up to 10 words of options possible } tcpHeaderType; +