Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of webserverBlinky by
Diff: PPP-Blinky/ppp-blinky.h
- Revision:
- 152:025c73b6c0a9
- Parent:
- 150:3366bf3d294e
- Child:
- 153:7993def8663f
--- a/PPP-Blinky/ppp-blinky.h Wed Aug 30 16:34:51 2017 +0000 +++ b/PPP-Blinky/ppp-blinky.h Fri Sep 01 15:25:04 2017 +0000 @@ -8,4 +8,77 @@ int connectedPpp(); void scanForConnectString(); void waitForPppFrame(); -void determinePacketType(); \ No newline at end of file +void determinePacketType(); + +typedef struct { // ff 03 00 21 + unsigned int pppAddress : 8, // always 0xff + pppControl : 8, // always 03 + pppProtocol : 16; // 2100 for IP (byte reversed, should be 0021) +} pppHeaderType; + +/// structure of an IP header for small-endian devices +typedef struct { + pppHeaderType pppHeader; // first four bytes is the PPP header [ff 03 00 21] + unsigned int headerLength : 4, // ip headerlength / 4 + version : 4, // ip version number + ect : 1, // ecn capable transport + ce : 1, // ecn-ce + dscp : 6, // differentiated services + length : 16; // ip packet length (byte-reversed) + + unsigned int fragmentOffset : 13, + reserved : 1, + dontFragment : 1, + lastFragment : 1, + ident : 16; + + unsigned int checksum : 16, + protocol : 8, // next protocol + ttl : 8; + + unsigned int srcAdr; // source IP address + + unsigned int dstAdr; // destination IP address +} ipHeaderType; + +typedef struct { + ipHeaderType ip; // first part of TCP header is IP header + unsigned int srcAdr : 16, // byte reversed + dstAdr : 16; // byte reversed + unsigned int seqTcp; + unsigned int ackTcp; + unsigned int res1 : 4, + offset : 4; // tcp header length [5..15] + union { + unsigned int flags : 8; + struct { + unsigned int f:1, s:1, r:1, p:1, a:1, u:1; + }; + }; + unsigned int window : 16; // byte reversed + unsigned int checksum : 16, // byte reversed + urgentPointer : 16; // byte reversed; + unsigned int tcpOptions[10]; // 10 words of options possible +} tcpHeaderType1; + +typedef struct { + ipHeaderType ip; + unsigned int options; + unsigned int srcAdr : 16, // byte reversed + dstAdr : 16; // byte reversed + unsigned int seqTcp; + unsigned int ackTcp; + unsigned int res1 : 4, + offset : 4; // tcp header length [5..15] + union { + unsigned int flags : 8; + struct { + unsigned int f:1, s:1, r:1, p:1, a:1, u:1; + }; + }; + unsigned int window : 16; // byte reversed + unsigned int checksum : 16, // byte reversed + urgentPointer : 16; // byte reversed; + unsigned int tcpOptions[10]; // 10 words of options possible +} tcpHeaderType2; +