Minor tweak to callback function name for clarity (in code and documentation)
This commit is contained in:
@@ -66,7 +66,7 @@ At this stage, if a cryptographic identity for this node does not already exist
|
|||||||
|
|
||||||
bool networkReady = false;
|
bool networkReady = false;
|
||||||
|
|
||||||
void myZeroTierEventCallback(struct zts_callback_msg *msg)
|
void on_zts_event(struct zts_callback_msg *msg)
|
||||||
{
|
{
|
||||||
if (msg->eventCode == ZTS_EVENT_NODE_ONLINE) {
|
if (msg->eventCode == ZTS_EVENT_NODE_ONLINE) {
|
||||||
printf("ZTS_EVENT_NODE_ONLINE, nodeId=%llx\n", msg->node->address);
|
printf("ZTS_EVENT_NODE_ONLINE, nodeId=%llx\n", msg->node->address);
|
||||||
@@ -77,7 +77,7 @@ void myZeroTierEventCallback(struct zts_callback_msg *msg)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
zts_start("configPath", &myZeroTierEventCallback, 9994);
|
zts_start("configPath", &on_zts_event, 9994);
|
||||||
uint64_t nwid = 0x0123456789abcdef;
|
uint64_t nwid = 0x0123456789abcdef;
|
||||||
while (!networkReady) { sleep(1); }
|
while (!networkReady) { sleep(1); }
|
||||||
zts_join(nwid);
|
zts_join(nwid);
|
||||||
@@ -138,7 +138,7 @@ struct zts_callback_msg
|
|||||||
Here's an example of a callback function:
|
Here's an example of a callback function:
|
||||||
|
|
||||||
```
|
```
|
||||||
void myZeroTierEventCallback(struct zts_callback_msg *msg)
|
void on_zts_event(struct zts_callback_msg *msg)
|
||||||
{
|
{
|
||||||
if (msg->eventCode == ZTS_EVENT_NODE_ONLINE) {
|
if (msg->eventCode == ZTS_EVENT_NODE_ONLINE) {
|
||||||
printf("ZTS_EVENT_NODE_ONLINE, node=%llx\n", msg->node->address);
|
printf("ZTS_EVENT_NODE_ONLINE, node=%llx\n", msg->node->address);
|
||||||
|
|||||||
BIN
README.pdf
BIN
README.pdf
Binary file not shown.
@@ -104,7 +104,7 @@ struct Node
|
|||||||
to ensure timely receipt of future events. You should not call libzt API functions from
|
to ensure timely receipt of future events. You should not call libzt API functions from
|
||||||
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
||||||
no state-change implications. */
|
no state-change implications. */
|
||||||
void myZeroTierEventCallback(void *msgPtr)
|
void on_zts_event(void *msgPtr)
|
||||||
{
|
{
|
||||||
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ int main(int argc, char **argv)
|
|||||||
// If disabled: Settings will NOT be read from local.conf
|
// If disabled: Settings will NOT be read from local.conf
|
||||||
zts_allow_local_conf(1);
|
zts_allow_local_conf(1);
|
||||||
|
|
||||||
if((err = zts_start(argv[1], &myZeroTierEventCallback, ztServicePort)) != ZTS_ERR_OK) {
|
if((err = zts_start(argv[1], &on_zts_event, ztServicePort)) != ZTS_ERR_OK) {
|
||||||
printf("Unable to start service, error = %d. Exiting.\n", err);
|
printf("Unable to start service, error = %d. Exiting.\n", err);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ struct Node
|
|||||||
to ensure timely receipt of future events. You should not call libzt API functions from
|
to ensure timely receipt of future events. You should not call libzt API functions from
|
||||||
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
||||||
no state-change implications. */
|
no state-change implications. */
|
||||||
void myZeroTierEventCallback(void *msgPtr)
|
void on_zts_event(void *msgPtr)
|
||||||
{
|
{
|
||||||
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ int main(int argc, char **argv)
|
|||||||
// If disabled: Settings will NOT be read from local.conf
|
// If disabled: Settings will NOT be read from local.conf
|
||||||
zts_allow_local_conf(1);
|
zts_allow_local_conf(1);
|
||||||
|
|
||||||
if((err = zts_start(argv[1], &myZeroTierEventCallback, ztServicePort)) != ZTS_ERR_OK) {
|
if((err = zts_start(argv[1], &on_zts_event, ztServicePort)) != ZTS_ERR_OK) {
|
||||||
printf("Unable to start service, error = %d. Exiting.\n", err);
|
printf("Unable to start service, error = %d. Exiting.\n", err);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ void printNetifDetails(const char *msgStr, struct zts_netif_details *d)
|
|||||||
to ensure timely receipt of future events. You should not call libzt API functions from
|
to ensure timely receipt of future events. You should not call libzt API functions from
|
||||||
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
||||||
no state-change implications. */
|
no state-change implications. */
|
||||||
void myZeroTierEventCallback(void *msgPtr)
|
void on_zts_event(void *msgPtr)
|
||||||
{
|
{
|
||||||
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
||||||
printf("eventCode=%d\n", msg->eventCode);
|
printf("eventCode=%d\n", msg->eventCode);
|
||||||
@@ -393,7 +393,7 @@ int main(int argc, char **argv)
|
|||||||
// If disabled: Settings will NOT be read from local.conf
|
// If disabled: Settings will NOT be read from local.conf
|
||||||
zts_allow_local_conf(1);
|
zts_allow_local_conf(1);
|
||||||
|
|
||||||
if((err = zts_start(configPath.c_str(), &myZeroTierEventCallback, ztServicePort)) != ZTS_ERR_OK) {
|
if((err = zts_start(configPath.c_str(), &on_zts_event, ztServicePort)) != ZTS_ERR_OK) {
|
||||||
printf("Unable to start service, error = %d. Exiting.\n", err);
|
printf("Unable to start service, error = %d. Exiting.\n", err);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ struct Node
|
|||||||
to ensure timely receipt of future events. You should not call libzt API functions from
|
to ensure timely receipt of future events. You should not call libzt API functions from
|
||||||
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
||||||
no state-change implications. */
|
no state-change implications. */
|
||||||
void myZeroTierEventCallback(void *msgPtr)
|
void on_zts_event(void *msgPtr)
|
||||||
{
|
{
|
||||||
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ int main(int argc, char **argv)
|
|||||||
// If disabled: Settings will NOT be read from local.conf
|
// If disabled: Settings will NOT be read from local.conf
|
||||||
zts_allow_local_conf(1);
|
zts_allow_local_conf(1);
|
||||||
|
|
||||||
if((err = zts_start(argv[1], &myZeroTierEventCallback, ztServicePort)) != ZTS_ERR_OK) {
|
if((err = zts_start(argv[1], &on_zts_event, ztServicePort)) != ZTS_ERR_OK) {
|
||||||
printf("Unable to start service, error = %d. Exiting.\n", err);
|
printf("Unable to start service, error = %d. Exiting.\n", err);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ struct Node
|
|||||||
to ensure timely receipt of future events. You should not call libzt API functions from
|
to ensure timely receipt of future events. You should not call libzt API functions from
|
||||||
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
||||||
no state-change implications. */
|
no state-change implications. */
|
||||||
void myZeroTierEventCallback(void *msgPtr)
|
void on_zts_event(void *msgPtr)
|
||||||
{
|
{
|
||||||
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ int main(int argc, char **argv)
|
|||||||
// If disabled: Settings will NOT be read from local.conf
|
// If disabled: Settings will NOT be read from local.conf
|
||||||
zts_allow_local_conf(1);
|
zts_allow_local_conf(1);
|
||||||
|
|
||||||
if((err = zts_start(argv[1], &myZeroTierEventCallback, ztServicePort)) != ZTS_ERR_OK) {
|
if((err = zts_start(argv[1], &on_zts_event, ztServicePort)) != ZTS_ERR_OK) {
|
||||||
printf("Unable to start service, error = %d. Exiting.\n", err);
|
printf("Unable to start service, error = %d. Exiting.\n", err);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ struct Node
|
|||||||
to ensure timely receipt of future events. You should not call libzt API functions from
|
to ensure timely receipt of future events. You should not call libzt API functions from
|
||||||
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
||||||
no state-change implications. */
|
no state-change implications. */
|
||||||
void myZeroTierEventCallback(void *msgPtr)
|
void on_zts_event(void *msgPtr)
|
||||||
{
|
{
|
||||||
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ int main(int argc, char **argv)
|
|||||||
// If disabled: Settings will NOT be read from local.conf
|
// If disabled: Settings will NOT be read from local.conf
|
||||||
zts_allow_local_conf(1);
|
zts_allow_local_conf(1);
|
||||||
|
|
||||||
if((err = zts_start(argv[1], &myZeroTierEventCallback, ztServicePort)) != ZTS_ERR_OK) {
|
if((err = zts_start(argv[1], &on_zts_event, ztServicePort)) != ZTS_ERR_OK) {
|
||||||
printf("Unable to start service, error = %d. Exiting.\n", err);
|
printf("Unable to start service, error = %d. Exiting.\n", err);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ struct Node
|
|||||||
to ensure timely receipt of future events. You should not call libzt API functions from
|
to ensure timely receipt of future events. You should not call libzt API functions from
|
||||||
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
||||||
no state-change implications. */
|
no state-change implications. */
|
||||||
void myZeroTierEventCallback(void *msgPtr)
|
void on_zts_event(void *msgPtr)
|
||||||
{
|
{
|
||||||
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ int main(int argc, char **argv)
|
|||||||
// If disabled: Settings will NOT be read from local.conf
|
// If disabled: Settings will NOT be read from local.conf
|
||||||
zts_allow_local_conf(1);
|
zts_allow_local_conf(1);
|
||||||
|
|
||||||
if((err = zts_start(argv[1], &myZeroTierEventCallback, ztServicePort)) != ZTS_ERR_OK) {
|
if((err = zts_start(argv[1], &on_zts_event, ztServicePort)) != ZTS_ERR_OK) {
|
||||||
printf("Unable to start service, error = %d. Exiting.\n", err);
|
printf("Unable to start service, error = %d. Exiting.\n", err);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ struct Node
|
|||||||
to ensure timely receipt of future events. You should not call libzt API functions from
|
to ensure timely receipt of future events. You should not call libzt API functions from
|
||||||
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
this function unless it's something trivial like zts_inet_ntop() or similar that has
|
||||||
no state-change implications. */
|
no state-change implications. */
|
||||||
void myZeroTierEventCallback(void *msgPtr)
|
void on_zts_event(void *msgPtr)
|
||||||
{
|
{
|
||||||
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
struct zts_callback_msg *msg = (struct zts_callback_msg *)msgPtr;
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ public:
|
|||||||
|
|
||||||
int err = ZTS_ERR_OK;
|
int err = ZTS_ERR_OK;
|
||||||
|
|
||||||
if((err = zts_start(configPath, &myZeroTierEventCallback, servicePort)) != ZTS_ERR_OK) {
|
if((err = zts_start(configPath, &on_zts_event, servicePort)) != ZTS_ERR_OK) {
|
||||||
printf("Unable to start service, error = %d.\n", err);
|
printf("Unable to start service, error = %d.\n", err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ bool nodeReady = false;
|
|||||||
bool networkReady = false;
|
bool networkReady = false;
|
||||||
|
|
||||||
// Example callbacks
|
// Example callbacks
|
||||||
void myZeroTierEventCallback(struct zts_callback_msg *msg)
|
void on_zts_event(struct zts_callback_msg *msg)
|
||||||
{
|
{
|
||||||
// Node events
|
// Node events
|
||||||
if (msg->eventCode == ZTS_EVENT_NODE_ONLINE) {
|
if (msg->eventCode == ZTS_EVENT_NODE_ONLINE) {
|
||||||
@@ -213,7 +213,7 @@ int main(int argc, char **argv)
|
|||||||
// If disabled: Settings will NOT be read from local.conf
|
// If disabled: Settings will NOT be read from local.conf
|
||||||
zts_allow_local_conf(1);
|
zts_allow_local_conf(1);
|
||||||
|
|
||||||
if((err = zts_start(argv[1], &myZeroTierEventCallback, ztServicePort)) != ZTS_ERR_OK) {
|
if((err = zts_start(argv[1], &on_zts_event, ztServicePort)) != ZTS_ERR_OK) {
|
||||||
NSLog(@"Unable to start service, error = %d. Exiting.\n", err);
|
NSLog(@"Unable to start service, error = %d. Exiting.\n", err);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ let printNetifDetails : @convention(c) (UnsafeMutableRawPointer?) -> Void =
|
|||||||
var nodeReady:Bool = false
|
var nodeReady:Bool = false
|
||||||
var networkReady:Bool = false
|
var networkReady:Bool = false
|
||||||
|
|
||||||
let myZeroTierEventCallback : @convention(c) (UnsafeMutableRawPointer?) -> Void =
|
let on_zts_event : @convention(c) (UnsafeMutableRawPointer?) -> Void =
|
||||||
{
|
{
|
||||||
(msgPtr) -> Void in
|
(msgPtr) -> Void in
|
||||||
let msg = msgPtr?.bindMemory(to: zts_callback_msg.self, capacity: 1)
|
let msg = msgPtr?.bindMemory(to: zts_callback_msg.self, capacity: 1)
|
||||||
@@ -322,7 +322,7 @@ let myZeroTierEventCallback : @convention(c) (UnsafeMutableRawPointer?) -> Void
|
|||||||
func main()
|
func main()
|
||||||
{
|
{
|
||||||
print("waiting for node to come online...")
|
print("waiting for node to come online...")
|
||||||
zts_start("config_path", myZeroTierEventCallback, 0)
|
zts_start("config_path", on_zts_event, 0)
|
||||||
while(!nodeReady) {
|
while(!nodeReady) {
|
||||||
sleep(1)
|
sleep(1)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user