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: main.cpp
- Revision:
- 10:74f8233f72c0
- Parent:
- 9:0992486d4a30
- Child:
- 11:f58998c24f0b
--- a/main.cpp Fri Dec 30 13:11:43 2016 +0000 +++ b/main.cpp Sat Dec 31 03:13:46 2016 +0000 @@ -154,10 +154,36 @@ } } -void IPframe() { - xx.printf("IP frame proto %3d len %4d %d.%d.%d.%d %d.%d.%d.%d\n", ppp.pkt.buf[13],(ppp.pkt.buf[6]<<8)+ppp.pkt.buf[7],ppp.pkt.buf[16],ppp.pkt.buf[17],ppp.pkt.buf[18],ppp.pkt.buf[19],ppp.pkt.buf[20],ppp.pkt.buf[21],ppp.pkt.buf[22],ppp.pkt.buf[23] ); +void UDPpacket() { + xx.printf("UDP %d.%d.%d.%d %d.%d.%d.%d\n", ppp.pkt.buf[16],ppp.pkt.buf[17],ppp.pkt.buf[18],ppp.pkt.buf[19],ppp.pkt.buf[20],ppp.pkt.buf[21],ppp.pkt.buf[22],ppp.pkt.buf[23] ); + int idx = 4+((ppp.pkt.buf[4]&0xf)*4); + int srcPort = (ppp.pkt.buf[idx+0]<<8)|ppp.pkt.buf[idx+1]; + int destPort = (ppp.pkt.buf[idx+2]<<8)|ppp.pkt.buf[idx+3]; + xx.printf("Src %04x Dest %04x\n", srcPort, destPort); } +void ICMPpacket() { + xx.printf("ICMP\n"); + /* + xx.printf("ICMP len %4d %d.%d.%d.%d %d.%d.%d.%d\n", (ppp.pkt.buf[6]<<8)+ppp.pkt.buf[7],ppp.pkt.buf[16],ppp.pkt.buf[17],ppp.pkt.buf[18],ppp.pkt.buf[19],ppp.pkt.buf[20],ppp.pkt.buf[21],ppp.pkt.buf[22],ppp.pkt.buf[23] ); + xx.printf("Byte0 = %02x\n", ppp.pkt.buf[4]); + xx.printf("Type %x Code %d\n", ppp.pkt.buf[28], ppp.pkt.buf[29]); + xx.printf("Number of records %d %d\n", ppp.pkt.buf[34],ppp.pkt.buf[35]); + xx.printf("Group %d.%d.%d.%d\n", ppp.pkt.buf[36],ppp.pkt.buf[37],ppp.pkt.buf[38],ppp.pkt.buf[39]); + */ + +} + +void IPframe() { + int protocol = ppp.pkt.buf[13]; + switch (protocol) { + case 2: ICMPpacket(); break; + case 17: UDPpacket(); break; + case 6: debug( "TCP \n" ); break; + default: debug( "Other \n"); + } + //xx.printf("IP frame proto %3d len %4d %d.%d.%d.%d %d.%d.%d.%d\n", ppp.pkt.buf[13],(ppp.pkt.buf[6]<<8)+ppp.pkt.buf[7],ppp.pkt.buf[16],ppp.pkt.buf[17],ppp.pkt.buf[18],ppp.pkt.buf[19],ppp.pkt.buf[20],ppp.pkt.buf[21],ppp.pkt.buf[22],ppp.pkt.buf[23] ); +} void LCPconfReq() { @@ -170,7 +196,7 @@ ppp.pkt.buf[4]=2; // ack zero conf debug("Ack\n"); sendFrame(); - debug("LCP ask\n"); + debug("LCP Ask\n"); ppp.pkt.buf[4]=1; // request zero conf sendFrame(); }