Giter Site home page Giter Site logo

Comments (6)

fspiot avatar fspiot commented on July 21, 2024

Hello! Do you use FreeRTOS+LWIP to implement Wireguard on STM32F407? Can you share your project?

from wireguard-lwip.

AndyW999 avatar AndyW999 commented on July 21, 2024

Sorry I do not use an RTOS, I prefer being in control of my code ;)

from wireguard-lwip.

fspiot avatar fspiot commented on July 21, 2024

Sorry I do not use an RTOS, I prefer being in control of my code ;)

thanks!
Can you really realize it using STM32F407?
I compiled it according to the demo provided by the author. But
wg_netif = netif_add(&wg_netif_struct, &ipaddr, &netmask, &gateway, &wg, &wireguardif_init, &ip_input);
There seems to be a problem with this function. Do you know what's going on here?

from wireguard-lwip.

AndyW999 avatar AndyW999 commented on July 21, 2024

Set it up and my WG implementation is in the attached ZIP file, hope it is of some use!

I also got it working with ESP32

static void wireguard_setup()
{
struct wireguardif_init_data wg;
struct wireguardif_peer peer;
ip_addr_t ipaddr = IPADDR4_INIT_BYTES(WIREGUARD_IPADDRESS[0], WIREGUARD_IPADDRESS[1], WIREGUARD_IPADDRESS[2], WIREGUARD_IPADDRESS[3]);
ip_addr_t netmask = IPADDR4_INIT_BYTES(WIREGUARD_SUBNET[0], WIREGUARD_SUBNET[1], WIREGUARD_SUBNET[2], WIREGUARD_SUBNET[3]);
ip_addr_t gateway = IPADDR4_INIT_BYTES(WIREGUARD_GW[0], WIREGUARD_GW[1], WIREGUARD_GW[2], WIREGUARD_GW[3]);

// Setup the WireGuard device structure
wg.private_key = &WIREGUARD_MY_PRIV;
wg.listen_port = WIREGUARD_LISTENPORT;
wg.bind_netif = NULL;

// Register the new WireGuard network interface with lwIP
wg_netif = netif_add(&wg_netif_struct, &ipaddr, &netmask, &gateway, &wg, &wireguardif_init, &ip_input);

// Mark the interface as administratively up, link up flag is set automatically when peer connects
netif_set_up(wg_netif);

// Initialise the first WireGuard peer structure
wireguardif_peer_init(&peer);
peer.public_key = &WIREGUARD_THEIR_PUB;
peer.preshared_key = NULL;
// Allow all IPs through tunnel
IP4_ADDR(&peer.allowed_ip, 0, 0, 0, 0);

// peer.allowed_ip = IPADDR4_INIT_BYTES(0, 0, 0, 0);
IP4_ADDR(&peer.allowed_mask, 0, 0, 0, 0);
// peer.allowed_mask = IPADDR4_INIT_BYTES(0, 0, 0, 0);

// If we know the endpoint's address can add here
IP4_ADDR(&peer.endpoint_ip, WIREGUARD_ENDPOINTIP[0], WIREGUARD_ENDPOINTIP[1], WIREGUARD_ENDPOINTIP[2], WIREGUARD_ENDPOINTIP[3]);

// peer.endpoint_ip = IPADDR4_INIT_BYTES(10, 0, 0, 12);
peer.endport_port = WIREGUARD_LISTENPORT;//51820;

// Register the new WireGuard peer with the netwok interface
wireguardif_add_peer(wg_netif, &peer, &wireguard_peer_index);

if ((wireguard_peer_index != WIREGUARDIF_INVALID_INDEX) && !ip_addr_isany(&peer.endpoint_ip)) {
	// Start outbound connection to peer
	wireguardif_connect(wg_netif, wireguard_peer_index);
}

}
Wireguard.zip

from wireguard-lwip.

AndyW999 avatar AndyW999 commented on July 21, 2024

Looks like the paste got a bit screwed!

WGSetup.txt

from wireguard-lwip.

fspiot avatar fspiot commented on July 21, 2024

Looks like the paste got a bit screwed!

WGSetup.txt
Thank you very much

from wireguard-lwip.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.