Lab2_web / Mbed 2 deprecated webserverBlinky

Dependencies:   mbed

Fork of webserverBlinky by RealTimeCompLab2

Revision:
176:011dbb3f7d03
Parent:
174:e5a3f16421a5
Parent:
175:b4e6f8a6fe00
Child:
177:dab9e685af53
--- a/PPP-Blinky/ppp-blinky.cpp	Wed Sep 06 14:27:04 2017 +0000
+++ b/PPP-Blinky/ppp-blinky.cpp	Wed Sep 06 21:15:44 2017 +0000
@@ -155,57 +155,6 @@
 // the standard hdlc frame start/end character. It's the tilde character "~"
 #define FRAME_7E (0x7e)
 
-/// a structure to keep all our ppp variables in
-struct pppType {
-    union {
-        pppHeaderType * ppp; // pointer to ppp structure
-        ipcpHeaderType * ipcp; // pointer to ipcp structure
-    };
-    union {
-        ipHeaderType * ip; // pointer to ip header struct
-        char * ipStart; // char pointer to ip header struct (need a char pointer for byte offset calculations)
-    };
-    union { // a union for the packet type contained in the IP packet
-        tcpHeaderType  * tcp;  // pointer to tcp header struct
-        udpHeaderType  * udp;  // pointer to udp header struct
-        icmpHeaderType * icmp; // pointer to udp header struct
-        char * tcpStart;  // char pointer to tcp header struct  (need a char pointer for byte offset calculations)
-        char * udpStart;  // char pointer to udp header struct  (need a char pointer for byte offset calculations)
-        char * icmpStart; // char pointer to icmp header struct (need a char pointer for byte offset calculations)
-    };
-    char * tcpData; // char pointer to where tcp data starts
-    int online; // we hunt for a PPP connection if this is zero
-    int hostIP; // ip address of host
-    int fcs; // PPP "frame check sequence" - a 16-bit HDLC-like checksum used in all PPP frames
-    int ledState; // state of LED1
-    int responseCounter;
-    int firstFrame; // cleared after first frame
-    unsigned int sum; // a checksum used in headers
-    struct {
-#define RXBUFLEN (1<<11)
-        // the serial port receive buffer and packet buffer, size is RXBUFLEN (currently 2048 bytes)
-        char buf[RXBUFLEN]; // RXBUFLEN MUST be a power of two because we use & operator for fast wrap-around in ring buffer
-        int head;
-        int tail;
-        int rtail;
-        int buflevel;
-    } rx; // serial port objects
-    struct {
-        int len; // number of bytes in buffer
-        int crc; // PPP CRC (frame check)
-#define PPP_max_size 1600
-        // we are assuming 100 bytes more than MTU size of 1500
-        char buf[PPP_max_size]; // send and receive buffer large enough for largest IP packet
-    } pkt; // ppp buffer objects
-    struct {
-        int frameStartIndex; // frame start marker
-        int frameEndIndex; // frame end marker
-    } hdlc; // hdlc frame objects
-    struct {
-        unsigned int ident; // our IP ident value (outgoing frame count)
-    } ipData; // ip related object
-};
-
 pppType ppp; // our global - definitely not thread safe
 
 /// Initialize the ppp structure and clear the receive buffer
@@ -223,8 +172,8 @@
     ppp.hdlc.frameStartIndex=0;
     ppp.responseCounter=0;
     ppp.firstFrame=1;
-    ppp.ppp = (pppHeaderType *)ppp.pkt.buf;
-    ppp.ip = (ipHeaderType *)(ppp.pkt.buf+4); // ppp header is 4 bytes long
+    ppp.ppp = (pppHeaderType *)ppp.pkt.buf; // pointer to ppp header
+    ppp.ip = (ipHeaderType *)(ppp.pkt.buf+4); // pointer to IP header
 }
 
 /// Toggle the LED on every second PPP packet received
@@ -1155,16 +1104,16 @@
 void LCPconfReq()
 {
     debugPrintf("LCP Config ");
-    if ( ppp.ipcp->lengthR != __REV16(4) ) {
-        ppp.ipcp->code=4; // allow only "no options" which means Maximum Receive Unit (MRU) is default 1500 bytes
+    if ( ppp.lcp->lengthR != __REV16(4) ) {
+        ppp.lcp->code=4; // allow only "no options" which means Maximum Receive Unit (MRU) is default 1500 bytes
         debugPrintf("Reject\n");
         sendPppFrame();
     } else {
-        ppp.ipcp->code=2; // ack zero conf
+        ppp.lcp->code=2; // ack zero conf
         debugPrintf("Ack\n");
         sendPppFrame();
         debugPrintf("LCP Ask\n");
-        ppp.ipcp->code=1; // request no options
+        ppp.lcp->code=1; // request no options
         sendPppFrame();
     }
 }
@@ -1178,7 +1127,7 @@
 /// handle LCP end (disconnect) packets by acknowledging them and by setting ppp.online to false
 void LCPend()
 {
-    ppp.ipcp->code=6; // end
+    ppp.lcp->code=6; // end
     sendPppFrame(); // acknowledge
     ppp.online=0; // start hunting for connect string again
     pppInitStruct(); // flush the receive buffer
@@ -1195,7 +1144,7 @@
 /// process incoming LCP packets
 void LCPframe()
 {
-    int code = ppp.ipcp->code;
+    int code = ppp.lcp->code;
     switch (code) {
         case 1:
             LCPconfReq();