1 #ifndef MESHLINK_DEVTOOLS_H
2 #define MESHLINK_DEVTOOLS_H
5 devtools.h -- header for devtools.h
6 Copyright (C) 2014, 2017 Guus Sliepen <guus@meshlink.io>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 /** This header files declares functions that are only intended for debugging and quality control.
25 * They are not necessary for the normal operation of MeshLink.
26 * Applications should not depend on any of these functions for their normal operation.
29 /// Open a MeshLink instance in a given network namespace.
30 /** This function opens MeshLink in the given network namespace.
32 * @param confbase The directory in which MeshLink will store its configuration files.
33 * After the function returns, the application is free to overwrite or free @a confbase @a.
34 * @param name The name which this instance of the application will use in the mesh.
35 * After the function returns, the application is free to overwrite or free @a name @a.
36 * @param appname The application name which will be used in the mesh.
37 * After the function returns, the application is free to overwrite or free @a name @a.
38 * @param devclass The device class which will be used in the mesh.
39 * @param netns A filedescriptor that represents the network namespace.
41 * @return A pointer to a meshlink_handle_t which represents this instance of MeshLink, or NULL in case of an error.
42 * The pointer is valid until meshlink_close() is called.
44 meshlink_handle_t *devtool_open_in_netns(const char *confbase, const char *name, const char *appname, dev_class_t devclass, int netns);
46 /// Debug function pointer variable for set port API
47 /** This function pointer variable is a userspace tracepoint or debugger callback for
48 * set port function @a meshlink_set_port @a.
49 * On assigning a debug function variable invokes callback when try_bind() succeeds in meshlink_set_port API.
52 extern void (*devtool_trybind_probe)(void);
54 /// Debug function pointer variable for encrypted key rotate API
55 /** This function pointer variable is a userspace tracepoint or debugger callback for
56 * encrypted key rotation function @a meshlink_encrypted_key_rotate @a.
57 * On assigning a debug function variable invokes callback for each stage from the key rotate API.
59 * @param stage Debug stage number.
61 extern void (*devtool_keyrotate_probe)(int stage);
63 /// Debug function pointer variable for SPTPS key renewal
64 /** This function pointer variable is a userspace tracepoint or debugger callback for
67 * @param node The node whose SPTPS key(s) are being renewed
69 extern void (*devtool_sptps_renewal_probe)(meshlink_node_t *node);
71 /// Force renewal of SPTPS sessions with the given node.
72 /** This causes the SPTPS sessions for both the UDP and TCP connections to renew their keys.
74 * @param mesh A handle which represents an instance of MeshLink.
75 * @param node The node whose SPTPS key(s) should be renewed
77 void devtool_force_sptps_renewal(meshlink_handle_t *mesh, meshlink_node_t *node);
79 /// Debug function pointer variable for asserting inviter/invitee committing sequence
80 /** This function pointer variable is a userspace tracepoint or debugger callback which
81 * invokes either after inviter writing invitees host file into the disk
82 * or after invitee writing it's main config file and host config files that inviter sent into
85 * @param inviter_commited_first true if inviter committed first else false if invitee committed first the other host file into the disk.
87 extern void (*devtool_set_inviter_commits_first)(bool inviter_commited_first);
89 /// Set the meta-connection status callback.
90 /** This functions sets the callback that is called whenever a meta-connection is made or closed.
91 * The callback is run in MeshLink's own thread.
92 * It is therefore important that the callback uses apprioriate methods (queues, pipes, locking, etc.)
93 * to hand the data over to the application's thread.
94 * The callback should also not block itself and return as quickly as possible.
96 * \memberof meshlink_handle
97 * @param mesh A handle which represents an instance of MeshLink.
98 * @param cb A pointer to the function which will be called when a node's meta-connection status changes.
99 * If a NULL pointer is given, the callback will be disabled.
101 void devtool_set_meta_status_cb(struct meshlink_handle *mesh, meshlink_node_status_cb_t cb);