From: Guus Sliepen Date: Sun, 26 Sep 2021 22:22:25 +0000 (+0200) Subject: Add support for devtool_reset_node_counters to the full MeshLink shim. X-Git-Url: http://git.meshlink.io/?p=meshlink-tiny;a=commitdiff_plain;h=0415fb063d619275837827a4f76c2445da43127a Add support for devtool_reset_node_counters to the full MeshLink shim. Also assert that all symbols have been resolved. --- diff --git a/test/full.c b/test/full.c index 97d5d41..df8cb0b 100644 --- a/test/full.c +++ b/test/full.c @@ -106,112 +106,114 @@ void (*full_meshlink_set_scheduling_granularity)(struct meshlink_handle *mesh, l void (*full_meshlink_set_storage_policy)(struct meshlink_handle *mesh, meshlink_storage_policy_t policy); full_devtool_set_inviter_commits_first_t *full_devtool_set_inviter_commits_first; +void (*full_devtool_reset_node_counters)(struct meshlink_handle *mesh, meshlink_node_t *node, struct devtool_node_status *); void init_full(void) { void *handle = dlopen("libmeshlink.so", RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND); assert(handle); - full_meshlink_errno = dlsym(handle, "meshlink_errno"); - full_meshlink_strerror = dlsym(handle, "meshlink_strerror"); - full_meshlink_open_params_init = dlsym(handle, "meshlink_open_params_init"); - full_meshlink_open_params_free = dlsym(handle, "meshlink_open_params_free"); - full_meshlink_open_params_set_netns = dlsym(handle, "meshlink_open_params_set_netns"); - full_meshlink_open_params_set_storage_key = dlsym(handle, "meshlink_open_params_set_storage_key"); - full_meshlink_open_params_set_storage_policy = dlsym(handle, "meshlink_open_params_set_storage_policy"); - full_meshlink_open_params_set_lock_filename = dlsym(handle, "meshlink_open_params_set_lock_filename"); - full_meshlink_open_ex = dlsym(handle, "meshlink_open_ex"); - full_meshlink_open = dlsym(handle, "meshlink_open"); - full_meshlink_open_encrypted = dlsym(handle, "meshlink_open_encrypted"); - full_meshlink_open_ephemeral = dlsym(handle, "meshlink_open_ephemeral"); - full_meshlink_submesh_open = dlsym(handle, "meshlink_submesh_open"); - full_meshlink_start = dlsym(handle, "meshlink_start"); - full_meshlink_stop = dlsym(handle, "meshlink_stop"); - full_meshlink_close = dlsym(handle, "meshlink_close"); - full_meshlink_destroy = dlsym(handle, "meshlink_destroy"); - full_meshlink_destroy_ex = dlsym(handle, "meshlink_destroy_ex"); - full_meshlink_set_receive_cb = dlsym(handle, "meshlink_set_receive_cb"); - full_meshlink_set_connection_try_cb = dlsym(handle, "meshlink_set_connection_try_cb"); - full_meshlink_set_node_status_cb = dlsym(handle, "meshlink_set_node_status_cb"); - full_meshlink_set_node_pmtu_cb = dlsym(handle, "meshlink_set_node_pmtu_cb"); - full_meshlink_set_node_duplicate_cb = dlsym(handle, "meshlink_set_node_duplicate_cb"); - full_meshlink_set_log_cb = dlsym(handle, "meshlink_set_log_cb"); - full_meshlink_set_error_cb = dlsym(handle, "meshlink_set_error_cb"); - full_meshlink_set_blacklisted_cb = dlsym(handle, "meshlink_set_blacklisted_cb"); - full_meshlink_send = dlsym(handle, "meshlink_send"); - full_meshlink_get_pmtu = dlsym(handle, "meshlink_get_pmtu"); - full_meshlink_get_self = dlsym(handle, "meshlink_get_self"); - full_meshlink_get_node = dlsym(handle, "meshlink_get_node"); - full_meshlink_get_submesh = dlsym(handle, "meshlink_get_submesh"); - full_meshlink_get_fingerprint = dlsym(handle, "meshlink_get_fingerprint"); - full_meshlink_get_all_nodes = dlsym(handle, "meshlink_get_all_nodes"); - full_meshlink_sign = dlsym(handle, "meshlink_sign"); - full_meshlink_get_all_nodes_by_dev_class = dlsym(handle, "meshlink_get_all_nodes_by_dev_class"); - full_meshlink_get_all_nodes_by_submesh = dlsym(handle, "meshlink_get_all_nodes_by_submesh"); - full_meshlink_get_all_nodes_by_last_reachable = dlsym(handle, "meshlink_get_all_nodes_by_last_reachable"); - full_meshlink_get_all_nodes_by_blacklisted = dlsym(handle, "meshlink_get_all_nodes_by_blacklisted"); - full_meshlink_get_node_dev_class = dlsym(handle, "meshlink_get_node_dev_class"); - full_meshlink_get_node_blacklisted = dlsym(handle, "meshlink_get_node_blacklisted"); - full_meshlink_get_node_submesh = dlsym(handle, "meshlink_get_node_submesh"); - full_meshlink_get_node_reachability = dlsym(handle, "meshlink_get_node_reachability"); - full_meshlink_verify = dlsym(handle, "meshlink_verify"); - full_meshlink_set_canonical_address = dlsym(handle, "meshlink_set_canonical_address"); - full_meshlink_clear_canonical_address = dlsym(handle, "meshlink_clear_canonical_address"); - full_meshlink_add_invitation_address = dlsym(handle, "meshlink_add_invitation_address"); - full_meshlink_clear_invitation_addresses = dlsym(handle, "meshlink_clear_invitation_addresses"); - full_meshlink_get_external_address = dlsym(handle, "meshlink_get_external_address"); - full_meshlink_get_external_address_for_family = dlsym(handle, "meshlink_get_external_address_for_family"); - full_meshlink_get_local_address_for_family = dlsym(handle, "meshlink_get_local_address_for_family"); - full_meshlink_add_external_address = dlsym(handle, "meshlink_add_external_address"); - full_meshlink_get_port = dlsym(handle, "meshlink_get_port"); - full_meshlink_set_port = dlsym(handle, "meshlink_set_port"); - full_meshlink_set_invitation_timeout = dlsym(handle, "meshlink_set_invitation_timeout"); - full_meshlink_invite_ex = dlsym(handle, "meshlink_invite_ex"); - full_meshlink_invite = dlsym(handle, "meshlink_invite"); - full_meshlink_join = dlsym(handle, "meshlink_join"); - full_meshlink_export = dlsym(handle, "meshlink_export"); - full_meshlink_import = dlsym(handle, "meshlink_import"); - full_meshlink_forget_node = dlsym(handle, "meshlink_forget_node"); - full_meshlink_blacklist = dlsym(handle, "meshlink_blacklist"); - full_meshlink_blacklist_by_name = dlsym(handle, "meshlink_blacklist_by_name"); - full_meshlink_whitelist = dlsym(handle, "meshlink_whitelist"); - full_meshlink_whitelist_by_name = dlsym(handle, "meshlink_whitelist_by_name"); - full_meshlink_set_default_blacklist = dlsym(handle, "meshlink_set_default_blacklist"); - full_meshlink_set_channel_listen_cb = dlsym(handle, "meshlink_set_channel_listen_cb"); - full_meshlink_set_channel_accept_cb = dlsym(handle, "meshlink_set_channel_accept_cb"); - full_meshlink_set_channel_receive_cb = dlsym(handle, "meshlink_set_channel_receive_cb"); - full_meshlink_set_channel_poll_cb = dlsym(handle, "meshlink_set_channel_poll_cb"); - full_meshlink_set_channel_sndbuf = dlsym(handle, "meshlink_set_channel_sndbuf"); - full_meshlink_set_channel_rcvbuf = dlsym(handle, "meshlink_set_channel_rcvbuf"); - full_meshlink_set_channel_sndbuf_storage = dlsym(handle, "meshlink_set_channel_sndbuf_storage"); - full_meshlink_set_channel_rcvbuf_storage = dlsym(handle, "meshlink_set_channel_rcvbuf_storage"); - full_meshlink_set_channel_flags = dlsym(handle, "meshlink_set_channel_flags"); - full_meshlink_channel_open_ex = dlsym(handle, "meshlink_channel_open_ex"); - full_meshlink_channel_open = dlsym(handle, "meshlink_channel_open"); - full_meshlink_channel_shutdown = dlsym(handle, "meshlink_channel_shutdown"); - full_meshlink_channel_close = dlsym(handle, "meshlink_channel_close"); - full_meshlink_channel_abort = dlsym(handle, "meshlink_channel_abort"); - full_meshlink_channel_send = dlsym(handle, "meshlink_channel_send"); - full_meshlink_channel_aio_send = dlsym(handle, "meshlink_channel_aio_send"); - full_meshlink_channel_aio_fd_send = dlsym(handle, "meshlink_channel_aio_fd_send"); - full_meshlink_channel_aio_receive = dlsym(handle, "meshlink_channel_aio_receive"); - full_meshlink_channel_aio_fd_receive = dlsym(handle, "meshlink_channel_aio_fd_receive"); - full_meshlink_channel_get_flags = dlsym(handle, "meshlink_channel_get_flags"); - full_meshlink_channel_get_sendq = dlsym(handle, "meshlink_channel_get_sendq"); - full_meshlink_channel_get_recvq = dlsym(handle, "meshlink_channel_get_recvq"); - full_meshlink_channel_get_mss = dlsym(handle, "meshlink_channel_get_mss"); - full_meshlink_set_node_channel_timeout = dlsym(handle, "meshlink_set_node_channel_timeout"); - full_meshlink_hint_address = dlsym(handle, "meshlink_hint_address"); - full_meshlink_enable_discovery = dlsym(handle, "meshlink_enable_discovery"); - full_meshlink_hint_network_change = dlsym(handle, "meshlink_hint_network_change"); - full_meshlink_encrypted_key_rotate = dlsym(handle, "meshlink_encrypted_key_rotate"); - full_meshlink_set_dev_class_timeouts = dlsym(handle, "meshlink_set_dev_class_timeouts"); - full_meshlink_set_dev_class_fast_retry_period = dlsym(handle, "meshlink_set_dev_class_fast_retry_period"); - full_meshlink_set_dev_class_maxtimeout = dlsym(handle, "meshlink_set_dev_class_maxtimeout"); - full_meshlink_reset_timers = dlsym(handle, "meshlink_reset_timers"); - full_meshlink_set_inviter_commits_first = dlsym(handle, "meshlink_set_inviter_commits_first"); - full_meshlink_set_external_address_discovery_url = dlsym(handle, "meshlink_set_external_address_discovery_url"); - full_meshlink_set_scheduling_granularity = dlsym(handle, "meshlink_set_scheduling_granularity"); - full_meshlink_set_storage_policy = dlsym(handle, "meshlink_set_storage_policy"); + assert(full_meshlink_errno = dlsym(handle, "meshlink_errno")); + assert(full_meshlink_strerror = dlsym(handle, "meshlink_strerror")); + assert(full_meshlink_open_params_init = dlsym(handle, "meshlink_open_params_init")); + assert(full_meshlink_open_params_free = dlsym(handle, "meshlink_open_params_free")); + assert(full_meshlink_open_params_set_netns = dlsym(handle, "meshlink_open_params_set_netns")); + assert(full_meshlink_open_params_set_storage_key = dlsym(handle, "meshlink_open_params_set_storage_key")); + assert(full_meshlink_open_params_set_storage_policy = dlsym(handle, "meshlink_open_params_set_storage_policy")); + assert(full_meshlink_open_params_set_lock_filename = dlsym(handle, "meshlink_open_params_set_lock_filename")); + assert(full_meshlink_open_ex = dlsym(handle, "meshlink_open_ex")); + assert(full_meshlink_open = dlsym(handle, "meshlink_open")); + assert(full_meshlink_open_encrypted = dlsym(handle, "meshlink_open_encrypted")); + assert(full_meshlink_open_ephemeral = dlsym(handle, "meshlink_open_ephemeral")); + assert(full_meshlink_submesh_open = dlsym(handle, "meshlink_submesh_open")); + assert(full_meshlink_start = dlsym(handle, "meshlink_start")); + assert(full_meshlink_stop = dlsym(handle, "meshlink_stop")); + assert(full_meshlink_close = dlsym(handle, "meshlink_close")); + assert(full_meshlink_destroy = dlsym(handle, "meshlink_destroy")); + assert(full_meshlink_destroy_ex = dlsym(handle, "meshlink_destroy_ex")); + assert(full_meshlink_set_receive_cb = dlsym(handle, "meshlink_set_receive_cb")); + assert(full_meshlink_set_connection_try_cb = dlsym(handle, "meshlink_set_connection_try_cb")); + assert(full_meshlink_set_node_status_cb = dlsym(handle, "meshlink_set_node_status_cb")); + assert(full_meshlink_set_node_pmtu_cb = dlsym(handle, "meshlink_set_node_pmtu_cb")); + assert(full_meshlink_set_node_duplicate_cb = dlsym(handle, "meshlink_set_node_duplicate_cb")); + assert(full_meshlink_set_log_cb = dlsym(handle, "meshlink_set_log_cb")); + assert(full_meshlink_set_error_cb = dlsym(handle, "meshlink_set_error_cb")); + assert(full_meshlink_set_blacklisted_cb = dlsym(handle, "meshlink_set_blacklisted_cb")); + assert(full_meshlink_send = dlsym(handle, "meshlink_send")); + assert(full_meshlink_get_pmtu = dlsym(handle, "meshlink_get_pmtu")); + assert(full_meshlink_get_self = dlsym(handle, "meshlink_get_self")); + assert(full_meshlink_get_node = dlsym(handle, "meshlink_get_node")); + assert(full_meshlink_get_submesh = dlsym(handle, "meshlink_get_submesh")); + assert(full_meshlink_get_fingerprint = dlsym(handle, "meshlink_get_fingerprint")); + assert(full_meshlink_get_all_nodes = dlsym(handle, "meshlink_get_all_nodes")); + assert(full_meshlink_sign = dlsym(handle, "meshlink_sign")); + assert(full_meshlink_get_all_nodes_by_dev_class = dlsym(handle, "meshlink_get_all_nodes_by_dev_class")); + assert(full_meshlink_get_all_nodes_by_submesh = dlsym(handle, "meshlink_get_all_nodes_by_submesh")); + assert(full_meshlink_get_all_nodes_by_last_reachable = dlsym(handle, "meshlink_get_all_nodes_by_last_reachable")); + assert(full_meshlink_get_all_nodes_by_blacklisted = dlsym(handle, "meshlink_get_all_nodes_by_blacklisted")); + assert(full_meshlink_get_node_dev_class = dlsym(handle, "meshlink_get_node_dev_class")); + assert(full_meshlink_get_node_blacklisted = dlsym(handle, "meshlink_get_node_blacklisted")); + assert(full_meshlink_get_node_submesh = dlsym(handle, "meshlink_get_node_submesh")); + assert(full_meshlink_get_node_reachability = dlsym(handle, "meshlink_get_node_reachability")); + assert(full_meshlink_verify = dlsym(handle, "meshlink_verify")); + assert(full_meshlink_set_canonical_address = dlsym(handle, "meshlink_set_canonical_address")); + assert(full_meshlink_clear_canonical_address = dlsym(handle, "meshlink_clear_canonical_address")); + assert(full_meshlink_add_invitation_address = dlsym(handle, "meshlink_add_invitation_address")); + assert(full_meshlink_clear_invitation_addresses = dlsym(handle, "meshlink_clear_invitation_addresses")); + assert(full_meshlink_get_external_address = dlsym(handle, "meshlink_get_external_address")); + assert(full_meshlink_get_external_address_for_family = dlsym(handle, "meshlink_get_external_address_for_family")); + assert(full_meshlink_get_local_address_for_family = dlsym(handle, "meshlink_get_local_address_for_family")); + assert(full_meshlink_add_external_address = dlsym(handle, "meshlink_add_external_address")); + assert(full_meshlink_get_port = dlsym(handle, "meshlink_get_port")); + assert(full_meshlink_set_port = dlsym(handle, "meshlink_set_port")); + assert(full_meshlink_set_invitation_timeout = dlsym(handle, "meshlink_set_invitation_timeout")); + assert(full_meshlink_invite_ex = dlsym(handle, "meshlink_invite_ex")); + assert(full_meshlink_invite = dlsym(handle, "meshlink_invite")); + assert(full_meshlink_join = dlsym(handle, "meshlink_join")); + assert(full_meshlink_export = dlsym(handle, "meshlink_export")); + assert(full_meshlink_import = dlsym(handle, "meshlink_import")); + assert(full_meshlink_forget_node = dlsym(handle, "meshlink_forget_node")); + assert(full_meshlink_blacklist = dlsym(handle, "meshlink_blacklist")); + assert(full_meshlink_blacklist_by_name = dlsym(handle, "meshlink_blacklist_by_name")); + assert(full_meshlink_whitelist = dlsym(handle, "meshlink_whitelist")); + assert(full_meshlink_whitelist_by_name = dlsym(handle, "meshlink_whitelist_by_name")); + assert(full_meshlink_set_default_blacklist = dlsym(handle, "meshlink_set_default_blacklist")); + assert(full_meshlink_set_channel_listen_cb = dlsym(handle, "meshlink_set_channel_listen_cb")); + assert(full_meshlink_set_channel_accept_cb = dlsym(handle, "meshlink_set_channel_accept_cb")); + assert(full_meshlink_set_channel_receive_cb = dlsym(handle, "meshlink_set_channel_receive_cb")); + assert(full_meshlink_set_channel_poll_cb = dlsym(handle, "meshlink_set_channel_poll_cb")); + assert(full_meshlink_set_channel_sndbuf = dlsym(handle, "meshlink_set_channel_sndbuf")); + assert(full_meshlink_set_channel_rcvbuf = dlsym(handle, "meshlink_set_channel_rcvbuf")); + assert(full_meshlink_set_channel_sndbuf_storage = dlsym(handle, "meshlink_set_channel_sndbuf_storage")); + assert(full_meshlink_set_channel_rcvbuf_storage = dlsym(handle, "meshlink_set_channel_rcvbuf_storage")); + assert(full_meshlink_set_channel_flags = dlsym(handle, "meshlink_set_channel_flags")); + assert(full_meshlink_channel_open_ex = dlsym(handle, "meshlink_channel_open_ex")); + assert(full_meshlink_channel_open = dlsym(handle, "meshlink_channel_open")); + assert(full_meshlink_channel_shutdown = dlsym(handle, "meshlink_channel_shutdown")); + assert(full_meshlink_channel_close = dlsym(handle, "meshlink_channel_close")); + assert(full_meshlink_channel_abort = dlsym(handle, "meshlink_channel_abort")); + assert(full_meshlink_channel_send = dlsym(handle, "meshlink_channel_send")); + assert(full_meshlink_channel_aio_send = dlsym(handle, "meshlink_channel_aio_send")); + assert(full_meshlink_channel_aio_fd_send = dlsym(handle, "meshlink_channel_aio_fd_send")); + assert(full_meshlink_channel_aio_receive = dlsym(handle, "meshlink_channel_aio_receive")); + assert(full_meshlink_channel_aio_fd_receive = dlsym(handle, "meshlink_channel_aio_fd_receive")); + assert(full_meshlink_channel_get_flags = dlsym(handle, "meshlink_channel_get_flags")); + assert(full_meshlink_channel_get_sendq = dlsym(handle, "meshlink_channel_get_sendq")); + assert(full_meshlink_channel_get_recvq = dlsym(handle, "meshlink_channel_get_recvq")); + assert(full_meshlink_channel_get_mss = dlsym(handle, "meshlink_channel_get_mss")); + assert(full_meshlink_set_node_channel_timeout = dlsym(handle, "meshlink_set_node_channel_timeout")); + assert(full_meshlink_hint_address = dlsym(handle, "meshlink_hint_address")); + assert(full_meshlink_enable_discovery = dlsym(handle, "meshlink_enable_discovery")); + assert(full_meshlink_hint_network_change = dlsym(handle, "meshlink_hint_network_change")); + assert(full_meshlink_encrypted_key_rotate = dlsym(handle, "meshlink_encrypted_key_rotate")); + assert(full_meshlink_set_dev_class_timeouts = dlsym(handle, "meshlink_set_dev_class_timeouts")); + assert(full_meshlink_set_dev_class_fast_retry_period = dlsym(handle, "meshlink_set_dev_class_fast_retry_period")); + assert(full_meshlink_set_dev_class_maxtimeout = dlsym(handle, "meshlink_set_dev_class_maxtimeout")); + assert(full_meshlink_reset_timers = dlsym(handle, "meshlink_reset_timers")); + assert(full_meshlink_set_inviter_commits_first = dlsym(handle, "meshlink_set_inviter_commits_first")); + assert(full_meshlink_set_external_address_discovery_url = dlsym(handle, "meshlink_set_external_address_discovery_url")); + assert(full_meshlink_set_scheduling_granularity = dlsym(handle, "meshlink_set_scheduling_granularity")); + assert(full_meshlink_set_storage_policy = dlsym(handle, "meshlink_set_storage_policy")); - full_devtool_set_inviter_commits_first = dlsym(handle, "devtool_set_inviter_commits_first"); + assert(full_devtool_set_inviter_commits_first = dlsym(handle, "devtool_set_inviter_commits_first")); + assert(full_devtool_reset_node_counters = dlsym(handle, "devtool_reset_node_counters")); } diff --git a/test/full.h b/test/full.h index 93f5a1d..4dd7e62 100644 --- a/test/full.h +++ b/test/full.h @@ -16,6 +16,31 @@ struct meshlink_submesh { void *priv; ///< Private pointer which may be set freely by the application, and is never used or modified by MeshLink. }; +/// The status of a node. +struct devtool_node_status { + uint32_t status; + struct sockaddr_storage address; + uint16_t mtu; + uint16_t minmtu; + uint16_t maxmtu; + int mtuprobes; + + enum { + DEVTOOL_UDP_FAILED = -2, /// UDP tried but failed + DEVTOOL_UDP_IMPOSSIBLE = -1, /// UDP not possible (node unreachable) + DEVTOOL_UDP_UNKNOWN = 0, /// UDP status not known (never tried to communicate with the node) + DEVTOOL_UDP_TRYING, /// UDP detection in progress + DEVTOOL_UDP_WORKING, /// UDP communication established + } udp_status; + + uint64_t in_data; /// Bytes received from channels + uint64_t out_data; /// Bytes sent via channels + uint64_t in_forward; /// Bytes received for channels that need to be forwarded to other nodes + uint64_t out_forward; /// Bytes forwarded from channel from other nodes + uint64_t in_meta; /// Bytes received from meta-connections, heartbeat packets etc. + uint64_t out_meta; /// Bytes sent on meta-connections, heartbeat packets etc. +}; + typedef void (*meshlink_node_pmtu_cb_t)(struct meshlink_handle *mesh, struct meshlink_node *node, uint16_t pmtu); typedef void (*meshlink_blacklisted_cb_t)(struct meshlink_handle *mesh, struct meshlink_node *node); typedef bool (*meshlink_channel_listen_cb_t)(struct meshlink_handle *mesh, struct meshlink_node *node, uint16_t port); @@ -129,6 +154,7 @@ extern void (*full_meshlink_set_storage_policy)(struct meshlink_handle *mesh, me typedef void (*full_devtool_set_inviter_commits_first_t)(bool inviter_commited_first); extern full_devtool_set_inviter_commits_first_t *full_devtool_set_inviter_commits_first; +extern void (*full_devtool_reset_node_counters)(struct meshlink_handle *mesh, meshlink_node_t *node, struct devtool_node_status *); void init_full(void); #endif