diff --git a/libraries/ESP8266WiFi/src/WiFiServer.cpp b/libraries/ESP8266WiFi/src/WiFiServer.cpp index 16f5bcc754..482376c695 100644 --- a/libraries/ESP8266WiFi/src/WiFiServer.cpp +++ b/libraries/ESP8266WiFi/src/WiFiServer.cpp @@ -61,7 +61,7 @@ void WiFiServer::begin() { void WiFiServer::begin(uint16_t port) { close(); - _port = port; + _port = port; err_t err; tcp_pcb* pcb = tcp_new(); if (!pcb) diff --git a/libraries/NetDump/examples/netdump/netdump.ino b/libraries/NetDump/examples/netdump/netdump.ino new file mode 100644 index 0000000000..f51c4c2caa --- /dev/null +++ b/libraries/NetDump/examples/netdump/netdump.ino @@ -0,0 +1,31 @@ + +/* + dump network packets on serial console + released to the public domain +*/ + +#include +#include // get global handler phy_capture + +void dump (int netif_idx, const char* data, size_t len, int out, int success) { + (void)success; + Serial.print(out ? F("out ") : F(" in ")); + Serial.printf("%d ", netif_idx); + + // optional filter example: if (netDump_is_ARP(data)) + { + netDump(Serial, data, len); + //netDumpHex(Serial, data, len); + } +} + +void setup(void) { + Serial.begin(115200); + phy_capture = dump; + + // put your setup code here, to run once: +} + +void loop(void) { + // put your main code here, to run repeatedly: +} diff --git a/libraries/NetDump/examples/tcpdump/tcpdump.ino b/libraries/NetDump/examples/tcpdump/tcpdump.ino new file mode 100644 index 0000000000..8e5d7b60ee --- /dev/null +++ b/libraries/NetDump/examples/tcpdump/tcpdump.ino @@ -0,0 +1,22 @@ + +/* + provide a tcp-server for tcpdump of locally sent/received packets + under unix with NetCat, open a terminal, run: + nc esp-ip-address 2 | tcpdump -r - [] [] + + released to the public domain +*/ + +#include + +void setup() { + // put your setup code here, to run once: + // setup WiFi + // now tcpdump server can be initialized + tcpdump_setup(); +} + +void loop() { + tcpdump_loop(); + // put your main code here, to run repeatedly: +} diff --git a/libraries/NetDump/library.properties b/libraries/NetDump/library.properties new file mode 100644 index 0000000000..b1f1355967 --- /dev/null +++ b/libraries/NetDump/library.properties @@ -0,0 +1,9 @@ +name=NetDump +version=1 +author=David Gauchard +maintainer=David Gauchard +sentence=tcpdump-like logger facility +paragraph=dump in/out packets on Printable, or provide a server for the real tcpdump +category=Uncategorized +url=https:// +architectures=esp8266 diff --git a/libraries/NetDump/src/NetDump.cpp b/libraries/NetDump/src/NetDump.cpp new file mode 100644 index 0000000000..49aa50708c --- /dev/null +++ b/libraries/NetDump/src/NetDump.cpp @@ -0,0 +1,194 @@ +/* + NetDump library - tcpdump-like packet logger facility + + Copyright (c) 2018 David Gauchard. All rights reserved. + This file is part of the esp8266 core for Arduino environment. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +static void snap (Print& out) +{ + out.println(F("(snap)")); +} + +void netDumpMac (Print& out, const char* mac) +{ + for (int i = 0; i < 6; i++) + { + out.printf("%02x", (unsigned char)mac[i]); + if (i < 5) + out.print(':'); + } +} + +void netDumpIPv4 (Print& out, const char* ethdata) +{ + for (int i = 0; i < 4; i++) + { + out.printf("%u", (unsigned char)ethdata[i]); + if (i < 3) + out.print('.'); + } +} + +static void netDumpARP (Print& out, const char* ethdata, size_t size) +{ + out.print(F(" ARP ")); + if (size < ETH_HDR_LEN + 28) + return; + char type = netDump_getARPType(ethdata); + if (type == 1) + { + out.print(F("who has ")); + netDumpIPv4(out, ethdata + ETH_HDR_LEN + 24); + out.print(F(" tell ")); + netDumpIPv4(out, ethdata + ETH_HDR_LEN + 14); + } + else if (type == 2) + { + netDumpIPv4(out, ethdata + ETH_HDR_LEN + 14); + out.print(F(" is at ")); + netDumpMac(out, ethdata + ETH_HDR_LEN + 8); + } + else + out.printf("(type=%d)", type); + out.println(); +} + +static void netDumpICMP (Print& out, const char* ethdata, size_t size) +{ + out.print(F(" ICMP ")); + if (size < 1) + return snap(out); + + switch (ethdata[ETH_HDR_LEN + 20 + 0]) + { + case 0: out.println(F("ping reply")); break; + case 8: out.println(F("ping request")); break; + default: out.printf("type(0x%02x)\r\n", ethdata[ETH_HDR_LEN + 20 + 0]); + } +} + +static void netDumpIGMP (Print& out, const char* ethdata, size_t size) +{ + out.println(F(" IGMP")); + if (size < 1) + return snap(out); + (void)ethdata; +} + +static void netDumpPort (Print& out, const char* ethdata) +{ + out.printf("%d>%d", netDump_getSrcPort(ethdata), netDump_getDstPort (ethdata)); +} + +void netDumpTCPFlags (Print& out, const char* ethdata) +{ + uint16_t flags = netDump_getTcpFlags(ethdata); + out.print('['); + const char chars [] = "FSRP.UECN"; + for (uint8_t i = 0; i < sizeof chars; i++) + if (flags & (1 << i)) + out.print(chars[i]); + out.print(']'); +} + +static void netDumpTCP (Print& out, const char* ethdata, size_t size) +{ + out.print(F(" TCP ")); + if (size < ETH_HDR_LEN + 20 + 16) + return snap(out); + netDumpPort(out, ethdata); + netDumpTCPFlags(out, ethdata); + + uint16_t tcplen = netDump_getIpUsrLen(ethdata) - netDump_getTcpHdrLen(ethdata); + uint32_t seq = netDump_getTcpSeq(ethdata); + out.printf(" seq:%u", seq); + if (tcplen) + out.printf("..%u", seq + tcplen); + out.printf(" ack:%u win:%d", + (unsigned)netDump_getTcpAck(ethdata), + netDump_getTcpWindow(ethdata)); + if (tcplen) + out.printf(" len=%u", tcplen); + + size_t options = ETH_HDR_LEN + netDump_getIpHdrLen(ethdata) + 20; + size_t options_len = netDump_getTcpHdrLen(ethdata) - 20; + for (size_t i = 0; i < options_len; ) + { + uint8_t opt = ethdata[options + i]; + uint8_t sz = opt >= 2? ethdata[options + i + 1]: 1; + switch (opt) + { + case 0: + case 1: break; + case 2: out.printf(" mss=%u", ntoh16(ethdata + options + i + 2)); break; + default: out.printf(" opt%u(%u)", opt, sz); + } + if (!opt) + // end of option + break; + i += sz; + } + + out.println(); +} + +static void netDumpUDP (Print& out, const char* ethdata, size_t size) +{ + out.print(F(" UDP ")); + if (size < ETH_HDR_LEN + 20 + 8) + return snap(out); + + netDumpPort(out, ethdata); + uint16_t udplen = netDump_getUdpUsrLen(ethdata); + uint16_t iplen = netDump_getIpUsrLen(ethdata) - 8/*udp hdr size*/; + if (udplen != iplen) + out.printf(" len=%d?", iplen); + out.printf(" len=%d\r\n", udplen); +} + +static void netDumpIPv4 (Print& out, const char* ethdata, size_t size) +{ + if (size < ETH_HDR_LEN + 20) + return snap(out); + + out.print(F(" IPv4 ")); + + netDumpIPv4(out, ethdata + ETH_HDR_LEN + 12); + out.print('>'); + netDumpIPv4(out, ethdata + ETH_HDR_LEN + 16); + //out.printf(" (iphdrlen=%d)", netDump_getIpHdrLen(ethdata)); + + if (netDump_is_ICMP(ethdata)) netDumpICMP(out, ethdata, size); + else if (netDump_is_IGMP(ethdata)) netDumpIGMP(out, ethdata, size); + else if (netDump_is_TCP(ethdata)) netDumpTCP (out, ethdata, size); + else if (netDump_is_UDP(ethdata)) netDumpUDP (out, ethdata, size); + else out.printf(" ip proto 0x%02x\r\n", netDump_getIpType(ethdata)); +} + +void netDump (Print& out, const char* ethdata, size_t size) +{ + if (size < ETH_HDR_LEN) + return snap(out); + + if (netDump_is_ARP(ethdata)) netDumpARP (out, ethdata, size); + else if (netDump_is_IPv4(ethdata)) netDumpIPv4(out, ethdata, size); + else if (netDump_is_IPv6(ethdata)) out.println(F(" IPV6")); + else out.printf(" eth proto 0x%04x\r\n", netDump_ethtype(ethdata)); +} diff --git a/libraries/NetDump/src/NetDump.h b/libraries/NetDump/src/NetDump.h new file mode 100644 index 0000000000..d8f36e5759 --- /dev/null +++ b/libraries/NetDump/src/NetDump.h @@ -0,0 +1,84 @@ +/* + NetDump library - tcpdump-like packet logger facility + + Copyright (c) 2018 David Gauchard. All rights reserved. + This file is part of the esp8266 core for Arduino environment. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef __NETDUMP_H +#define __NETDUMP_H + +#include + +#define ETH_HDR_LEN 14 + +// helpers that can be used for filtering + +inline uint16_t ntoh16 (const char* data) { return data[1] | (((uint16_t)data[0]) << 8); } +inline uint32_t ntoh32 (const char* data) { return ntoh16(data + 2) | (((uint32_t)ntoh16(data)) << 16); } + +inline uint16_t netDump_ethtype (const char* ethdata) { return ntoh16(ethdata + 12); } +inline bool netDump_is_ARP (const char* ethdata) { return netDump_ethtype(ethdata) == 0x0806; } +inline bool netDump_is_IPv4 (const char* ethdata) { return netDump_ethtype(ethdata) == 0x0800; } +inline bool netDump_is_IPv6 (const char* ethdata) { return netDump_ethtype(ethdata) == 0x86dd; } +inline uint8_t netDump_getIpType (const char* ethdata) { return ethdata[ETH_HDR_LEN + 9]; } +inline bool netDump_is_ICMP (const char* ethdata) { return netDump_getIpType(ethdata) == 1; } +inline bool netDump_is_IGMP (const char* ethdata) { return netDump_getIpType(ethdata) == 2; } +inline bool netDump_is_TCP (const char* ethdata) { return netDump_getIpType(ethdata) == 6; } +inline bool netDump_is_UDP (const char* ethdata) { return netDump_getIpType(ethdata) == 17; } + +inline uint8_t netDump_getARPType (const char* ethdata) { return ethdata[ETH_HDR_LEN + 7]; } +inline bool netDump_is_ARP_who (const char* ethdata) { return netDump_getARPType(ethdata) == 1; } +inline bool netDump_is_ARP_is (const char* ethdata) { return netDump_getARPType(ethdata) == 2; } + +inline uint16_t netDump_getIpHdrLen (const char* ethdata) { return (((unsigned char)ethdata[ETH_HDR_LEN]) & 0x0f) << 2; } +inline uint16_t netDump_getIpTotLen (const char* ethdata) { return ntoh16(ethdata + ETH_HDR_LEN + 2); } +inline uint16_t netDump_getIpOptLen (const char* ethdata) { return netDump_getIpHdrLen(ethdata) - 20; } +inline uint16_t netDump_getIpUsrLen (const char* ethdata) { return netDump_getIpTotLen(ethdata) - netDump_getIpHdrLen(ethdata); } + +inline uint16_t netDump_getSrcPort (const char* ethdata) { return ntoh16(ethdata + ETH_HDR_LEN + netDump_getIpHdrLen(ethdata) + 0); } +inline uint16_t netDump_getDstPort (const char* ethdata) { return ntoh16(ethdata + ETH_HDR_LEN + netDump_getIpHdrLen(ethdata) + 2); } + +inline uint16_t netDump_getUdpUsrLen (const char* ethdata) { return ntoh16(ethdata + ETH_HDR_LEN + netDump_getIpHdrLen(ethdata) + 4) - 8; } + +inline uint32_t netDump_getTcpSeq (const char* ethdata) { return ntoh32(ethdata + ETH_HDR_LEN + netDump_getIpHdrLen(ethdata) + 4); } +inline uint32_t netDump_getTcpAck (const char* ethdata) { return ntoh32(ethdata + ETH_HDR_LEN + netDump_getIpHdrLen(ethdata) + 8); } +inline uint16_t netDump_getTcpFlags (const char* ethdata) { return ntoh16(ethdata + ETH_HDR_LEN + netDump_getIpHdrLen(ethdata) + 12); } +inline uint16_t netDump_getTcpHdrLen (const char* ethdata) { return (ntoh16(ethdata + ETH_HDR_LEN + netDump_getIpHdrLen(ethdata) + 12) >> 12) << 2; } +inline uint16_t netDump_getTcpWindow (const char* ethdata) { return ntoh16(ethdata + ETH_HDR_LEN + netDump_getIpHdrLen(ethdata) + 14); } +inline uint16_t netDump_getTcpUsrLen (const char* ethdata) { return netDump_getIpUsrLen(ethdata) - netDump_getTcpHdrLen(ethdata); } + +void netDumpIPv4 (Print& out, const char* ethdata); +void netDumpMac (Print& out, const char* mac); +void netDumpMacs (Print& out, const char* mac); + +// main dump functions + +void netDump (Print& out, const char* ethdata, size_t size); +void netDumpHex (Print& out, const char* data, size_t size, bool show_hex = true, bool show_ascii = true, size_t per_line = 16); + +// tcpdump server: +// call tcpdump_setup() in your setup() +// call tcpdump_loop() in your loop() +// open a terminal, run: +// nc esp-ip-address 2 | tcpdump -r - [] [] + +bool tcpdump_setup (uint16_t port = 2, size_t snap = 96, bool fast = true); +void tcpdump_loop (); +extern size_t tcpdump_err; + +#endif // __NETDUMP_H diff --git a/libraries/NetDump/src/NetDumpHex.cpp b/libraries/NetDump/src/NetDumpHex.cpp new file mode 100644 index 0000000000..2c68f62aea --- /dev/null +++ b/libraries/NetDump/src/NetDumpHex.cpp @@ -0,0 +1,49 @@ +/* + NetDump library - tcpdump-like packet logger facility + + Copyright (c) 2018 David Gauchard. All rights reserved. + This file is part of the esp8266 core for Arduino environment. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +void netDumpHex (Print& out, const char* data, size_t size, bool show_hex, bool show_ascii, size_t per_line) +{ + size_t start = 0; + + while (start < size) + { + size_t end = start + per_line; + if (end > size) + end = size; + if (show_hex) + for (size_t i = start; i < end; i++) + out.printf("%02x ", (unsigned char)data[i]); + if (show_ascii) + { + if (show_hex) + for (size_t i = end; i < start + per_line; i++) + out.print(" "); + for (size_t i = start; i < end; i++) + out.printf("%c", data[i] >= 32 && data[i] < 128? data[i]: '.'); + } + out.println(); + + start += per_line; + } +} + diff --git a/libraries/NetDump/src/NetDumpMac.cpp b/libraries/NetDump/src/NetDumpMac.cpp new file mode 100644 index 0000000000..76a63202cb --- /dev/null +++ b/libraries/NetDump/src/NetDumpMac.cpp @@ -0,0 +1,78 @@ +/* + NetDump library - tcpdump-like packet logger facility + + Copyright (c) 2018 David Gauchard. All rights reserved. + This file is part of the esp8266 core for Arduino environment. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#if 0 +#include +#include + +// WIP - attempt to show correct mac addresses for output packets +void netDumpMacsForOutput (Print& out, const char* ethdata, char netif_idx) +{ + uint32_t ip = 0; + if (netDump_is_IPv4(ethdata)) + memcpy(&ip, ethdata + ETH_HDR_LEN + 16, 4); + else if (netDump_is_ARP(ethdata)) + { + if (netDump_is_ARP_who(ethdata)) + { + netDumpMac(out, ethdata + 6); + out.print(F(">ff:ff:ff:ff:ff:ff")); + return; + } + else if (netDump_is_ARP_is(ethdata)) + memcpy(&ip, ethdata + ETH_HDR_LEN + 14, 4); + else + { + out.print(F("arpmac?")); + return; + } + } + else + out.print(F("mac/proto?")); + + ip4_addr_t ip4dst; + struct eth_addr* eth_ret; + struct netif* netif_ret; + ip4_addr_t* ip_ret; + + ip4_addr_set_u32(&ip4dst, ip); + + for (int i = 0; etharp_get_entry(i, &ip_ret, &netif_ret, ð_ret); i++) + if (ip_ret->addr == ip4dst.addr) + { + netDumpMac(out, (const char*)netif_ret->hwaddr); + out.print('>'); + netDumpMac(out, (const char*)eth_ret->addr); + return; + } + + out.print(F("mac?")); +} +#endif + +void netDumpMacs (Print& out, const char* ethdata) +{ + netDumpMac(out, ethdata + 6); + out.print('>'); + netDumpMac(out, ethdata); +} diff --git a/libraries/NetDump/src/NetDumpOut.cpp b/libraries/NetDump/src/NetDumpOut.cpp new file mode 100644 index 0000000000..76fb01a10b --- /dev/null +++ b/libraries/NetDump/src/NetDumpOut.cpp @@ -0,0 +1,130 @@ +/* + NetDump library - tcpdump-like packet logger facility + + Copyright (c) 2018 David Gauchard. All rights reserved. + This file is part of the esp8266 core for Arduino environment. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include +#include + +static WiFiServer tcpdump_server(2); // port will be overwritten +static WiFiClient tcpdump_client; // only one allowed + +static bool fastsend; +static size_t snaplen, ptr; +static char* buf = nullptr; +static uint16_t svcport; + +size_t tcpdump_err = 0; + +#define BUFSIZE TCP_MSS // one tcp segment max, multiple of 4 + +static void dump (int netif_idx, const char* data, size_t len, int out, int success) +{ + (void)netif_idx; + (void)success; + + if ( netDump_is_IPv4(data) + && netDump_is_TCP(data) + && ( ( out && netDump_getSrcPort(data) == svcport) + || (!out && netDump_getDstPort(data) == svcport) + ) + ) + { + // skip myself + return; + } + + size_t snap = (len + 3) & ~3; + if (snaplen < snap) + snap = snaplen; + + if ((ptr + (4*4) + snap) > BUFSIZE) + { + // no room, lost capture + tcpdump_err++; + return; + } + + if (!buf || snap <= 0) + return; + + // pcap-savefile(5) packet header + struct timeval tv; + gettimeofday(&tv, nullptr); + *(uint32_t*)&buf[ptr] = tv.tv_sec; + *(uint32_t*)&buf[ptr+4] = tv.tv_usec; + *(uint32_t*)&buf[ptr+8] = snap; + *(uint32_t*)&buf[ptr+12] = len < snap? snap: len; + + memcpy(buf + ptr + 4*4, data, snap > len? len: snap); + + ptr += 4*4 + snap; +} + +bool tcpdump_setup (uint16_t port, size_t snap, bool fast) +{ + if (!buf) + buf = new char[BUFSIZE]; + + if (buf) + { + snaplen = (snap + 3) & ~3; + fastsend = fast; + svcport = port; + tcpdump_server.begin(svcport); + return true; //!!tcpdump_server; + } + + if (buf) + delete [] buf; + buf = nullptr; + return false; +} + +void tcpdump_loop () +{ + if (tcpdump_server.hasClient()) + { + tcpdump_client = tcpdump_server.available(); + if (fastsend) + tcpdump_client.setNoDelay(true); + + // pcap-savefile(5) capture preamble + *(uint32_t*)&buf[0] = 0xa1b2c3d4; + *(uint32_t*)&buf[4] = 0x00040002; + *(uint32_t*)&buf[8] = 0; + *(uint32_t*)&buf[12] = 0; + *(uint32_t*)&buf[16] = snaplen; + *(uint32_t*)&buf[20] = 1; + tcpdump_client.write(buf, 24); + + ptr = 0; + phy_capture = dump; + } + + if (!tcpdump_client || !tcpdump_client.connected()) + phy_capture = nullptr; + + if (ptr && tcpdump_client && tcpdump_client.availableForWrite() >= ptr) + { + tcpdump_client.write(buf, ptr); + ptr = 0; + } +} diff --git a/tools/sdk/lib/liblwip2.a b/tools/sdk/lib/liblwip2.a index e681bdc398..e4798cf40f 100644 Binary files a/tools/sdk/lib/liblwip2.a and b/tools/sdk/lib/liblwip2.a differ diff --git a/tools/sdk/lib/liblwip2_1460.a b/tools/sdk/lib/liblwip2_1460.a index 8929c2d009..62a95bd9f4 100644 Binary files a/tools/sdk/lib/liblwip2_1460.a and b/tools/sdk/lib/liblwip2_1460.a differ diff --git a/tools/sdk/lwip2/Makefile b/tools/sdk/lwip2/Makefile index 6284486a7c..90d157270e 100644 --- a/tools/sdk/lwip2/Makefile +++ b/tools/sdk/lwip2/Makefile @@ -2,6 +2,16 @@ all install clean: builder/lwip2-src/README make -C builder -f Makefile.arduino $@ +latestmaster: downloadmaster install + +latestupstream: downloadupstream install + +downloadupstream: downloadmaster + cd builder/lwip2-src; git checkout master + +downloadmaster: download + cd builder; git checkout master + download: builder/lwip2-src/README builder/lwip2-src/README: diff --git a/tools/sdk/lwip2/README.md b/tools/sdk/lwip2/README.md index 4063071013..8f17da128b 100644 --- a/tools/sdk/lwip2/README.md +++ b/tools/sdk/lwip2/README.md @@ -1,5 +1,9 @@ ```make install```: download, compile, install lwip2 +```make latestmaster```: download latest lwip2, compile, install + +```make latestupstream```: download latest lwip2 and latest upstream lwIP, compile, install + ```make download```: download lwIP-2 builder ```make clean```: clean builder only @@ -10,4 +14,4 @@ MSS values are in builder/Makefile.arduino MSS values in boards.txt are only informative -current lwip2 submodule repository: https://github.com/d-a-v/esp82xx-nonos-linklayer/tree/arduino-2.4.0 +current lwip2 submodule repository: https://github.com/d-a-v/esp82xx-nonos-linklayer/tree/arduino-2.4.1 diff --git a/tools/sdk/lwip2/builder b/tools/sdk/lwip2/builder index a376280e35..690c178df6 160000 --- a/tools/sdk/lwip2/builder +++ b/tools/sdk/lwip2/builder @@ -1 +1 @@ -Subproject commit a376280e3567dff7d494d6fe3e54146f6125f5c6 +Subproject commit 690c178df6b92a5754932aed5fc0427aeb45e346 diff --git a/tools/sdk/lwip2/include/gluedebug.h b/tools/sdk/lwip2/include/gluedebug.h index 55d0e8d746..0252666524 100644 --- a/tools/sdk/lwip2/include/gluedebug.h +++ b/tools/sdk/lwip2/include/gluedebug.h @@ -2,6 +2,7 @@ #ifndef __GLUE_DEBUG_H #define __GLUE_DEBUG_H +// this file is commonly included by both sides of the glue ///////////////////////////////////////////////////////////////////////////// // user-definable @@ -27,6 +28,15 @@ #define LWIP_DBG_TYPES_ON (LWIP_DBG_ON) #endif +///////////////////////////////////////////////////////////////////////////// +// packet capture callback from esp side +#include + +#ifdef __cplusplus +extern "C" +#endif +void (*phy_capture) (int netif_idx, const char* data, size_t len, int out, int success); + ///////////////////////////////////////////////////////////////////////////// #if UDEBUG && UDEBUGSTORE diff --git a/tools/sdk/lwip2/include/lwip-git-hash.h b/tools/sdk/lwip2/include/lwip-git-hash.h index 2d1392e4e5..dfafce9b40 100644 --- a/tools/sdk/lwip2/include/lwip-git-hash.h +++ b/tools/sdk/lwip2/include/lwip-git-hash.h @@ -1,5 +1,5 @@ // generated by makefiles/make-lwip2-hash #ifndef LWIP_HASH_H #define LWIP_HASH_H -#define LWIP_HASH_STR "STABLE-2_0_3_RELEASE/glue:arduino-2.4.1" +#define LWIP_HASH_STR "STABLE-2_0_3_RELEASE/glue:arduino-2.4.1-5-g690c178" #endif // LWIP_HASH_H diff --git a/tools/sdk/lwip2/include/lwipopts.h b/tools/sdk/lwip2/include/lwipopts.h index 9d365498d6..1c9d0a9e0f 100644 --- a/tools/sdk/lwip2/include/lwipopts.h +++ b/tools/sdk/lwip2/include/lwipopts.h @@ -2688,9 +2688,11 @@ * Return ERR_OK if packet is accepted, any error code otherwise. * Payload points to ethernet header! */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif) -#endif +//#ifdef __DOXYGEN__ +//#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif) +//#endif +#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif) lwip_unhandled_packet((pbuf), (netif)) + /** * @} */ @@ -3003,4 +3005,12 @@ #include "lwip-git-hash.h" #include // settimeofday() + struct timeval +// allow to handle special packets (user redefinable) +struct pbuf; +struct netif; +#ifndef LWIP_ERR_T +#define LWIP_ERR_T s8 +#endif +LWIP_ERR_T lwip_unhandled_packet (struct pbuf* pbuf, struct netif* netif) __attribute__((weak)); + #endif // MYLWIPOPTS_H