Skip to content

Commit 7832450

Browse files
committed
print header debug functions, cleanup, and beginning of esp unwrap.
1 parent f5dd378 commit 7832450

File tree

22 files changed

+373
-124
lines changed

22 files changed

+373
-124
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*.dis
66
*.uf2
77
*.bin
8+
*.swp
89
CMakeCache.txt
910
CMakeFiles
1011
CMakeScripts

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ CFLAGS:=-Wall -Werror -Wextra -I. -D_GNU_SOURCE
33
CFLAGS+=-g -ggdb
44
LDFLAGS+=-pthread
55

6+
# Debug flags:
7+
# CFLAGS+=-DDEBUG_TAP
8+
# print ethernet headers
9+
# CFLAGS+=-DDEBUG_ETH
10+
# print ip headers
11+
CFLAGS+=-DDEBUG_IP
12+
# print tcp headers
13+
# CFLAGS+=-DDEBUG_TCP
14+
# print esp headers
15+
CFLAGS+=-DWOLFIP_DEBUG_ESP
16+
17+
# ESP support
18+
CFLAGS+=-DWOLFIP_ESP
19+
620
CPPCHECK=cppcheck
721
CPPCHECK_FLAGS=--enable=all --suppress=missingIncludeSystem \
822
--suppress=unusedFunction --suppress=unusedVariable \

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
## Description and project goals
44

5-
wolfIP is a TCP/IP stack with no dynamic memory allocations, designed to be
5+
wolfIP is a TCP/IP stack with no dynamic memory allocations, designed to be
66
used in resource-constrained embedded systems.
77

8-
Endpoint only mode is supported, which means that wolfip can be used to
8+
Endpoint only mode is supported, which means that wolfip can be used to
99
establish network connections but it does not route traffic between different
1010
network interfaces.
1111

@@ -19,7 +19,7 @@ A single network interface can be associated with the device.
1919
- DHCP (RFC 2131): client only
2020
- DNS (RFC 1035): client only
2121
- UDP (RFC 768): unicast only
22-
- TCP (RFC 793)
22+
- TCP (RFC 793)
2323
- TCP options supported: Timestamps, Maximum Segment Size
2424
- BSD-like, non blocking socket API, with custom callbacks
2525
- No dynamic memory allocation

core.md

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@
2424

2525
```
2626
+---------------------------------------------------------------------------------------------------------------------------+
27-
| +-----+---+----+-----+------------------+-----+---+----+-----+------------------+ |
27+
| +-----+---+----+-----+------------------+-----+---+----+-----+------------------+ |
2828
| | De | E | IP | TCP | Payload | De | E | IP | TCP | Payload | |
2929
| | sc | T | | | | sc | T | | | | |
3030
|* FREE SPACE * | ri | H | | | | ri | H | | | | * FREE SPACE* |
3131
| | pt | | | | | pt | | | | | |
3232
| | or | | | | | or | | | | | |
3333
| +-----+---+----+-----+------------------+-----+---+----+-----+------------------+ |
3434
+---------------------------------------------------------------------------------------------------------------------------+
35-
^ ^
36-
| |
37-
| |
38-
| |
39-
|Tail Head|
35+
^ ^
36+
| |
37+
| |
38+
| |
39+
|Tail Head|
4040
4141
```
4242

@@ -54,11 +54,11 @@
5454
| || || |
5555
| |*------------------------------------------*| |
5656
+--------------+--------------------------------------------+---------------------------------------------------------------+
57-
^ ^
58-
| |
59-
| |
60-
| |
61-
|Tail Head|
57+
^ ^
58+
| |
59+
| |
60+
| |
61+
|Tail Head|
6262
```
6363

6464

@@ -71,37 +71,32 @@
7171
+-------------+
7272
|Main loop TX |
7373
+-------------+
74-
^
75-
+----------------------------------+ |
76-
| | +------+
77-
| TCP Socket | |
78-
| | |
79-
| | |
80-
| | |
81-
| +-----------------------+
82-
| +---------------+ | |
83-
>DATA OUT==>>|socket send() |-->| TX buffer (fifo) |
84-
| +---------------+ | |
85-
| +-----------------------+
86-
| |
87-
| |
88-
| |
89-
| +-----------------------+
90-
| +-------------+ | |
91-
<DATA IN<<====|socket recv()|<---| RX buffer (queue) |
92-
| +-------------+ | |
93-
| +-----------------------+
94-
+----------------------------------+ ^
95-
|
96-
|
97-
|
98-
+--------------+
99-
| tcp_recv() |
74+
^
75+
+----------------------------------+ |
76+
| | +------+
77+
| TCP Socket | |
78+
| | |
79+
| | |
80+
| | |
81+
| +-----------------------+
82+
| +---------------+ | |
83+
>DATA OUT==>>|socket send() |-->| TX buffer (fifo) |
84+
| +---------------+ | |
85+
| +-----------------------+
86+
| |
87+
| |
88+
| |
89+
| +-----------------------+
90+
| +-------------+ | |
91+
<DATA IN<<====|socket recv()|<---| RX buffer (queue) |
92+
| +-------------+ | |
93+
| +-----------------------+
94+
+----------------------------------+ ^
95+
|
96+
|
97+
|
98+
+--------------+
99+
| tcp_recv() |
100100
+--------------+
101101
```
102102

103-
104-
105-
106-
107-

scripts/ip-xfrm/delete_all

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
sudo ip xfrm policy deleteall
3+
sudo ip xfrm state deleteall

scripts/ip-xfrm/hmac_auth

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
#
3+
# hmac-[md5,sha1]-96 example.
4+
#
5+
6+
alg=sha1
7+
ip_proto=tcp
8+
9+
if [ $# -eq 1 ]; then
10+
alg=$1
11+
fi
12+
13+
if [ $# -eq 2 ]; then
14+
alg=$1
15+
ip_proto=$2
16+
fi
17+
18+
# State
19+
# ipv4
20+
sudo ip xfrm state add \
21+
src 10.10.10.1 dst 10.10.10.2 \
22+
proto esp \
23+
spi 0x2fa9d8c8 \
24+
mode transport auth $alg 0x01010101010101010101010101010101 \
25+
enc cipher_null "" \
26+
sel src 10.10.10.1 dst 10.10.10.2
27+
28+
sudo ip xfrm state add \
29+
src 10.10.10.2 dst 10.10.10.1 \
30+
proto esp \
31+
spi 0xf6e9b80d \
32+
mode transport auth $alg 0x02020202020202020202020202020202 \
33+
enc cipher_null "" \
34+
sel src 10.10.10.2 dst 10.10.10.1
35+
36+
# Policies
37+
# ipv4
38+
sudo ip xfrm policy add \
39+
dst 10.10.10.2 proto $ip_proto dir out tmpl proto esp spi 0x2fa9d8c8 mode transport
40+
41+
#sudo ip xfrm policy add \
42+
# dst 10.10.10.1 proto $ip_proto dir out tmpl proto esp spi 0xf6e9b80d mode transport
43+

scripts/ip-xfrm/monitor

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
sudo ip xfrm monitor

scripts/ip-xfrm/show

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
echo "ip xfrm policy show"
3+
sudo ip xfrm policy show
4+
5+
echo ""
6+
echo "ip xfrm state show"
7+
sudo ip xfrm state show

scripts/ip-xfrm/watch_stat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
watch cat /proc/net/xfrm_stat

src/http/httpd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static int parse_http_request(struct http_client *hc, uint8_t *buf, size_t len)
214214
struct http_request req;
215215
struct http_url *url = NULL;
216216
memset(&req, 0, sizeof(struct http_request));
217-
http_url_decode(p, len); /* Decode can be done in place */
217+
http_url_decode(p, len); /* Decode can be done in place */
218218
if (len < 4) goto bad_request;
219219
/* Parse the request line */
220220
q = strchr(p, ' ');
@@ -267,7 +267,7 @@ static int parse_http_request(struct http_client *hc, uint8_t *buf, size_t len)
267267
goto bad_request;
268268
url = http_find_url(hc->httpd, req.path);
269269
if (!url) goto not_found;
270-
270+
271271
if ((url->handler == NULL) && (url->static_content == NULL))
272272
goto service_unavailable;
273273
if (url->handler == NULL) {

0 commit comments

Comments
 (0)