Skip to content

Commit 42833ae

Browse files
committed
Rename API
1 parent c6a09c9 commit 42833ae

File tree

21 files changed

+554
-554
lines changed

21 files changed

+554
-554
lines changed

Makefile

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

6-
OBJ=build/wolftcp.o \
6+
OBJ=build/wolfip.o \
77
build/port/posix/linux_tap.o
88

99
EXE=build/tcpecho build/tcp_netcat_poll build/tcp_netcat_select \
1010
build/test-evloop build/test-dns
11-
LIB=libwolftcp.so
11+
LIB=libwolfip.so
1212

1313
PREFIX=/usr/local
1414

@@ -24,8 +24,8 @@ static: libtcpip.a
2424
libtcpip.a: $(OBJ)
2525
@ar rcs $@ $^
2626

27-
libwolftcp.so:CFLAGS+=-fPIC
28-
libwolftcp.so: build/pie/port/posix/bsd_socket.o build/pie/wolftcp.o \
27+
libwolfip.so:CFLAGS+=-fPIC
28+
libwolfip.so: build/pie/port/posix/bsd_socket.o build/pie/wolfip.o \
2929
build/pie/port/posix/linux_tap.o
3030
@mkdir -p `dirname $@` || true
3131
@echo "[LD] $@"
@@ -65,8 +65,8 @@ build/tcp_netcat_select: $(OBJ) build/port/posix/bsd_socket.o build/test/tcp_net
6565
@$(CC) $(CFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $(^) -Wl,--end-group
6666

6767

68-
build/test-wolfssl:CFLAGS+=-Wno-cpp -DWOLFSSL_DEBUG -DWOLFSSL_WOLFTCP
69-
build/test-httpd:CFLAGS+=-Wno-cpp -DWOLFSSL_DEBUG -DWOLFSSL_WOLFTCP -Isrc/http
68+
build/test-wolfssl:CFLAGS+=-Wno-cpp -DWOLFSSL_DEBUG -DWOLFSSL_WOLFIP
69+
build/test-httpd:CFLAGS+=-Wno-cpp -DWOLFSSL_DEBUG -DWOLFSSL_WOLFIP -Isrc/http
7070

7171

7272
build/test-wolfssl: $(OBJ) build/test/test_native_wolfssl.o build/port/wolfssl_io.o build/certs/server_key.o build/certs/ca_cert.o build/certs/server_cert.o
@@ -126,7 +126,7 @@ build/test/unit:
126126
# Install dynamic library to re-link linux applications
127127
#
128128
install:
129-
install libwolftcp.so $(PREFIX)/lib
129+
install libwolfip.so $(PREFIX)/lib
130130
ldconfig
131131

132132
.PHONY: clean all static

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# wolfTCP
1+
# wolfIP
22

33
The smallest TCP/IP stack on the planet
44

55
## Description and project goals
66

7-
wolfTCP is a TCP/IP stack with no dynamic memory allocations, designed to be
7+
wolfIP is a TCP/IP stack with no dynamic memory allocations, designed to be
88
used in resource-constrained embedded systems.
99

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

@@ -31,6 +31,6 @@ A single network interface can be associated with the device.
3131

3232
## Copyright and License
3333

34-
wolfTCP is licensed under the GPLv3 license. See the LICENSE file for details.
34+
wolfIP is licensed under the GPLv3 license. See the LICENSE file for details.
3535
Copyright (c) 2025 wolfSSL Inc.
3636

config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
#define ETHERNET
55
#define LINK_MTU 1536
66

7-
#define MAX_TCPSOCKETS 20
7+
#define MAX_TCPSOCKETS 4
88
#define MAX_UDPSOCKETS 2
99
#define RXBUF_SIZE LINK_MTU * 4
10-
#define TXBUF_SIZE LINK_MTU * 16
10+
#define TXBUF_SIZE LINK_MTU * 4
1111

1212
#define MAX_NEIGHBORS 16
1313

1414
/* Linux test configuration */
15-
#define WOLFTCP_IP "10.10.10.2"
15+
#define WOLFIP_IP "10.10.10.2"
1616
#define LINUX_IP "10.10.10.1"
1717

1818
#endif

core.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# wolfTCP
1+
# wolfIP
22

33
## Stack architecture
44

@@ -20,7 +20,7 @@
2020

2121

2222

23-
### wolfTCP fifo
23+
### wolfIP fifo
2424

2525
```
2626
+---------------------------------------------------------------------------------------------------------------------------+
@@ -42,7 +42,7 @@
4242

4343

4444

45-
### wolfTCP queue
45+
### wolfIP queue
4646

4747
```
4848
+--------------+--------------------------------------------+---------------------------------------------------------------+

src/http/httpd.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* (c) Danielinux 2024 <root@danielinux.net>
33
* This code is licensed under the GPLv3 license.
44
*/
5-
#include "wolftcp.h"
5+
#include "wolfip.h"
66
#include "httpd.h"
77

88
static const char *http_status_text(int status_code) {
@@ -90,7 +90,7 @@ void http_send_response_headers(struct http_client *hc, int status_code, const c
9090
if (hc->ssl) {
9191
wolfSSL_write(hc->ssl, txt_response, strlen(txt_response));
9292
} else {
93-
ft_send(hc->httpd->ipstack, hc->client_sd, txt_response, strlen(txt_response), 0);
93+
wolfIP_sock_send(hc->httpd->ipstack, hc->client_sd, txt_response, strlen(txt_response), 0);
9494
}
9595
}
9696

@@ -99,7 +99,7 @@ void http_send_response_body(struct http_client *hc, const void *body, size_t le
9999
if (hc->ssl) {
100100
wolfSSL_write(hc->ssl, body, len);
101101
} else {
102-
ft_send(hc->httpd->ipstack, hc->client_sd, body, len, 0);
102+
wolfIP_sock_send(hc->httpd->ipstack, hc->client_sd, body, len, 0);
103103
}
104104
}
105105

@@ -113,10 +113,10 @@ void http_send_response_chunk(struct http_client *hc, const void *chunk, size_t
113113
wolfSSL_write(hc->ssl, chunk, len);
114114
wolfSSL_write(hc->ssl, "\r\n", 2);
115115
} else {
116-
struct ipstack *s = hc->httpd->ipstack;
117-
ft_send(s, hc->client_sd, txt_chunk, strlen(txt_chunk), 0);
118-
ft_send(s, hc->client_sd, chunk, len, 0);
119-
ft_send(s, hc->client_sd, "\r\n", 2, 0);
116+
struct wolfIP *s = hc->httpd->ipstack;
117+
wolfIP_sock_send(s, hc->client_sd, txt_chunk, strlen(txt_chunk), 0);
118+
wolfIP_sock_send(s, hc->client_sd, chunk, len, 0);
119+
wolfIP_sock_send(s, hc->client_sd, "\r\n", 2, 0);
120120
}
121121
}
122122

@@ -125,7 +125,7 @@ void http_send_response_chunk_end(struct http_client *hc) {
125125
if (hc->ssl) {
126126
wolfSSL_write(hc->ssl, "0\r\n\r\n", 5);
127127
} else {
128-
ft_send(hc->httpd->ipstack, hc->client_sd, "0\r\n\r\n", 5, 0);
128+
wolfIP_sock_send(hc->httpd->ipstack, hc->client_sd, "0\r\n\r\n", 5, 0);
129129
}
130130
}
131131

@@ -289,7 +289,7 @@ static void http_recv_cb(int sd, uint16_t event, void *arg) {
289289
}
290290
}
291291
} else {
292-
ret = ft_recv(hc->httpd->ipstack, sd, buf, sizeof(buf), 0);
292+
ret = wolfIP_sock_recv(hc->httpd->ipstack, sd, buf, sizeof(buf), 0);
293293
if (ret == -11)
294294
return;
295295
}
@@ -306,15 +306,15 @@ static void http_recv_cb(int sd, uint16_t event, void *arg) {
306306
wolfSSL_free(hc->ssl);
307307
hc->ssl = NULL;
308308
}
309-
ft_close(hc->httpd->ipstack, sd);
309+
wolfIP_sock_close(hc->httpd->ipstack, sd);
310310
hc->client_sd = 0;
311311
}
312312

313313
static void http_accept_cb(int sd, uint16_t event, void *arg) {
314314
struct httpd *httpd = (struct httpd *) arg;
315-
struct ipstack_sockaddr_in addr;
316-
socklen_t addr_len = sizeof(struct ipstack_sockaddr_in);
317-
int client_sd = ft_accept(httpd->ipstack, sd, (struct ipstack_sockaddr *) &addr, &addr_len);
315+
struct wolfIP_sockaddr_in addr;
316+
socklen_t addr_len = sizeof(struct wolfIP_sockaddr_in);
317+
int client_sd = wolfIP_sock_accept(httpd->ipstack, sd, (struct wolfIP_sockaddr *) &addr, &addr_len);
318318
if (client_sd < 0) {
319319
return;
320320
}
@@ -330,12 +330,12 @@ static void http_accept_cb(int sd, uint16_t event, void *arg) {
330330
wolfSSL_SetIO_FT(httpd->clients[i].ssl, client_sd);
331331
} else {
332332
/* Failed to create SSL object */
333-
ft_close(httpd->ipstack, client_sd);
333+
wolfIP_sock_close(httpd->ipstack, client_sd);
334334
httpd->clients[i].client_sd = 0;
335335
return;
336336
}
337337
}
338-
ipstack_register_callback(httpd->ipstack, client_sd, http_recv_cb, &httpd->clients[i]);
338+
wolfIP_register_callback(httpd->ipstack, client_sd, http_recv_cb, &httpd->clients[i]);
339339
break;
340340
}
341341
}
@@ -377,8 +377,8 @@ int httpd_get_request_arg(struct http_request *req, const char *name, char *valu
377377
return -1; // Key not found
378378
}
379379

380-
int httpd_init(struct httpd *httpd, struct ipstack *s, uint16_t port, void *ssl_ctx) {
381-
struct ipstack_sockaddr_in addr;
380+
int httpd_init(struct httpd *httpd, struct wolfIP *s, uint16_t port, void *ssl_ctx) {
381+
struct wolfIP_sockaddr_in addr;
382382
memset(&addr, 0, sizeof(addr));
383383
addr.sin_family = AF_INET;
384384
addr.sin_port = htons(port);
@@ -388,21 +388,21 @@ int httpd_init(struct httpd *httpd, struct ipstack *s, uint16_t port, void *ssl_
388388
memset(httpd, 0, sizeof(struct httpd));
389389
httpd->ipstack = s;
390390
httpd->port = port;
391-
httpd->listen_sd = ft_socket(s, AF_INET, SOCK_STREAM, 0);
391+
httpd->listen_sd = wolfIP_sock_socket(s, AF_INET, SOCK_STREAM, 0);
392392
if (httpd->listen_sd < 0) {
393393
return -1;
394394
}
395-
if (ft_bind(s, httpd->listen_sd, (struct ipstack_sockaddr *) &addr, sizeof(addr)) < 0) {
395+
if (wolfIP_sock_bind(s, httpd->listen_sd, (struct wolfIP_sockaddr *) &addr, sizeof(addr)) < 0) {
396396
return -1;
397397
}
398-
if (ft_listen(s, httpd->listen_sd, 5) < 0) {
398+
if (wolfIP_sock_listen(s, httpd->listen_sd, 5) < 0) {
399399
return -1;
400400
}
401401
if (ssl_ctx) {
402402
httpd->ssl_ctx = (WOLFSSL_CTX *) ssl_ctx;
403403
wolfSSL_SetIO_FT_CTX(httpd->ssl_ctx, httpd->ipstack);
404404
}
405-
ipstack_register_callback(s, httpd->listen_sd, http_accept_cb, httpd);
405+
wolfIP_register_callback(s, httpd->listen_sd, http_accept_cb, httpd);
406406
return 0;
407407
}
408408

src/http/httpd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct http_request {
4646
struct http_client {
4747
struct httpd *httpd;
4848
int client_sd;
49-
struct ipstack_sockaddr_in addr;
49+
struct wolfIP_sockaddr_in addr;
5050
WOLFSSL *ssl; /* NULL if not using SSL */
5151
};
5252

@@ -59,13 +59,13 @@ struct http_url {
5959
struct httpd {
6060
struct http_url urls[HTTPD_MAX_URLS];
6161
struct http_client clients[HTTPD_MAX_CLIENTS];
62-
struct ipstack *ipstack;
62+
struct wolfIP *ipstack;
6363
int listen_sd;
6464
uint16_t port;
6565
WOLFSSL_CTX *ssl_ctx;
6666
};
6767

68-
int httpd_init(struct httpd *httpd, struct ipstack *s, uint16_t port, void *ssl_ctx);
68+
int httpd_init(struct httpd *httpd, struct wolfIP *s, uint16_t port, void *ssl_ctx);
6969
int httpd_register_handler(struct httpd *httpd, const char *path, int (*handler)(struct httpd *httpd, struct http_client *hc, struct http_request *req));
7070
int httpd_register_static_page(struct httpd *httpd, const char *path, const char *content);
7171
int httpd_get_request_arg(struct http_request *req, const char *name, char *value, size_t value_len);

0 commit comments

Comments
 (0)