X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet.h;h=4da61bd4f2320a5abfa78c8bfd6e93df7b50017c;hb=8d4ac42ceb67a93fc1e5c0d045819597c5da47d0;hp=04bd55a50a0a5ff42fc50d2f314738f32d6b58a6;hpb=5c7be85686db219955e1af592b32d0d4108625cb;p=meshlink diff --git a/src/net.h b/src/net.h index 04bd55a5..4da61bd4 100644 --- a/src/net.h +++ b/src/net.h @@ -36,10 +36,8 @@ #define MAXBUFSIZE ((MAXSIZE > 2048 ? MAXSIZE : 2048) + 128) typedef struct vpn_packet_t { - struct { - unsigned int probe: 1; - unsigned int tcp: 1; - }; + uint16_t probe: 1; + int16_t tcp: 1; uint16_t len; /* the actual number of bytes in the `data' field */ uint8_t data[MAXSIZE]; } vpn_packet_t; @@ -59,9 +57,7 @@ typedef enum packet_type_t { #include "list.h" typedef struct outgoing_t { - char *name; - struct splay_tree_t *config_tree; - int timeout; + struct node_t *node; enum { OUTGOING_START, OUTGOING_CANONICAL, @@ -70,24 +66,19 @@ typedef struct outgoing_t { OUTGOING_END, OUTGOING_NO_KNOWN_ADDRESSES, } state; - struct config_t *cfg; + int timeout; + timeout_t ev; struct addrinfo *ai; struct addrinfo *aip; - timeout_t ev; - struct meshlink_handle *mesh; } outgoing_t; -extern int maxoutbufsize; -extern int addressfamily; - -extern int keylifetime; -extern int max_connection_burst; -extern bool do_prune; - /* Yes, very strange placement indeed, but otherwise the typedefs get all tangled up */ #include "connection.h" #include "node.h" +extern void init_outgoings(struct meshlink_handle *mesh); +extern void exit_outgoings(struct meshlink_handle *mesh); + extern void retry_outgoing(struct meshlink_handle *mesh, outgoing_t *); extern void handle_incoming_vpn_data(struct event_loop_t *loop, void *, int); extern void finish_connecting(struct meshlink_handle *mesh, struct connection_t *); @@ -98,19 +89,19 @@ extern int setup_vpn_in_socket(struct meshlink_handle *mesh, const sockaddr_t *) extern bool send_sptps_data(void *handle, uint8_t type, const void *data, size_t len); extern bool receive_sptps_record(void *handle, uint8_t type, const void *data, uint16_t len); extern void send_packet(struct meshlink_handle *mesh, struct node_t *, struct vpn_packet_t *); -extern void broadcast_packet(struct meshlink_handle *mesh, const struct node_t *, struct vpn_packet_t *); extern char *get_name(struct meshlink_handle *mesh); extern void load_all_nodes(struct meshlink_handle *mesh); extern bool setup_myself_reloadable(struct meshlink_handle *mesh); extern bool setup_network(struct meshlink_handle *mesh); extern void setup_outgoing_connection(struct meshlink_handle *mesh, struct outgoing_t *); -extern void try_outgoing_connections(struct meshlink_handle *mesh); extern void close_network_connections(struct meshlink_handle *mesh); extern int main_loop(struct meshlink_handle *mesh); extern void terminate_connection(struct meshlink_handle *mesh, struct connection_t *, bool); -extern bool node_read_ecdsa_public_key(struct meshlink_handle *mesh, struct node_t *); +extern bool node_read_public_key(struct meshlink_handle *mesh, struct node_t *); +extern bool node_read_from_config(struct meshlink_handle *mesh, struct node_t *, const config_t *config); extern bool read_ecdsa_public_key(struct meshlink_handle *mesh, struct connection_t *); extern bool read_ecdsa_private_key(struct meshlink_handle *mesh); +extern bool node_write_config(struct meshlink_handle *mesh, struct node_t *); extern void send_mtu_probe(struct meshlink_handle *mesh, struct node_t *); extern void handle_meta_connection_data(struct meshlink_handle *mesh, struct connection_t *); extern void retry(struct meshlink_handle *mesh);