RealtimeCompLab2
Dependencies: mbed
Fork of PPP-Blinky by
Diff: main.cpp
- Revision:
- 55:43faae812be3
- Parent:
- 54:13f83621db80
- Child:
- 56:b5b2e1c09f42
--- a/main.cpp Sun Jan 29 21:34:46 2017 +0000 +++ b/main.cpp Sun Jan 29 21:45:33 2017 +0000 @@ -276,14 +276,18 @@ char * udpPkt = ppp.pkt.buf+4; // udp packet start int headerSizeIP = (( udpPkt[0]&0xf)*4); char * udpBlock = udpPkt + headerSizeIP; // udp info start +#ifndef SERIAL_PORT_MONITOR_NO char * udpSrc = udpBlock; // source port char * udpDst = udpBlock+2; // destination port +#endif char * udpLen = udpBlock+4; // udp data length char * udpInf = udpBlock+8; // actual start of info +#ifndef SERIAL_PORT_MONITOR_NO int srcPort = (udpSrc[0]<<8) | udpSrc[1]; int dstPort = (udpDst[0]<<8) | udpDst[1]; char * srcIP = udpPkt+12; // udp src addr char * dstIP = udpPkt+16; // udp dst addr +#endif #define UDP_HEADER_SIZE 8 int udpLength = ((udpLen[0]<<8) | udpLen[1]) - UDP_HEADER_SIZE; // size of the actual udp data if(v1) debug("UDP %d.%d.%d.%d:%d ", srcIP[0],srcIP[1],srcIP[2],srcIP[3],srcPort); @@ -361,8 +365,10 @@ ipTTL[0]--; // decrement time to live char * srcAdr = ipPkt+12; char * dstAdr = ipPkt+16; +#ifndef SERIAL_PORT_MONITOR_NO int icmpIdent = (icmpType[4]<<8)|icmpType[5]; int icmpSequence = (icmpType[6]<<8)|icmpType[7]; +#endif debug("ICMP PING %d.%d.%d.d %d.%d.%d.%d ", srcAdr[0],srcAdr[1],srcAdr[2],srcAdr[3],dstAdr[0],dstAdr[1],dstAdr[2],dstAdr[3]); debug("Ident %04x Sequence %04d ",icmpIdent,icmpSequence); char src[4]; @@ -417,6 +423,7 @@ void dumpHeaderIP () { char * ipPkt = ppp.pkt.buf+4; // ip packet start +#ifndef SERIAL_PORT_MONITOR_NO char * version = ipPkt; // top 4 bits char * ihl = ipPkt; // bottom 4 bits char * dscp = ipPkt+1; // top 6 bits @@ -427,9 +434,11 @@ char * ttl = ipPkt+8; // 1 byte char * protocol = ipPkt+9; // 1 byte char * headercheck= ipPkt+10; // 2 bytes +#endif char * srcAdr = ipPkt+12; // 4 bytes char * dstAdr = ipPkt+16; // 4 bytes = total of 20 bytes +#ifndef SERIAL_PORT_MONITOR_NO int versionIP = (version[0]>>4)&0xf; int headerSizeIP = (ihl[0]&0xf)*4; int dscpIP = (dscp[0]>>2)&0x3f; @@ -439,7 +448,9 @@ int flagsIP = flags[0]>>14&3; int ttlIP = ttl[0]; int protocolIP = protocol[0]; - int checksumIP = (headercheck[0]<<8)|headercheck[1]; + int checksumIP = (headercheck[0]<<8)|headercheck[1]; +#endif + char srcIP [16]; snprintf(srcIP,16, "%d.%d.%d.%d", srcAdr[0],srcAdr[1],srcAdr[2],srcAdr[3]); char dstIP [16]; @@ -452,11 +463,15 @@ { int headerSizeIP = (ppp.pkt.buf[4]&0xf)*4; // header size of ip portion char * tcpStart = ppp.pkt.buf+4+headerSizeIP; // start of tcp packet +#ifndef SERIAL_PORT_MONITOR_NO char * seqtcp = tcpStart + 4; // 4 bytes char * acktcp = tcpStart + 8; // 4 bytes +#endif char * flagbitstcp = tcpStart + 12; // 9 bits +#ifndef SERIAL_PORT_MONITOR_NO unsigned int seq = (seqtcp[0]<<24)|(seqtcp[1]<<16)|(seqtcp[2]<<8)|(seqtcp[3]); unsigned int ack = (acktcp[0]<<24)|(acktcp[1]<<16)|(acktcp[2]<<8)|(acktcp[3]); +#endif int flags = ((flagbitstcp[0]&1)<<8)|flagbitstcp[1]; char flagInfo[10]; @@ -693,6 +708,7 @@ void TCPpacket() { char * ipPkt = ppp.pkt.buf+4; // ip packet start +#ifndef SERIAL_PORT_MONITOR_NO char * version = ipPkt; // top 4 bits char * ihl = ipPkt; // bottom 4 bits char * dscp = ipPkt+1; // top 6 bits @@ -703,9 +719,11 @@ char * ttl = ipPkt+8; // 1 byte char * protocol = ipPkt+9; // 1 byte char * headercheck= ipPkt+10; // 2 bytes +#endif char * srcAdr = ipPkt+12; // 4 bytes char * dstAdr = ipPkt+16; // 4 bytes = total of 20 bytes +#ifndef SERIAL_PORT_MONITOR_NO int versionIP = (version[0]>>4)&0xf; int headerSizeIP = (ihl[0]&0xf)*4; int dscpIP = (dscp[0]>>2)&0x3f; @@ -716,6 +734,7 @@ int ttlIP = ttl[0]; int protocolIP = protocol[0]; int checksumIP = (headercheck[0]<<8)|headercheck[1]; +#endif char srcIP [16]; snprintf(srcIP,16, "%d.%d.%d.%d", srcAdr[0],srcAdr[1],srcAdr[2],srcAdr[3]); char dstIP [16];