RealtimeCompLab2
Dependencies: mbed
Fork of PPP-Blinky by
Diff: main.cpp
- Revision:
- 18:3e35de1bc877
- Parent:
- 17:4918c893d802
- Child:
- 19:e53cdee9a33c
--- a/main.cpp Sun Jan 01 22:20:13 2017 +0000 +++ b/main.cpp Sun Jan 01 22:37:44 2017 +0000 @@ -232,8 +232,9 @@ ipTTL[0]--; // decrement time to live char * srcAdr = ipPkt+12; char * dstAdr = ipPkt+16; - debug(("Ping\n")); - if (0) { debug(("ICMP PING %d.%d.%d.%d %d.%d.%d.%d Head %04d Tail=%04d ", srcAdr[0],srcAdr[1],srcAdr[2],srcAdr[3],dstAdr[0],dstAdr[1],dstAdr[2],dstAdr[3],ppp.rx.head,ppp.rx.tail)); } + int icmpIdent = (icmpType[4]<<8)|icmpType[5]; + int icmpSequence = (icmpType[6]<<8)|icmpType[7]; + debug(("ICMP PING %d.%d.%d.%d %d.%d.%d.%d Ident %04x Sequence %04d ", srcAdr[0],srcAdr[1],srcAdr[2],srcAdr[3],dstAdr[0],dstAdr[1],dstAdr[2],dstAdr[3],icmpIdent,icmpSequence)); char src[4]; char dst[4]; memcpy(src, srcAdr,4); memcpy(dst, dstAdr,4); @@ -252,12 +253,9 @@ int printSize = icmpLength-8; // exclude size of icmp header char * icmpData = icmpType+8; // the actual data is after the header if (printSize > 10) printSize = 10; // print only first 20 characters -// for (int i=0; i<printSize; i++) { char ch = icmpData[i]; if (ch>31 && ch<127) { debug(("%c",ch)); } else { debug(("%c",'_')); }} -// debug(("%c",'\n')); - + for (int i=0; i<printSize; i++) { char ch = icmpData[i]; if (ch>31 && ch<127) { debug(("%c",ch)); } else { debug(("%c",'_')); }} + debug(("%c",'\n')); sendFrame(); // reply to the ping - - } else { debug(("ICMP type=%d \n", icmpType[0])); }