mirror of https://github.com/oxen-io/lokinet
more
parent
8c2bbbb2eb
commit
2687d9aeee
@ -1,4 +1,5 @@
|
||||
[router]
|
||||
threads=1
|
||||
|
||||
[links]
|
||||
lo=ip
|
||||
lo=1090
|
||||
|
@ -0,0 +1,12 @@
|
||||
#ifndef LLARP_PROTO_H
|
||||
#define LLARP_PROTO_H
|
||||
|
||||
#ifndef LLARP_PROTO_VERSION
|
||||
#define LLARP_PROTO_VERSION (0)
|
||||
#endif
|
||||
|
||||
#ifndef LLARP_ETH_PROTO
|
||||
#define LLARP_ETH_PROTO (0xD1CE)
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,19 @@
|
||||
#ifndef LLARP_STRING_H
|
||||
#define LLARP_STRING_H
|
||||
#include <llarp/common.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
size_t INLINE strnlen(const char * str, size_t sz)
|
||||
{
|
||||
size_t slen = 0;
|
||||
while(sz-- && str[slen])
|
||||
slen ++;
|
||||
return slen;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,39 +1,97 @@
|
||||
#include <llarp/iwp.h>
|
||||
#include <cstring>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
namespace iwp
|
||||
{
|
||||
|
||||
struct link_impl
|
||||
{
|
||||
link_impl(llarp_seckey_t k)
|
||||
link_impl(llarp_seckey_t k, llarp_msg_muxer *m) : muxer(m)
|
||||
{
|
||||
memcpy(seckey, k, sizeof(seckey));
|
||||
}
|
||||
|
||||
std::list<llarp_link_ev_listener> link_listeners;
|
||||
|
||||
llarp_seckey_t seckey;
|
||||
|
||||
int configure(const char * ifname, int af, uint16_t port)
|
||||
llarp_msg_muxer * muxer;
|
||||
|
||||
std::string linkname;
|
||||
|
||||
bool configure(const char * ifname, int af, uint16_t port)
|
||||
{
|
||||
// todo: implement
|
||||
return -1;
|
||||
linkname = std::string(ifname) + std::string("+") + std::to_string(port);
|
||||
return false;
|
||||
}
|
||||
|
||||
const char * name()
|
||||
{
|
||||
return linkname.c_str();
|
||||
}
|
||||
|
||||
bool start(llarp_ev_loop * loop)
|
||||
{
|
||||
// todo: implement
|
||||
return false;
|
||||
}
|
||||
|
||||
bool stop()
|
||||
{
|
||||
// todo: implement
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
static int configure_addr(struct llarp_link * l, const char * ifname, int af, uint16_t port)
|
||||
static bool configure(struct llarp_link * l, const char * ifname, int af, uint16_t port)
|
||||
{
|
||||
link_impl * link = static_cast<link_impl *>(l->impl);
|
||||
return link->configure(ifname, af, port);
|
||||
}
|
||||
|
||||
static bool start_link(struct llarp_link * l, struct llarp_ev_loop * loop)
|
||||
{
|
||||
link_impl * link = static_cast<link_impl *>(l->impl);
|
||||
return link->start(loop);
|
||||
}
|
||||
|
||||
static bool stop_link(struct llarp_link * l)
|
||||
{
|
||||
link_impl * link = static_cast<link_impl *>(l->impl);
|
||||
return link->stop();
|
||||
}
|
||||
|
||||
static void free_link(struct llarp_link * l)
|
||||
{
|
||||
link_impl * link = static_cast<link_impl *>(l->impl);
|
||||
delete link;
|
||||
}
|
||||
|
||||
static const char * link_name(struct llarp_link * l)
|
||||
{
|
||||
link_impl * link = static_cast<link_impl *>(l->impl);
|
||||
return link->name();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
void iwp_link_init(struct llarp_link * link, struct iwp_configure_args args, struct llarp_msg_muxer * muxer)
|
||||
bool iwp_link_init(struct llarp_link * link, struct iwp_configure_args args, struct llarp_msg_muxer * muxer)
|
||||
{
|
||||
link->impl = new iwp::link_impl(args.seckey);
|
||||
link->configure_addr = &iwp::configure_addr;
|
||||
llarp_seckey_t seckey;
|
||||
args.crypto->keygen(&seckey);
|
||||
link->impl = new iwp::link_impl(seckey, muxer);
|
||||
|
||||
link->name = &iwp::link_name;
|
||||
link->configure = &iwp::configure;
|
||||
link->start_link = &iwp::start_link;
|
||||
link->stop_link = &iwp::stop_link;
|
||||
link->free = &iwp::free_link;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue