mirror of https://github.com/oxen-io/lokinet
sarp -> llarp
parent
045a692522
commit
485e780552
@ -0,0 +1,7 @@
|
||||
#ifndef LLARP_H_
|
||||
#define LLARP_H_
|
||||
#include <llarp/router.h>
|
||||
#include <llarp/version.h>
|
||||
#include <llarp/mem.h>
|
||||
#include <llarp/ev.h>
|
||||
#endif
|
@ -0,0 +1,29 @@
|
||||
#ifndef LLARP_AI_H
|
||||
#define LLARP_AI_H
|
||||
#include <llarp/crypto.h>
|
||||
#include <llarp/net.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct llarp_address_info
|
||||
{
|
||||
uint16_t rank;
|
||||
llarp_pubkey_t enc_key;
|
||||
char * dialect;
|
||||
struct in6_addr ip;
|
||||
uint16_t port;
|
||||
};
|
||||
|
||||
bool llarp_address_info_bencode(struct llarp_address_info * ai, llarp_buffer_t * buff);
|
||||
bool llarp_address_info_bdecode(struct llarp_address_info * ai, llarp_buffer_t buff);
|
||||
|
||||
struct llarp_address_info_list;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,20 @@
|
||||
#ifndef LLARP_BUFFER_H_
|
||||
#define LLARP_BUFFER_H_
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct llarp_buffer_t {
|
||||
char * base;
|
||||
size_t sz;
|
||||
char * cur;
|
||||
} llarp_buffer_t;
|
||||
|
||||
size_t llarp_buffer_size_left(llarp_buffer_t * buff);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,30 @@
|
||||
#ifndef LLARP_CONFIG_H_
|
||||
#define LLARP_CONFIG_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct llarp_config;
|
||||
|
||||
void llarp_new_config(struct llarp_config ** conf);
|
||||
void llarp_free_config(struct llarp_config ** conf);
|
||||
|
||||
/** @brief return -1 on fail otherwiwse 0 */
|
||||
int llarp_load_config(struct llarp_config * conf, const char * fname);
|
||||
|
||||
struct llarp_config_iterator
|
||||
{
|
||||
void * user;
|
||||
/** set by sarp_config_iter */
|
||||
struct llarp_config * conf;
|
||||
/** visit (self, section, key, value) */
|
||||
void (*visit)(struct llarp_config_iterator *, const char *, const char *, const char *);
|
||||
};
|
||||
|
||||
void llarp_config_iter(struct llarp_config * conf, struct llarp_config_iterator * iter);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,45 @@
|
||||
#ifndef LLARP_CRYPTO_H_
|
||||
#define LLARP_CRYPTO_H_
|
||||
#include <llarp/buffer.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PUBKEYSIZE 32
|
||||
#define SECKEYSIZE 32
|
||||
#define NOUNCESIZE 24
|
||||
#define SHAREDKEYSIZE 32
|
||||
#define HASHSIZE 64
|
||||
#define HMACSECSIZE 32
|
||||
#define SIGSIZE 64
|
||||
#define TUNNOUNCESIZE 32
|
||||
|
||||
typedef uint8_t llarp_pubkey_t[PUBKEYSIZE];
|
||||
typedef uint8_t llarp_seckey_t[SECKEYSIZE];
|
||||
typedef uint8_t llarp_nounce_t[NOUNCESIZE];
|
||||
typedef uint8_t llarp_sharedkey_t[SHAREDKEYSIZE];
|
||||
typedef uint8_t llarp_hash_t[HASHSIZE];
|
||||
typedef uint8_t llarp_hmacsec_t[HMACSECSIZE];
|
||||
typedef uint8_t llarp_sig_t[SIGSIZE];
|
||||
typedef uint8_t llarp_tunnel_nounce_t[TUNNOUNCESIZE];
|
||||
|
||||
struct llarp_crypto
|
||||
{
|
||||
bool (*xchacha20)(llarp_buffer_t, llarp_sharedkey_t, llarp_nounce_t);
|
||||
bool (*dh_client)(llarp_sharedkey_t *, llarp_pubkey_t, llarp_tunnel_nounce_t, llarp_seckey_t);
|
||||
bool (*dh_server)(llarp_sharedkey_t *, llarp_pubkey_t, llarp_tunnel_nounce_t, llarp_seckey_t);
|
||||
bool (*hash)(llarp_hash_t *, llarp_buffer_t);
|
||||
bool (*hmac)(llarp_hash_t *, llarp_buffer_t, llarp_hmacsec_t);
|
||||
bool (*sign)(llarp_sig_t *, llarp_seckey_t, llarp_buffer_t);
|
||||
bool (*verify)(llarp_pubkey_t, llarp_buffer_t, llarp_sig_t);
|
||||
};
|
||||
|
||||
void llarp_crypto_libsodium_init(struct llarp_crypto * c);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,36 @@
|
||||
#ifndef LLARP_EV_H
|
||||
#define LLARP_EV_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct llarp_ev_loop;
|
||||
|
||||
void llarp_ev_loop_alloc(struct llarp_ev_loop ** ev);
|
||||
void llarp_ev_loop_free(struct llarp_ev_loop ** ev);
|
||||
|
||||
int llarp_ev_loop_run(struct llarp_ev_loop * ev);
|
||||
|
||||
struct llarp_udp_listener
|
||||
{
|
||||
char * host;
|
||||
uint16_t port;
|
||||
void * user;
|
||||
void * impl;
|
||||
void (*recvfrom)(struct llarp_udp_listener *, const struct sockaddr *, char *, ssize_t);
|
||||
void (*closed)(struct llarp_udp_listener *);
|
||||
};
|
||||
|
||||
int llarp_ev_add_udp_listener(struct llarp_ev_loop * ev, struct llarp_udp_listener * listener);
|
||||
|
||||
int llarp_ev_close_udp_listener(struct llarp_udp_listener * listener);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,18 +1,18 @@
|
||||
#ifndef SARP_XI_H
|
||||
#define SARP_XI_H
|
||||
#include <sarp/net.h>
|
||||
#ifndef LLARP_XI_H
|
||||
#define LLARP_XI_H
|
||||
#include <llarp/net.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct sarp_exit_info
|
||||
struct llarp_exit_info
|
||||
{
|
||||
in6_addr address;
|
||||
in6_addr netmask;
|
||||
};
|
||||
|
||||
struct sarp_exit_info_list;
|
||||
struct llarp_exit_info_list;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
#ifndef LLARP_LINK_H_
|
||||
#define LLARP_LINK_H_
|
||||
#include <llarp/config.h>
|
||||
#include <llarp/mem.h>
|
||||
#include <llarp/router.h>
|
||||
#include <llarp/ev.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct llarp_inet_link;
|
||||
|
||||
void llarp_inet_link_alloc(struct llarp_inet_link ** link, struct llarp_alloc * mem);
|
||||
void llarp_inet_link_free(struct llarp_inet_link ** link);
|
||||
|
||||
void llarp_inet_link_configure(struct llarp_inet_link * link, struct llarp_config * conf);
|
||||
|
||||
void llarp_inet_link_start(struct llarp_inet_link * link, struct llarp_router * router);
|
||||
|
||||
void llarp_inet_link_stop(struct llarp_inet_link * link);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,24 @@
|
||||
#ifndef LLARP_ROUTER_H_
|
||||
#define LLARP_ROUTER_H_
|
||||
#include <llarp/config.h>
|
||||
#include <llarp/ev.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct llarp_router;
|
||||
|
||||
void llarp_init_router(struct llarp_router ** router);
|
||||
void llarp_free_router(struct llarp_router ** router);
|
||||
|
||||
int llarp_configure_router(struct llarp_router * router, struct llarp_config * conf);
|
||||
|
||||
void llarp_run_router(struct llarp_router * router, struct llarp_ev_loop * loop);
|
||||
void llarp_stop_router(struct llarp_router * router);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,29 @@
|
||||
#ifndef LLARP_RC_H
|
||||
#define LLARP_RC_H
|
||||
#include <llarp/address_info.h>
|
||||
#include <llarp/exit_info.h>
|
||||
#include <llarp/crypto.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct llarp_router_contact
|
||||
{
|
||||
llarp_buffer_t raw;
|
||||
struct llarp_address_info_list * addreses;
|
||||
llarp_pubkey_t pubkey;
|
||||
struct llarp_exit_info_list * exits;
|
||||
llarp_sig_t signature;
|
||||
};
|
||||
|
||||
bool llarp_rc_bdecode(struct llarp_router_contact * rc, llarp_buffer_t buf);
|
||||
bool llarp_rc_bencode(struct llarp_router_contact * rc, llarp_buffer_t * buf);
|
||||
void llarp_rc_free(struct llarp_router_contact ** rc);
|
||||
bool llarp_rc_verify_sig(struct llarp_rotuer_contact * rc);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,24 @@
|
||||
#ifndef LLARP_SI_H
|
||||
#define LLARP_SI_H
|
||||
#include <llarp/crypto.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct llarp_service_info
|
||||
{
|
||||
llarp_buffer_t name;
|
||||
llarp_pubkey_t signingkey;
|
||||
llarp_buffer_t vanity;
|
||||
};
|
||||
|
||||
void llarp_service_info_hash(struct llarp_service_info * si, llarp_hash_t * h);
|
||||
bool llarp_service_info_bencode(struct llarp_serivce_info * si, llarp_buffer_t * buff);
|
||||
bool llarp_service_info_bdecode(struct llarp_serivce_info * si, llarp_buffer_t buff);
|
||||
void llarp_service_info_free(struct llarp_service_info ** si);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,14 @@
|
||||
#ifndef LLARP_TIME_H
|
||||
#define LLARP_TIME_H
|
||||
#include <stdint.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint64_t llarp_time_now_ms();
|
||||
uint64_t llarp_time_now_sec();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,25 @@
|
||||
#ifndef LLARP_VERSION_H
|
||||
#define LLARP_VERSION_H
|
||||
|
||||
#ifndef LLARP_VERSION_MAJ
|
||||
#define LLARP_VERSION_MAJ "0"
|
||||
#endif
|
||||
|
||||
#ifndef LLARP_VERSION_MIN
|
||||
#define LLARP_VERSION_MIN "0"
|
||||
#endif
|
||||
|
||||
#ifndef LLARP_VERSION_PATCH
|
||||
#define LLARP_VERSION_PATCH "0"
|
||||
#endif
|
||||
|
||||
#ifndef LLARP_VERSION_NUM
|
||||
#ifdef GIT_REV
|
||||
#define LLARP_VERSION_NUM "-"LLARP_VERSION_MAJ"."LLARP_VERSION_MIN"."LLARP_VERSION_PATCH"-"GIT_REV
|
||||
#else
|
||||
#define LLARP_VERSION_NUM "-"LLARP_VERSION_MAJ"."LLARP_VERSION_MIN"."LLARP_VERSION_PATCH
|
||||
#endif
|
||||
#endif
|
||||
#define LLARP_VERSION "llarpd"LLARP_VERSION_NUM
|
||||
|
||||
#endif
|
@ -1,5 +0,0 @@
|
||||
#ifndef SARP_H_
|
||||
#define SARP_H_
|
||||
#include <sarp/router.h>
|
||||
#include <sarp/version.h>
|
||||
#endif
|
@ -1,29 +0,0 @@
|
||||
#ifndef SARP_AI_H
|
||||
#define SARP_AI_H
|
||||
#include <sarp/crypto.h>
|
||||
#include <sarp/net.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct sarp_address_info
|
||||
{
|
||||
uint16_t rank;
|
||||
sarp_pubkey_t enc_key;
|
||||
char * dialect;
|
||||
struct in6_addr ip;
|
||||
uint16_t port;
|
||||
};
|
||||
|
||||
bool sarp_address_info_bencode(struct sarp_address_info * ai, sarp_buffer_t * buff);
|
||||
bool sarp_address_info_bdecode(struct sarp_address_info * ai, sarp_buffer_t buff);
|
||||
|
||||
struct sarp_address_info_list;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,20 +0,0 @@
|
||||
#ifndef SARP_BUFFER_H_
|
||||
#define SARP_BUFFER_H_
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct sarp_buffer_t {
|
||||
char * base;
|
||||
size_t sz;
|
||||
char * cur;
|
||||
} sarp_buffer_t;
|
||||
|
||||
size_t sarp_buffer_size_left(sarp_buffer_t * buff);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,30 +0,0 @@
|
||||
#ifndef SARP_CONFIG_H_
|
||||
#define SARP_CONFIG_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct sarp_config;
|
||||
|
||||
void sarp_new_config(struct sarp_config ** conf);
|
||||
void sarp_free_config(struct sarp_config ** conf);
|
||||
|
||||
/** @brief return -1 on fail otherwiwse 0 */
|
||||
int sarp_load_config(struct sarp_config * conf, const char * fname);
|
||||
|
||||
struct sarp_config_iterator
|
||||
{
|
||||
void * user;
|
||||
/** set by sarp_config_iter */
|
||||
struct sarp_config * conf;
|
||||
/** visit (self, section, key, value) */
|
||||
void (*visit)(struct sarp_config_iterator *, const char *, const char *, const char *);
|
||||
};
|
||||
|
||||
void sarp_config_iter(struct sarp_config * conf, struct sarp_config_iterator * iter);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,45 +0,0 @@
|
||||
#ifndef SARP_CRYPTO_H_
|
||||
#define SARP_CRYPTO_H_
|
||||
#include <sarp/buffer.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PUBKEYSIZE 32
|
||||
#define SECKEYSIZE 32
|
||||
#define NOUNCESIZE 24
|
||||
#define SHAREDKEYSIZE 32
|
||||
#define HASHSIZE 64
|
||||
#define HMACSECSIZE 32
|
||||
#define SIGSIZE 64
|
||||
#define TUNNOUNCESIZE 32
|
||||
|
||||
typedef uint8_t sarp_pubkey_t[PUBKEYSIZE];
|
||||
typedef uint8_t sarp_seckey_t[SECKEYSIZE];
|
||||
typedef uint8_t sarp_nounce_t[NOUNCESIZE];
|
||||
typedef uint8_t sarp_sharedkey_t[SHAREDKEYSIZE];
|
||||
typedef uint8_t sarp_hash_t[HASHSIZE];
|
||||
typedef uint8_t sarp_hmacsec_t[HMACSECSIZE];
|
||||
typedef uint8_t sarp_sig_t[SIGSIZE];
|
||||
typedef uint8_t sarp_tunnel_nounce_t[TUNNOUNCESIZE];
|
||||
|
||||
struct sarp_crypto
|
||||
{
|
||||
bool (*xchacha20)(sarp_buffer_t, sarp_sharedkey_t, sarp_nounce_t);
|
||||
bool (*dh_client)(sarp_sharedkey_t *, sarp_pubkey_t, sarp_tunnel_nounce_t, sarp_seckey_t);
|
||||
bool (*dh_server)(sarp_sharedkey_t *, sarp_pubkey_t, sarp_tunnel_nounce_t, sarp_seckey_t);
|
||||
bool (*hash)(sarp_hash_t *, sarp_buffer_t);
|
||||
bool (*hmac)(sarp_hash_t *, sarp_buffer_t, sarp_hmacsec_t);
|
||||
bool (*sign)(sarp_sig_t *, sarp_seckey_t, sarp_buffer_t);
|
||||
bool (*verify)(sarp_pubkey_t, sarp_buffer_t, sarp_sig_t);
|
||||
};
|
||||
|
||||
void sarp_crypto_libsodium_init(struct sarp_crypto * c);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,36 +0,0 @@
|
||||
#ifndef SARP_EV_H
|
||||
#define SARP_EV_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct sarp_ev_loop;
|
||||
|
||||
void sarp_ev_loop_alloc(struct sarp_ev_loop ** ev);
|
||||
void sarp_ev_loop_free(struct sarp_ev_loop ** ev);
|
||||
|
||||
int sarp_ev_loop_run(struct sarp_ev_loop * ev);
|
||||
|
||||
struct sarp_udp_listener
|
||||
{
|
||||
char * host;
|
||||
uint16_t port;
|
||||
void * user;
|
||||
void * impl;
|
||||
void (*recvfrom)(struct sarp_udp_listener *, const struct sockaddr *, char *, ssize_t);
|
||||
void (*closed)(struct sarp_udp_listener *);
|
||||
};
|
||||
|
||||
int sarp_ev_add_udp_listener(struct sarp_ev_loop * ev, struct sarp_udp_listener * listener);
|
||||
|
||||
int sarp_ev_close_udp_listener(struct sarp_udp_listener * listener);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,27 +0,0 @@
|
||||
#ifndef SARP_LINK_H_
|
||||
#define SARP_LINK_H_
|
||||
#include <sarp/config.h>
|
||||
#include <sarp/mem.h>
|
||||
#include <sarp/router.h>
|
||||
#include <sarp/ev.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct sarp_inet_link;
|
||||
|
||||
void sarp_inet_link_alloc(struct sarp_inet_link ** link, struct sarp_alloc * mem);
|
||||
void sarp_inet_link_free(struct sarp_inet_link ** link);
|
||||
|
||||
void sarp_inet_link_configure(struct sarp_inet_link * link, struct sarp_config * conf);
|
||||
|
||||
void sarp_inet_link_start(struct sarp_inet_link * link, struct sarp_router * router);
|
||||
|
||||
void sarp_inet_link_stop(struct sarp_inet_link * link);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,24 +0,0 @@
|
||||
#ifndef SARP_ROUTER_H_
|
||||
#define SARP_ROUTER_H_
|
||||
#include <sarp/config.h>
|
||||
#include <sarp/ev.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct sarp_router;
|
||||
|
||||
void sarp_init_router(struct sarp_router ** router);
|
||||
void sarp_free_router(struct sarp_router ** router);
|
||||
|
||||
int sarp_configure_router(struct sarp_router * router, struct sarp_config * conf);
|
||||
|
||||
void sarp_run_router(struct sarp_router * router, struct sarp_ev_loop * loop);
|
||||
void sarp_stop_router(struct sarp_router * router);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,29 +0,0 @@
|
||||
#ifndef SARP_RC_H
|
||||
#define SARP_RC_H
|
||||
#include <sarp/address_info.h>
|
||||
#include <sarp/exit_info.h>
|
||||
#include <sarp/crypto.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct sarp_router_contact
|
||||
{
|
||||
sarp_buffer_t raw;
|
||||
struct sarp_address_info_list * addreses;
|
||||
sarp_pubkey_t pubkey;
|
||||
struct sarp_exit_info_list * exits;
|
||||
sarp_sig_t signature;
|
||||
};
|
||||
|
||||
bool sarp_rc_bdecode(struct sarp_router_contact * rc, sarp_buffer_t buf);
|
||||
bool sarp_rc_bencode(struct sarp_router_contact * rc, sarp_buffer_t * buf);
|
||||
void sarp_rc_free(struct sarp_router_contact ** rc);
|
||||
bool sarp_rc_verify_sig(struct sarp_rotuer_contact * rc);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,24 +0,0 @@
|
||||
#ifndef SARP_SI_H
|
||||
#define SARP_SI_H
|
||||
#include <sarp/crypto.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct sarp_service_info
|
||||
{
|
||||
sarp_buffer_t name;
|
||||
sarp_pubkey_t signingkey;
|
||||
sarp_buffer_t vanity;
|
||||
};
|
||||
|
||||
void sarp_service_info_hash(struct sarp_service_info * si, sarp_hash_t * h);
|
||||
bool sarp_service_info_bencode(struct sarp_serivce_info * si, sarp_buffer_t * buff);
|
||||
bool sarp_service_info_bdecode(struct sarp_serivce_info * si, sarp_buffer_t buff);
|
||||
void sarp_service_info_free(struct sarp_service_info ** si);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,14 +0,0 @@
|
||||
#ifndef SARP_TIME_H
|
||||
#define SARP_TIME_H
|
||||
#include <stdint.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint64_t sarp_time_now_ms();
|
||||
uint64_t sarp_time_now_sec();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
#ifndef SARP_VERSION_H
|
||||
#define SARP_VERSION_H
|
||||
|
||||
#ifndef SARP_VERSION_MAJ
|
||||
#define SARP_VERSION_MAJ "0"
|
||||
#endif
|
||||
|
||||
#ifndef SARP_VERSION_MIN
|
||||
#define SARP_VERSION_MIN "0"
|
||||
#endif
|
||||
|
||||
#ifndef SARP_VERSION_PATCH
|
||||
#define SARP_VERSION_PATCH "0"
|
||||
#endif
|
||||
|
||||
#ifndef SARP_VERSION_NUM
|
||||
#ifdef GIT_REV
|
||||
#define SARP_VERSION_NUM "-"SARP_VERSION_MAJ"."SARP_VERSION_MIN"."SARP_VERSION_PATCH"-"GIT_REV
|
||||
#else
|
||||
#define SARP_VERSION_NUM "-"SARP_VERSION_MAJ"."SARP_VERSION_MIN"."SARP_VERSION_PATCH
|
||||
#endif
|
||||
#endif
|
||||
#define SARP_VERSION "llarpd"SARP_VERSION_NUM
|
||||
|
||||
#endif
|
@ -1,25 +1,25 @@
|
||||
#include <sarp/time.h>
|
||||
#include <llarp/time.h>
|
||||
#include <chrono>
|
||||
|
||||
namespace sarp
|
||||
namespace llarp
|
||||
{
|
||||
typedef std::chrono::steady_clock clock_t;
|
||||
|
||||
template<typename Res>
|
||||
static uint64_t time_since_epoch()
|
||||
{
|
||||
return std::chrono::duration_cast<Res>(sarp::clock_t::now().time_since_epoch()).count();
|
||||
return std::chrono::duration_cast<Res>(llarp::clock_t::now().time_since_epoch()).count();
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
uint64_t sarp_time_now_ms()
|
||||
uint64_t llarp_time_now_ms()
|
||||
{
|
||||
return sarp::time_since_epoch<std::chrono::milliseconds>();
|
||||
return llarp::time_since_epoch<std::chrono::milliseconds>();
|
||||
}
|
||||
|
||||
uint64_t sarp_time_now_sec()
|
||||
uint64_t llarp_time_now_sec()
|
||||
{
|
||||
return sarp::time_since_epoch<std::chrono::seconds>();
|
||||
return llarp::time_since_epoch<std::chrono::seconds>();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue