From a0b6e70ff86d7b6a67a275ff18676a0d8fcbe852 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Mon, 29 Apr 2024 10:15:53 -0300 Subject: [PATCH] move to new skeleton --- examples/mip-pcap/mongoose.c | 1 - examples/mip-pcap/mongoose.h | 1 - examples/mip-tap/mongoose.c | 1 - examples/mip-tap/mongoose.h | 1 - examples/mip-tap/net.c | 1 - examples/mip-tap/net.h | 1 - examples/mip-tap/packed_fs.c | 1 - test/Makefile | 8 +++--- tutorials/tcpip/README.md | 1 + .../tcpip/pcap-driver}/Makefile | 0 .../tcpip/pcap-driver}/README.md | 27 +++++++++---------- .../tcpip/pcap-driver}/main.c | 0 tutorials/tcpip/pcap-driver/mongoose.c | 1 + tutorials/tcpip/pcap-driver/mongoose.h | 1 + .../tcpip/tap-driver}/Makefile | 0 .../tcpip/tap-driver}/README.md | 20 +++++++------- .../tcpip/tap-driver}/main.c | 0 tutorials/tcpip/tap-driver/mongoose.c | 1 + tutorials/tcpip/tap-driver/mongoose.h | 1 + tutorials/tcpip/tap-driver/net.c | 1 + tutorials/tcpip/tap-driver/net.h | 1 + tutorials/tcpip/tap-driver/packed_fs.c | 1 + tutorials/tcpip_stack/README.md | 1 - 23 files changed, 34 insertions(+), 37 deletions(-) delete mode 120000 examples/mip-pcap/mongoose.c delete mode 120000 examples/mip-pcap/mongoose.h delete mode 120000 examples/mip-tap/mongoose.c delete mode 120000 examples/mip-tap/mongoose.h delete mode 120000 examples/mip-tap/net.c delete mode 120000 examples/mip-tap/net.h delete mode 120000 examples/mip-tap/packed_fs.c create mode 100644 tutorials/tcpip/README.md rename {examples/mip-pcap => tutorials/tcpip/pcap-driver}/Makefile (100%) rename {examples/mip-pcap => tutorials/tcpip/pcap-driver}/README.md (95%) rename {examples/mip-pcap => tutorials/tcpip/pcap-driver}/main.c (100%) create mode 120000 tutorials/tcpip/pcap-driver/mongoose.c create mode 120000 tutorials/tcpip/pcap-driver/mongoose.h rename {examples/mip-tap => tutorials/tcpip/tap-driver}/Makefile (100%) rename {examples/mip-tap => tutorials/tcpip/tap-driver}/README.md (95%) rename {examples/mip-tap => tutorials/tcpip/tap-driver}/main.c (100%) create mode 120000 tutorials/tcpip/tap-driver/mongoose.c create mode 120000 tutorials/tcpip/tap-driver/mongoose.h create mode 120000 tutorials/tcpip/tap-driver/net.c create mode 120000 tutorials/tcpip/tap-driver/net.h create mode 120000 tutorials/tcpip/tap-driver/packed_fs.c delete mode 100644 tutorials/tcpip_stack/README.md diff --git a/examples/mip-pcap/mongoose.c b/examples/mip-pcap/mongoose.c deleted file mode 120000 index 8ef6e62d..00000000 --- a/examples/mip-pcap/mongoose.c +++ /dev/null @@ -1 +0,0 @@ -../../mongoose.c \ No newline at end of file diff --git a/examples/mip-pcap/mongoose.h b/examples/mip-pcap/mongoose.h deleted file mode 120000 index 488ef358..00000000 --- a/examples/mip-pcap/mongoose.h +++ /dev/null @@ -1 +0,0 @@ -../../mongoose.h \ No newline at end of file diff --git a/examples/mip-tap/mongoose.c b/examples/mip-tap/mongoose.c deleted file mode 120000 index 8ef6e62d..00000000 --- a/examples/mip-tap/mongoose.c +++ /dev/null @@ -1 +0,0 @@ -../../mongoose.c \ No newline at end of file diff --git a/examples/mip-tap/mongoose.h b/examples/mip-tap/mongoose.h deleted file mode 120000 index 488ef358..00000000 --- a/examples/mip-tap/mongoose.h +++ /dev/null @@ -1 +0,0 @@ -../../mongoose.h \ No newline at end of file diff --git a/examples/mip-tap/net.c b/examples/mip-tap/net.c deleted file mode 120000 index 207df8b5..00000000 --- a/examples/mip-tap/net.c +++ /dev/null @@ -1 +0,0 @@ -../device-dashboard/net.c \ No newline at end of file diff --git a/examples/mip-tap/net.h b/examples/mip-tap/net.h deleted file mode 120000 index c734b06a..00000000 --- a/examples/mip-tap/net.h +++ /dev/null @@ -1 +0,0 @@ -../device-dashboard/net.h \ No newline at end of file diff --git a/examples/mip-tap/packed_fs.c b/examples/mip-tap/packed_fs.c deleted file mode 120000 index e199a5c9..00000000 --- a/examples/mip-tap/packed_fs.c +++ /dev/null @@ -1 +0,0 @@ -../device-dashboard/packed_fs.c \ No newline at end of file diff --git a/test/Makefile b/test/Makefile index 66bcdbc7..95391b4b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -14,14 +14,14 @@ IPV6 ?= 1 ASAN ?= -fsanitize=address,undefined,alignment -fno-sanitize-recover=all -fno-omit-frame-pointer -fno-common ASAN_OPTIONS ?= detect_leaks=1 EXAMPLES := $(dir $(wildcard ../examples/*/Makefile)) -EXAMPLES_QUICK := $(filter-out ../examples/mip-pcap/ ../examples/micropython/, $(EXAMPLES)) -EXAMPLES_MAC := $(filter-out ../examples/mip-pcap/ ../examples/mip-tap/ ../examples/micropython/, $(EXAMPLES)) +EXAMPLES_QUICK := $(filter-out ../examples/micropython/, $(EXAMPLES)) +EXAMPLES_MAC := $(filter-out ../examples/micropython/, $(EXAMPLES)) EXAMPLES_WIN := $(dir $(wildcard ../examples/device-dashboard/Makefile) $(wildcard ../examples/file-*/Makefile) $(wildcard ../examples/http-*/Makefile) $(wildcard ../examples/mqtt-*/Makefile) $(wildcard ../examples/websocket-*/Makefile) $(wildcard ../examples/webui-*/Makefile)) EXAMPLES_EMBEDDED := $(filter-out $(wildcard ../examples/zephyr/*/), $(dir $(wildcard ../examples/*/*/Makefile))) REFPROJS := $(dir $(wildcard ../reference-projects/windows-macos-linux/*/Makefile)) TUTORIALS := $(dir $(wildcard ../tutorials/*/*/Makefile)) -TUTORIALS_QUICK := $(filter-out ../tutorials/tcpip_stack/pcap/ , $(TUTORIALS)) -TUTORIALS_MAC := TUTORIALS +TUTORIALS_QUICK := $(filter-out ../tutorials/tcpip/pcap-driver/ , $(TUTORIALS)) +TUTORIALS_MAC := $(filter-out ../tutorials/tcpip/pcap-driver/ ../tutorials/tcpip/tap-driver/, $(TUTORIALS)) TUTORIALS_WIN := $(dir $(wildcard ../tutorials/http/file-*/Makefile) $(wildcard ../tutorials/http/http-*/Makefile) $(wildcard ../tutorials/mqtt/mqtt-*/Makefile) $(wildcard ../tutorials/websocket/websocket-*/Makefile) $(wildcard ../tutorials/webui/webui-*/Makefile)) PREFIX ?= /usr/local LIBDIR ?= $(PREFIX)/lib diff --git a/tutorials/tcpip/README.md b/tutorials/tcpip/README.md new file mode 100644 index 00000000..7e294d5f --- /dev/null +++ b/tutorials/tcpip/README.md @@ -0,0 +1 @@ +See detailed tutorials at https://mongoose.ws/documentation/#drivers-for-mongoose-built-in-tcpip-stack \ No newline at end of file diff --git a/examples/mip-pcap/Makefile b/tutorials/tcpip/pcap-driver/Makefile similarity index 100% rename from examples/mip-pcap/Makefile rename to tutorials/tcpip/pcap-driver/Makefile diff --git a/examples/mip-pcap/README.md b/tutorials/tcpip/pcap-driver/README.md similarity index 95% rename from examples/mip-pcap/README.md rename to tutorials/tcpip/pcap-driver/README.md index e3c09c6d..51d18308 100644 --- a/examples/mip-pcap/README.md +++ b/tutorials/tcpip/pcap-driver/README.md @@ -41,10 +41,7 @@ $ sudo ifconfig bridge0 addm feth1 We can start an example using the `feth0`: ```sh -$ make -C examples/mip-pcap/ clean all ARGS="-i feth0" -... -2386718 3 mip.c:279:arp_cache_add ARP cache: added 0xc0a80201 @ 36:77:4d:be:e0:80 -2386718 2 mip.c:300:onstatechange READY, IP: 192.168.2.17 +$ make -C tutorials/tcpip/pcap-driver/ clean all ARGS="-i feth0" ``` The diagram of the setup is below: @@ -59,7 +56,7 @@ The diagram of the setup is below: ┌─────────┐ │ └─────────┘ │ └────┬────┘ │ en0 │ │ │ │ └────┬────┘ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ - │ │ │ en1 │ │ en2 │ │ en3 │ │ mip-pcap + │ │ │ en1 │ │ en2 │ │ en3 │ │ pcap-driver │ └────┬────┘ └────┬────┘ └────┬────┘ │ WiFi │ │ │ │ │ └──────┼───────────┼───────────┼──────┘ @@ -97,11 +94,11 @@ This is similar to using the loopback device, Mongoose is only reachable from th - Start your DHCP server at that interface serving that subnet, or otherwise configure Mongoose to use a fixed address within that subnet. - Now start the example opening the other end of the virtual interface: ```sh - $ make -C examples/mip-pcap/ clean all ARGS="-i my0" + $ make -C tutorials/tcpip/pcap-driver/ clean all ARGS="-i my0" ``` - In some systems, you will probably need superuser privileges to open the device: ```sh - $ sudo examples/mip-pcap/example -i my0 + $ sudo tutorials/tcpip/pcap-driver/example -i my0 ``` ``` @@ -112,7 +109,7 @@ This is similar to using the loopback device, Mongoose is only reachable from th └─────────┘ └────┬────┘ │ │ - mip-pcap + pcap-driver ``` As you can't access any other host than your workstation, you need to add any required services (as DNS) there, and configure Mongoose appropriately. This is a foundation, you can expand it by choosing one of the solutions that follow. @@ -144,11 +141,11 @@ We will attach one end of the virtual interface to a bridge, which will also be ``` - Now start the example opening the other end of the virtual interface: ```sh - $ make -C examples/mip-pcap/ clean all ARGS="-i my0" + $ make -C tutorials/tcpip/pcap-driver/ clean all ARGS="-i my0" ``` - In some systems, you will probably need superuser privileges to open the device: ```sh - $ sudo examples/mip-pcap/example -i my0 + $ sudo tutorials/tcpip/pcap-driver/example -i my0 ``` ``` @@ -162,7 +159,7 @@ We will attach one end of the virtual interface to a bridge, which will also be │ └─────────┘ │ └────┬────┘ │ │ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ - │ │ vnet1 │ │ enp9s0 │ │ vnet2 │ │ mip-pcap + │ │ vnet1 │ │ enp9s0 │ │ vnet2 │ │ pcap-driver │ └────┬────┘ └────┬────┘ └────┬────┘ │ │ │ │ │ │ └──────┼───────────┼───────────┼──────┘ @@ -189,11 +186,11 @@ Once you have your virtual interface up and running with an IP address, you can Remember to use the proper network interface name - Now start the example opening the other end of the virtual interface: ```sh - $ make -C examples/mip-pcap/ clean all ARGS="-i my0" + $ make -C tutorials/tcpip/pcap-driver/ clean all ARGS="-i my0" ``` - In some systems, you will probably need superuser privileges to open the device: ```sh - $ sudo examples/mip-pcap/example -i my0 + $ sudo tutorials/tcpip/pcap-driver/example -i my0 ``` ``` @@ -204,7 +201,7 @@ Once you have your virtual interface up and running with an IP address, you can │ └─────────┘ └────┬────┘ ▼ │ Your IP (LAN / Public) │ - ┌─────────┐ mip-pcap + ┌─────────┐ pcap-driver │ enp9s0 │ └────┬────┘ │ @@ -231,7 +228,7 @@ You can also use this setup if your NIC is part of a bridge (for example: you ha │ └─────────┘ └────┬────┘ ┌──────────────────┴──────────────────┐ │ │ │ │ - │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ mip-pcap + │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ pcap-driver │ │ vnet1 │ │ enp9s0 │ │ vnet2 │ │ │ └────┬────┘ └────┬────┘ └────┬────┘ │ │ │ │ │ │ diff --git a/examples/mip-pcap/main.c b/tutorials/tcpip/pcap-driver/main.c similarity index 100% rename from examples/mip-pcap/main.c rename to tutorials/tcpip/pcap-driver/main.c diff --git a/tutorials/tcpip/pcap-driver/mongoose.c b/tutorials/tcpip/pcap-driver/mongoose.c new file mode 120000 index 00000000..5e522bbc --- /dev/null +++ b/tutorials/tcpip/pcap-driver/mongoose.c @@ -0,0 +1 @@ +../../../mongoose.c \ No newline at end of file diff --git a/tutorials/tcpip/pcap-driver/mongoose.h b/tutorials/tcpip/pcap-driver/mongoose.h new file mode 120000 index 00000000..ee4ac823 --- /dev/null +++ b/tutorials/tcpip/pcap-driver/mongoose.h @@ -0,0 +1 @@ +../../../mongoose.h \ No newline at end of file diff --git a/examples/mip-tap/Makefile b/tutorials/tcpip/tap-driver/Makefile similarity index 100% rename from examples/mip-tap/Makefile rename to tutorials/tcpip/tap-driver/Makefile diff --git a/examples/mip-tap/README.md b/tutorials/tcpip/tap-driver/README.md similarity index 95% rename from examples/mip-tap/README.md rename to tutorials/tcpip/tap-driver/README.md index 8992ee0f..2fca5541 100644 --- a/examples/mip-tap/README.md +++ b/tutorials/tcpip/tap-driver/README.md @@ -26,15 +26,15 @@ In this scenario, Mongoose is only reachable from the hosting machine, but you c - Start your DHCP server at that interface serving that subnet, or otherwise configure Mongoose to use a fixed address within that subnet. - Now start the example opening the very same TAP interface: ```sh - $ make -C examples/mip-tap/ clean all + $ make -C tutorials/tcpip/tap-driver/ clean all ``` If you are using a different interface name than `tap0`, add `ARGS="-i ifcname"`, and use the proper interface name ``` [DHCP server for 192.168.0.x] - 192.168.0.1 192.168.0.x + 192.168.0.1 192.168.0.x ┌─────────┐ - │ tap0 ├──────────────────── mip-tap + │ tap0 ├──────────────────── tap-driver └─────────┘ ``` @@ -69,7 +69,7 @@ We will attach one end of the virtual interface to a bridge, which will also be ``` - Now start the example ```sh - $ make -C examples/mip-tap/ clean all + $ make -C tutorials/tcpip/tap-driver/ clean all ``` If you are using a different interface name than `tap0`, add `ARGS="-i ifcname"`, and use the proper interface name - Now if everything is fine, besides the example working, you'll see your interface state is UP: @@ -86,9 +86,9 @@ We will attach one end of the virtual interface to a bridge, which will also be virbr0 │ ┌──────────────────┴──────────────────┐ - │ │ 10.1.0.x + │ │ 10.1.0.x │ ┌────────┐ │ - │ │ tap0 ├─────────────┼─────── mip-tap + │ │ tap0 ├─────────────┼─────── tap-driver │ └────────┘ │ │ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ @@ -119,15 +119,15 @@ Once you have your virtual interface up and running with an IP address, you can Remember to use the proper network interface name - Now start the example ```sh - $ make -C examples/mip-tap/ clean all + $ make -C tutorials/tcpip/tap-driver/ clean all ``` If you are using a different interface name than `tap0`, add `ARGS="-i ifcname"`, and use the proper interface name ``` [DHCP server for 192.168.0.x] - ┌────────────► 192.168.0.1 192.168.0.x + ┌────────────► 192.168.0.1 192.168.0.x │ forwarding ┌─────────┐ - │ masquerading │ tap0 ├──────────────────── mip-tap + │ masquerading │ tap0 ├──────────────────── tap-driver │ └─────────┘ ▼ Your IP (LAN / Public) @@ -154,7 +154,7 @@ You can also use this setup if your NIC is part of a bridge (for example: you ha [DHCP server for 192.168.0.x] 10.1.0.10 ◀──────────────► 192.168.0.1 192.168.0.x virbr0 forwarding ┌─────────┐ - │ masquerading │ tap0 ├──────────────────── mip-tap + │ masquerading │ tap0 ├──────────────────── tap-driver │ └─────────┘ ┌──────────────────┴──────────────────┐ │ │ diff --git a/examples/mip-tap/main.c b/tutorials/tcpip/tap-driver/main.c similarity index 100% rename from examples/mip-tap/main.c rename to tutorials/tcpip/tap-driver/main.c diff --git a/tutorials/tcpip/tap-driver/mongoose.c b/tutorials/tcpip/tap-driver/mongoose.c new file mode 120000 index 00000000..5e522bbc --- /dev/null +++ b/tutorials/tcpip/tap-driver/mongoose.c @@ -0,0 +1 @@ +../../../mongoose.c \ No newline at end of file diff --git a/tutorials/tcpip/tap-driver/mongoose.h b/tutorials/tcpip/tap-driver/mongoose.h new file mode 120000 index 00000000..ee4ac823 --- /dev/null +++ b/tutorials/tcpip/tap-driver/mongoose.h @@ -0,0 +1 @@ +../../../mongoose.h \ No newline at end of file diff --git a/tutorials/tcpip/tap-driver/net.c b/tutorials/tcpip/tap-driver/net.c new file mode 120000 index 00000000..8ef1f70f --- /dev/null +++ b/tutorials/tcpip/tap-driver/net.c @@ -0,0 +1 @@ +../../../examples/device-dashboard/net.c \ No newline at end of file diff --git a/tutorials/tcpip/tap-driver/net.h b/tutorials/tcpip/tap-driver/net.h new file mode 120000 index 00000000..65495135 --- /dev/null +++ b/tutorials/tcpip/tap-driver/net.h @@ -0,0 +1 @@ +../../../examples/device-dashboard/net.h \ No newline at end of file diff --git a/tutorials/tcpip/tap-driver/packed_fs.c b/tutorials/tcpip/tap-driver/packed_fs.c new file mode 120000 index 00000000..0b7f46c6 --- /dev/null +++ b/tutorials/tcpip/tap-driver/packed_fs.c @@ -0,0 +1 @@ +../../../examples/device-dashboard/packed_fs.c \ No newline at end of file diff --git a/tutorials/tcpip_stack/README.md b/tutorials/tcpip_stack/README.md deleted file mode 100644 index bc89c042..00000000 --- a/tutorials/tcpip_stack/README.md +++ /dev/null @@ -1 +0,0 @@ -See detailed tutorials at https://mongoose.ws/documentation/#tcpip-stack \ No newline at end of file