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/link.h

96 lines
2.7 KiB
C

7 years ago
#ifndef LLARP_LINK_H_
#define LLARP_LINK_H_
7 years ago
#include <llarp/crypto.h>
7 years ago
#include <llarp/ev.h>
6 years ago
#include <llarp/logic.h>
7 years ago
#include <llarp/mem.h>
7 years ago
#include <llarp/msg_handler.h>
#include <llarp/obmd.h>
7 years ago
7 years ago
#include <stdbool.h>
7 years ago
#include <stdint.h>
7 years ago
7 years ago
#ifdef __cplusplus
extern "C" {
#endif
7 years ago
7 years ago
/**
7 years ago
* wire layer transport interface
7 years ago
*/
7 years ago
struct llarp_link;
7 years ago
/**
7 years ago
* wire layer transport session for point to point communication between us and
* another
7 years ago
*/
7 years ago
struct llarp_link_session;
7 years ago
struct llarp_link_session_listener {
void *user;
7 years ago
/** set by try_establish */
7 years ago
struct llarp_link *link;
7 years ago
/** set by try_establish */
7 years ago
struct llarp_ai *ai;
7 years ago
/** callback to handle result */
7 years ago
void (*result)(struct llarp_link_session_listener *,
struct llarp_link_session *);
};
7 years ago
/** information for establishing an outbound session */
struct llarp_link_establish_job {
7 years ago
struct llarp_ai *ai;
7 years ago
uint64_t timeout;
};
7 years ago
struct llarp_link_session_iter {
void *user;
struct llarp_link *link;
bool (*visit)(struct llarp_link_session_iter *, struct llarp_link_session *);
};
7 years ago
struct llarp_link_ev_listener {
void *user;
6 years ago
void (*established)(struct llarp_link_ev_listener *, struct llarp_link_session *,
7 years ago
bool);
6 years ago
void (*timeout)(struct llarp_link_ev_listener *, struct llarp_link_session *,
7 years ago
bool);
6 years ago
void (*tx)(struct llarp_link_ev_listener *, struct llarp_link_session *, size_t);
void (*rx)(struct llarp_link_ev_listener *, struct llarp_link_session *, size_t);
void (*error)(struct llarp_link_ev_listener *, struct llarp_link_session *,
7 years ago
const char *);
7 years ago
};
7 years ago
struct llarp_link {
void *impl;
const char *(*name)(struct llarp_link *);
6 years ago
/*
7 years ago
int (*register_listener)(struct llarp_link *, struct llarp_link_ev_listener);
void (*deregister_listener)(struct llarp_link *, int);
6 years ago
*/
7 years ago
bool (*configure)(struct llarp_link *, const char *, int, uint16_t);
6 years ago
bool (*start_link)(struct llarp_link *, struct llarp_logic *);
7 years ago
bool (*stop_link)(struct llarp_link *);
6 years ago
void (*iter_sessions)(struct llarp_link *, struct llarp_link_session_iter*);
7 years ago
void (*try_establish)(struct llarp_link *, struct llarp_link_establish_job,
7 years ago
struct llarp_link_session_listener);
6 years ago
void (*free_impl)(struct llarp_link *);
7 years ago
};
7 years ago
struct llarp_link_session {
void *impl;
struct llarp_rc *(*remote_rc)(struct llarp_link_session *);
/** send an entire message, splits up into smaller pieces and does encryption
*/
7 years ago
ssize_t (*sendto)(struct llarp_link_session *, llarp_buffer_t);
7 years ago
/** return true if this session is timed out */
bool (*timeout)(struct llarp_link_session *);
/** explicit close session */
void (*close)(struct llarp_link_session *);
7 years ago
};
7 years ago
#ifdef __cplusplus
}
#endif
#endif