Comments (2)
The Wireguard LwIP code simply adds a new “netif” network interface to the LwIP stack. Once set up you use it exactly the same was as you would any other network interface.
e.g. if using the LwIP “raw” APIs (https://www.nongnu.org/lwip/2_1_x/group__callbackstyle__api.html) you would send a UDP packet using the udp_sendto() function (which would follow the normal LwIP interface selection algorithm), or to force traffic out a specific interface (e.g. the wg_netif one) you would use udp_sendto_if(…, …, wg_netif)
Your WireGuard server will decrypt the packet and then it is up to that server how it handles it - e.g. does it route it to your client directly? perform some form of NAT, etc
// Create a new UDP connection handle
struct udp_pcb *udp = udp_new();
if (!udp) {
return ERR_MEM;
}
// Allocate a packet buffer to hold packet data - e.g. 5 bytes of data for text
struct pbuf *udp_data = pbuf_alloc(PBUF_TRANSPORT, 5, PBUF_RAM);
if (!udp_data) {
return ERR_MEM;
}
// Populate the packet buffer with sample data
pbuf_take(udp_data, "Hello", 5);
// Choose where to send the UDP packet to
ip_addr_t dst_ip = IPADDR4_INIT_BYTES(192, 168, 1, 100);
u16_t dst_port = 1234;
// Send the packet out - specifically choose to send over the WireGuard interface for this example
err_t err = udp_sendto_if(udp, udp_data, &dst_ip, dst_port, wg_netif);
pbuf_free(udp_data);
return err;
from wireguard-lwip.
Thank you very much, your answer helped me to solve my problem :)
from wireguard-lwip.
Related Issues (12)
- Implementation on ESP8266 HOT 3
- Show when link has dropped? HOT 6
- handshake_destroy
- Chacha20poly1305 enc/dec function not symmetrical
- wireguardif_init crashes the program?
- Crash on esp8266 arduino ide HOT 6
- Replay window is only 4 packets wide, instead of 32 HOT 1
- wireguard_check_replay() always rejects first data packet of session HOT 1
- about keypair_update HOT 1
- esp32 device as the vpn server HOT 8
- Problem with wireguard-lwip on esp32C3 using esp-if latest version (5.0), is it possible to work on this version ? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wireguard-lwip.