├── .gitattributes ├── .gitignore ├── README.md ├── tun2socks-cli ├── main.cpp ├── tun2socks-cli.vcxproj └── tun2socks-cli.vcxproj.filters ├── tun2socks-core ├── include │ ├── lwipstack.h │ ├── netifc.h │ ├── socks5.h │ ├── socks5_auth.h │ ├── tap-windows.h │ ├── tun2socks.h │ └── tuntap.h ├── lwip │ ├── CHANGELOG │ ├── CMakeLists.txt │ ├── COPYING │ ├── FEATURES │ ├── FILES │ ├── README │ ├── UPGRADING │ ├── src │ │ ├── FILES │ │ ├── Filelists.cmake │ │ ├── Filelists.mk │ │ ├── api │ │ │ ├── api_lib.c │ │ │ ├── api_msg.c │ │ │ ├── err.c │ │ │ ├── if_api.c │ │ │ ├── netbuf.c │ │ │ ├── netdb.c │ │ │ ├── netifapi.c │ │ │ ├── sockets.c │ │ │ └── tcpip.c │ │ ├── apps │ │ │ ├── altcp_tls │ │ │ │ ├── altcp_tls_mbedtls.c │ │ │ │ ├── altcp_tls_mbedtls_mem.c │ │ │ │ ├── altcp_tls_mbedtls_mem.h │ │ │ │ └── altcp_tls_mbedtls_structs.h │ │ │ ├── http │ │ │ │ ├── altcp_proxyconnect.c │ │ │ │ ├── fs.c │ │ │ │ ├── fs │ │ │ │ │ ├── 404.html │ │ │ │ │ ├── img │ │ │ │ │ │ └── sics.gif │ │ │ │ │ └── index.html │ │ │ │ ├── fsdata.c │ │ │ │ ├── fsdata.h │ │ │ │ ├── http_client.c │ │ │ │ ├── httpd.c │ │ │ │ ├── httpd_structs.h │ │ │ │ └── makefsdata │ │ │ │ │ ├── makefsdata │ │ │ │ │ ├── makefsdata.c │ │ │ │ │ ├── readme.txt │ │ │ │ │ └── tinydir.h │ │ │ ├── lwiperf │ │ │ │ └── lwiperf.c │ │ │ ├── mdns │ │ │ │ └── mdns.c │ │ │ ├── mqtt │ │ │ │ └── mqtt.c │ │ │ ├── netbiosns │ │ │ │ └── netbiosns.c │ │ │ ├── smtp │ │ │ │ └── smtp.c │ │ │ ├── snmp │ │ │ │ ├── snmp_asn1.c │ │ │ │ ├── snmp_asn1.h │ │ │ │ ├── snmp_core.c │ │ │ │ ├── snmp_core_priv.h │ │ │ │ ├── snmp_mib2.c │ │ │ │ ├── snmp_mib2_icmp.c │ │ │ │ ├── snmp_mib2_interfaces.c │ │ │ │ ├── snmp_mib2_ip.c │ │ │ │ ├── snmp_mib2_snmp.c │ │ │ │ ├── snmp_mib2_system.c │ │ │ │ ├── snmp_mib2_tcp.c │ │ │ │ ├── snmp_mib2_udp.c │ │ │ │ ├── snmp_msg.c │ │ │ │ ├── snmp_msg.h │ │ │ │ ├── snmp_netconn.c │ │ │ │ ├── snmp_pbuf_stream.c │ │ │ │ ├── snmp_pbuf_stream.h │ │ │ │ ├── snmp_raw.c │ │ │ │ ├── snmp_scalar.c │ │ │ │ ├── snmp_snmpv2_framework.c │ │ │ │ ├── snmp_snmpv2_usm.c │ │ │ │ ├── snmp_table.c │ │ │ │ ├── snmp_threadsync.c │ │ │ │ ├── snmp_traps.c │ │ │ │ ├── snmpv3.c │ │ │ │ ├── snmpv3_mbedtls.c │ │ │ │ └── snmpv3_priv.h │ │ │ ├── sntp │ │ │ │ └── sntp.c │ │ │ └── tftp │ │ │ │ └── tftp_server.c │ │ ├── core │ │ │ ├── altcp.c │ │ │ ├── altcp_alloc.c │ │ │ ├── altcp_tcp.c │ │ │ ├── def.c │ │ │ ├── dns.c │ │ │ ├── inet_chksum.c │ │ │ ├── init.c │ │ │ ├── ip.c │ │ │ ├── ipv4 │ │ │ │ ├── autoip.c │ │ │ │ ├── dhcp.c │ │ │ │ ├── etharp.c │ │ │ │ ├── icmp.c │ │ │ │ ├── igmp.c │ │ │ │ ├── ip4.c │ │ │ │ ├── ip4_addr.c │ │ │ │ └── ip4_frag.c │ │ │ ├── ipv6 │ │ │ │ ├── dhcp6.c │ │ │ │ ├── ethip6.c │ │ │ │ ├── icmp6.c │ │ │ │ ├── inet6.c │ │ │ │ ├── ip6.c │ │ │ │ ├── ip6_addr.c │ │ │ │ ├── ip6_frag.c │ │ │ │ ├── mld6.c │ │ │ │ └── nd6.c │ │ │ ├── mem.cpp │ │ │ ├── memp.c │ │ │ ├── netif.c │ │ │ ├── pbuf.c │ │ │ ├── raw.c │ │ │ ├── stats.c │ │ │ ├── sys.c │ │ │ ├── tcp.c │ │ │ ├── tcp_in.c │ │ │ ├── tcp_out.c │ │ │ ├── timeouts.c │ │ │ └── udp.c │ │ ├── include │ │ │ ├── arch │ │ │ │ ├── bpstruct.h │ │ │ │ ├── cc.h │ │ │ │ ├── epstruct.h │ │ │ │ ├── perf.h │ │ │ │ └── sys_arch.h │ │ │ ├── compat │ │ │ │ ├── posix │ │ │ │ │ ├── arpa │ │ │ │ │ │ └── inet.h │ │ │ │ │ ├── net │ │ │ │ │ │ └── if.h │ │ │ │ │ ├── netdb.h │ │ │ │ │ └── sys │ │ │ │ │ │ └── socket.h │ │ │ │ └── stdc │ │ │ │ │ └── errno.h │ │ │ ├── lwip │ │ │ │ ├── altcp.h │ │ │ │ ├── altcp_tcp.h │ │ │ │ ├── altcp_tls.h │ │ │ │ ├── api.h │ │ │ │ ├── apps │ │ │ │ │ ├── FILES │ │ │ │ │ ├── altcp_proxyconnect.h │ │ │ │ │ ├── altcp_tls_mbedtls_opts.h │ │ │ │ │ ├── fs.h │ │ │ │ │ ├── http_client.h │ │ │ │ │ ├── httpd.h │ │ │ │ │ ├── httpd_opts.h │ │ │ │ │ ├── lwiperf.h │ │ │ │ │ ├── mdns.h │ │ │ │ │ ├── mdns_opts.h │ │ │ │ │ ├── mdns_priv.h │ │ │ │ │ ├── mqtt.h │ │ │ │ │ ├── mqtt_opts.h │ │ │ │ │ ├── mqtt_priv.h │ │ │ │ │ ├── netbiosns.h │ │ │ │ │ ├── netbiosns_opts.h │ │ │ │ │ ├── smtp.h │ │ │ │ │ ├── smtp_opts.h │ │ │ │ │ ├── snmp.h │ │ │ │ │ ├── snmp_core.h │ │ │ │ │ ├── snmp_mib2.h │ │ │ │ │ ├── snmp_opts.h │ │ │ │ │ ├── snmp_scalar.h │ │ │ │ │ ├── snmp_snmpv2_framework.h │ │ │ │ │ ├── snmp_snmpv2_usm.h │ │ │ │ │ ├── snmp_table.h │ │ │ │ │ ├── snmp_threadsync.h │ │ │ │ │ ├── snmpv3.h │ │ │ │ │ ├── sntp.h │ │ │ │ │ ├── sntp_opts.h │ │ │ │ │ ├── tftp_opts.h │ │ │ │ │ └── tftp_server.h │ │ │ │ ├── arch.h │ │ │ │ ├── autoip.h │ │ │ │ ├── debug.h │ │ │ │ ├── def.h │ │ │ │ ├── dhcp.h │ │ │ │ ├── dhcp6.h │ │ │ │ ├── dns.h │ │ │ │ ├── err.h │ │ │ │ ├── errno.h │ │ │ │ ├── etharp.h │ │ │ │ ├── ethip6.h │ │ │ │ ├── icmp.h │ │ │ │ ├── icmp6.h │ │ │ │ ├── if_api.h │ │ │ │ ├── igmp.h │ │ │ │ ├── inet.h │ │ │ │ ├── inet_chksum.h │ │ │ │ ├── init.h │ │ │ │ ├── init.h.cmake.in │ │ │ │ ├── ip.h │ │ │ │ ├── ip4.h │ │ │ │ ├── ip4_addr.h │ │ │ │ ├── ip4_frag.h │ │ │ │ ├── ip6.h │ │ │ │ ├── ip6_addr.h │ │ │ │ ├── ip6_frag.h │ │ │ │ ├── ip6_zone.h │ │ │ │ ├── ip_addr.h │ │ │ │ ├── lwipopts.h │ │ │ │ ├── mem.h │ │ │ │ ├── memp.h │ │ │ │ ├── mld6.h │ │ │ │ ├── nd6.h │ │ │ │ ├── netbuf.h │ │ │ │ ├── netdb.h │ │ │ │ ├── netif.h │ │ │ │ ├── netifapi.h │ │ │ │ ├── opt.h │ │ │ │ ├── pbuf.h │ │ │ │ ├── priv │ │ │ │ │ ├── altcp_priv.h │ │ │ │ │ ├── api_msg.h │ │ │ │ │ ├── mem_priv.h │ │ │ │ │ ├── memp_priv.h │ │ │ │ │ ├── memp_std.h │ │ │ │ │ ├── nd6_priv.h │ │ │ │ │ ├── raw_priv.h │ │ │ │ │ ├── sockets_priv.h │ │ │ │ │ ├── tcp_priv.h │ │ │ │ │ └── tcpip_priv.h │ │ │ │ ├── prot │ │ │ │ │ ├── autoip.h │ │ │ │ │ ├── dhcp.h │ │ │ │ │ ├── dhcp6.h │ │ │ │ │ ├── dns.h │ │ │ │ │ ├── etharp.h │ │ │ │ │ ├── ethernet.h │ │ │ │ │ ├── iana.h │ │ │ │ │ ├── icmp.h │ │ │ │ │ ├── icmp6.h │ │ │ │ │ ├── ieee.h │ │ │ │ │ ├── igmp.h │ │ │ │ │ ├── ip.h │ │ │ │ │ ├── ip4.h │ │ │ │ │ ├── ip6.h │ │ │ │ │ ├── mld6.h │ │ │ │ │ ├── nd6.h │ │ │ │ │ ├── tcp.h │ │ │ │ │ └── udp.h │ │ │ │ ├── raw.h │ │ │ │ ├── sio.h │ │ │ │ ├── snmp.h │ │ │ │ ├── sockets.h │ │ │ │ ├── stats.h │ │ │ │ ├── sys.h │ │ │ │ ├── tcp.h │ │ │ │ ├── tcpbase.h │ │ │ │ ├── tcpip.h │ │ │ │ ├── timeouts.h │ │ │ │ └── udp.h │ │ │ └── netif │ │ │ │ ├── bridgeif.h │ │ │ │ ├── bridgeif_opts.h │ │ │ │ ├── etharp.h │ │ │ │ ├── ethernet.h │ │ │ │ ├── ieee802154.h │ │ │ │ ├── lowpan6.h │ │ │ │ ├── lowpan6_ble.h │ │ │ │ ├── lowpan6_common.h │ │ │ │ ├── lowpan6_opts.h │ │ │ │ ├── ppp │ │ │ │ ├── ccp.h │ │ │ │ ├── chap-md5.h │ │ │ │ ├── chap-new.h │ │ │ │ ├── chap_ms.h │ │ │ │ ├── eap.h │ │ │ │ ├── ecp.h │ │ │ │ ├── eui64.h │ │ │ │ ├── fsm.h │ │ │ │ ├── ipcp.h │ │ │ │ ├── ipv6cp.h │ │ │ │ ├── lcp.h │ │ │ │ ├── magic.h │ │ │ │ ├── mppe.h │ │ │ │ ├── polarssl │ │ │ │ │ ├── arc4.h │ │ │ │ │ ├── des.h │ │ │ │ │ ├── md4.h │ │ │ │ │ ├── md5.h │ │ │ │ │ └── sha1.h │ │ │ │ ├── ppp.h │ │ │ │ ├── ppp_impl.h │ │ │ │ ├── ppp_opts.h │ │ │ │ ├── pppapi.h │ │ │ │ ├── pppcrypt.h │ │ │ │ ├── pppdebug.h │ │ │ │ ├── pppoe.h │ │ │ │ ├── pppol2tp.h │ │ │ │ ├── pppos.h │ │ │ │ ├── upap.h │ │ │ │ └── vj.h │ │ │ │ ├── slipif.h │ │ │ │ └── zepif.h │ │ ├── netif │ │ │ ├── FILES │ │ │ ├── bridgeif.c │ │ │ ├── bridgeif_fdb.c │ │ │ ├── ethernet.c │ │ │ ├── lowpan6.c │ │ │ ├── lowpan6_ble.c │ │ │ ├── lowpan6_common.c │ │ │ ├── ppp │ │ │ │ ├── PPPD_FOLLOWUP │ │ │ │ ├── auth.c │ │ │ │ ├── ccp.c │ │ │ │ ├── chap-md5.c │ │ │ │ ├── chap-new.c │ │ │ │ ├── chap_ms.c │ │ │ │ ├── demand.c │ │ │ │ ├── eap.c │ │ │ │ ├── ecp.c │ │ │ │ ├── eui64.c │ │ │ │ ├── fsm.c │ │ │ │ ├── ipcp.c │ │ │ │ ├── ipv6cp.c │ │ │ │ ├── lcp.c │ │ │ │ ├── magic.c │ │ │ │ ├── mppe.c │ │ │ │ ├── multilink.c │ │ │ │ ├── polarssl │ │ │ │ │ ├── README │ │ │ │ │ ├── arc4.c │ │ │ │ │ ├── des.c │ │ │ │ │ ├── md4.c │ │ │ │ │ ├── md5.c │ │ │ │ │ └── sha1.c │ │ │ │ ├── ppp.c │ │ │ │ ├── pppapi.c │ │ │ │ ├── pppcrypt.c │ │ │ │ ├── pppoe.c │ │ │ │ ├── pppol2tp.c │ │ │ │ ├── pppos.c │ │ │ │ ├── upap.c │ │ │ │ ├── utils.c │ │ │ │ └── vj.c │ │ │ ├── slipif.c │ │ │ └── zepif.c │ │ └── sys_arch.cpp │ └── test │ │ ├── fuzz │ │ ├── Makefile │ │ ├── README │ │ ├── config.h │ │ ├── fuzz.c │ │ ├── inputs │ │ │ ├── arp │ │ │ │ └── arp_req.bin │ │ │ ├── icmp │ │ │ │ └── icmp_ping.bin │ │ │ ├── ipv6 │ │ │ │ ├── neighbor_solicitation.bin │ │ │ │ └── router_adv.bin │ │ │ ├── tcp │ │ │ │ └── tcp_syn.bin │ │ │ └── udp │ │ │ │ └── udp_port_5000.bin │ │ ├── lwipopts.h │ │ └── output_to_pcap.sh │ │ ├── sockets │ │ ├── sockets_stresstest.c │ │ └── sockets_stresstest.h │ │ └── unit │ │ ├── Filelists.cmake │ │ ├── Filelists.mk │ │ ├── api │ │ ├── test_sockets.c │ │ └── test_sockets.h │ │ ├── arch │ │ ├── sys_arch.c │ │ └── sys_arch.h │ │ ├── core │ │ ├── test_def.c │ │ ├── test_def.h │ │ ├── test_mem.c │ │ ├── test_mem.h │ │ ├── test_netif.c │ │ ├── test_netif.h │ │ ├── test_pbuf.c │ │ ├── test_pbuf.h │ │ ├── test_timers.c │ │ └── test_timers.h │ │ ├── dhcp │ │ ├── test_dhcp.c │ │ └── test_dhcp.h │ │ ├── etharp │ │ ├── test_etharp.c │ │ └── test_etharp.h │ │ ├── ip4 │ │ ├── test_ip4.c │ │ └── test_ip4.h │ │ ├── ip6 │ │ ├── test_ip6.c │ │ └── test_ip6.h │ │ ├── lwip_check.h │ │ ├── lwip_unittests.c │ │ ├── lwipopts.h │ │ ├── mdns │ │ ├── test_mdns.c │ │ └── test_mdns.h │ │ ├── mqtt │ │ ├── test_mqtt.c │ │ └── test_mqtt.h │ │ ├── tcp │ │ ├── tcp_helper.c │ │ ├── tcp_helper.h │ │ ├── test_tcp.c │ │ ├── test_tcp.h │ │ ├── test_tcp_oos.c │ │ └── test_tcp_oos.h │ │ └── udp │ │ ├── test_udp.c │ │ └── test_udp.h ├── netifc.cpp ├── socks5.cpp ├── tests │ └── lwip_test.cpp ├── tun2socks-core.vcxproj ├── tun2socks-core.vcxproj.filters ├── tun2socks.cpp └── tuntap-windows.cpp └── tun2socks.sln /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tun2socks 2 | A tun2socks implementation written in C/C++ 2015 + Lwip-win32k. 3 | -------------------------------------------------------------------------------- /tun2socks-cli/tun2socks-cli.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /tun2socks-core/include/netifc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class NetworkInterface 9 | { 10 | public: 11 | std::string Id; 12 | std::string Name; 13 | std::string Address; 14 | std::string Mask; 15 | std::string GatewayServer; 16 | std::string DhcpServer; 17 | std::string PrimaryWinsServer; 18 | std::string SecondaryWinsServer; 19 | std::string MacAddress; 20 | uint32_t IfIndex; 21 | uint32_t IfType; // MIB_IF_TYPE 22 | 23 | public: 24 | static BOOL System(const char* CommandLine); 25 | static int GetAllNetworkInterfaces(std::map& s); 26 | }; -------------------------------------------------------------------------------- /tun2socks-core/include/socks5_auth.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | using size_t = std::size_t; 6 | 7 | enum SOCKS5METHOD :uint8_t { 8 | NO_AUTH = 0, 9 | USERNAME_PASSWORD = 2 10 | }; 11 | 12 | #define SOCKS5AUTH_BASE_MEMBER \ 13 | SOCKS5METHOD method; 14 | 15 | typedef struct _SOCKS5NoAuth { 16 | SOCKS5AUTH_BASE_MEMBER 17 | } BaseAuth, *PBaseAuth, SOCKS5NoAuth, *PSOCKS5NoAuth; 18 | 19 | typedef struct _SOCKS5UsernamePassword { 20 | SOCKS5AUTH_BASE_MEMBER 21 | char username[256]; 22 | size_t username_length; 23 | char password[256]; 24 | size_t password_length; 25 | } SOCKS5UsernamePassword, *PSOCKS5UsernamePassword; -------------------------------------------------------------------------------- /tun2socks-core/include/tap-windows.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TAP-Windows -- A kernel driver to provide virtual tap 3 | * device functionality on Windows. 4 | * 5 | * This code was inspired by the CIPE-Win32 driver by Damion K. Wilson. 6 | * 7 | * This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc., 8 | * and is released under the GPL version 2 (see below). This particular file 9 | * (tap-windows.h) is also licensed using the MIT license (see COPYRIGHT.MIT). 10 | * 11 | * This program is free software; you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License version 2 13 | * as published by the Free Software Foundation. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program (see the file COPYING included with this 22 | * distribution); if not, write to the Free Software Foundation, Inc., 23 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | */ 25 | #ifndef __TAP_WIN_H 26 | #define __TAP_WIN_H 27 | 28 | /* 29 | * ============= 30 | * TAP IOCTLs 31 | * ============= 32 | */ 33 | 34 | #include 35 | #include 36 | 37 | #define TAP_WIN_CONTROL_CODE(request,method) \ 38 | CTL_CODE (FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS) 39 | 40 | /* Present in 8.1 */ 41 | 42 | #define TAP_WIN_IOCTL_GET_MAC TAP_WIN_CONTROL_CODE (1, METHOD_BUFFERED) 43 | #define TAP_WIN_IOCTL_GET_VERSION TAP_WIN_CONTROL_CODE (2, METHOD_BUFFERED) 44 | #define TAP_WIN_IOCTL_GET_MTU TAP_WIN_CONTROL_CODE (3, METHOD_BUFFERED) 45 | #define TAP_WIN_IOCTL_GET_INFO TAP_WIN_CONTROL_CODE (4, METHOD_BUFFERED) 46 | #define TAP_WIN_IOCTL_CONFIG_POINT_TO_POINT TAP_WIN_CONTROL_CODE (5, METHOD_BUFFERED) 47 | #define TAP_WIN_IOCTL_SET_MEDIA_STATUS TAP_WIN_CONTROL_CODE (6, METHOD_BUFFERED) 48 | #define TAP_WIN_IOCTL_CONFIG_DHCP_MASQ TAP_WIN_CONTROL_CODE (7, METHOD_BUFFERED) 49 | #define TAP_WIN_IOCTL_GET_LOG_LINE TAP_WIN_CONTROL_CODE (8, METHOD_BUFFERED) 50 | #define TAP_WIN_IOCTL_CONFIG_DHCP_SET_OPT TAP_WIN_CONTROL_CODE (9, METHOD_BUFFERED) 51 | 52 | /* Added in 8.2 */ 53 | 54 | /* obsoletes TAP_WIN_IOCTL_CONFIG_POINT_TO_POINT */ 55 | #define TAP_WIN_IOCTL_CONFIG_TUN TAP_WIN_CONTROL_CODE (10, METHOD_BUFFERED) 56 | 57 | /* 58 | * ================= 59 | * Registry keys 60 | * ================= 61 | */ 62 | 63 | #define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}" 64 | 65 | #define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}" 66 | 67 | /* 68 | * ====================== 69 | * Filesystem prefixes 70 | * ====================== 71 | */ 72 | 73 | #define USERMODEDEVICEDIR "\\\\.\\Global\\" 74 | #define SYSDEVICEDIR "\\Device\\" 75 | #define USERDEVICEDIR "\\DosDevices\\Global\\" 76 | #define TAP_WIN_SUFFIX ".tap" 77 | 78 | #endif // __TAP_WIN_H 79 | -------------------------------------------------------------------------------- /tun2socks-core/include/tun2socks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef USE_DLL 4 | #ifdef COMPILE_DLL 5 | #define DECLSPEC extern "C" __declspec(dllexport) 6 | #else 7 | #define DECLSPEC extern "C" __declspec(dllimport) 8 | #endif 9 | #else 10 | #define DECLSPEC extern "C" 11 | #endif 12 | 13 | #include 14 | #include // for std::size_t 15 | 16 | #include "socks5_auth.h" 17 | 18 | #ifdef __WIN32__ 19 | #include 20 | 21 | typedef HANDLE TUNHANDLE; 22 | 23 | #define TUN_INVALID_HANDLE INVALID_HANDLE_VALUE; 24 | 25 | #endif 26 | 27 | #ifdef __LINUX__ 28 | typedef int HANDLE; 29 | typedef HANDLE TUNHANDLE; 30 | #define INVALID_HANDLE_VALUE (-1) 31 | #define TUN_INVALID_HANDLE INVALID_HANDLE_VALUE 32 | #endif 33 | 34 | #define MAX_LEN 256 35 | 36 | #ifndef NULL 37 | #define NULL (0) 38 | #endif 39 | 40 | using size_t = std::size_t; 41 | 42 | typedef uint32_t IPADDR; 43 | 44 | typedef struct _TUNAdapter { 45 | TUNHANDLE hd; 46 | #ifdef __WIN32__ 47 | char dev_id[MAX_LEN + 1]; 48 | DWORD index; 49 | #endif 50 | #ifdef __LINUX__ 51 | int ctrl_socket; 52 | int flags; 53 | #endif 54 | char dev_name[MAX_LEN + 1]; 55 | IPADDR ip; 56 | IPADDR mask; 57 | uint32_t network; 58 | } TUNAdapter, *PTUNAdapter; 59 | 60 | typedef struct _TUN2SOCKSConfig { 61 | PTUNAdapter adapter; 62 | char socks5_address[256]; 63 | size_t socks5_address_length; 64 | uint16_t socks5_port; 65 | PBaseAuth socks5_auth; 66 | uint32_t udp_timeout; 67 | } TUN2SOCKSConfig, *PTUN2SOCKSConfig; 68 | 69 | #ifdef __WIN32__ 70 | DECLSPEC 71 | size_t get_tuns(TUNAdapter*, size_t); 72 | #endif 73 | 74 | DECLSPEC 75 | TUNAdapter* open_tun(TUNAdapter* = NULL); 76 | 77 | DECLSPEC 78 | void delete_tun(TUNAdapter*); 79 | 80 | DECLSPEC 81 | PTUN2SOCKSConfig make_config_with_socks5_no_auth( 82 | const TUNAdapter*, 83 | const char*, size_t, 84 | uint16_t, 85 | uint32_t, 86 | const SOCKS5NoAuth* 87 | ); 88 | 89 | DECLSPEC 90 | PTUN2SOCKSConfig make_config_with_socks5_password_auth( 91 | const TUNAdapter*, 92 | const char*, size_t, 93 | uint16_t, 94 | uint32_t, 95 | const SOCKS5UsernamePassword* 96 | ); 97 | 98 | DECLSPEC 99 | void delete_config(PTUN2SOCKSConfig); 100 | 101 | DECLSPEC 102 | void tun2socks_start(const TUN2SOCKSConfig*); -------------------------------------------------------------------------------- /tun2socks-core/include/tuntap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include // for memcpy 9 | #include 10 | 11 | namespace tun2socks { 12 | inline std::string get_address_string(u32_t ip) { 13 | char buf[160]; 14 | snprintf(buf, 16, "%d.%d.%d.%d", ip & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, (ip >> 24) & 0xFF); 15 | return std::string(buf); 16 | } 17 | 18 | enum TUNSTATE { 19 | CLOSE = 0, 20 | OPEN, 21 | OPEN_FAILURE 22 | }; 23 | 24 | #ifdef __WIN32__ 25 | struct Request { 26 | OVERLAPPED overlapped; 27 | DWORD transfered; 28 | std::shared_ptr buf; 29 | }; 30 | #endif 31 | #ifdef __LINUX__ 32 | struct Request{ 33 | pbuf* buf; 34 | int transfered; 35 | }; 36 | #endif 37 | 38 | class TUNDevice { 39 | 40 | public: 41 | TUNDevice(boost::asio::io_context&, const TUNAdapter&); 42 | 43 | int tap_set_address(); 44 | 45 | void start_read(const std::function)>&, const std::function&); 46 | 47 | void do_write(std::unique_ptr&&, size_t, std::function, std::function); 48 | 49 | 50 | private: 51 | TUNHANDLE _tun_handle; 52 | TUNAdapter _adapter; 53 | boost::asio::io_context& _ctx; 54 | #ifdef __LINUX__ 55 | boost::asio::posix::stream_descriptor _stream; 56 | #endif 57 | }; 58 | } -------------------------------------------------------------------------------- /tun2socks-core/lwip/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | 3 | project(lwIP) 4 | 5 | set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 6 | include(src/Filelists.cmake) 7 | 8 | # Package generation 9 | set(CPACK_SOURCE_GENERATOR "ZIP") 10 | set(CPACK_SOURCE_PACKAGE_DESCRIPTION_SUMMARY "lwIP lightweight IP stack") 11 | set(CPACK_PACKAGE_VERSION_MAJOR "${LWIP_VERSION_MAJOR}") 12 | set(CPACK_PACKAGE_VERSION_MINOR "${LWIP_VERSION_MINOR}") 13 | set(CPACK_PACKAGE_VERSION_PATCH "${LWIP_VERSION_REVISION}") 14 | set(CPACK_SOURCE_IGNORE_FILES "/build/;${CPACK_SOURCE_IGNORE_FILES};.git") 15 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "lwip-${LWIP_VERSION_MAJOR}.${LWIP_VERSION_MINOR}.${LWIP_VERSION_REVISION}") 16 | include(CPack) 17 | 18 | # Target for package generation 19 | add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) 20 | add_dependencies(dist lwipdocs) 21 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/COPYING: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, 2002 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | 34 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/FEATURES: -------------------------------------------------------------------------------- 1 | lwIP is a small independent implementation of the TCP/IP protocol suite targeted at embedded systems. 2 | 3 | The focus of the lwIP TCP/IP implementation is to reduce resource usage while still having a full scale TCP. This makes lwIP suitable for use in embedded systems with tens of kilobytes of free RAM and room for around 40 kilobytes of code ROM. 4 | 5 | Main features include: 6 | - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE, 6LowPAN (via IEEE 802.15.4, BLE or ZEP; since v2.1.0) 7 | - DHCP client, stateless DHCPv6 (since v2.1.0), DNS client (incl. mDNS hostname resolver), AutoIP/APIPA (Zeroconf), SNMP agent (v1, v2c, v3 (since v2.1.0), private MIB support & MIB compiler) 8 | - APIs: specialized APIs for enhanced performance & zero copy, optional Berkeley-alike socket API 9 | - Extended features: IP forwarding over multiple network interfaces 10 | - Extended TCP features: congestion control, RTT estimation and fast recovery/fast retransmit, sending SACKs (since v2.1.0), "altcp": nearly transparent TLS for any tcp pcb (since v2.1.0) 11 | - Addon applications: HTTP server (HTTPS via altcp), HTTP(S) client (since v2.1.0), SNTP client, SMTP client (SMTPS via altcp), ping, NetBIOS nameserver, mDNS responder, MQTT client (TLS support since v2.1.0), TFTP server, iPerf2 counterpart 12 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/FILES: -------------------------------------------------------------------------------- 1 | src/ - The source code for the lwIP TCP/IP stack. 2 | doc/ - The documentation for lwIP. 3 | test/ - Some code to test whether the sources do what they should. 4 | 5 | See also the FILES file in each subdirectory. 6 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/FILES: -------------------------------------------------------------------------------- 1 | api/ - The code for the high-level wrapper API. Not needed if 2 | you use the lowel-level call-back/raw API. 3 | 4 | apps/ - Higher layer applications that are specifically programmed 5 | with the lwIP low-level raw API. 6 | 7 | core/ - The core of the TPC/IP stack; protocol implementations, 8 | memory and buffer management, and the low-level raw API. 9 | 10 | include/ - lwIP include files. 11 | 12 | netif/ - Generic network interface device drivers are kept here. 13 | 14 | For more information on the various subdirectories, check the FILES 15 | file in each directory. 16 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/apps/altcp_tls/altcp_tls_mbedtls_mem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Application layered TCP/TLS connection API (to be used from TCPIP thread) 4 | * 5 | * This file contains memory management function prototypes for a TLS layer using mbedTLS. 6 | * 7 | * Memory management contains: 8 | * - allocating/freeing altcp_mbedtls_state_t 9 | * - allocating/freeing memory used in the mbedTLS library 10 | */ 11 | 12 | /* 13 | * Copyright (c) 2017 Simon Goldschmidt 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without modification, 17 | * are permitted provided that the following conditions are met: 18 | * 19 | * 1. Redistributions of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. The name of the author may not be used to endorse or promote products 25 | * derived from this software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 28 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 29 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 30 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 32 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 35 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 36 | * OF SUCH DAMAGE. 37 | * 38 | * This file is part of the lwIP TCP/IP stack. 39 | * 40 | * Author: Simon Goldschmidt 41 | * 42 | */ 43 | #ifndef LWIP_HDR_ALTCP_MBEDTLS_MEM_H 44 | #define LWIP_HDR_ALTCP_MBEDTLS_MEM_H 45 | 46 | #include "lwip/opt.h" 47 | 48 | #if LWIP_ALTCP /* don't build if not configured for use in lwipopts.h */ 49 | 50 | #include "lwip/apps/altcp_tls_mbedtls_opts.h" 51 | 52 | #if LWIP_ALTCP_TLS && LWIP_ALTCP_TLS_MBEDTLS 53 | 54 | #include "altcp_tls_mbedtls_structs.h" 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | 60 | void altcp_mbedtls_mem_init(void); 61 | altcp_mbedtls_state_t *altcp_mbedtls_alloc(void *conf); 62 | void altcp_mbedtls_free(void *conf, altcp_mbedtls_state_t *state); 63 | void *altcp_mbedtls_alloc_config(size_t size); 64 | void altcp_mbedtls_free_config(void *item); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* LWIP_ALTCP_TLS && LWIP_ALTCP_TLS_MBEDTLS */ 71 | #endif /* LWIP_ALTCP */ 72 | #endif /* LWIP_HDR_ALTCP_MBEDTLS_MEM_H */ 73 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/apps/altcp_tls/altcp_tls_mbedtls_structs.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Application layered TCP/TLS connection API (to be used from TCPIP thread) 4 | * 5 | * This file contains structure definitions for a TLS layer using mbedTLS. 6 | */ 7 | 8 | /* 9 | * Copyright (c) 2017 Simon Goldschmidt 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * This file is part of the lwIP TCP/IP stack. 35 | * 36 | * Author: Simon Goldschmidt 37 | * 38 | */ 39 | #ifndef LWIP_HDR_ALTCP_MBEDTLS_STRUCTS_H 40 | #define LWIP_HDR_ALTCP_MBEDTLS_STRUCTS_H 41 | 42 | #include "lwip/opt.h" 43 | 44 | #if LWIP_ALTCP /* don't build if not configured for use in lwipopts.h */ 45 | 46 | #include "lwip/apps/altcp_tls_mbedtls_opts.h" 47 | 48 | #if LWIP_ALTCP_TLS && LWIP_ALTCP_TLS_MBEDTLS 49 | 50 | #include "lwip/altcp.h" 51 | #include "lwip/pbuf.h" 52 | 53 | #include "mbedtls/ssl.h" 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | #define ALTCP_MBEDTLS_FLAGS_HANDSHAKE_DONE 0x01 60 | #define ALTCP_MBEDTLS_FLAGS_UPPER_CALLED 0x02 61 | #define ALTCP_MBEDTLS_FLAGS_RX_CLOSE_QUEUED 0x04 62 | #define ALTCP_MBEDTLS_FLAGS_RX_CLOSED 0x08 63 | #define ALTCP_MBEDTLS_FLAGS_APPLDATA_SENT 0x10 64 | 65 | typedef struct altcp_mbedtls_state_s { 66 | void *conf; 67 | mbedtls_ssl_context ssl_context; 68 | /* chain of rx pbufs (before decryption) */ 69 | struct pbuf *rx; 70 | struct pbuf *rx_app; 71 | u8_t flags; 72 | int rx_passed_unrecved; 73 | int bio_bytes_read; 74 | int bio_bytes_appl; 75 | } altcp_mbedtls_state_t; 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* LWIP_ALTCP_TLS && LWIP_ALTCP_TLS_MBEDTLS */ 82 | #endif /* LWIP_ALTCP */ 83 | #endif /* LWIP_HDR_ALTCP_MBEDTLS_STRUCTS_H */ 84 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/apps/http/fs/404.html: -------------------------------------------------------------------------------- 1 | 2 | lwIP - A Lightweight TCP/IP Stack 3 | 4 | 5 | 6 | 19 |
7 | SICS logo 9 | 10 |

lwIP - A Lightweight TCP/IP Stack

11 |

404 - Page not found

12 |

13 | Sorry, the page you are requesting was not found on this 14 | server. 15 |

16 |
17 |   18 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/apps/http/fs/img/sics.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liulilittle/tun2socks/b5187f387fb9c2b62adc7e5afc3cd6b0c5c90943/tun2socks-core/lwip/src/apps/http/fs/img/sics.gif -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/apps/http/fs/index.html: -------------------------------------------------------------------------------- 1 | 2 | lwIP - A Lightweight TCP/IP Stack 3 | 4 | 5 | 6 | 44 |
7 | SICS logo 9 | 10 |

lwIP - A Lightweight TCP/IP Stack

11 |

12 | The web page you are watching was served by a simple web 13 | server running on top of the lightweight TCP/IP stack lwIP. 15 |

16 |

17 | lwIP is an open source implementation of the TCP/IP 18 | protocol suite that was originally written by Adam Dunkels 20 | of the Swedish Institute of Computer Science but now is 21 | being actively developed by a team of developers 22 | distributed world-wide. Since it's release, lwIP has 23 | spurred a lot of interest and has been ported to several 24 | platforms and operating systems. lwIP can be used either 25 | with or without an underlying OS. 26 |

27 |

28 | The focus of the lwIP TCP/IP implementation is to reduce 29 | the RAM usage while still having a full scale TCP. This 30 | makes lwIP suitable for use in embedded systems with tens 31 | of kilobytes of free RAM and room for around 40 kilobytes 32 | of code ROM. 33 |

34 |

35 | More information about lwIP can be found at the lwIP 36 | homepage at http://savannah.nongnu.org/projects/lwip/ 38 | or at the lwIP wiki at http://lwip.wikia.com/. 40 |

41 |
42 |   43 |
45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/apps/http/fsdata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef LWIP_FSDATA_H 33 | #define LWIP_FSDATA_H 34 | 35 | #include "lwip/apps/httpd_opts.h" 36 | #include "lwip/apps/fs.h" 37 | 38 | /* THIS FILE IS DEPRECATED AND WILL BE REMOVED IN THE FUTURE */ 39 | /* content was moved to fs.h to simplify #include structure */ 40 | 41 | #endif /* LWIP_FSDATA_H */ 42 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/apps/http/makefsdata/makefsdata: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | open(OUTPUT, "> fsdata.c"); 4 | 5 | chdir("fs"); 6 | open(FILES, "find . -type f |"); 7 | 8 | while($file = ) { 9 | 10 | # Do not include files in CVS directories nor backup files. 11 | if($file =~ /(CVS|~)/) { 12 | next; 13 | } 14 | 15 | chop($file); 16 | 17 | open(HEADER, "> /tmp/header") || die $!; 18 | if($file =~ /404/) { 19 | print(HEADER "HTTP/1.0 404 File not found\r\n"); 20 | } else { 21 | print(HEADER "HTTP/1.0 200 OK\r\n"); 22 | } 23 | print(HEADER "Server: lwIP/pre-0.6 (http://www.sics.se/~adam/lwip/)\r\n"); 24 | if($file =~ /\.html$/) { 25 | print(HEADER "Content-type: text/html\r\n"); 26 | } elsif($file =~ /\.gif$/) { 27 | print(HEADER "Content-type: image/gif\r\n"); 28 | } elsif($file =~ /\.png$/) { 29 | print(HEADER "Content-type: image/png\r\n"); 30 | } elsif($file =~ /\.jpg$/) { 31 | print(HEADER "Content-type: image/jpeg\r\n"); 32 | } elsif($file =~ /\.class$/) { 33 | print(HEADER "Content-type: application/octet-stream\r\n"); 34 | } elsif($file =~ /\.ram$/) { 35 | print(HEADER "Content-type: audio/x-pn-realaudio\r\n"); 36 | } else { 37 | print(HEADER "Content-type: text/plain\r\n"); 38 | } 39 | print(HEADER "\r\n"); 40 | close(HEADER); 41 | 42 | unless($file =~ /\.plain$/ || $file =~ /cgi/) { 43 | system("cat /tmp/header $file > /tmp/file"); 44 | } else { 45 | system("cp $file /tmp/file"); 46 | } 47 | 48 | open(FILE, "/tmp/file"); 49 | unlink("/tmp/file"); 50 | unlink("/tmp/header"); 51 | 52 | $file =~ s/\.//; 53 | $fvar = $file; 54 | $fvar =~ s-/-_-g; 55 | $fvar =~ s-\.-_-g; 56 | print(OUTPUT "static const unsigned char data".$fvar."[] = {\n"); 57 | print(OUTPUT "\t/* $file */\n\t"); 58 | for($j = 0; $j < length($file); $j++) { 59 | printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1))); 60 | } 61 | printf(OUTPUT "0,\n"); 62 | 63 | 64 | $i = 0; 65 | while(read(FILE, $data, 1)) { 66 | if($i == 0) { 67 | print(OUTPUT "\t"); 68 | } 69 | printf(OUTPUT "%#02x, ", unpack("C", $data)); 70 | $i++; 71 | if($i == 10) { 72 | print(OUTPUT "\n"); 73 | $i = 0; 74 | } 75 | } 76 | print(OUTPUT "};\n\n"); 77 | close(FILE); 78 | push(@fvars, $fvar); 79 | push(@files, $file); 80 | } 81 | 82 | for($i = 0; $i < @fvars; $i++) { 83 | $file = $files[$i]; 84 | $fvar = $fvars[$i]; 85 | 86 | if($i == 0) { 87 | $prevfile = "NULL"; 88 | } else { 89 | $prevfile = "file" . $fvars[$i - 1]; 90 | } 91 | print(OUTPUT "const struct fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, "); 92 | print(OUTPUT "data$fvar + ". (length($file) + 1) .", "); 93 | print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n"); 94 | } 95 | 96 | print(OUTPUT "#define FS_ROOT file$fvars[$i - 1]\n\n"); 97 | print(OUTPUT "#define FS_NUMFILES $i\n"); 98 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/apps/http/makefsdata/readme.txt: -------------------------------------------------------------------------------- 1 | This directory contains a script ('makefsdata') to create C code suitable for 2 | httpd for given html pages (or other files) in a directory. 3 | 4 | There is also a plain C console application doing the same and extended a bit. 5 | 6 | Usage: htmlgen [targetdir] [-s] [-i]s 7 | targetdir: relative or absolute path to files to convert 8 | switch -s: toggle processing of subdirectories (default is on) 9 | switch -e: exclude HTTP header from file (header is created at runtime, default is on) 10 | switch -11: include HTTP 1.1 header (1.0 is default) 11 | 12 | if targetdir not specified, makefsdata will attempt to 13 | process files in subdirectory 'fs'. 14 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/apps/snmp/snmp_pbuf_stream.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * SNMP pbuf stream wrapper (internal API, do not use in client code). 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Martin Hentschel 35 | * 36 | */ 37 | 38 | #ifndef LWIP_HDR_APPS_SNMP_PBUF_STREAM_H 39 | #define LWIP_HDR_APPS_SNMP_PBUF_STREAM_H 40 | 41 | #include "lwip/apps/snmp_opts.h" 42 | 43 | #if LWIP_SNMP 44 | 45 | #include "lwip/err.h" 46 | #include "lwip/pbuf.h" 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | struct snmp_pbuf_stream { 53 | struct pbuf *pbuf; 54 | u16_t offset; 55 | u16_t length; 56 | }; 57 | 58 | err_t snmp_pbuf_stream_init(struct snmp_pbuf_stream *pbuf_stream, struct pbuf *p, u16_t offset, u16_t length); 59 | err_t snmp_pbuf_stream_read(struct snmp_pbuf_stream *pbuf_stream, u8_t *data); 60 | err_t snmp_pbuf_stream_write(struct snmp_pbuf_stream *pbuf_stream, u8_t data); 61 | err_t snmp_pbuf_stream_writebuf(struct snmp_pbuf_stream *pbuf_stream, const void *buf, u16_t buf_len); 62 | err_t snmp_pbuf_stream_writeto(struct snmp_pbuf_stream *pbuf_stream, struct snmp_pbuf_stream *target_pbuf_stream, u16_t len); 63 | err_t snmp_pbuf_stream_seek(struct snmp_pbuf_stream *pbuf_stream, s32_t offset); 64 | err_t snmp_pbuf_stream_seek_abs(struct snmp_pbuf_stream *pbuf_stream, u32_t offset); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* LWIP_SNMP */ 71 | 72 | #endif /* LWIP_HDR_APPS_SNMP_PBUF_STREAM_H */ 73 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/apps/snmp/snmpv3_priv.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Additional SNMPv3 functionality RFC3414 and RFC3826 (internal API, do not use in client code). 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2016 Elias Oenal. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * Author: Elias Oenal 33 | */ 34 | 35 | #ifndef LWIP_HDR_APPS_SNMP_V3_PRIV_H 36 | #define LWIP_HDR_APPS_SNMP_V3_PRIV_H 37 | 38 | #include "lwip/apps/snmp_opts.h" 39 | 40 | #if LWIP_SNMP && LWIP_SNMP_V3 41 | 42 | #include "lwip/apps/snmpv3.h" 43 | #include "snmp_pbuf_stream.h" 44 | 45 | /* According to RFC 3411 */ 46 | #define SNMP_V3_MAX_ENGINE_ID_LENGTH 32 47 | #define SNMP_V3_MAX_USER_LENGTH 32 48 | 49 | #define SNMP_V3_MAX_AUTH_PARAM_LENGTH 12 50 | #define SNMP_V3_MAX_PRIV_PARAM_LENGTH 8 51 | 52 | #define SNMP_V3_MD5_LEN 16 53 | #define SNMP_V3_SHA_LEN 20 54 | 55 | typedef enum { 56 | SNMP_V3_PRIV_MODE_DECRYPT = 0, 57 | SNMP_V3_PRIV_MODE_ENCRYPT = 1 58 | } snmpv3_priv_mode_t; 59 | 60 | s32_t snmpv3_get_engine_boots_internal(void); 61 | err_t snmpv3_auth(struct snmp_pbuf_stream *stream, u16_t length, const u8_t *key, snmpv3_auth_algo_t algo, u8_t *hmac_out); 62 | err_t snmpv3_crypt(struct snmp_pbuf_stream *stream, u16_t length, const u8_t *key, 63 | const u8_t *priv_param, const u32_t engine_boots, const u32_t engine_time, snmpv3_priv_algo_t algo, snmpv3_priv_mode_t mode); 64 | err_t snmpv3_build_priv_param(u8_t *priv_param); 65 | void snmpv3_enginetime_timer(void *arg); 66 | 67 | #endif 68 | 69 | #endif /* LWIP_HDR_APPS_SNMP_V3_PRIV_H */ 70 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/core/altcp_alloc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Application layered TCP connection API (to be used from TCPIP thread)\n 4 | * This interface mimics the tcp callback API to the application while preventing 5 | * direct linking (much like virtual functions). 6 | * This way, an application can make use of other application layer protocols 7 | * on top of TCP without knowing the details (e.g. TLS, proxy connection). 8 | * 9 | * This file contains allocation implementation that combine several layers. 10 | */ 11 | 12 | /* 13 | * Copyright (c) 2017 Simon Goldschmidt 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without modification, 17 | * are permitted provided that the following conditions are met: 18 | * 19 | * 1. Redistributions of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. The name of the author may not be used to endorse or promote products 25 | * derived from this software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 28 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 29 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 30 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 32 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 35 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 36 | * OF SUCH DAMAGE. 37 | * 38 | * This file is part of the lwIP TCP/IP stack. 39 | * 40 | * Author: Simon Goldschmidt 41 | * 42 | */ 43 | 44 | #include "lwip/opt.h" 45 | 46 | #if LWIP_ALTCP /* don't build if not configured for use in lwipopts.h */ 47 | 48 | #include "lwip/altcp.h" 49 | #include "lwip/altcp_tcp.h" 50 | #include "lwip/altcp_tls.h" 51 | #include "lwip/priv/altcp_priv.h" 52 | #include "lwip/mem.h" 53 | 54 | #include 55 | 56 | #if LWIP_ALTCP_TLS 57 | 58 | /** This standard allocator function creates an altcp pcb for 59 | * TLS over TCP */ 60 | struct altcp_pcb * 61 | altcp_tls_new(struct altcp_tls_config *config, u8_t ip_type) 62 | { 63 | struct altcp_pcb *inner_conn, *ret; 64 | LWIP_UNUSED_ARG(ip_type); 65 | 66 | inner_conn = altcp_tcp_new_ip_type(ip_type); 67 | if (inner_conn == NULL) { 68 | return NULL; 69 | } 70 | ret = altcp_tls_wrap(config, inner_conn); 71 | if (ret == NULL) { 72 | altcp_close(inner_conn); 73 | } 74 | return ret; 75 | } 76 | 77 | /** This standard allocator function creates an altcp pcb for 78 | * TLS over TCP */ 79 | struct altcp_pcb * 80 | altcp_tls_alloc(void *arg, u8_t ip_type) 81 | { 82 | return altcp_tls_new((struct altcp_tls_config *)arg, ip_type); 83 | } 84 | 85 | #endif /* LWIP_ALTCP_TLS */ 86 | 87 | #endif /* LWIP_ALTCP */ 88 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/core/ipv6/inet6.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * INET v6 addresses. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #include "lwip/opt.h" 43 | 44 | #if LWIP_IPV6 && LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ 45 | 46 | #include "lwip/def.h" 47 | #include "lwip/inet.h" 48 | 49 | /** This variable is initialized by the system to contain the wildcard IPv6 address. 50 | */ 51 | const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; 52 | 53 | #endif /* LWIP_IPV6 */ 54 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/arch/bpstruct.h: -------------------------------------------------------------------------------- 1 | #pragma pack(push,1) 2 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/arch/cc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Lazymio 2/10/2019 3 | Port lwip to Windows. 4 | The codes below are under GPLv3 License. 5 | */ 6 | #ifndef LWIP_ARCH_CC_H 7 | #define LWIP_ARCH_CC_H 8 | 9 | /* 10 | Just for memset. 11 | */ 12 | #include 13 | 14 | /* 15 | We didn't have unistd.h indeed. 16 | */ 17 | #define LWIP_NO_UNISTD_H 1 18 | 19 | /* 20 | Using default values is okay. 21 | */ 22 | 23 | #define PACK_STRUCT_USE_INCLUDES 1 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/arch/epstruct.h: -------------------------------------------------------------------------------- 1 | #pragma pack(pop) -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/arch/perf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | */ 34 | #ifndef LWIP_PERF_H 35 | #define LWIP_PERF_H 36 | 37 | #define PERF_START /* null definition */ 38 | #define PERF_STOP(x) /* null definition */ 39 | 40 | #endif /* LWIP_PERF_H */ 41 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/arch/sys_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_ARCH_SYS_ARCH_H 2 | #define LWIP_ARCH_SYS_ARCH_H 3 | 4 | #define SYS_MBOX_NULL NULL 5 | #define SYS_SEM_NULL NULL 6 | #define LWIP_NO_UNISTD_H 1 7 | 8 | int sys_arch_pcb_watch(void* pcb); 9 | int sys_arch_pcb_is_watch(void* pcb); 10 | int sys_arch_pcb_unwatch(void* pcb); 11 | #endif /* LWIP_ARCH_SYS_ARCH_H */ -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/compat/posix/arpa/inet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/sockets.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/sockets.h" 34 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/compat/posix/net/if.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/if_api.h. 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2017 Joel Cunningham, Garmin International, Inc. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | */ 35 | 36 | #include "lwip/if_api.h" 37 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/compat/posix/netdb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/netdb.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/netdb.h" 34 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/compat/posix/sys/socket.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/sockets.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/sockets.h" 34 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/compat/stdc/errno.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix/stdc wrapper for lwip/errno.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/errno.h" 34 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/altcp_tcp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Application layered TCP connection API (to be used from TCPIP thread)\n 4 | * This interface mimics the tcp callback API to the application while preventing 5 | * direct linking (much like virtual functions). 6 | * This way, an application can make use of other application layer protocols 7 | * on top of TCP without knowing the details (e.g. TLS, proxy connection). 8 | * 9 | * This file contains the base implementation calling into tcp. 10 | */ 11 | 12 | /* 13 | * Copyright (c) 2017 Simon Goldschmidt 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without modification, 17 | * are permitted provided that the following conditions are met: 18 | * 19 | * 1. Redistributions of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. The name of the author may not be used to endorse or promote products 25 | * derived from this software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 28 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 29 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 30 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 32 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 35 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 36 | * OF SUCH DAMAGE. 37 | * 38 | * This file is part of the lwIP TCP/IP stack. 39 | * 40 | * Author: Simon Goldschmidt 41 | * 42 | */ 43 | #ifndef LWIP_HDR_ALTCP_TCP_H 44 | #define LWIP_HDR_ALTCP_TCP_H 45 | 46 | #include "lwip/opt.h" 47 | 48 | #if LWIP_ALTCP /* don't build if not configured for use in lwipopts.h */ 49 | 50 | #include "lwip/altcp.h" 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | struct altcp_pcb *altcp_tcp_new_ip_type(u8_t ip_type); 57 | 58 | #define altcp_tcp_new() altcp_tcp_new_ip_type(IPADDR_TYPE_V4) 59 | #define altcp_tcp_new_ip6() altcp_tcp_new_ip_type(IPADDR_TYPE_V6) 60 | 61 | struct altcp_pcb *altcp_tcp_alloc(void *arg, u8_t ip_type); 62 | 63 | struct tcp_pcb; 64 | struct altcp_pcb *altcp_tcp_wrap(struct tcp_pcb *tpcb); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* LWIP_ALTCP */ 71 | 72 | #endif /* LWIP_HDR_ALTCP_TCP_H */ 73 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/FILES: -------------------------------------------------------------------------------- 1 | This directory contains application headers. 2 | Every application shall provide one api file APP.h and optionally one options file APP_opts.h 3 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/altcp_proxyconnect.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Application layered TCP connection API that executes a proxy-connect. 4 | * 5 | * This file provides a starting layer that executes a proxy-connect e.g. to 6 | * set up TLS connections through a http proxy. 7 | */ 8 | 9 | /* 10 | * Copyright (c) 2018 Simon Goldschmidt 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. The name of the author may not be used to endorse or promote products 22 | * derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 27 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 29 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 33 | * OF SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Simon Goldschmidt 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_APPS_ALTCP_PROXYCONNECT_H 42 | #define LWIP_HDR_APPS_ALTCP_PROXYCONNECT_H 43 | 44 | #include "lwip/opt.h" 45 | 46 | #if LWIP_ALTCP /* don't build if not configured for use in lwipopts.h */ 47 | 48 | #include "lwip/ip_addr.h" 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | struct altcp_proxyconnect_config { 55 | ip_addr_t proxy_addr; 56 | u16_t proxy_port; 57 | }; 58 | 59 | 60 | struct altcp_pcb *altcp_proxyconnect_new(struct altcp_proxyconnect_config *config, struct altcp_pcb *inner_pcb); 61 | struct altcp_pcb *altcp_proxyconnect_new_tcp(struct altcp_proxyconnect_config *config, u8_t ip_type); 62 | 63 | struct altcp_pcb *altcp_proxyconnect_alloc(void *arg, u8_t ip_type); 64 | 65 | #if LWIP_ALTCP_TLS 66 | struct altcp_proxyconnect_tls_config { 67 | struct altcp_proxyconnect_config proxy; 68 | struct altcp_tls_config *tls_config; 69 | }; 70 | 71 | struct altcp_pcb *altcp_proxyconnect_tls_alloc(void *arg, u8_t ip_type); 72 | #endif /* LWIP_ALTCP_TLS */ 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif /* LWIP_ALTCP */ 79 | #endif /* LWIP_HDR_APPS_ALTCP_PROXYCONNECT_H */ 80 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/altcp_tls_mbedtls_opts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Application layered TCP/TLS connection API (to be used from TCPIP thread) 4 | * 5 | * This file contains options for an mbedtls port of the TLS layer. 6 | */ 7 | 8 | /* 9 | * Copyright (c) 2017 Simon Goldschmidt 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * This file is part of the lwIP TCP/IP stack. 35 | * 36 | * Author: Simon Goldschmidt 37 | * 38 | */ 39 | #ifndef LWIP_HDR_ALTCP_TLS_OPTS_H 40 | #define LWIP_HDR_ALTCP_TLS_OPTS_H 41 | 42 | #include "lwip/opt.h" 43 | 44 | #if LWIP_ALTCP /* don't build if not configured for use in lwipopts.h */ 45 | 46 | /** LWIP_ALTCP_TLS_MBEDTLS==1: use mbedTLS for TLS support for altcp API 47 | * mbedtls include directory must be reachable via include search path 48 | */ 49 | #ifndef LWIP_ALTCP_TLS_MBEDTLS 50 | #define LWIP_ALTCP_TLS_MBEDTLS 0 51 | #endif 52 | 53 | /** Configure debug level of this file */ 54 | #ifndef ALTCP_MBEDTLS_DEBUG 55 | #define ALTCP_MBEDTLS_DEBUG LWIP_DBG_OFF 56 | #endif 57 | 58 | /** Set a session timeout in seconds for the basic session cache 59 | * ATTENTION: Using a session cache can lower security by reusing keys! 60 | */ 61 | #ifndef ALTCP_MBEDTLS_SESSION_CACHE_TIMEOUT_SECONDS 62 | #define ALTCP_MBEDTLS_SESSION_CACHE_TIMEOUT_SECONDS 0 63 | #endif 64 | 65 | #endif /* LWIP_ALTCP */ 66 | 67 | #endif /* LWIP_HDR_ALTCP_TLS_OPTS_H */ 68 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/mdns_opts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * MDNS responder 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2015 Verisure Innovation AB 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Erik Ekman 35 | * 36 | */ 37 | 38 | #ifndef LWIP_HDR_APPS_MDNS_OPTS_H 39 | #define LWIP_HDR_APPS_MDNS_OPTS_H 40 | 41 | #include "lwip/opt.h" 42 | 43 | /** 44 | * @defgroup mdns_opts Options 45 | * @ingroup mdns 46 | * @{ 47 | */ 48 | 49 | /** 50 | * LWIP_MDNS_RESPONDER==1: Turn on multicast DNS module. UDP must be available for MDNS 51 | * transport. IGMP is needed for IPv4 multicast. 52 | */ 53 | #ifndef LWIP_MDNS_RESPONDER 54 | #define LWIP_MDNS_RESPONDER 0 55 | #endif /* LWIP_MDNS_RESPONDER */ 56 | 57 | /** The maximum number of services per netif */ 58 | #ifndef MDNS_MAX_SERVICES 59 | #define MDNS_MAX_SERVICES 1 60 | #endif 61 | 62 | /** MDNS_RESP_USENETIF_EXTCALLBACK==1: register an ext_callback on the netif 63 | * to automatically restart probing/announcing on status or address change. 64 | */ 65 | #ifndef MDNS_RESP_USENETIF_EXTCALLBACK 66 | #define MDNS_RESP_USENETIF_EXTCALLBACK LWIP_NETIF_EXT_STATUS_CALLBACK 67 | #endif 68 | 69 | /** 70 | * MDNS_DEBUG: Enable debugging for multicast DNS. 71 | */ 72 | #ifndef MDNS_DEBUG 73 | #define MDNS_DEBUG LWIP_DBG_OFF 74 | #endif 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | #endif /* LWIP_HDR_APPS_MDNS_OPTS_H */ 81 | 82 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/mdns_priv.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * MDNS responder private definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2015 Verisure Innovation AB 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Erik Ekman 35 | * 36 | */ 37 | #ifndef LWIP_HDR_MDNS_PRIV_H 38 | #define LWIP_HDR_MDNS_PRIV_H 39 | 40 | #include "lwip/apps/mdns_opts.h" 41 | #include "lwip/pbuf.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #if LWIP_MDNS_RESPONDER 48 | 49 | /* Domain struct and methods - visible for unit tests */ 50 | 51 | #define MDNS_DOMAIN_MAXLEN 256 52 | #define MDNS_READNAME_ERROR 0xFFFF 53 | 54 | struct mdns_domain { 55 | /* Encoded domain name */ 56 | u8_t name[MDNS_DOMAIN_MAXLEN]; 57 | /* Total length of domain name, including zero */ 58 | u16_t length; 59 | /* Set if compression of this domain is not allowed */ 60 | u8_t skip_compression; 61 | }; 62 | 63 | err_t mdns_domain_add_label(struct mdns_domain *domain, const char *label, u8_t len); 64 | u16_t mdns_readname(struct pbuf *p, u16_t offset, struct mdns_domain *domain); 65 | int mdns_domain_eq(struct mdns_domain *a, struct mdns_domain *b); 66 | u16_t mdns_compress_domain(struct pbuf *pbuf, u16_t *offset, struct mdns_domain *domain); 67 | 68 | #endif /* LWIP_MDNS_RESPONDER */ 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif /* LWIP_HDR_MDNS_PRIV_H */ 75 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/mqtt_opts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * MQTT client options 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2016 Erik Andersson 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Erik Andersson 35 | * 36 | */ 37 | #ifndef LWIP_HDR_APPS_MQTT_OPTS_H 38 | #define LWIP_HDR_APPS_MQTT_OPTS_H 39 | 40 | #include "lwip/opt.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** 47 | * @defgroup mqtt_opts Options 48 | * @ingroup mqtt 49 | * @{ 50 | */ 51 | 52 | /** 53 | * Output ring-buffer size, must be able to fit largest outgoing publish message topic+payloads 54 | */ 55 | #ifndef MQTT_OUTPUT_RINGBUF_SIZE 56 | #define MQTT_OUTPUT_RINGBUF_SIZE 256 57 | #endif 58 | 59 | /** 60 | * Number of bytes in receive buffer, must be at least the size of the longest incoming topic + 8 61 | * If one wants to avoid fragmented incoming publish, set length to max incoming topic length + max payload length + 8 62 | */ 63 | #ifndef MQTT_VAR_HEADER_BUFFER_LEN 64 | #define MQTT_VAR_HEADER_BUFFER_LEN 128 65 | #endif 66 | 67 | /** 68 | * Maximum number of pending subscribe, unsubscribe and publish requests to server . 69 | */ 70 | #ifndef MQTT_REQ_MAX_IN_FLIGHT 71 | #define MQTT_REQ_MAX_IN_FLIGHT 4 72 | #endif 73 | 74 | /** 75 | * Seconds between each cyclic timer call. 76 | */ 77 | #ifndef MQTT_CYCLIC_TIMER_INTERVAL 78 | #define MQTT_CYCLIC_TIMER_INTERVAL 5 79 | #endif 80 | 81 | /** 82 | * Publish, subscribe and unsubscribe request timeout in seconds. 83 | */ 84 | #ifndef MQTT_REQ_TIMEOUT 85 | #define MQTT_REQ_TIMEOUT 30 86 | #endif 87 | 88 | /** 89 | * Seconds for MQTT connect response timeout after sending connect request 90 | */ 91 | #ifndef MQTT_CONNECT_TIMOUT 92 | #define MQTT_CONNECT_TIMOUT 100 93 | #endif 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | #ifdef __cplusplus 100 | } 101 | #endif 102 | 103 | #endif /* LWIP_HDR_APPS_MQTT_OPTS_H */ 104 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/netbiosns.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * NETBIOS name service responder 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | #ifndef LWIP_HDR_APPS_NETBIOS_H 33 | #define LWIP_HDR_APPS_NETBIOS_H 34 | 35 | #include "lwip/apps/netbiosns_opts.h" 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | void netbiosns_init(void); 42 | #ifndef NETBIOS_LWIP_NAME 43 | void netbiosns_set_name(const char* hostname); 44 | #endif 45 | void netbiosns_stop(void); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* LWIP_HDR_APPS_NETBIOS_H */ 52 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/netbiosns_opts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * NETBIOS name service responder options 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | #ifndef LWIP_HDR_APPS_NETBIOS_OPTS_H 33 | #define LWIP_HDR_APPS_NETBIOS_OPTS_H 34 | 35 | #include "lwip/opt.h" 36 | 37 | /** 38 | * @defgroup netbiosns_opts Options 39 | * @ingroup netbiosns 40 | * @{ 41 | */ 42 | 43 | /** NetBIOS name of lwip device 44 | * This must be uppercase until NETBIOS_STRCMP() is defined to a string 45 | * comparision function that is case insensitive. 46 | * If you want to use the netif's hostname, use this (with LWIP_NETIF_HOSTNAME): 47 | * (ip_current_netif() != NULL ? ip_current_netif()->hostname != NULL ? ip_current_netif()->hostname : "" : "") 48 | * 49 | * If this is not defined, netbiosns_set_name() can be called at runtime to change the name. 50 | */ 51 | #ifdef __DOXYGEN__ 52 | #define NETBIOS_LWIP_NAME "NETBIOSLWIPDEV" 53 | #endif 54 | 55 | /** Respond to NetBIOS name queries 56 | * Default is disabled 57 | */ 58 | #if !defined LWIP_NETBIOS_RESPOND_NAME_QUERY || defined __DOXYGEN__ 59 | #define LWIP_NETBIOS_RESPOND_NAME_QUERY 0 60 | #endif 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | #endif /* LWIP_HDR_APPS_NETBIOS_OPTS_H */ 67 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/smtp_opts.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_APPS_SMTP_OPTS_H 2 | #define LWIP_HDR_APPS_SMTP_OPTS_H 3 | 4 | #include "lwip/opt.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | /** 11 | * @defgroup smtp_opts Options 12 | * @ingroup smtp 13 | * 14 | * @{ 15 | */ 16 | 17 | /** Set this to 1 to enable data handler callback on BODY */ 18 | #ifndef SMTP_BODYDH 19 | #define SMTP_BODYDH 0 20 | #endif 21 | 22 | /** SMTP_DEBUG: Enable debugging for SNTP. */ 23 | #ifndef SMTP_DEBUG 24 | #define SMTP_DEBUG LWIP_DBG_OFF 25 | #endif 26 | 27 | /** Maximum length reserved for server name including terminating 0 byte */ 28 | #ifndef SMTP_MAX_SERVERNAME_LEN 29 | #define SMTP_MAX_SERVERNAME_LEN 256 30 | #endif 31 | 32 | /** Maximum length reserved for username */ 33 | #ifndef SMTP_MAX_USERNAME_LEN 34 | #define SMTP_MAX_USERNAME_LEN 32 35 | #endif 36 | 37 | /** Maximum length reserved for password */ 38 | #ifndef SMTP_MAX_PASS_LEN 39 | #define SMTP_MAX_PASS_LEN 32 40 | #endif 41 | 42 | /** Set this to 0 if you know the authentication data will not change 43 | * during the smtp session, which saves some heap space. */ 44 | #ifndef SMTP_COPY_AUTHDATA 45 | #define SMTP_COPY_AUTHDATA 1 46 | #endif 47 | 48 | /** Set this to 0 to save some code space if you know for sure that all data 49 | * passed to this module conforms to the requirements in the SMTP RFC. 50 | * WARNING: use this with care! 51 | */ 52 | #ifndef SMTP_CHECK_DATA 53 | #define SMTP_CHECK_DATA 1 54 | #endif 55 | 56 | /** Set this to 1 to enable AUTH PLAIN support */ 57 | #ifndef SMTP_SUPPORT_AUTH_PLAIN 58 | #define SMTP_SUPPORT_AUTH_PLAIN 1 59 | #endif 60 | 61 | /** Set this to 1 to enable AUTH LOGIN support */ 62 | #ifndef SMTP_SUPPORT_AUTH_LOGIN 63 | #define SMTP_SUPPORT_AUTH_LOGIN 1 64 | #endif 65 | 66 | /* Memory allocation/deallocation can be overridden... */ 67 | #ifndef SMTP_STATE_MALLOC 68 | #define SMTP_STATE_MALLOC(size) mem_malloc(size) 69 | #define SMTP_STATE_FREE(ptr) mem_free(ptr) 70 | #endif 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* SMTP_OPTS_H */ 81 | 82 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/snmp_mib2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * SNMP MIB2 API 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Dirk Ziegelmeier 35 | * 36 | */ 37 | #ifndef LWIP_HDR_APPS_SNMP_MIB2_H 38 | #define LWIP_HDR_APPS_SNMP_MIB2_H 39 | 40 | #include "lwip/apps/snmp_opts.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ 47 | #if SNMP_LWIP_MIB2 48 | 49 | #include "lwip/apps/snmp_core.h" 50 | 51 | extern const struct snmp_mib mib2; 52 | 53 | #if SNMP_USE_NETCONN 54 | #include "lwip/apps/snmp_threadsync.h" 55 | void snmp_mib2_lwip_synchronizer(snmp_threadsync_called_fn fn, void* arg); 56 | extern struct snmp_threadsync_instance snmp_mib2_lwip_locks; 57 | #endif 58 | 59 | #ifndef SNMP_SYSSERVICES 60 | #define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2)) 61 | #endif 62 | 63 | void snmp_mib2_set_sysdescr(const u8_t* str, const u16_t* len); /* read-only be defintion */ 64 | void snmp_mib2_set_syscontact(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); 65 | void snmp_mib2_set_syscontact_readonly(const u8_t *ocstr, const u16_t *ocstrlen); 66 | void snmp_mib2_set_sysname(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); 67 | void snmp_mib2_set_sysname_readonly(const u8_t *ocstr, const u16_t *ocstrlen); 68 | void snmp_mib2_set_syslocation(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); 69 | void snmp_mib2_set_syslocation_readonly(const u8_t *ocstr, const u16_t *ocstrlen); 70 | 71 | #endif /* SNMP_LWIP_MIB2 */ 72 | #endif /* LWIP_SNMP */ 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif /* LWIP_HDR_APPS_SNMP_MIB2_H */ 79 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/snmp_snmpv2_framework.h: -------------------------------------------------------------------------------- 1 | /* 2 | Generated by LwipMibCompiler 3 | */ 4 | 5 | #ifndef LWIP_HDR_APPS_SNMP_FRAMEWORK_MIB_H 6 | #define LWIP_HDR_APPS_SNMP_FRAMEWORK_MIB_H 7 | 8 | #include "lwip/apps/snmp_opts.h" 9 | #if LWIP_SNMP 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | #include "lwip/apps/snmp_core.h" 16 | 17 | extern const struct snmp_obj_id usmNoAuthProtocol; 18 | extern const struct snmp_obj_id usmHMACMD5AuthProtocol; 19 | extern const struct snmp_obj_id usmHMACSHAAuthProtocol; 20 | 21 | extern const struct snmp_obj_id usmNoPrivProtocol; 22 | extern const struct snmp_obj_id usmDESPrivProtocol; 23 | extern const struct snmp_obj_id usmAESPrivProtocol; 24 | 25 | extern const struct snmp_mib snmpframeworkmib; 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif /* __cplusplus */ 30 | 31 | #endif /* LWIP_SNMP */ 32 | #endif /* LWIP_HDR_APPS_SNMP_FRAMEWORK_MIB_H */ 33 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/snmp_snmpv2_usm.h: -------------------------------------------------------------------------------- 1 | /* 2 | Generated by LwipMibCompiler 3 | */ 4 | 5 | #ifndef LWIP_HDR_APPS_SNMP_USER_BASED_SM_MIB_H 6 | #define LWIP_HDR_APPS_SNMP_USER_BASED_SM_MIB_H 7 | 8 | #include "lwip/apps/snmp_opts.h" 9 | #if LWIP_SNMP 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | #include "lwip/apps/snmp_core.h" 16 | 17 | extern const struct snmp_mib snmpusmmib; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif /* __cplusplus */ 22 | 23 | #endif /* LWIP_SNMP */ 24 | #endif /* LWIP_HDR_APPS_SNMP_USER_BASED_SM_MIB_H */ 25 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/sntp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * SNTP client API 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2007-2009 Frédéric Bernon, Simon Goldschmidt 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Frédéric Bernon, Simon Goldschmidt 35 | * 36 | */ 37 | #ifndef LWIP_HDR_APPS_SNTP_H 38 | #define LWIP_HDR_APPS_SNTP_H 39 | 40 | #include "lwip/apps/sntp_opts.h" 41 | #include "lwip/ip_addr.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* SNTP operating modes: default is to poll using unicast. 48 | The mode has to be set before calling sntp_init(). */ 49 | #define SNTP_OPMODE_POLL 0 50 | #define SNTP_OPMODE_LISTENONLY 1 51 | void sntp_setoperatingmode(u8_t operating_mode); 52 | u8_t sntp_getoperatingmode(void); 53 | 54 | void sntp_init(void); 55 | void sntp_stop(void); 56 | u8_t sntp_enabled(void); 57 | 58 | void sntp_setserver(u8_t idx, const ip_addr_t *addr); 59 | const ip_addr_t* sntp_getserver(u8_t idx); 60 | 61 | #if SNTP_MONITOR_SERVER_REACHABILITY 62 | u8_t sntp_getreachability(u8_t idx); 63 | #endif /* SNTP_MONITOR_SERVER_REACHABILITY */ 64 | 65 | #if SNTP_SERVER_DNS 66 | void sntp_setservername(u8_t idx, const char *server); 67 | const char *sntp_getservername(u8_t idx); 68 | #endif /* SNTP_SERVER_DNS */ 69 | 70 | #if SNTP_GET_SERVERS_FROM_DHCP 71 | void sntp_servermode_dhcp(int set_servers_from_dhcp); 72 | #else /* SNTP_GET_SERVERS_FROM_DHCP */ 73 | #define sntp_servermode_dhcp(x) 74 | #endif /* SNTP_GET_SERVERS_FROM_DHCP */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* LWIP_HDR_APPS_SNTP_H */ 81 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/apps/tftp_opts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @file tftp_opts.h 4 | * 5 | * @author Logan Gunthorpe 6 | * 7 | * @brief Trivial File Transfer Protocol (RFC 1350) implementation options 8 | * 9 | * Copyright (c) Deltatee Enterprises Ltd. 2013 10 | * All rights reserved. 11 | * 12 | */ 13 | 14 | /* 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification,are permitted provided that the following conditions are met: 17 | * 18 | * 1. Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. The name of the author may not be used to endorse or promote products 24 | * derived from this software without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 29 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 31 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 32 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 34 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * Author: Logan Gunthorpe 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_APPS_TFTP_OPTS_H 42 | #define LWIP_HDR_APPS_TFTP_OPTS_H 43 | 44 | #include "lwip/opt.h" 45 | #include "lwip/prot/iana.h" 46 | 47 | /** 48 | * @defgroup tftp_opts Options 49 | * @ingroup tftp 50 | * @{ 51 | */ 52 | 53 | /** 54 | * Enable TFTP debug messages 55 | */ 56 | #if !defined TFTP_DEBUG || defined __DOXYGEN__ 57 | #define TFTP_DEBUG LWIP_DBG_OFF 58 | #endif 59 | 60 | /** 61 | * TFTP server port 62 | */ 63 | #if !defined TFTP_PORT || defined __DOXYGEN__ 64 | #define TFTP_PORT LWIP_IANA_PORT_TFTP 65 | #endif 66 | 67 | /** 68 | * TFTP timeout 69 | */ 70 | #if !defined TFTP_TIMEOUT_MSECS || defined __DOXYGEN__ 71 | #define TFTP_TIMEOUT_MSECS 10000 72 | #endif 73 | 74 | /** 75 | * Max. number of retries when a file is read from server 76 | */ 77 | #if !defined TFTP_MAX_RETRIES || defined __DOXYGEN__ 78 | #define TFTP_MAX_RETRIES 5 79 | #endif 80 | 81 | /** 82 | * TFTP timer cyclic interval 83 | */ 84 | #if !defined TFTP_TIMER_MSECS || defined __DOXYGEN__ 85 | #define TFTP_TIMER_MSECS (TFTP_TIMEOUT_MSECS / 10) 86 | #endif 87 | 88 | /** 89 | * Max. length of TFTP filename 90 | */ 91 | #if !defined TFTP_MAX_FILENAME_LEN || defined __DOXYGEN__ 92 | #define TFTP_MAX_FILENAME_LEN 20 93 | #endif 94 | 95 | /** 96 | * Max. length of TFTP mode 97 | */ 98 | #if !defined TFTP_MAX_MODE_LEN || defined __DOXYGEN__ 99 | #define TFTP_MAX_MODE_LEN 7 100 | #endif 101 | 102 | /** 103 | * @} 104 | */ 105 | 106 | #endif /* LWIP_HDR_APPS_TFTP_OPTS_H */ 107 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/ethip6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Ethernet output for IPv6. Uses ND tables for link-layer addressing. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #ifndef LWIP_HDR_ETHIP6_H 43 | #define LWIP_HDR_ETHIP6_H 44 | 45 | #include "lwip/opt.h" 46 | 47 | #if LWIP_IPV6 && LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ 48 | 49 | #include "lwip/pbuf.h" 50 | #include "lwip/ip6.h" 51 | #include "lwip/ip6_addr.h" 52 | #include "lwip/netif.h" 53 | 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | 60 | err_t ethip6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* LWIP_IPV6 && LWIP_ETHERNET */ 67 | 68 | #endif /* LWIP_HDR_ETHIP6_H */ 69 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/icmp6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * IPv6 version of ICMP, as per RFC 4443. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | #ifndef LWIP_HDR_ICMP6_H 42 | #define LWIP_HDR_ICMP6_H 43 | 44 | #include "lwip/opt.h" 45 | #include "lwip/pbuf.h" 46 | #include "lwip/ip6_addr.h" 47 | #include "lwip/netif.h" 48 | #include "lwip/prot/icmp6.h" 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | #if LWIP_ICMP6 && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 55 | 56 | void icmp6_input(struct pbuf *p, struct netif *inp); 57 | void icmp6_dest_unreach(struct pbuf *p, enum icmp6_dur_code c); 58 | void icmp6_packet_too_big(struct pbuf *p, u32_t mtu); 59 | void icmp6_time_exceeded(struct pbuf *p, enum icmp6_te_code c); 60 | void icmp6_time_exceeded_with_addrs(struct pbuf *p, enum icmp6_te_code c, 61 | const ip6_addr_t *src_addr, const ip6_addr_t *dest_addr); 62 | void icmp6_param_problem(struct pbuf *p, enum icmp6_pp_code c, const void *pointer); 63 | 64 | #endif /* LWIP_ICMP6 && LWIP_IPV6 */ 65 | 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | 72 | #endif /* LWIP_HDR_ICMP6_H */ 73 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/if_api.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Interface Identification APIs from: 4 | * RFC 3493: Basic Socket Interface Extensions for IPv6 5 | * Section 4: Interface Identification 6 | */ 7 | 8 | /* 9 | * Copyright (c) 2017 Joel Cunningham, Garmin International, Inc. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * This file is part of the lwIP TCP/IP stack. 35 | * 36 | * Author: Joel Cunningham 37 | * 38 | */ 39 | #ifndef LWIP_HDR_IF_H 40 | #define LWIP_HDR_IF_H 41 | 42 | #include "lwip/opt.h" 43 | 44 | #if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ 45 | 46 | #include "lwip/netif.h" 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | #define IF_NAMESIZE NETIF_NAMESIZE 53 | 54 | char * lwip_if_indextoname(unsigned int ifindex, char *ifname); 55 | unsigned int lwip_if_nametoindex(const char *ifname); 56 | 57 | #if LWIP_COMPAT_SOCKETS 58 | #define if_indextoname(ifindex, ifname) lwip_if_indextoname(ifindex,ifname) 59 | #define if_nametoindex(ifname) lwip_if_nametoindex(ifname) 60 | #endif /* LWIP_COMPAT_SOCKETS */ 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* LWIP_SOCKET */ 67 | 68 | #endif /* LWIP_HDR_IF_H */ 69 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/lwipopts.h: -------------------------------------------------------------------------------- 1 | /* 2 | Lazymio 2/10/2019. 3 | Options for tun2socks. 4 | The codes below are under GPLv3 License. 5 | */ 6 | #pragma once 7 | 8 | #ifndef LWIP_LWIPOPTS_H 9 | #define LWIP_LWIPOPTS_H 10 | 11 | /* 12 | We just need raw API. 13 | */ 14 | #define NO_SYS 1 15 | #define SYS_LIGHTWEIGHT_PROT 0 16 | #define LWIP_NETCONN 0 17 | #define LWIP_SOCKET 0 18 | /* 19 | 4 bytes alignment. 20 | */ 21 | #define MEM_ALIGNMENT 4 22 | 23 | /* 24 | We don't need extra interfaces. 25 | */ 26 | #define LWIP_HAVE_LOOPIF 1 27 | #define LWIP_NETIF_LOOPBACK 1 28 | 29 | /* 30 | We don't need ethernet layer and therefore arp protocol. 31 | */ 32 | #define LWIP_ARP 0 33 | 34 | #define LWIP_ETHERNET 0 35 | 36 | /* 37 | Enable scaling. 38 | */ 39 | #define LWIP_WND_SCALE 1 40 | #define TCP_RCV_SCALE 4 41 | 42 | 43 | /* 44 | What's wrong with my program??? 45 | */ 46 | #define LWIP_DEBUG 1 47 | #define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL 48 | #define TCP_DEBUG LWIP_DBG_ON 49 | #define TCP_OUTPUT_DEBUG LWIP_DBG_ON 50 | #define TCP_INPUT_DEBUG LWIP_DBG_ON 51 | #define MEM_DEBUG LWIP_DBG_ON 52 | 53 | /* 54 | Memory management. 55 | */ 56 | #define MEM_LIBC_MALLOC 1 57 | #define MEMP_MEM_MALLOC 1 58 | 59 | #define MEM_SIZE 2048000 60 | 61 | /* 62 | Internal pools 63 | */ 64 | #define MEMP_NUM_PBUF 8192 65 | 66 | #define MEMP_NUM_UDP_PCB 4096 67 | 68 | #define MEMP_NUM_TCP_PCB 4096 69 | 70 | #define MEMP_NUM_TCP_PCB_LISTEN 16 71 | 72 | #define MEMP_NUM_TCP_SEG 8192 73 | 74 | #define MEMP_NUM_FRAG_PBUF 4096 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/mem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Heap API 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_MEM_H 38 | #define LWIP_HDR_MEM_H 39 | 40 | #include "lwip/opt.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if MEM_LIBC_MALLOC 47 | 48 | #include "lwip/arch.h" 49 | 50 | typedef size_t mem_size_t; 51 | #define MEM_SIZE_F SZT_F 52 | 53 | #elif MEM_USE_POOLS 54 | 55 | typedef u16_t mem_size_t; 56 | #define MEM_SIZE_F U16_F 57 | 58 | #else 59 | 60 | /* MEM_SIZE would have to be aligned, but using 64000 here instead of 61 | * 65535 leaves some room for alignment... 62 | */ 63 | #if MEM_SIZE > 64000L 64 | typedef u32_t mem_size_t; 65 | #define MEM_SIZE_F U32_F 66 | #else 67 | typedef u16_t mem_size_t; 68 | #define MEM_SIZE_F U16_F 69 | #endif /* MEM_SIZE > 64000 */ 70 | #endif 71 | 72 | void mem_init(void); 73 | void *mem_trim(void *mem, mem_size_t size); 74 | void *mem_malloc(mem_size_t size); 75 | void *mem_calloc(mem_size_t count, mem_size_t size); 76 | void mem_free(void *mem); 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /* LWIP_HDR_MEM_H */ 83 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/nd6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Neighbor discovery and stateless address autoconfiguration for IPv6. 5 | * Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862 6 | * (Address autoconfiguration). 7 | */ 8 | 9 | /* 10 | * Copyright (c) 2010 Inico Technologies Ltd. 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. The name of the author may not be used to endorse or promote products 22 | * derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 27 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 29 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 33 | * OF SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Ivan Delamer 38 | * 39 | * 40 | * Please coordinate changes and requests with Ivan Delamer 41 | * 42 | */ 43 | 44 | #ifndef LWIP_HDR_ND6_H 45 | #define LWIP_HDR_ND6_H 46 | 47 | #include "lwip/opt.h" 48 | 49 | #if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 50 | 51 | #include "lwip/ip6_addr.h" 52 | #include "lwip/err.h" 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /** 1 second period */ 59 | #define ND6_TMR_INTERVAL 1000 60 | 61 | /** Router solicitations are sent in 4 second intervals (see RFC 4861, ch. 6.3.7) */ 62 | #ifndef ND6_RTR_SOLICITATION_INTERVAL 63 | #define ND6_RTR_SOLICITATION_INTERVAL 4000 64 | #endif 65 | 66 | struct pbuf; 67 | struct netif; 68 | 69 | void nd6_tmr(void); 70 | void nd6_input(struct pbuf *p, struct netif *inp); 71 | void nd6_clear_destination_cache(void); 72 | struct netif *nd6_find_route(const ip6_addr_t *ip6addr); 73 | err_t nd6_get_next_hop_addr_or_queue(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr, const u8_t **hwaddrp); 74 | u16_t nd6_get_destination_mtu(const ip6_addr_t *ip6addr, struct netif *netif); 75 | #if LWIP_ND6_TCP_REACHABILITY_HINTS 76 | void nd6_reachability_hint(const ip6_addr_t *ip6addr); 77 | #endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */ 78 | void nd6_cleanup_netif(struct netif *netif); 79 | #if LWIP_IPV6_MLD 80 | void nd6_adjust_mld_membership(struct netif *netif, s8_t addr_idx, u8_t new_state); 81 | #endif /* LWIP_IPV6_MLD */ 82 | void nd6_restart_netif(struct netif *netif); 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* LWIP_IPV6 */ 89 | 90 | #endif /* LWIP_HDR_ND6_H */ 91 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/priv/raw_priv.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * raw API internal implementations (do not use in application code) 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_RAW_PRIV_H 38 | #define LWIP_HDR_RAW_PRIV_H 39 | 40 | #include "lwip/opt.h" 41 | 42 | #if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ 43 | 44 | #include "lwip/raw.h" 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | /** return codes for raw_input */ 51 | typedef enum raw_input_state 52 | { 53 | RAW_INPUT_NONE = 0, /* pbuf did not match any pcbs */ 54 | RAW_INPUT_EATEN, /* pbuf handed off and delivered to pcb */ 55 | RAW_INPUT_DELIVERED /* pbuf only delivered to pcb (pbuf can still be referenced) */ 56 | } raw_input_state_t; 57 | 58 | /* The following functions are the lower layer interface to RAW. */ 59 | raw_input_state_t raw_input(struct pbuf *p, struct netif *inp); 60 | 61 | void raw_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* LWIP_RAW */ 68 | 69 | #endif /* LWIP_HDR_RAW_PRIV_H */ 70 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/prot/autoip.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * AutoIP protocol definitions 4 | */ 5 | 6 | /* 7 | * 8 | * Copyright (c) 2007 Dominik Spies 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * Author: Dominik Spies 34 | * 35 | * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform 36 | * with RFC 3927. 37 | * 38 | */ 39 | 40 | #ifndef LWIP_HDR_PROT_AUTOIP_H 41 | #define LWIP_HDR_PROT_AUTOIP_H 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* 169.254.0.0 */ 48 | #define AUTOIP_NET 0xA9FE0000 49 | /* 169.254.1.0 */ 50 | #define AUTOIP_RANGE_START (AUTOIP_NET | 0x0100) 51 | /* 169.254.254.255 */ 52 | #define AUTOIP_RANGE_END (AUTOIP_NET | 0xFEFF) 53 | 54 | /* RFC 3927 Constants */ 55 | #define PROBE_WAIT 1 /* second (initial random delay) */ 56 | #define PROBE_MIN 1 /* second (minimum delay till repeated probe) */ 57 | #define PROBE_MAX 2 /* seconds (maximum delay till repeated probe) */ 58 | #define PROBE_NUM 3 /* (number of probe packets) */ 59 | #define ANNOUNCE_NUM 2 /* (number of announcement packets) */ 60 | #define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */ 61 | #define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */ 62 | #define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */ 63 | #define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */ 64 | #define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */ 65 | 66 | /* AutoIP client states */ 67 | typedef enum { 68 | AUTOIP_STATE_OFF = 0, 69 | AUTOIP_STATE_PROBING = 1, 70 | AUTOIP_STATE_ANNOUNCING = 2, 71 | AUTOIP_STATE_BOUND = 3 72 | } autoip_state_enum_t; 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif /* LWIP_HDR_PROT_AUTOIP_H */ 79 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/prot/iana.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * IANA assigned numbers (RFC 1700 and successors) 4 | * 5 | * @defgroup iana IANA assigned numbers 6 | * @ingroup infrastructure 7 | */ 8 | 9 | /* 10 | * Copyright (c) 2017 Dirk Ziegelmeier. 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. The name of the author may not be used to endorse or promote products 22 | * derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 27 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 29 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 33 | * OF SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Dirk Ziegelmeier 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_PROT_IANA_H 42 | #define LWIP_HDR_PROT_IANA_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /** 49 | * @ingroup iana 50 | * Hardware types 51 | */ 52 | enum lwip_iana_hwtype { 53 | /** Ethernet */ 54 | LWIP_IANA_HWTYPE_ETHERNET = 1 55 | }; 56 | 57 | /** 58 | * @ingroup iana 59 | * Port numbers 60 | * https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt 61 | */ 62 | enum lwip_iana_port_number { 63 | /** SMTP */ 64 | LWIP_IANA_PORT_SMTP = 25, 65 | /** DHCP server */ 66 | LWIP_IANA_PORT_DHCP_SERVER = 67, 67 | /** DHCP client */ 68 | LWIP_IANA_PORT_DHCP_CLIENT = 68, 69 | /** TFTP */ 70 | LWIP_IANA_PORT_TFTP = 69, 71 | /** HTTP */ 72 | LWIP_IANA_PORT_HTTP = 80, 73 | /** SNTP */ 74 | LWIP_IANA_PORT_SNTP = 123, 75 | /** NETBIOS */ 76 | LWIP_IANA_PORT_NETBIOS = 137, 77 | /** SNMP */ 78 | LWIP_IANA_PORT_SNMP = 161, 79 | /** SNMP traps */ 80 | LWIP_IANA_PORT_SNMP_TRAP = 162, 81 | /** HTTPS */ 82 | LWIP_IANA_PORT_HTTPS = 443, 83 | /** SMTPS */ 84 | LWIP_IANA_PORT_SMTPS = 465, 85 | /** MQTT */ 86 | LWIP_IANA_PORT_MQTT = 1883, 87 | /** MDNS */ 88 | LWIP_IANA_PORT_MDNS = 5353, 89 | /** Secure MQTT */ 90 | LWIP_IANA_PORT_SECURE_MQTT = 8883 91 | }; 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* LWIP_HDR_PROT_IANA_H */ 98 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/prot/ieee.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * IEEE assigned numbers 4 | * 5 | * @defgroup ieee IEEE assigned numbers 6 | * @ingroup infrastructure 7 | */ 8 | 9 | /* 10 | * Copyright (c) 2017 Dirk Ziegelmeier. 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. The name of the author may not be used to endorse or promote products 22 | * derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 27 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 29 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 33 | * OF SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Dirk Ziegelmeier 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_PROT_IEEE_H 42 | #define LWIP_HDR_PROT_IEEE_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /** 49 | * @ingroup ieee 50 | * A list of often ethtypes (although lwIP does not use all of them). 51 | */ 52 | enum lwip_ieee_eth_type { 53 | /** Internet protocol v4 */ 54 | ETHTYPE_IP = 0x0800U, 55 | /** Address resolution protocol */ 56 | ETHTYPE_ARP = 0x0806U, 57 | /** Wake on lan */ 58 | ETHTYPE_WOL = 0x0842U, 59 | /** RARP */ 60 | ETHTYPE_RARP = 0x8035U, 61 | /** Virtual local area network */ 62 | ETHTYPE_VLAN = 0x8100U, 63 | /** Internet protocol v6 */ 64 | ETHTYPE_IPV6 = 0x86DDU, 65 | /** PPP Over Ethernet Discovery Stage */ 66 | ETHTYPE_PPPOEDISC = 0x8863U, 67 | /** PPP Over Ethernet Session Stage */ 68 | ETHTYPE_PPPOE = 0x8864U, 69 | /** Jumbo Frames */ 70 | ETHTYPE_JUMBO = 0x8870U, 71 | /** Process field network */ 72 | ETHTYPE_PROFINET = 0x8892U, 73 | /** Ethernet for control automation technology */ 74 | ETHTYPE_ETHERCAT = 0x88A4U, 75 | /** Link layer discovery protocol */ 76 | ETHTYPE_LLDP = 0x88CCU, 77 | /** Serial real-time communication system */ 78 | ETHTYPE_SERCOS = 0x88CDU, 79 | /** Media redundancy protocol */ 80 | ETHTYPE_MRP = 0x88E3U, 81 | /** Precision time protocol */ 82 | ETHTYPE_PTP = 0x88F7U, 83 | /** Q-in-Q, 802.1ad */ 84 | ETHTYPE_QINQ = 0x9100U 85 | }; 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* LWIP_HDR_PROT_IEEE_H */ 92 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/prot/igmp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * IGMP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_IGMP_H 38 | #define LWIP_HDR_PROT_IGMP_H 39 | 40 | #include "lwip/arch.h" 41 | #include "lwip/prot/ip4.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* 48 | * IGMP constants 49 | */ 50 | #define IGMP_TTL 1 51 | #define IGMP_MINLEN 8 52 | #define ROUTER_ALERT 0x9404U 53 | #define ROUTER_ALERTLEN 4 54 | 55 | /* 56 | * IGMP message types, including version number. 57 | */ 58 | #define IGMP_MEMB_QUERY 0x11 /* Membership query */ 59 | #define IGMP_V1_MEMB_REPORT 0x12 /* Ver. 1 membership report */ 60 | #define IGMP_V2_MEMB_REPORT 0x16 /* Ver. 2 membership report */ 61 | #define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */ 62 | 63 | /* Group membership states */ 64 | #define IGMP_GROUP_NON_MEMBER 0 65 | #define IGMP_GROUP_DELAYING_MEMBER 1 66 | #define IGMP_GROUP_IDLE_MEMBER 2 67 | 68 | /** 69 | * IGMP packet format. 70 | */ 71 | #ifdef PACK_STRUCT_USE_INCLUDES 72 | # include "arch/bpstruct.h" 73 | #endif 74 | PACK_STRUCT_BEGIN 75 | struct igmp_msg { 76 | PACK_STRUCT_FLD_8(u8_t igmp_msgtype); 77 | PACK_STRUCT_FLD_8(u8_t igmp_maxresp); 78 | PACK_STRUCT_FIELD(u16_t igmp_checksum); 79 | PACK_STRUCT_FLD_S(ip4_addr_p_t igmp_group_address); 80 | } PACK_STRUCT_STRUCT; 81 | PACK_STRUCT_END 82 | #ifdef PACK_STRUCT_USE_INCLUDES 83 | # include "arch/epstruct.h" 84 | #endif 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* LWIP_HDR_PROT_IGMP_H */ 91 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/prot/ip.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * IP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_IP_H 38 | #define LWIP_HDR_PROT_IP_H 39 | 40 | #include "lwip/arch.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #define IP_PROTO_ICMP 1 47 | #define IP_PROTO_IGMP 2 48 | #define IP_PROTO_UDP 17 49 | #define IP_PROTO_UDPLITE 136 50 | #define IP_PROTO_TCP 6 51 | 52 | /** This operates on a void* by loading the first byte */ 53 | #define IP_HDR_GET_VERSION(ptr) ((*(u8_t*)(ptr)) >> 4) 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* LWIP_HDR_PROT_IP_H */ 60 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/prot/mld6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * MLD6 protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_MLD6_H 38 | #define LWIP_HDR_PROT_MLD6_H 39 | 40 | #include "lwip/arch.h" 41 | #include "lwip/prot/ip6.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #define MLD6_HBH_HLEN 8 48 | /** Multicast listener report/query/done message header. */ 49 | #ifdef PACK_STRUCT_USE_INCLUDES 50 | # include "arch/bpstruct.h" 51 | #endif 52 | PACK_STRUCT_BEGIN 53 | struct mld_header { 54 | PACK_STRUCT_FLD_8(u8_t type); 55 | PACK_STRUCT_FLD_8(u8_t code); 56 | PACK_STRUCT_FIELD(u16_t chksum); 57 | PACK_STRUCT_FIELD(u16_t max_resp_delay); 58 | PACK_STRUCT_FIELD(u16_t reserved); 59 | PACK_STRUCT_FLD_S(ip6_addr_p_t multicast_address); 60 | /* Options follow. */ 61 | } PACK_STRUCT_STRUCT; 62 | PACK_STRUCT_END 63 | #ifdef PACK_STRUCT_USE_INCLUDES 64 | # include "arch/epstruct.h" 65 | #endif 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* LWIP_HDR_PROT_MLD6_H */ 72 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/prot/udp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * UDP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_UDP_H 38 | #define LWIP_HDR_PROT_UDP_H 39 | 40 | #include "lwip/arch.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #define UDP_HLEN 8 47 | 48 | /* Fields are (of course) in network byte order. */ 49 | #ifdef PACK_STRUCT_USE_INCLUDES 50 | # include "arch/bpstruct.h" 51 | #endif 52 | PACK_STRUCT_BEGIN 53 | struct udp_hdr { 54 | PACK_STRUCT_FIELD(u16_t src); 55 | PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */ 56 | PACK_STRUCT_FIELD(u16_t len); 57 | PACK_STRUCT_FIELD(u16_t chksum); 58 | } PACK_STRUCT_STRUCT; 59 | PACK_STRUCT_END 60 | #ifdef PACK_STRUCT_USE_INCLUDES 61 | # include "arch/epstruct.h" 62 | #endif 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif /* LWIP_HDR_PROT_UDP_H */ 69 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/lwip/tcpbase.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Base TCP API definitions shared by TCP and ALTCP\n 4 | * See also @ref tcp_raw 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | #ifndef LWIP_HDR_TCPBASE_H 39 | #define LWIP_HDR_TCPBASE_H 40 | 41 | #include "lwip/opt.h" 42 | 43 | #if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | 50 | #if LWIP_WND_SCALE 51 | typedef u32_t tcpwnd_size_t; 52 | #else 53 | typedef u16_t tcpwnd_size_t; 54 | #endif 55 | 56 | enum tcp_state { 57 | CLOSED = 0, 58 | LISTEN = 1, 59 | SYN_SENT = 2, 60 | SYN_RCVD = 3, 61 | ESTABLISHED = 4, 62 | FIN_WAIT_1 = 5, 63 | FIN_WAIT_2 = 6, 64 | CLOSE_WAIT = 7, 65 | CLOSING = 8, 66 | LAST_ACK = 9, 67 | TIME_WAIT = 10 68 | }; 69 | /* ATTENTION: this depends on state number ordering! */ 70 | #define TCP_STATE_IS_CLOSING(state) ((state) >= FIN_WAIT_1) 71 | 72 | /* Flags for "apiflags" parameter in tcp_write */ 73 | #define TCP_WRITE_FLAG_COPY 0x01 74 | #define TCP_WRITE_FLAG_MORE 0x02 75 | 76 | #define TCP_PRIO_MIN 1 77 | #define TCP_PRIO_NORMAL 64 78 | #define TCP_PRIO_MAX 127 79 | 80 | const char* tcp_debug_state_str(enum tcp_state s); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* LWIP_TCP */ 87 | 88 | #endif /* LWIP_HDR_TCPBASE_H */ 89 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/etharp.h: -------------------------------------------------------------------------------- 1 | /* ARP has been moved to core/ipv4, provide this #include for compatibility only */ 2 | #include "lwip/etharp.h" 3 | #include "netif/ethernet.h" 4 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/ethernet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Ethernet input function - handles INCOMING ethernet level traffic 4 | * To be used in most low-level netif implementations 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 9 | * Copyright (c) 2003-2004 Leon Woestenberg 10 | * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. The name of the author may not be used to endorse or promote products 22 | * derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 27 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 29 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 33 | * OF SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Adam Dunkels 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_NETIF_ETHERNET_H 42 | #define LWIP_HDR_NETIF_ETHERNET_H 43 | 44 | #include "lwip/opt.h" 45 | 46 | #include "lwip/pbuf.h" 47 | #include "lwip/netif.h" 48 | #include "lwip/prot/ethernet.h" 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | #if LWIP_ARP || LWIP_ETHERNET 55 | 56 | /** Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type) 57 | * to a filter function that returns the correct netif when using multiple 58 | * netifs on one hardware interface where the netif's low-level receive 59 | * routine cannot decide for the correct netif (e.g. when mapping multiple 60 | * IP addresses to one hardware interface). 61 | */ 62 | #ifndef LWIP_ARP_FILTER_NETIF 63 | #define LWIP_ARP_FILTER_NETIF 0 64 | #endif 65 | 66 | err_t ethernet_input(struct pbuf *p, struct netif *netif); 67 | err_t ethernet_output(struct netif* netif, struct pbuf* p, const struct eth_addr* src, const struct eth_addr* dst, u16_t eth_type); 68 | 69 | extern const struct eth_addr ethbroadcast, ethzero; 70 | 71 | #endif /* LWIP_ARP || LWIP_ETHERNET */ 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif /* LWIP_HDR_NETIF_ETHERNET_H */ 78 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/lowpan6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * 6LowPAN output for IPv6. Uses ND tables for link-layer addressing. Fragments packets to 6LowPAN units. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2015 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #ifndef LWIP_HDR_LOWPAN6_H 43 | #define LWIP_HDR_LOWPAN6_H 44 | 45 | #include "netif/lowpan6_opts.h" 46 | 47 | #if LWIP_IPV6 48 | 49 | #include "netif/lowpan6_common.h" 50 | #include "lwip/pbuf.h" 51 | #include "lwip/ip.h" 52 | #include "lwip/ip_addr.h" 53 | #include "lwip/netif.h" 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | /** 1 second period for reassembly */ 60 | #define LOWPAN6_TMR_INTERVAL 1000 61 | 62 | void lowpan6_tmr(void); 63 | 64 | err_t lowpan6_set_context(u8_t idx, const ip6_addr_t * context); 65 | err_t lowpan6_set_short_addr(u8_t addr_high, u8_t addr_low); 66 | 67 | #if LWIP_IPV4 68 | err_t lowpan4_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr); 69 | #endif /* LWIP_IPV4 */ 70 | err_t lowpan6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); 71 | err_t lowpan6_input(struct pbuf * p, struct netif *netif); 72 | err_t lowpan6_if_init(struct netif *netif); 73 | 74 | /* pan_id in network byte order. */ 75 | err_t lowpan6_set_pan_id(u16_t pan_id); 76 | 77 | u16_t lowpan6_calc_crc(const void *buf, u16_t len); 78 | 79 | #if !NO_SYS 80 | err_t tcpip_6lowpan_input(struct pbuf *p, struct netif *inp); 81 | #endif /* !NO_SYS */ 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif /* LWIP_IPV6 */ 88 | 89 | #endif /* LWIP_HDR_LOWPAN6_H */ 90 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/lowpan6_ble.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 6LowPAN over BLE for IPv6 (RFC7668). 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2017 Benjamin Aigner 8 | * Copyright (c) 2015 Inico Technologies Ltd. , Author: Ivan Delamer 9 | * 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * Author: Benjamin Aigner 35 | * 36 | * Based on the original 6lowpan implementation of lwIP ( @see 6lowpan.c) 37 | */ 38 | 39 | #ifndef LWIP_HDR_LOWPAN6_BLE_H 40 | #define LWIP_HDR_LOWPAN6_BLE_H 41 | 42 | #include "netif/lowpan6_opts.h" 43 | 44 | #if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 45 | 46 | #include "netif/lowpan6_common.h" 47 | #include "lwip/pbuf.h" 48 | #include "lwip/ip.h" 49 | #include "lwip/ip_addr.h" 50 | #include "lwip/netif.h" 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | err_t rfc7668_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); 57 | err_t rfc7668_input(struct pbuf * p, struct netif *netif); 58 | err_t rfc7668_set_local_addr_eui64(struct netif *netif, const u8_t *local_addr, size_t local_addr_len); 59 | err_t rfc7668_set_local_addr_mac48(struct netif *netif, const u8_t *local_addr, size_t local_addr_len, int is_public_addr); 60 | err_t rfc7668_set_peer_addr_eui64(struct netif *netif, const u8_t *peer_addr, size_t peer_addr_len); 61 | err_t rfc7668_set_peer_addr_mac48(struct netif *netif, const u8_t *peer_addr, size_t peer_addr_len, int is_public_addr); 62 | err_t rfc7668_set_context(u8_t index, const ip6_addr_t * context); 63 | err_t rfc7668_if_init(struct netif *netif); 64 | 65 | #if !NO_SYS 66 | err_t tcpip_rfc7668_input(struct pbuf *p, struct netif *inp); 67 | #endif 68 | 69 | void ble_addr_to_eui64(uint8_t *dst, const uint8_t *src, int public_addr); 70 | void eui64_to_ble_addr(uint8_t *dst, const uint8_t *src); 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif /* LWIP_IPV6 */ 77 | 78 | #endif /* LWIP_HDR_LOWPAN6_BLE_H */ 79 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/lowpan6_common.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Common 6LowPAN routines for IPv6. Uses ND tables for link-layer addressing. Fragments packets to 6LowPAN units. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2015 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #ifndef LWIP_HDR_LOWPAN6_COMMON_H 43 | #define LWIP_HDR_LOWPAN6_COMMON_H 44 | 45 | #include "netif/lowpan6_opts.h" 46 | 47 | #if LWIP_IPV6 /* don't build if IPv6 is disabled in lwipopts.h */ 48 | 49 | #include "lwip/pbuf.h" 50 | #include "lwip/ip.h" 51 | #include "lwip/ip6_addr.h" 52 | #include "lwip/netif.h" 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /** Helper define for a link layer address, which can be encoded as 0, 2 or 8 bytes */ 59 | struct lowpan6_link_addr { 60 | /* encoded length of the address */ 61 | u8_t addr_len; 62 | /* address bytes */ 63 | u8_t addr[8]; 64 | }; 65 | 66 | s8_t lowpan6_get_address_mode(const ip6_addr_t *ip6addr, const struct lowpan6_link_addr *mac_addr); 67 | 68 | #if LWIP_6LOWPAN_IPHC 69 | err_t lowpan6_compress_headers(struct netif *netif, u8_t *inbuf, size_t inbuf_size, u8_t *outbuf, size_t outbuf_size, 70 | u8_t *lowpan6_header_len_out, u8_t *hidden_header_len_out, ip6_addr_t *lowpan6_contexts, 71 | const struct lowpan6_link_addr *src, const struct lowpan6_link_addr *dst); 72 | struct pbuf *lowpan6_decompress(struct pbuf *p, u16_t datagram_size, ip6_addr_t *lowpan6_contexts, 73 | struct lowpan6_link_addr *src, struct lowpan6_link_addr *dest); 74 | #endif /* LWIP_6LOWPAN_IPHC */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* LWIP_IPV6 */ 81 | 82 | #endif /* LWIP_HDR_LOWPAN6_COMMON_H */ 83 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/ppp/chap-md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * chap-md5.h - New CHAP/MD5 implementation. 3 | * 4 | * Copyright (c) 2003 Paul Mackerras. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. The name(s) of the authors of this software must not be used to 14 | * endorse or promote products derived from this software without 15 | * prior written permission. 16 | * 17 | * 3. Redistributions of any form whatsoever must retain the following 18 | * acknowledgment: 19 | * "This product includes software developed by Paul Mackerras 20 | * ". 21 | * 22 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 23 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 24 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 25 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 26 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 27 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 28 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 | */ 30 | 31 | #include "netif/ppp/ppp_opts.h" 32 | #if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 33 | 34 | extern const struct chap_digest_type md5_digest; 35 | 36 | #endif /* PPP_SUPPORT && CHAP_SUPPORT */ 37 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/ppp/chap_ms.h: -------------------------------------------------------------------------------- 1 | /* 2 | * chap_ms.h - Challenge Handshake Authentication Protocol definitions. 3 | * 4 | * Copyright (c) 1995 Eric Rosenquist. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The name(s) of the authors of this software must not be used to 19 | * endorse or promote products derived from this software without 20 | * prior written permission. 21 | * 22 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 23 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 24 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 25 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 26 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 27 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 28 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 | * 30 | * $Id: chap_ms.h,v 1.13 2004/11/15 22:13:26 paulus Exp $ 31 | */ 32 | 33 | #include "netif/ppp/ppp_opts.h" 34 | #if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 35 | 36 | #ifndef CHAPMS_INCLUDE 37 | #define CHAPMS_INCLUDE 38 | 39 | extern const struct chap_digest_type chapms_digest; 40 | extern const struct chap_digest_type chapms2_digest; 41 | 42 | #endif /* CHAPMS_INCLUDE */ 43 | 44 | #endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ 45 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/ppp/ecp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ecp.h - Definitions for PPP Encryption Control Protocol. 3 | * 4 | * Copyright (c) 2002 Google, Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. The name(s) of the authors of this software must not be used to 20 | * endorse or promote products derived from this software without 21 | * prior written permission. 22 | * 23 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 24 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 25 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 26 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 27 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 28 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 29 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 30 | * 31 | * $Id: ecp.h,v 1.2 2003/01/10 07:12:36 fcusack Exp $ 32 | */ 33 | 34 | #include "netif/ppp/ppp_opts.h" 35 | #if PPP_SUPPORT && ECP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 36 | 37 | #ifndef ECP_H 38 | #define ECP_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef struct ecp_options { 45 | bool required; /* Is ECP required? */ 46 | unsigned enctype; /* Encryption type */ 47 | } ecp_options; 48 | 49 | extern fsm ecp_fsm[]; 50 | extern ecp_options ecp_wantoptions[]; 51 | extern ecp_options ecp_gotoptions[]; 52 | extern ecp_options ecp_allowoptions[]; 53 | extern ecp_options ecp_hisoptions[]; 54 | 55 | extern const struct protent ecp_protent; 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* ECP_H */ 62 | #endif /* PPP_SUPPORT && ECP_SUPPORT */ 63 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/ppp/eui64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * eui64.h - EUI64 routines for IPv6CP. 3 | * 4 | * Copyright (c) 1999 Tommi Komulainen. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The name(s) of the authors of this software must not be used to 19 | * endorse or promote products derived from this software without 20 | * prior written permission. 21 | * 22 | * 4. Redistributions of any form whatsoever must retain the following 23 | * acknowledgment: 24 | * "This product includes software developed by Tommi Komulainen 25 | * ". 26 | * 27 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 28 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 29 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 30 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 31 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 32 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 33 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 34 | * 35 | * $Id: eui64.h,v 1.6 2002/12/04 23:03:32 paulus Exp $ 36 | */ 37 | 38 | #include "netif/ppp/ppp_opts.h" 39 | #if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */ 40 | 41 | #ifndef EUI64_H 42 | #define EUI64_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /* 49 | * @todo: 50 | * 51 | * Maybe this should be done by processing struct in6_addr directly... 52 | */ 53 | typedef union 54 | { 55 | u8_t e8[8]; 56 | u16_t e16[4]; 57 | u32_t e32[2]; 58 | } eui64_t; 59 | 60 | #define eui64_iszero(e) (((e).e32[0] | (e).e32[1]) == 0) 61 | #define eui64_equals(e, o) (((e).e32[0] == (o).e32[0]) && \ 62 | ((e).e32[1] == (o).e32[1])) 63 | #define eui64_zero(e) (e).e32[0] = (e).e32[1] = 0; 64 | 65 | #define eui64_copy(s, d) memcpy(&(d), &(s), sizeof(eui64_t)) 66 | 67 | #define eui64_magic(e) do { \ 68 | (e).e32[0] = magic(); \ 69 | (e).e32[1] = magic(); \ 70 | (e).e8[0] &= ~2; \ 71 | } while (0) 72 | #define eui64_magic_nz(x) do { \ 73 | eui64_magic(x); \ 74 | } while (eui64_iszero(x)) 75 | #define eui64_magic_ne(x, y) do { \ 76 | eui64_magic(x); \ 77 | } while (eui64_equals(x, y)) 78 | 79 | #define eui64_get(ll, cp) do { \ 80 | eui64_copy((*cp), (ll)); \ 81 | (cp) += sizeof(eui64_t); \ 82 | } while (0) 83 | 84 | #define eui64_put(ll, cp) do { \ 85 | eui64_copy((ll), (*cp)); \ 86 | (cp) += sizeof(eui64_t); \ 87 | } while (0) 88 | 89 | #define eui64_set32(e, l) do { \ 90 | (e).e32[0] = 0; \ 91 | (e).e32[1] = lwip_htonl(l); \ 92 | } while (0) 93 | #define eui64_setlo32(e, l) eui64_set32(e, l) 94 | 95 | char *eui64_ntoa(eui64_t); /* Returns ascii representation of id */ 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* EUI64_H */ 102 | #endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */ 103 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/ppp/polarssl/arc4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file arc4.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_ARC4 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_ARC4_H 40 | #define LWIP_INCLUDED_POLARSSL_ARC4_H 41 | 42 | /** 43 | * \brief ARC4 context structure 44 | */ 45 | typedef struct 46 | { 47 | int x; /*!< permutation index */ 48 | int y; /*!< permutation index */ 49 | unsigned char m[256]; /*!< permutation table */ 50 | } 51 | arc4_context; 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** 58 | * \brief ARC4 key schedule 59 | * 60 | * \param ctx ARC4 context to be initialized 61 | * \param key the secret key 62 | * \param keylen length of the key 63 | */ 64 | void arc4_setup( arc4_context *ctx, unsigned char *key, int keylen ); 65 | 66 | /** 67 | * \brief ARC4 cipher function 68 | * 69 | * \param ctx ARC4 context 70 | * \param buf buffer to be processed 71 | * \param buflen amount of data in buf 72 | */ 73 | void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ); 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* LWIP_INCLUDED_POLARSSL_ARC4_H */ 80 | 81 | #endif /* LWIP_INCLUDED_POLARSSL_ARC4 */ 82 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/ppp/polarssl/des.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file des.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_DES 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_DES_H 40 | #define LWIP_INCLUDED_POLARSSL_DES_H 41 | 42 | #define DES_ENCRYPT 1 43 | #define DES_DECRYPT 0 44 | 45 | /** 46 | * \brief DES context structure 47 | */ 48 | typedef struct 49 | { 50 | int mode; /*!< encrypt/decrypt */ 51 | unsigned long sk[32]; /*!< DES subkeys */ 52 | } 53 | des_context; 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | /** 60 | * \brief DES key schedule (56-bit, encryption) 61 | * 62 | * \param ctx DES context to be initialized 63 | * \param key 8-byte secret key 64 | */ 65 | void des_setkey_enc( des_context *ctx, unsigned char key[8] ); 66 | 67 | /** 68 | * \brief DES key schedule (56-bit, decryption) 69 | * 70 | * \param ctx DES context to be initialized 71 | * \param key 8-byte secret key 72 | */ 73 | void des_setkey_dec( des_context *ctx, unsigned char key[8] ); 74 | 75 | /** 76 | * \brief DES-ECB block encryption/decryption 77 | * 78 | * \param ctx DES context 79 | * \param input 64-bit input block 80 | * \param output 64-bit output block 81 | */ 82 | void des_crypt_ecb( des_context *ctx, 83 | const unsigned char input[8], 84 | unsigned char output[8] ); 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* LWIP_INCLUDED_POLARSSL_DES_H */ 91 | 92 | #endif /* LWIP_INCLUDED_POLARSSL_DES */ 93 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/ppp/polarssl/md4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file md4.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_MD4 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_MD4_H 40 | #define LWIP_INCLUDED_POLARSSL_MD4_H 41 | 42 | /** 43 | * \brief MD4 context structure 44 | */ 45 | typedef struct 46 | { 47 | unsigned long total[2]; /*!< number of bytes processed */ 48 | unsigned long state[4]; /*!< intermediate digest state */ 49 | unsigned char buffer[64]; /*!< data block being processed */ 50 | } 51 | md4_context; 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** 58 | * \brief MD4 context setup 59 | * 60 | * \param ctx context to be initialized 61 | */ 62 | void md4_starts( md4_context *ctx ); 63 | 64 | /** 65 | * \brief MD4 process buffer 66 | * 67 | * \param ctx MD4 context 68 | * \param input buffer holding the data 69 | * \param ilen length of the input data 70 | */ 71 | void md4_update( md4_context *ctx, const unsigned char *input, int ilen ); 72 | 73 | /** 74 | * \brief MD4 final digest 75 | * 76 | * \param ctx MD4 context 77 | * \param output MD4 checksum result 78 | */ 79 | void md4_finish( md4_context *ctx, unsigned char output[16] ); 80 | 81 | /** 82 | * \brief Output = MD4( input buffer ) 83 | * 84 | * \param input buffer holding the data 85 | * \param ilen length of the input data 86 | * \param output MD4 checksum result 87 | */ 88 | void md4( unsigned char *input, int ilen, unsigned char output[16] ); 89 | 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif /* LWIP_INCLUDED_POLARSSL_MD4_H */ 96 | 97 | #endif /* LWIP_INCLUDED_POLARSSL_MD4 */ 98 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/ppp/polarssl/md5.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file md5.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_MD5 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_MD5_H 40 | #define LWIP_INCLUDED_POLARSSL_MD5_H 41 | 42 | /** 43 | * \brief MD5 context structure 44 | */ 45 | typedef struct 46 | { 47 | unsigned long total[2]; /*!< number of bytes processed */ 48 | unsigned long state[4]; /*!< intermediate digest state */ 49 | unsigned char buffer[64]; /*!< data block being processed */ 50 | } 51 | md5_context; 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** 58 | * \brief MD5 context setup 59 | * 60 | * \param ctx context to be initialized 61 | */ 62 | void md5_starts( md5_context *ctx ); 63 | 64 | /** 65 | * \brief MD5 process buffer 66 | * 67 | * \param ctx MD5 context 68 | * \param input buffer holding the data 69 | * \param ilen length of the input data 70 | */ 71 | void md5_update( md5_context *ctx, const unsigned char *input, int ilen ); 72 | 73 | /** 74 | * \brief MD5 final digest 75 | * 76 | * \param ctx MD5 context 77 | * \param output MD5 checksum result 78 | */ 79 | void md5_finish( md5_context *ctx, unsigned char output[16] ); 80 | 81 | /** 82 | * \brief Output = MD5( input buffer ) 83 | * 84 | * \param input buffer holding the data 85 | * \param ilen length of the input data 86 | * \param output MD5 checksum result 87 | */ 88 | void md5( unsigned char *input, int ilen, unsigned char output[16] ); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* LWIP_INCLUDED_POLARSSL_MD5_H */ 95 | 96 | #endif /* LWIP_INCLUDED_POLARSSL_MD5 */ 97 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/ppp/polarssl/sha1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file sha1.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_SHA1 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_SHA1_H 40 | #define LWIP_INCLUDED_POLARSSL_SHA1_H 41 | 42 | /** 43 | * \brief SHA-1 context structure 44 | */ 45 | typedef struct 46 | { 47 | unsigned long total[2]; /*!< number of bytes processed */ 48 | unsigned long state[5]; /*!< intermediate digest state */ 49 | unsigned char buffer[64]; /*!< data block being processed */ 50 | } 51 | sha1_context; 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** 58 | * \brief SHA-1 context setup 59 | * 60 | * \param ctx context to be initialized 61 | */ 62 | void sha1_starts( sha1_context *ctx ); 63 | 64 | /** 65 | * \brief SHA-1 process buffer 66 | * 67 | * \param ctx SHA-1 context 68 | * \param input buffer holding the data 69 | * \param ilen length of the input data 70 | */ 71 | void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen ); 72 | 73 | /** 74 | * \brief SHA-1 final digest 75 | * 76 | * \param ctx SHA-1 context 77 | * \param output SHA-1 checksum result 78 | */ 79 | void sha1_finish( sha1_context *ctx, unsigned char output[20] ); 80 | 81 | /** 82 | * \brief Output = SHA-1( input buffer ) 83 | * 84 | * \param input buffer holding the data 85 | * \param ilen length of the input data 86 | * \param output SHA-1 checksum result 87 | */ 88 | void sha1( unsigned char *input, int ilen, unsigned char output[20] ); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* LWIP_INCLUDED_POLARSSL_SHA1_H */ 95 | 96 | #endif /* LWIP_INCLUDED_POLARSSL_SHA1 */ 97 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/slipif.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * SLIP netif API 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001, Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the Institute nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Adam Dunkels 38 | * 39 | */ 40 | #ifndef LWIP_HDR_NETIF_SLIPIF_H 41 | #define LWIP_HDR_NETIF_SLIPIF_H 42 | 43 | #include "lwip/opt.h" 44 | #include "lwip/netif.h" 45 | 46 | /** Set this to 1 to start a thread that blocks reading on the serial line 47 | * (using sio_read()). 48 | */ 49 | #ifndef SLIP_USE_RX_THREAD 50 | #define SLIP_USE_RX_THREAD !NO_SYS 51 | #endif 52 | 53 | /** Set this to 1 to enable functions to pass in RX bytes from ISR context. 54 | * If enabled, slipif_received_byte[s]() process incoming bytes and put assembled 55 | * packets on a queue, which is fed into lwIP from slipif_poll(). 56 | * If disabled, slipif_poll() polls the serial line (using sio_tryread()). 57 | */ 58 | #ifndef SLIP_RX_FROM_ISR 59 | #define SLIP_RX_FROM_ISR 0 60 | #endif 61 | 62 | /** Set this to 1 (default for SLIP_RX_FROM_ISR) to queue incoming packets 63 | * received by slipif_received_byte[s]() as long as PBUF_POOL pbufs are available. 64 | * If disabled, packets will be dropped if more than one packet is received. 65 | */ 66 | #ifndef SLIP_RX_QUEUE 67 | #define SLIP_RX_QUEUE SLIP_RX_FROM_ISR 68 | #endif 69 | 70 | #ifdef __cplusplus 71 | extern "C" { 72 | #endif 73 | 74 | err_t slipif_init(struct netif * netif); 75 | void slipif_poll(struct netif *netif); 76 | #if SLIP_RX_FROM_ISR 77 | void slipif_process_rxqueue(struct netif *netif); 78 | void slipif_received_byte(struct netif *netif, u8_t data); 79 | void slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len); 80 | #endif /* SLIP_RX_FROM_ISR */ 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* LWIP_HDR_NETIF_SLIPIF_H */ 87 | 88 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/include/netif/zepif.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * A netif implementing the ZigBee Eencapsulation Protocol (ZEP). 5 | * This is used to tunnel 6LowPAN over UDP. 6 | */ 7 | 8 | /* 9 | * Copyright (c) 2018 Simon Goldschmidt 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * This file is part of the lwIP TCP/IP stack. 35 | * 36 | * Author: Simon Goldschmidt 37 | * 38 | */ 39 | 40 | #ifndef LWIP_HDR_ZEPIF_H 41 | #define LWIP_HDR_ZEPIF_H 42 | 43 | #include "lwip/opt.h" 44 | #include "netif/lowpan6.h" 45 | 46 | #if LWIP_IPV6 && LWIP_UDP /* don't build if not configured for use in lwipopts.h */ 47 | 48 | #include "lwip/netif.h" 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | #define ZEPIF_DEFAULT_UDP_PORT 17754 55 | 56 | /** Pass this struct as 'state' to netif_add to control the behaviour 57 | * of this netif. If NULL is passed, default behaviour is chosen */ 58 | struct zepif_init { 59 | /** The UDP port used to ZEP frames from (0 = default) */ 60 | u16_t zep_src_udp_port; 61 | /** The UDP port used to ZEP frames to (0 = default) */ 62 | u16_t zep_dst_udp_port; 63 | /** The IP address to sed ZEP frames from (NULL = ANY) */ 64 | const ip_addr_t *zep_src_ip_addr; 65 | /** The IP address to sed ZEP frames to (NULL = BROADCAST) */ 66 | const ip_addr_t *zep_dst_ip_addr; 67 | /** If != NULL, the udp pcb is bound to this netif */ 68 | const struct netif *zep_netif; 69 | /** MAC address of the 6LowPAN device */ 70 | u8_t addr[6]; 71 | }; 72 | 73 | err_t zepif_init(struct netif *netif); 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* LWIP_IPV6 && LWIP_UDP */ 80 | 81 | #endif /* LWIP_HDR_ZEPIF_H */ 82 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/netif/FILES: -------------------------------------------------------------------------------- 1 | This directory contains generic network interface device drivers that 2 | do not contain any hardware or architecture specific code. The files 3 | are: 4 | 5 | ethernet.c 6 | Shared code for Ethernet based interfaces. 7 | 8 | lowpan6.c 9 | A 6LoWPAN implementation as a netif. 10 | 11 | lowpan6_ble.c 12 | A 6LoWPAN over Bluetooth Low Energy (BLE) implementation as netif, 13 | according to RFC-7668. 14 | 15 | slipif.c 16 | A generic implementation of the SLIP (Serial Line IP) 17 | protocol. It requires a sio (serial I/O) module to work. 18 | 19 | ppp/ Point-to-Point Protocol stack 20 | The lwIP PPP support is based from pppd (http://ppp.samba.org) with 21 | huge changes to match code size and memory requirements for embedded 22 | devices. Please read /doc/ppp.txt and ppp/PPPD_FOLLOWUP for a detailed 23 | explanation. 24 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/netif/ppp/eui64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * eui64.c - EUI64 routines for IPv6CP. 3 | * 4 | * Copyright (c) 1999 Tommi Komulainen. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The name(s) of the authors of this software must not be used to 19 | * endorse or promote products derived from this software without 20 | * prior written permission. 21 | * 22 | * 4. Redistributions of any form whatsoever must retain the following 23 | * acknowledgment: 24 | * "This product includes software developed by Tommi Komulainen 25 | * ". 26 | * 27 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 28 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 29 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 30 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 31 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 32 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 33 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 34 | * 35 | * $Id: eui64.c,v 1.6 2002/12/04 23:03:32 paulus Exp $ 36 | */ 37 | 38 | #include "netif/ppp/ppp_opts.h" 39 | #if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */ 40 | 41 | #include "netif/ppp/ppp_impl.h" 42 | #include "netif/ppp/eui64.h" 43 | 44 | /* 45 | * eui64_ntoa - Make an ascii representation of an interface identifier 46 | */ 47 | char *eui64_ntoa(eui64_t e) { 48 | static char buf[20]; 49 | 50 | sprintf(buf, "%02x%02x:%02x%02x:%02x%02x:%02x%02x", 51 | e.e8[0], e.e8[1], e.e8[2], e.e8[3], 52 | e.e8[4], e.e8[5], e.e8[6], e.e8[7]); 53 | return buf; 54 | } 55 | 56 | #endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */ 57 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/netif/ppp/polarssl/README: -------------------------------------------------------------------------------- 1 | About PolarSSL files into lwIP PPP support 2 | ------------------------------------------ 3 | 4 | This folder contains some files fetched from the latest BSD release of 5 | the PolarSSL project (PolarSSL 0.10.1-bsd) for ciphers and encryption 6 | methods we need for lwIP PPP support. 7 | 8 | The PolarSSL files were cleaned to contain only the necessary struct 9 | fields and functions needed for lwIP. 10 | 11 | The PolarSSL API was not changed at all, so if you are already using 12 | PolarSSL you can choose to skip the compilation of the included PolarSSL 13 | library into lwIP. 14 | 15 | If you are not using the embedded copy you must include external 16 | libraries into your arch/cc.h port file. 17 | 18 | Beware of the stack requirements which can be a lot larger if you are not 19 | using our cleaned PolarSSL library. 20 | 21 | 22 | PolarSSL project website: http://polarssl.org/ 23 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/netif/ppp/pppcrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pppcrypt.c - PPP/DES linkage for MS-CHAP and EAP SRP-SHA1 3 | * 4 | * Extracted from chap_ms.c by James Carlson. 5 | * 6 | * Copyright (c) 1995 Eric Rosenquist. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. The name(s) of the authors of this software must not be used to 21 | * endorse or promote products derived from this software without 22 | * prior written permission. 23 | * 24 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 25 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 26 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 27 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 28 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 29 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 30 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 31 | */ 32 | 33 | #include "netif/ppp/ppp_opts.h" 34 | #if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not necessary */ 35 | 36 | #include "netif/ppp/ppp_impl.h" 37 | 38 | #include "netif/ppp/pppcrypt.h" 39 | 40 | 41 | static u_char pppcrypt_get_7bits(u_char *input, int startBit) { 42 | unsigned int word; 43 | 44 | word = (unsigned)input[startBit / 8] << 8; 45 | word |= (unsigned)input[startBit / 8 + 1]; 46 | 47 | word >>= 15 - (startBit % 8 + 7); 48 | 49 | return word & 0xFE; 50 | } 51 | 52 | /* IN 56 bit DES key missing parity bits 53 | * OUT 64 bit DES key with parity bits added 54 | */ 55 | void pppcrypt_56_to_64_bit_key(u_char *key, u_char * des_key) { 56 | des_key[0] = pppcrypt_get_7bits(key, 0); 57 | des_key[1] = pppcrypt_get_7bits(key, 7); 58 | des_key[2] = pppcrypt_get_7bits(key, 14); 59 | des_key[3] = pppcrypt_get_7bits(key, 21); 60 | des_key[4] = pppcrypt_get_7bits(key, 28); 61 | des_key[5] = pppcrypt_get_7bits(key, 35); 62 | des_key[6] = pppcrypt_get_7bits(key, 42); 63 | des_key[7] = pppcrypt_get_7bits(key, 49); 64 | } 65 | 66 | #endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ 67 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/src/sys_arch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "lwip/sys.h" 7 | 8 | static LARGE_INTEGER freq, sys_start_time; 9 | static std::mutex sys_arch_pcb_sets_syncobj; 10 | static stdext::hash_set sys_arch_pcb_sets; 11 | 12 | void sys_init(void) { 13 | QueryPerformanceFrequency(&freq); 14 | QueryPerformanceCounter(&sys_start_time); 15 | } 16 | 17 | static LONGLONG 18 | sys_get_ms_longlong(void) 19 | { 20 | LONGLONG ret; 21 | LARGE_INTEGER now; 22 | if (freq.QuadPart == 0) { 23 | sys_init(); 24 | } 25 | QueryPerformanceCounter(&now); 26 | ret = now.QuadPart - sys_start_time.QuadPart; 27 | return (u32_t)(((ret) * 1000) / freq.QuadPart); 28 | } 29 | 30 | u32_t 31 | sys_jiffies(void) 32 | { 33 | return (u32_t)sys_get_ms_longlong(); 34 | } 35 | 36 | u32_t 37 | sys_now(void) 38 | { 39 | return (u32_t)sys_get_ms_longlong(); 40 | } 41 | 42 | int sys_arch_pcb_watch(void* pcb) 43 | { 44 | if (NULL == pcb) { 45 | return 0; 46 | } 47 | 48 | int rc = 0; 49 | sys_arch_pcb_sets_syncobj.lock(); 50 | { 51 | rc = sys_arch_pcb_sets.insert(pcb).second ? 1 : 0; 52 | } 53 | sys_arch_pcb_sets_syncobj.unlock(); 54 | 55 | return rc; 56 | } 57 | 58 | int sys_arch_pcb_is_watch(void* pcb) 59 | { 60 | if (NULL == pcb) { 61 | return 0; 62 | } 63 | 64 | int rc = 0; 65 | sys_arch_pcb_sets_syncobj.lock(); 66 | { 67 | rc = sys_arch_pcb_sets.find(pcb) != sys_arch_pcb_sets.end() ? 1 : 0; 68 | } 69 | sys_arch_pcb_sets_syncobj.unlock(); 70 | 71 | return rc; 72 | } 73 | 74 | int sys_arch_pcb_unwatch(void* pcb) 75 | { 76 | if (NULL == pcb) { 77 | return 0; 78 | } 79 | 80 | int rc = 0; 81 | sys_arch_pcb_sets_syncobj.lock(); 82 | { 83 | auto tail = sys_arch_pcb_sets.find(pcb); 84 | if (tail != sys_arch_pcb_sets.end()) { 85 | rc = 1; 86 | sys_arch_pcb_sets.erase(tail); 87 | } 88 | } 89 | sys_arch_pcb_sets_syncobj.unlock(); 90 | 91 | return rc; 92 | } 93 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/fuzz/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2001, 2002 Swedish Institute of Computer Science. 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without modification, 6 | # are permitted provided that the following conditions are met: 7 | # 8 | # 1. Redistributions of source code must retain the above copyright notice, 9 | # this list of conditions and the following disclaimer. 10 | # 2. Redistributions in binary form must reproduce the above copyright notice, 11 | # this list of conditions and the following disclaimer in the documentation 12 | # and/or other materials provided with the distribution. 13 | # 3. The name of the author may not be used to endorse or promote products 14 | # derived from this software without specific prior written permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | # SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | # OF SUCH DAMAGE. 26 | # 27 | # This file is part of the lwIP TCP/IP stack. 28 | # 29 | # Author: Adam Dunkels 30 | # 31 | 32 | all compile: lwip_fuzz 33 | .PHONY: all clean 34 | 35 | CC=afl-gcc 36 | LDFLAGS=-lm 37 | # use 'make D=-DUSER_DEFINE' to pass a user define to gcc 38 | CFLAGS=-O0 $(D) 39 | 40 | CONTRIBDIR=../../../lwip-contrib 41 | include $(CONTRIBDIR)/ports/unix/Common.mk 42 | 43 | clean: 44 | rm -f *.o $(LWIPLIBCOMMON) $(APPLIB) lwip_fuzz *.s .depend* *.core core 45 | 46 | depend dep: .depend 47 | 48 | include .depend 49 | 50 | .depend: fuzz.c $(LWIPFILES) $(APPFILES) 51 | $(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend 52 | 53 | lwip_fuzz: .depend $(LWIPLIBCOMMON) $(APPLIB) fuzz.o 54 | $(CC) $(CFLAGS) -o lwip_fuzz fuzz.o $(APPLIB) $(LWIPLIBCOMMON) $(LDFLAGS) 55 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/fuzz/README: -------------------------------------------------------------------------------- 1 | 2 | Fuzzing the lwIP stack (afl-fuzz requires linux/unix or similar) 3 | 4 | This directory contains a small app that reads Ethernet frames from stdin and 5 | processes them. It is used together with the 'american fuzzy lop' tool (found 6 | at http://lcamtuf.coredump.cx/afl/) and the sample inputs to test how 7 | unexpected inputs are handled. The afl tool will read the known inputs, and 8 | try to modify them to exercise as many code paths as possible, by instrumenting 9 | the code and keeping track of which code is executed. 10 | 11 | Just running make will produce the test program. 12 | 13 | Running make with parameter 'D=-DLWIP_FUZZ_MULTI_PACKET' will produce a binary 14 | that parses the input data as multiple packets (experimental!). 15 | 16 | Then run afl with: 17 | 18 | afl-fuzz -i inputs/ -o output ./lwip_fuzz 19 | 20 | and it should start working. It will probably complain about CPU scheduler, 21 | set AFL_SKIP_CPUFREQ=1 to ignore it. 22 | If it complains about invalid "/proc/sys/kernel/core_pattern" setting, try 23 | executing "sudo bash -c 'echo core > /proc/sys/kernel/core_pattern'". 24 | 25 | The input is split into different subdirectories since they test different 26 | parts of the code, and since you want to run one instance of afl-fuzz on each 27 | core. 28 | 29 | When afl finds a crash or a hang, the input that caused it will be placed in 30 | the output directory. If you have hexdump and text2pcap tools installed, 31 | running output_to_pcap.sh will create pcap files for each input 32 | file to simplify viewing in wireshark. 33 | 34 | The lwipopts.h file needs to have checksum checking off, otherwise almost every 35 | packet will be discarded because of that. The other options can be tuned to 36 | expose different parts of the code. 37 | 38 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/fuzz/config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liulilittle/tun2socks/b5187f387fb9c2b62adc7e5afc3cd6b0c5c90943/tun2socks-core/lwip/test/fuzz/config.h -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/fuzz/inputs/arp/arp_req.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liulilittle/tun2socks/b5187f387fb9c2b62adc7e5afc3cd6b0c5c90943/tun2socks-core/lwip/test/fuzz/inputs/arp/arp_req.bin -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/fuzz/inputs/icmp/icmp_ping.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liulilittle/tun2socks/b5187f387fb9c2b62adc7e5afc3cd6b0c5c90943/tun2socks-core/lwip/test/fuzz/inputs/icmp/icmp_ping.bin -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/fuzz/inputs/ipv6/neighbor_solicitation.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liulilittle/tun2socks/b5187f387fb9c2b62adc7e5afc3cd6b0c5c90943/tun2socks-core/lwip/test/fuzz/inputs/ipv6/neighbor_solicitation.bin -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/fuzz/inputs/ipv6/router_adv.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liulilittle/tun2socks/b5187f387fb9c2b62adc7e5afc3cd6b0c5c90943/tun2socks-core/lwip/test/fuzz/inputs/ipv6/router_adv.bin -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/fuzz/inputs/tcp/tcp_syn.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liulilittle/tun2socks/b5187f387fb9c2b62adc7e5afc3cd6b0c5c90943/tun2socks-core/lwip/test/fuzz/inputs/tcp/tcp_syn.bin -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/fuzz/inputs/udp/udp_port_5000.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liulilittle/tun2socks/b5187f387fb9c2b62adc7e5afc3cd6b0c5c90943/tun2socks-core/lwip/test/fuzz/inputs/udp/udp_port_5000.bin -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/fuzz/output_to_pcap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z "$1" ] 4 | then 5 | echo "This script will make pcap files from the afl-fuzz crash/hang files" 6 | echo "It needs hexdump and text2pcap" 7 | echo "Please give output directory as argument" 8 | exit 2 9 | fi 10 | 11 | for i in `ls $1/crashes/id*` 12 | do 13 | PCAPNAME=`echo $i | grep pcap` 14 | if [ -z "$PCAPNAME" ]; then 15 | hexdump -C $i > $1/$$.tmp 16 | text2pcap $1/$$.tmp ${i}.pcap 17 | fi 18 | done 19 | for i in `ls $1/hangs/id*` 20 | do 21 | PCAPNAME=`echo $i | grep pcap` 22 | if [ -z "$PCAPNAME" ]; then 23 | hexdump -C $i > $1/$$.tmp 24 | text2pcap $1/$$.tmp ${i}.pcap 25 | fi 26 | done 27 | rm -f $1/$$.tmp 28 | 29 | echo 30 | echo "Created pcap files:" 31 | ls $1/*/*.pcap 32 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/sockets/sockets_stresstest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Simon Goldschmidt 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Simon Goldschmidt 30 | * 31 | */ 32 | 33 | #ifndef LWIP_HDR_TEST_SOCKETS_STRESSTEST 34 | #define LWIP_HDR_TEST_SOCKETS_STRESSTEST 35 | 36 | void sockets_stresstest_init_loopback(int addr_family); 37 | void sockets_stresstest_init_server(int addr_family, u16_t server_port); 38 | void sockets_stresstest_init_client(const char *remote_ip, u16_t remote_port); 39 | 40 | #endif /* LWIP_HDR_TEST_SOCKETS_STRESSTEST */ 41 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/Filelists.cmake: -------------------------------------------------------------------------------- 1 | # This file is indended to be included in end-user CMakeLists.txt 2 | # include(/path/to/Filelists.cmake) 3 | # It assumes the variable LWIP_DIR is defined pointing to the 4 | # root path of lwIP sources. 5 | # 6 | # This file is NOT designed (on purpose) to be used as cmake 7 | # subdir via add_subdirectory() 8 | # The intention is to provide greater flexibility to users to 9 | # create their own targets using the *_SRCS variables. 10 | 11 | set(LWIP_TESTDIR ${LWIP_DIR}/test/unit) 12 | set(LWIP_TESTFILES 13 | ${LWIP_TESTDIR}/lwip_unittests.c 14 | ${LWIP_TESTDIR}/api/test_sockets.c 15 | ${LWIP_TESTDIR}/arch/sys_arch.c 16 | ${LWIP_TESTDIR}/core/test_def.c 17 | ${LWIP_TESTDIR}/core/test_mem.c 18 | ${LWIP_TESTDIR}/core/test_netif.c 19 | ${LWIP_TESTDIR}/core/test_pbuf.c 20 | ${LWIP_TESTDIR}/core/test_timers.c 21 | ${LWIP_TESTDIR}/dhcp/test_dhcp.c 22 | ${LWIP_TESTDIR}/etharp/test_etharp.c 23 | ${LWIP_TESTDIR}/ip4/test_ip4.c 24 | ${LWIP_TESTDIR}/ip6/test_ip6.c 25 | ${LWIP_TESTDIR}/mdns/test_mdns.c 26 | ${LWIP_TESTDIR}/mqtt/test_mqtt.c 27 | ${LWIP_TESTDIR}/tcp/tcp_helper.c 28 | ${LWIP_TESTDIR}/tcp/test_tcp_oos.c 29 | ${LWIP_TESTDIR}/tcp/test_tcp.c 30 | ${LWIP_TESTDIR}/udp/test_udp.c 31 | ) 32 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/Filelists.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2001, 2002 Swedish Institute of Computer Science. 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without modification, 6 | # are permitted provided that the following conditions are met: 7 | # 8 | # 1. Redistributions of source code must retain the above copyright notice, 9 | # this list of conditions and the following disclaimer. 10 | # 2. Redistributions in binary form must reproduce the above copyright notice, 11 | # this list of conditions and the following disclaimer in the documentation 12 | # and/or other materials provided with the distribution. 13 | # 3. The name of the author may not be used to endorse or promote products 14 | # derived from this software without specific prior written permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | # SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | # OF SUCH DAMAGE. 26 | # 27 | # This file is part of the lwIP TCP/IP stack. 28 | # 29 | # Author: Adam Dunkels 30 | # 31 | 32 | TESTDIR=$(LWIPDIR)/../test/unit 33 | TESTFILES=$(TESTDIR)/lwip_unittests.c \ 34 | $(TESTDIR)/api/test_sockets.c \ 35 | $(TESTDIR)/arch/sys_arch.c \ 36 | $(TESTDIR)/core/test_def.c \ 37 | $(TESTDIR)/core/test_mem.c \ 38 | $(TESTDIR)/core/test_netif.c \ 39 | $(TESTDIR)/core/test_pbuf.c \ 40 | $(TESTDIR)/core/test_timers.c \ 41 | $(TESTDIR)/dhcp/test_dhcp.c \ 42 | $(TESTDIR)/etharp/test_etharp.c \ 43 | $(TESTDIR)/ip4/test_ip4.c \ 44 | $(TESTDIR)/ip6/test_ip6.c \ 45 | $(TESTDIR)/mdns/test_mdns.c \ 46 | $(TESTDIR)/mqtt/test_mqtt.c \ 47 | $(TESTDIR)/tcp/tcp_helper.c \ 48 | $(TESTDIR)/tcp/test_tcp_oos.c \ 49 | $(TESTDIR)/tcp/test_tcp.c \ 50 | $(TESTDIR)/udp/test_udp.c 51 | 52 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/api/test_sockets.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_SOCKETS_H 2 | #define LWIP_HDR_TEST_SOCKETS_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *sockets_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/arch/sys_arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Simon Goldschmidt 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Simon Goldschmidt 30 | * 31 | */ 32 | #ifndef LWIP_HDR_TEST_SYS_ARCH_H 33 | #define LWIP_HDR_TEST_SYS_ARCH_H 34 | 35 | typedef int sys_sem_t; 36 | #define sys_sem_valid(sema) ((sema) != NULL) 37 | 38 | typedef int sys_mutex_t; 39 | #define sys_mutex_valid(mutex) (((mutex) != NULL) 40 | 41 | struct lwip_mbox { 42 | void* sem; 43 | void** q_mem; 44 | unsigned int head, tail; 45 | int size; 46 | int used; 47 | }; 48 | typedef struct lwip_mbox sys_mbox_t; 49 | #define SYS_MBOX_NULL NULL 50 | #define sys_mbox_valid(mbox) ((mbox != NULL) && ((mbox)->sem != NULL) && ((mbox)->sem != (void*)-1)) 51 | #define sys_mbox_valid_val(mbox) (((mbox).sem != NULL) && ((mbox).sem != (void*)-1)) 52 | 53 | /* DWORD (thread id) is used for sys_thread_t but we won't include windows.h */ 54 | typedef u32_t sys_thread_t; 55 | 56 | #define SYS_ARCH_DECL_PROTECT(lev) 57 | #define SYS_ARCH_PROTECT(lev) 58 | #define SYS_ARCH_UNPROTECT(lev) 59 | 60 | /* to implement doing something while blocking on an mbox or semaphore: 61 | * pass a function to test_sys_arch_wait_callback() that returns 62 | * '0' if waiting again and 63 | * '1' if now there should be something to do (used for asserting) 64 | */ 65 | typedef int (*test_sys_arch_waiting_fn)(sys_sem_t* wait_sem, sys_mbox_t* wait_mbox); 66 | void test_sys_arch_wait_callback(test_sys_arch_waiting_fn waiting_fn); 67 | 68 | /* current time */ 69 | extern u32_t lwip_sys_now; 70 | 71 | #endif /* LWIP_HDR_TEST_SYS_ARCH_H */ 72 | 73 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/core/test_def.c: -------------------------------------------------------------------------------- 1 | #include "test_def.h" 2 | 3 | #include "lwip/def.h" 4 | 5 | #define MAGIC_UNTOUCHED_BYTE 0x7a 6 | #define TEST_BUFSIZE 32 7 | #define GUARD_SIZE 4 8 | 9 | /* Setups/teardown functions */ 10 | 11 | static void 12 | def_setup(void) 13 | { 14 | } 15 | 16 | static void 17 | def_teardown(void) 18 | { 19 | } 20 | 21 | static void 22 | def_check_range_untouched(const char *buf, size_t len) 23 | { 24 | size_t i; 25 | 26 | for (i = 0; i < len; i++) { 27 | fail_unless(buf[i] == (char)MAGIC_UNTOUCHED_BYTE); 28 | } 29 | } 30 | 31 | static void test_def_itoa(int number, const char *expected) 32 | { 33 | char buf[TEST_BUFSIZE]; 34 | char *test_buf = &buf[GUARD_SIZE]; 35 | 36 | size_t exp_len = strlen(expected); 37 | fail_unless(exp_len + 4 < (TEST_BUFSIZE - (2 * GUARD_SIZE))); 38 | 39 | memset(buf, MAGIC_UNTOUCHED_BYTE, sizeof(buf)); 40 | lwip_itoa(test_buf, exp_len + 1, number); 41 | def_check_range_untouched(buf, GUARD_SIZE); 42 | fail_unless(test_buf[exp_len] == 0); 43 | fail_unless(!memcmp(test_buf, expected, exp_len)); 44 | def_check_range_untouched(&test_buf[exp_len + 1], TEST_BUFSIZE - GUARD_SIZE - exp_len - 1); 45 | 46 | /* check with too small buffer */ 47 | memset(buf, MAGIC_UNTOUCHED_BYTE, sizeof(buf)); 48 | lwip_itoa(test_buf, exp_len, number); 49 | def_check_range_untouched(buf, GUARD_SIZE); 50 | def_check_range_untouched(&test_buf[exp_len + 1], TEST_BUFSIZE - GUARD_SIZE - exp_len - 1); 51 | 52 | /* check with too large buffer */ 53 | memset(buf, MAGIC_UNTOUCHED_BYTE, sizeof(buf)); 54 | lwip_itoa(test_buf, exp_len + 4, number); 55 | def_check_range_untouched(buf, GUARD_SIZE); 56 | fail_unless(test_buf[exp_len] == 0); 57 | fail_unless(!memcmp(test_buf, expected, exp_len)); 58 | def_check_range_untouched(&test_buf[exp_len + 4], TEST_BUFSIZE - GUARD_SIZE - exp_len - 4); 59 | } 60 | 61 | START_TEST(test_def_lwip_itoa) 62 | { 63 | LWIP_UNUSED_ARG(_i); 64 | 65 | test_def_itoa(0, "0"); 66 | test_def_itoa(1, "1"); 67 | test_def_itoa(-1, "-1"); 68 | test_def_itoa(15, "15"); 69 | test_def_itoa(-15, "-15"); 70 | test_def_itoa(156, "156"); 71 | test_def_itoa(1192, "1192"); 72 | test_def_itoa(-156, "-156"); 73 | } 74 | END_TEST 75 | 76 | /** Create the suite including all tests for this module */ 77 | Suite * 78 | def_suite(void) 79 | { 80 | testfunc tests[] = { 81 | TESTFUNC(test_def_lwip_itoa) 82 | }; 83 | return create_suite("DEF", tests, sizeof(tests)/sizeof(testfunc), def_setup, def_teardown); 84 | } 85 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/core/test_def.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_DEF_H 2 | #define LWIP_HDR_TEST_DEF_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *def_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/core/test_mem.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_MEM_H 2 | #define LWIP_HDR_TEST_MEM_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *mem_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/core/test_netif.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_NETIF_H 2 | #define LWIP_HDR_TEST_NETIF_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *netif_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/core/test_pbuf.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_PBUF_H 2 | #define LWIP_HDR_TEST_PBUF_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *pbuf_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/core/test_timers.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_TIMERS_H 2 | #define LWIP_HDR_TEST_TIMERS_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *timers_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/dhcp/test_dhcp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_DHCP_H 2 | #define LWIP_HDR_TEST_DHCP_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* dhcp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/etharp/test_etharp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_ETHARP_H 2 | #define LWIP_HDR_TEST_ETHARP_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* etharp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/ip4/test_ip4.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_IP4_H 2 | #define LWIP_HDR_TEST_IP4_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* ip4_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/ip6/test_ip6.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_IP6_H 2 | #define LWIP_HDR_TEST_IP6_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* ip6_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/lwip_check.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_LWIP_CHECK_H 2 | #define LWIP_HDR_LWIP_CHECK_H 3 | 4 | /* Common header file for lwIP unit tests using the check framework */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #define FAIL_RET() do { fail(); return; } while(0) 11 | #define EXPECT(x) fail_unless(x) 12 | #define EXPECT_RET(x) do { fail_unless(x); if(!(x)) { return; }} while(0) 13 | #define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0) 14 | #define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL) 15 | 16 | typedef struct { 17 | TFun func; 18 | const char *name; 19 | } testfunc; 20 | 21 | #define TESTFUNC(x) {(x), "" # x "" } 22 | 23 | /* Modified function from check.h, supplying function name */ 24 | #define tcase_add_named_test(tc,tf) \ 25 | _tcase_add_test((tc),(tf).func,(tf).name,0, 0, 0, 1) 26 | 27 | /** typedef for a function returning a test suite */ 28 | typedef Suite* (suite_getter_fn)(void); 29 | 30 | /** Create a test suite */ 31 | Suite* create_suite(const char* name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown); 32 | 33 | #ifdef LWIP_UNITTESTS_LIB 34 | int lwip_unittests_run(void) 35 | #endif 36 | 37 | /* helper functions */ 38 | #define SKIP_POOL(x) (1 << x) 39 | #define SKIP_HEAP (1 << MEMP_MAX) 40 | void lwip_check_ensure_no_alloc(unsigned int skip); 41 | 42 | #endif /* LWIP_HDR_LWIP_CHECK_H */ 43 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/lwip_unittests.c: -------------------------------------------------------------------------------- 1 | #include "lwip_check.h" 2 | 3 | #include "ip4/test_ip4.h" 4 | #include "ip6/test_ip6.h" 5 | #include "udp/test_udp.h" 6 | #include "tcp/test_tcp.h" 7 | #include "tcp/test_tcp_oos.h" 8 | #include "core/test_def.h" 9 | #include "core/test_mem.h" 10 | #include "core/test_netif.h" 11 | #include "core/test_pbuf.h" 12 | #include "core/test_timers.h" 13 | #include "etharp/test_etharp.h" 14 | #include "dhcp/test_dhcp.h" 15 | #include "mdns/test_mdns.h" 16 | #include "mqtt/test_mqtt.h" 17 | #include "api/test_sockets.h" 18 | 19 | #include "lwip/init.h" 20 | #if !NO_SYS 21 | #include "lwip/tcpip.h" 22 | #endif 23 | 24 | Suite* create_suite(const char* name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown) 25 | { 26 | size_t i; 27 | Suite *s = suite_create(name); 28 | 29 | for(i = 0; i < num_tests; i++) { 30 | TCase *tc_core = tcase_create(name); 31 | if ((setup != NULL) || (teardown != NULL)) { 32 | tcase_add_checked_fixture(tc_core, setup, teardown); 33 | } 34 | tcase_add_named_test(tc_core, tests[i]); 35 | suite_add_tcase(s, tc_core); 36 | } 37 | return s; 38 | } 39 | 40 | void lwip_check_ensure_no_alloc(unsigned int skip) 41 | { 42 | int i; 43 | unsigned int mask; 44 | 45 | if (!(skip & SKIP_HEAP)) { 46 | fail_unless(lwip_stats.mem.used == 0); 47 | } 48 | for (i = 0, mask = 1; i < MEMP_MAX; i++, mask <<= 1) { 49 | if (!(skip & mask)) { 50 | fail_unless(lwip_stats.memp[i]->used == 0); 51 | } 52 | } 53 | } 54 | 55 | #ifdef LWIP_UNITTESTS_LIB 56 | int lwip_unittests_run(void) 57 | #else 58 | int main(void) 59 | #endif 60 | { 61 | int number_failed; 62 | SRunner *sr; 63 | size_t i; 64 | suite_getter_fn* suites[] = { 65 | ip4_suite, 66 | ip6_suite, 67 | udp_suite, 68 | tcp_suite, 69 | tcp_oos_suite, 70 | def_suite, 71 | mem_suite, 72 | netif_suite, 73 | pbuf_suite, 74 | timers_suite, 75 | etharp_suite, 76 | dhcp_suite, 77 | mdns_suite, 78 | mqtt_suite, 79 | sockets_suite 80 | }; 81 | size_t num = sizeof(suites)/sizeof(void*); 82 | LWIP_ASSERT("No suites defined", num > 0); 83 | 84 | #if NO_SYS 85 | lwip_init(); 86 | #else 87 | tcpip_init(NULL, NULL); 88 | #endif 89 | 90 | sr = srunner_create((suites[0])()); 91 | srunner_set_xml(sr, "lwip_unittests.xml"); 92 | for(i = 1; i < num; i++) { 93 | srunner_add_suite(sr, ((suite_getter_fn*)suites[i])()); 94 | } 95 | 96 | #ifdef LWIP_UNITTESTS_NOFORK 97 | srunner_set_fork_status(sr, CK_NOFORK); 98 | #endif 99 | #ifdef LWIP_UNITTESTS_FORK 100 | srunner_set_fork_status(sr, CK_FORK); 101 | #endif 102 | 103 | srunner_run_all(sr, CK_NORMAL); 104 | number_failed = srunner_ntests_failed(sr); 105 | srunner_free(sr); 106 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 107 | } 108 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/mdns/test_mdns.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_MDNS_H__ 2 | #define LWIP_HDR_TEST_MDNS_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* mdns_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/mqtt/test_mqtt.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_MQTT_H__ 2 | #define LWIP_HDR_TEST_MQTT_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* mqtt_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/tcp/tcp_helper.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TCP_HELPER_H 2 | #define LWIP_HDR_TCP_HELPER_H 3 | 4 | #include "../lwip_check.h" 5 | #include "lwip/arch.h" 6 | #include "lwip/tcp.h" 7 | #include "lwip/netif.h" 8 | 9 | /* counters used for test_tcp_counters_* callback functions */ 10 | struct test_tcp_counters { 11 | u32_t recv_calls; 12 | u32_t recved_bytes; 13 | u32_t recv_calls_after_close; 14 | u32_t recved_bytes_after_close; 15 | u32_t close_calls; 16 | u32_t err_calls; 17 | err_t last_err; 18 | char* expected_data; 19 | u32_t expected_data_len; 20 | }; 21 | 22 | struct test_tcp_txcounters { 23 | u32_t num_tx_calls; 24 | u32_t num_tx_bytes; 25 | u8_t copy_tx_packets; 26 | struct pbuf *tx_packets; 27 | }; 28 | 29 | extern const ip_addr_t test_local_ip; 30 | extern const ip_addr_t test_remote_ip; 31 | extern const ip_addr_t test_netmask; 32 | #define TEST_REMOTE_PORT 0x100 33 | #define TEST_LOCAL_PORT 0x101 34 | 35 | /* Helper functions */ 36 | void tcp_remove_all(void); 37 | 38 | struct pbuf* tcp_create_segment(ip_addr_t* src_ip, ip_addr_t* dst_ip, 39 | u16_t src_port, u16_t dst_port, void* data, size_t data_len, 40 | u32_t seqno, u32_t ackno, u8_t headerflags); 41 | struct pbuf* tcp_create_rx_segment(struct tcp_pcb* pcb, void* data, size_t data_len, 42 | u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags); 43 | struct pbuf* tcp_create_rx_segment_wnd(struct tcp_pcb* pcb, void* data, size_t data_len, 44 | u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags, u16_t wnd); 45 | void tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, const ip_addr_t* local_ip, 46 | const ip_addr_t* remote_ip, u16_t local_port, u16_t remote_port); 47 | void test_tcp_counters_err(void* arg, err_t err); 48 | err_t test_tcp_counters_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err); 49 | 50 | struct tcp_pcb* test_tcp_new_counters_pcb(struct test_tcp_counters* counters); 51 | 52 | void test_tcp_input(struct pbuf *p, struct netif *inp); 53 | 54 | void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcounters, 55 | const ip_addr_t *ip_addr, const ip_addr_t *netmask); 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/tcp/test_tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_TCP_H 2 | #define LWIP_HDR_TEST_TCP_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *tcp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/tcp/test_tcp_oos.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_TCP_OOS_H 2 | #define LWIP_HDR_TEST_TCP_OOS_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *tcp_oos_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/lwip/test/unit/udp/test_udp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_UDP_H 2 | #define LWIP_HDR_TEST_UDP_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* udp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tun2socks-core/tests/lwip_test.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #include "catch2/catch.hpp" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | void init(){ 13 | static bool initialized = false; 14 | if(!initialized){ 15 | lwip_init(); 16 | initialized = true; 17 | } 18 | } 19 | 20 | TEST_CASE("Test basic lwip functions"){ 21 | init(); 22 | SECTION("Test max udp_pcb"){ 23 | udp_pcb* u_arr[65536]; 24 | for(int i = 0; i < 65536; i++){ 25 | u_arr[i] = udp_new(); 26 | REQUIRE(u_arr[i] != NULL); 27 | } 28 | } 29 | SECTION("Test max tcp_pcb"){ 30 | tcp_pcb* t_arr[65536]; 31 | for(int i = 0;i < 65536; i++){ 32 | t_arr[i] = tcp_new(); 33 | REQUIRE(t_arr[i] != NULL); 34 | } 35 | } 36 | SECTION("Test max pbuf"){ 37 | pbuf* pbuf_arr[65536]; 38 | for(int i = 0 ;i < 65536; i++){ 39 | pbuf_arr[i] = pbuf_alloc(pbuf_layer::PBUF_TRANSPORT, 1600, pbuf_type::PBUF_RAM); 40 | REQUIRE(pbuf_arr[i] != NULL); 41 | } 42 | } 43 | SECTION("Test sys_arch"){ 44 | using namespace std::chrono_literals; 45 | auto before = sys_now(); 46 | std::this_thread::sleep_for(1000ms); 47 | auto after = sys_now(); 48 | REQUIRE( (after - before < 1100 &&after - before > 900) ); 49 | } 50 | } -------------------------------------------------------------------------------- /tun2socks-core/tun2socks.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liulilittle/tun2socks/b5187f387fb9c2b62adc7e5afc3cd6b0c5c90943/tun2socks-core/tun2socks.cpp --------------------------------------------------------------------------------