You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/include/llarp/address_info.h

77 lines
1.5 KiB
C

7 years ago
#ifndef LLARP_AI_H
#define LLARP_AI_H
#include <llarp/crypto.h>
7 years ago
#include <llarp/mem.h>
7 years ago
#include <llarp/net.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
7 years ago
#define MAX_AI_DIALECT_SIZE 5
7 years ago
struct llarp_ai
{
7 years ago
uint16_t rank;
6 years ago
char dialect[MAX_AI_DIALECT_SIZE + 1];
7 years ago
llarp_pubkey_t enc_key;
struct in6_addr ip;
uint16_t port;
};
bool
llarp_ai_bencode(struct llarp_ai *ai, llarp_buffer_t *buff);
bool
llarp_ai_bdecode(struct llarp_ai *ai, llarp_buffer_t *buff);
7 years ago
struct llarp_ai_list;
struct llarp_ai_list *
llarp_ai_list_new(struct llarp_alloc *mem);
void
llarp_ai_list_free(struct llarp_ai_list *l);
void
llarp_ai_copy(struct llarp_ai *dst, struct llarp_ai *src);
bool
llarp_ai_list_bencode(struct llarp_ai_list *l, llarp_buffer_t *buff);
bool
llarp_ai_list_bdecode(struct llarp_ai_list *l, llarp_buffer_t *buff);
struct llarp_ai
llarp_ai_list_popfront(struct llarp_ai_list *l);
/** pushes a copy of ai to the end of the list */
void
llarp_ai_list_pushback(struct llarp_ai_list *l, struct llarp_ai *ai);
6 years ago
size_t
llarp_ai_list_size(struct llarp_ai_list *l);
7 years ago
bool
llarp_ai_list_index(struct llarp_ai_list *l, ssize_t idx,
struct llarp_ai *result);
7 years ago
struct llarp_ai_list_iter
{
7 years ago
void *user;
/** set by llarp_ai_list_iterate() */
struct llarp_ai_list *list;
/** return false to break iteration */
bool (*visit)(struct llarp_ai_list_iter *, struct llarp_ai *);
};
void
llarp_ai_list_iterate(struct llarp_ai_list *l, struct llarp_ai_list_iter *iter);
7 years ago
7 years ago
#ifdef __cplusplus
}
#endif
7 years ago
7 years ago
#endif