mirror of https://github.com/oxen-io/lokinet
Move net components into a distinct folder
parent
317e29b777
commit
a3463120cc
@ -1,58 +0,0 @@
|
||||
#ifndef _WIN32
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#include <exit_route.h>
|
||||
#include <util/bencode.h>
|
||||
|
||||
#include <llarp/string.h>
|
||||
|
||||
bool
|
||||
llarp_xr_bencode(struct llarp_xr* xr, llarp_buffer_t* buff)
|
||||
{
|
||||
char addr_buff[128] = {0};
|
||||
const char* addr;
|
||||
|
||||
if(!bencode_start_dict(buff))
|
||||
return false;
|
||||
|
||||
/** gateway */
|
||||
addr = inet_ntop(AF_INET6, &xr->gateway, addr_buff, sizeof(addr_buff));
|
||||
if(!addr)
|
||||
return false;
|
||||
if(!bencode_write_bytestring(buff, "a", 1))
|
||||
return false;
|
||||
if(!bencode_write_bytestring(buff, addr, strnlen(addr, sizeof(addr_buff))))
|
||||
return false;
|
||||
|
||||
/** netmask */
|
||||
addr = inet_ntop(AF_INET6, &xr->netmask, addr_buff, sizeof(addr_buff));
|
||||
if(!addr)
|
||||
return false;
|
||||
if(!bencode_write_bytestring(buff, "b", 1))
|
||||
return false;
|
||||
if(!bencode_write_bytestring(buff, addr, strnlen(addr, sizeof(addr_buff))))
|
||||
return false;
|
||||
|
||||
/** source */
|
||||
addr = inet_ntop(AF_INET6, &xr->source, addr_buff, sizeof(addr_buff));
|
||||
if(!addr)
|
||||
return false;
|
||||
if(!bencode_write_bytestring(buff, "c", 1))
|
||||
return false;
|
||||
if(!bencode_write_bytestring(buff, addr, strnlen(addr, sizeof(addr_buff))))
|
||||
return false;
|
||||
|
||||
/** lifetime */
|
||||
if(!bencode_write_bytestring(buff, "l", 1))
|
||||
return false;
|
||||
if(!bencode_write_uint64(buff, xr->lifetime))
|
||||
return false;
|
||||
|
||||
/** version */
|
||||
if(!bencode_write_version_entry(buff))
|
||||
return false;
|
||||
|
||||
/* end */
|
||||
return bencode_end(buff);
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
#ifndef LLARP_XR_H
|
||||
#define LLARP_XR_H
|
||||
|
||||
#include <net.h>
|
||||
#include <util/buffer.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct llarp_xr
|
||||
{
|
||||
struct in6_addr gateway;
|
||||
struct in6_addr netmask;
|
||||
struct in6_addr source;
|
||||
uint64_t lifetime;
|
||||
};
|
||||
|
||||
bool
|
||||
llarp_xr_bencode(struct llarp_xr* xr, llarp_buffer_t* buff);
|
||||
bool
|
||||
llarp_xr_bdecode(struct llarp_xr* xr, llarp_buffer_t* buff);
|
||||
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
#include <net.hpp>
|
||||
#include <net_addr.hpp>
|
||||
#include <net/net.hpp>
|
||||
#include <net/net_addr.hpp>
|
||||
#include <util/string_view.hpp>
|
||||
|
||||
// for addrinfo
|
@ -1,4 +1,4 @@
|
||||
#include <net_inaddr.hpp>
|
||||
#include <net/net_inaddr.hpp>
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& out, const llarp::inAddr& a)
|
@ -1,7 +1,7 @@
|
||||
#ifndef LLARP_NET_INADDR_HPP
|
||||
#define LLARP_NET_INADDR_HPP
|
||||
|
||||
#include <net.hpp>
|
||||
#include <net/net.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
@ -0,0 +1 @@
|
||||
#include <net/net_int.hpp>
|
@ -1 +0,0 @@
|
||||
#include <net_int.hpp>
|
@ -1,7 +1,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <net.hpp>
|
||||
#include <net_inaddr.hpp>
|
||||
#include <net/net.hpp>
|
||||
#include <net/net_inaddr.hpp>
|
||||
|
||||
struct TestNet : public ::testing::Test
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <net_inaddr.hpp>
|
||||
#include <net/net_inaddr.hpp>
|
||||
|
||||
struct TestNetInAddr : public ::testing::Test
|
||||
{
|
Loading…
Reference in New Issue