1 /* 2 * Copyright (c)2019 ZeroTier, Inc. 3 * 4 * Use of this software is governed by the Business Source License included 5 * in the LICENSE.TXT file in the project's root directory. 6 * 7 * Change Date: 2025-01-01 8 * 9 * On the date above, in accordance with the Business Source License, use 10 * of this software will be governed by version 2.0 of the Apache License. 11 */ 12 /****/ 13 14 /* 15 * This defines the external C API for ZeroTier's core network virtualization 16 * engine. 17 */ 18 19 #ifndef ZT_ZEROTIER_API_H 20 #define ZT_ZEROTIER_API_H 21 22 #include <stdint.h> 23 24 // For the struct sockaddr_storage structure 25 #if defined(_WIN32) || defined(_WIN64) 26 #include <WinSock2.h> 27 #include <WS2tcpip.h> 28 #include <Windows.h> 29 #else /* not Windows */ 30 #include <arpa/inet.h> 31 #include <netinet/in.h> 32 #include <sys/types.h> 33 #include <sys/socket.h> 34 #endif /* Windows or not */ 35 36 #if defined (_MSC_VER) 37 #ifdef ZT_EXPORT 38 #define ZT_SDK_API __declspec(dllexport) 39 #else 40 #define ZT_SDK_API __declspec(dllimport) 41 #if !defined(ZT_SDK) 42 #ifdef _DEBUG 43 #ifdef _WIN64 44 #pragma comment(lib, "ZeroTierOne_x64d.lib") 45 #else 46 #pragma comment(lib, "ZeroTierOne_x86d.lib") 47 #endif 48 #else 49 #ifdef _WIN64 50 #pragma comment(lib, "ZeroTierOne_x64.lib") 51 #else 52 #pragma comment(lib, "ZeroTierOne_x86.lib") 53 #endif 54 #endif 55 #endif 56 #endif 57 #else 58 #define ZT_SDK_API 59 #endif 60 61 #ifdef __cplusplus 62 extern "C" { 63 #endif 64 65 /****************************************************************************/ 66 /* Core constants */ 67 /****************************************************************************/ 68 69 /** 70 * Default UDP port for devices running a ZeroTier endpoint 71 */ 72 #define ZT_DEFAULT_PORT 9993 73 74 /** 75 * Minimum MTU, which is the minimum allowed by IPv6 and several specs 76 */ 77 #define ZT_MIN_MTU 1280 78 79 /** 80 * Maximum MTU for ZeroTier virtual networks 81 */ 82 #define ZT_MAX_MTU 10000 83 84 /** 85 * Minimum UDP payload size allowed 86 */ 87 #define ZT_MIN_PHYSMTU 1400 88 89 /** 90 * Default UDP payload size (physical path MTU) not including UDP and IP overhead 91 * 92 * This is small enough for PPPoE and for Google Cloud's bizarrely tiny MTUs. 93 * A 2800 byte payload still fits into two packets, so this should not impact 94 * real world throughput at all vs the previous default of 1444. 95 */ 96 #define ZT_DEFAULT_PHYSMTU 1432 97 98 /** 99 * Maximum physical UDP payload 100 */ 101 #define ZT_MAX_PHYSPAYLOAD 10100 102 103 /** 104 * Headroom for max physical MTU 105 */ 106 #define ZT_MAX_HEADROOM 224 107 108 /** 109 * Maximum payload MTU for UDP packets 110 */ 111 #define ZT_MAX_PHYSMTU (ZT_MAX_PHYSPAYLOAD + ZT_MAX_HEADROOM) 112 113 /** 114 * Maximum size of a remote trace message's serialized Dictionary 115 */ 116 #define ZT_MAX_REMOTE_TRACE_SIZE 10000 117 118 /** 119 * Maximum length of network short name 120 */ 121 #define ZT_MAX_NETWORK_SHORT_NAME_LENGTH 127 122 123 /** 124 * Maximum number of pushed routes on a network 125 */ 126 #define ZT_MAX_NETWORK_ROUTES 32 127 128 /** 129 * Maximum number of statically assigned IP addresses per network endpoint using ZT address management (not DHCP) 130 */ 131 #define ZT_MAX_ZT_ASSIGNED_ADDRESSES 16 132 133 /** 134 * Maximum number of "specialists" on a network -- bridges, relays, etc. 135 */ 136 #define ZT_MAX_NETWORK_SPECIALISTS 256 137 138 /** 139 * Maximum number of multicast group subscriptions per network 140 */ 141 #define ZT_MAX_NETWORK_MULTICAST_SUBSCRIPTIONS 4096 142 143 /** 144 * Rules engine revision ID, which specifies rules engine capabilities 145 */ 146 #define ZT_RULES_ENGINE_REVISION 1 147 148 /** 149 * Maximum number of base (non-capability) network rules 150 */ 151 #define ZT_MAX_NETWORK_RULES 1024 152 153 /** 154 * Maximum number of per-member capabilities per network 155 */ 156 #define ZT_MAX_NETWORK_CAPABILITIES 128 157 158 /** 159 * Maximum number of per-member tags per network 160 */ 161 #define ZT_MAX_NETWORK_TAGS 128 162 163 /** 164 * Maximum number of direct network paths to a given peer 165 */ 166 #define ZT_MAX_PEER_NETWORK_PATHS 16 167 168 /** 169 * Maximum number of path configurations that can be set 170 */ 171 #define ZT_MAX_CONFIGURABLE_PATHS 32 172 173 /** 174 * Maximum number of rules per capability 175 */ 176 #define ZT_MAX_CAPABILITY_RULES 64 177 178 /** 179 * Maximum number of certificates of ownership to assign to a single network member 180 */ 181 #define ZT_MAX_CERTIFICATES_OF_OWNERSHIP 4 182 183 /** 184 * Global maximum length for capability chain of custody (including initial issue) 185 */ 186 #define ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH 7 187 188 /** 189 * Maximum number of multicast groups a device / network interface can be subscribed to at once 190 */ 191 #define ZT_MAX_MULTICAST_SUBSCRIPTIONS 1024 192 193 /** 194 * Maximum value for link quality (min is 0) 195 */ 196 #define ZT_PATH_LINK_QUALITY_MAX 0xff 197 198 /** 199 * Maximum number of DNS servers per domain 200 */ 201 #define ZT_MAX_DNS_SERVERS 4 202 203 /** 204 * Packet characteristics flag: packet direction, 1 if inbound 0 if outbound 205 */ 206 #define ZT_RULE_PACKET_CHARACTERISTICS_INBOUND 0x8000000000000000ULL 207 208 /** 209 * Packet characteristics flag: multicast or broadcast destination MAC 210 */ 211 #define ZT_RULE_PACKET_CHARACTERISTICS_MULTICAST 0x4000000000000000ULL 212 213 /** 214 * Packet characteristics flag: broadcast destination MAC 215 */ 216 #define ZT_RULE_PACKET_CHARACTERISTICS_BROADCAST 0x2000000000000000ULL 217 218 /** 219 * Packet characteristics flag: sending IP address has a certificate of ownership 220 */ 221 #define ZT_RULE_PACKET_CHARACTERISTICS_SENDER_IP_AUTHENTICATED 0x1000000000000000ULL 222 223 /** 224 * Packet characteristics flag: sending MAC address has a certificate of ownership 225 */ 226 #define ZT_RULE_PACKET_CHARACTERISTICS_SENDER_MAC_AUTHENTICATED 0x0800000000000000ULL 227 228 /** 229 * Packet characteristics flag: TCP left-most reserved bit 230 */ 231 #define ZT_RULE_PACKET_CHARACTERISTICS_TCP_RESERVED_0 0x0000000000000800ULL 232 233 /** 234 * Packet characteristics flag: TCP middle reserved bit 235 */ 236 #define ZT_RULE_PACKET_CHARACTERISTICS_TCP_RESERVED_1 0x0000000000000400ULL 237 238 /** 239 * Packet characteristics flag: TCP right-most reserved bit 240 */ 241 #define ZT_RULE_PACKET_CHARACTERISTICS_TCP_RESERVED_2 0x0000000000000200ULL 242 243 /** 244 * Packet characteristics flag: TCP NS flag 245 */ 246 #define ZT_RULE_PACKET_CHARACTERISTICS_TCP_NS 0x0000000000000100ULL 247 248 /** 249 * Packet characteristics flag: TCP CWR flag 250 */ 251 #define ZT_RULE_PACKET_CHARACTERISTICS_TCP_CWR 0x0000000000000080ULL 252 253 /** 254 * Packet characteristics flag: TCP ECE flag 255 */ 256 #define ZT_RULE_PACKET_CHARACTERISTICS_TCP_ECE 0x0000000000000040ULL 257 258 /** 259 * Packet characteristics flag: TCP URG flag 260 */ 261 #define ZT_RULE_PACKET_CHARACTERISTICS_TCP_URG 0x0000000000000020ULL 262 263 /** 264 * Packet characteristics flag: TCP ACK flag 265 */ 266 #define ZT_RULE_PACKET_CHARACTERISTICS_TCP_ACK 0x0000000000000010ULL 267 268 /** 269 * Packet characteristics flag: TCP PSH flag 270 */ 271 #define ZT_RULE_PACKET_CHARACTERISTICS_TCP_PSH 0x0000000000000008ULL 272 273 /** 274 * Packet characteristics flag: TCP RST flag 275 */ 276 #define ZT_RULE_PACKET_CHARACTERISTICS_TCP_RST 0x0000000000000004ULL 277 278 /** 279 * Packet characteristics flag: TCP SYN flag 280 */ 281 #define ZT_RULE_PACKET_CHARACTERISTICS_TCP_SYN 0x0000000000000002ULL 282 283 /** 284 * Packet characteristics flag: TCP FIN flag 285 */ 286 #define ZT_RULE_PACKET_CHARACTERISTICS_TCP_FIN 0x0000000000000001ULL 287 288 // Fields in remote trace dictionaries 289 #define ZT_REMOTE_TRACE_FIELD__EVENT "event" 290 #define ZT_REMOTE_TRACE_FIELD__NODE_ID "nodeId" 291 #define ZT_REMOTE_TRACE_FIELD__PACKET_ID "packetId" 292 #define ZT_REMOTE_TRACE_FIELD__PACKET_VERB "packetVerb" 293 #define ZT_REMOTE_TRACE_FIELD__PACKET_TRUSTED_PATH_ID "packetTrustedPathId" 294 #define ZT_REMOTE_TRACE_FIELD__PACKET_TRUSTED_PATH_APPROVED "packetTrustedPathApproved" 295 #define ZT_REMOTE_TRACE_FIELD__PACKET_HOPS "packetHops" 296 #define ZT_REMOTE_TRACE_FIELD__REMOTE_ZTADDR "remoteZtAddr" 297 #define ZT_REMOTE_TRACE_FIELD__REMOTE_PHYADDR "remotePhyAddr" 298 #define ZT_REMOTE_TRACE_FIELD__LOCAL_ZTADDR "localZtAddr" 299 #define ZT_REMOTE_TRACE_FIELD__LOCAL_PHYADDR "localPhyAddr" 300 #define ZT_REMOTE_TRACE_FIELD__LOCAL_SOCKET "localSocket" 301 #define ZT_REMOTE_TRACE_FIELD__IP_SCOPE "phyAddrIpScope" 302 #define ZT_REMOTE_TRACE_FIELD__NETWORK_ID "networkId" 303 #define ZT_REMOTE_TRACE_FIELD__SOURCE_ZTADDR "sourceZtAddr" 304 #define ZT_REMOTE_TRACE_FIELD__DEST_ZTADDR "destZtAddr" 305 #define ZT_REMOTE_TRACE_FIELD__SOURCE_MAC "sourceMac" 306 #define ZT_REMOTE_TRACE_FIELD__DEST_MAC "destMac" 307 #define ZT_REMOTE_TRACE_FIELD__ETHERTYPE "etherType" 308 #define ZT_REMOTE_TRACE_FIELD__VLAN_ID "vlanId" 309 #define ZT_REMOTE_TRACE_FIELD__FRAME_LENGTH "frameLength" 310 #define ZT_REMOTE_TRACE_FIELD__FRAME_DATA "frameData" 311 #define ZT_REMOTE_TRACE_FIELD__FILTER_FLAG_NOTEE "filterNoTee" 312 #define ZT_REMOTE_TRACE_FIELD__FILTER_FLAG_INBOUND "filterInbound" 313 #define ZT_REMOTE_TRACE_FIELD__FILTER_RESULT "filterResult" 314 #define ZT_REMOTE_TRACE_FIELD__FILTER_BASE_RULE_LOG "filterBaseRuleLog" 315 #define ZT_REMOTE_TRACE_FIELD__FILTER_CAP_RULE_LOG "filterCapRuleLog" 316 #define ZT_REMOTE_TRACE_FIELD__FILTER_CAP_ID "filterMatchingCapId" 317 #define ZT_REMOTE_TRACE_FIELD__CREDENTIAL_TYPE "credType" 318 #define ZT_REMOTE_TRACE_FIELD__CREDENTIAL_ID "credId" 319 #define ZT_REMOTE_TRACE_FIELD__CREDENTIAL_TIMESTAMP "credTs" 320 #define ZT_REMOTE_TRACE_FIELD__CREDENTIAL_INFO "credInfo" 321 #define ZT_REMOTE_TRACE_FIELD__CREDENTIAL_ISSUED_TO "credIssuedTo" 322 #define ZT_REMOTE_TRACE_FIELD__CREDENTIAL_REVOCATION_TARGET "credRevocationTarget" 323 #define ZT_REMOTE_TRACE_FIELD__REASON "reason" 324 #define ZT_REMOTE_TRACE_FIELD__NETWORK_CONTROLLER_ID "networkControllerId" 325 326 // Event types in remote traces 327 #define ZT_REMOTE_TRACE_EVENT__RESETTING_PATHS_IN_SCOPE 0x1000 328 #define ZT_REMOTE_TRACE_EVENT__PEER_CONFIRMING_UNKNOWN_PATH 0x1001 329 #define ZT_REMOTE_TRACE_EVENT__PEER_LEARNED_NEW_PATH 0x1002 330 #define ZT_REMOTE_TRACE_EVENT__PEER_REDIRECTED 0x1003 331 #define ZT_REMOTE_TRACE_EVENT__PACKET_MAC_FAILURE 0x1004 332 #define ZT_REMOTE_TRACE_EVENT__PACKET_INVALID 0x1005 333 #define ZT_REMOTE_TRACE_EVENT__DROPPED_HELLO 0x1006 334 #define ZT_REMOTE_TRACE_EVENT__OUTGOING_NETWORK_FRAME_DROPPED 0x2000 335 #define ZT_REMOTE_TRACE_EVENT__INCOMING_NETWORK_ACCESS_DENIED 0x2001 336 #define ZT_REMOTE_TRACE_EVENT__INCOMING_NETWORK_FRAME_DROPPED 0x2002 337 #define ZT_REMOTE_TRACE_EVENT__CREDENTIAL_REJECTED 0x2003 338 #define ZT_REMOTE_TRACE_EVENT__CREDENTIAL_ACCEPTED 0x2004 339 #define ZT_REMOTE_TRACE_EVENT__NETWORK_CONFIG_REQUEST_SENT 0x2005 340 #define ZT_REMOTE_TRACE_EVENT__NETWORK_FILTER_TRACE 0x2006 341 342 // Event types in remote traces in hex string form 343 #define ZT_REMOTE_TRACE_EVENT__RESETTING_PATHS_IN_SCOPE_S "1000" 344 #define ZT_REMOTE_TRACE_EVENT__PEER_CONFIRMING_UNKNOWN_PATH_S "1001" 345 #define ZT_REMOTE_TRACE_EVENT__PEER_LEARNED_NEW_PATH_S "1002" 346 #define ZT_REMOTE_TRACE_EVENT__PEER_REDIRECTED_S "1003" 347 #define ZT_REMOTE_TRACE_EVENT__PACKET_MAC_FAILURE_S "1004" 348 #define ZT_REMOTE_TRACE_EVENT__PACKET_INVALID_S "1005" 349 #define ZT_REMOTE_TRACE_EVENT__DROPPED_HELLO_S "1006" 350 #define ZT_REMOTE_TRACE_EVENT__OUTGOING_NETWORK_FRAME_DROPPED_S "2000" 351 #define ZT_REMOTE_TRACE_EVENT__INCOMING_NETWORK_ACCESS_DENIED_S "2001" 352 #define ZT_REMOTE_TRACE_EVENT__INCOMING_NETWORK_FRAME_DROPPED_S "2002" 353 #define ZT_REMOTE_TRACE_EVENT__CREDENTIAL_REJECTED_S "2003" 354 #define ZT_REMOTE_TRACE_EVENT__CREDENTIAL_ACCEPTED_S "2004" 355 #define ZT_REMOTE_TRACE_EVENT__NETWORK_CONFIG_REQUEST_SENT_S "2005" 356 #define ZT_REMOTE_TRACE_EVENT__NETWORK_FILTER_TRACE_S "2006" 357 358 /****************************************************************************/ 359 /* Structures and other types */ 360 /****************************************************************************/ 361 362 /** 363 * Function return code: OK (0) or error results 364 * 365 * Use ZT_ResultCode_isFatal() to check for a fatal error. If a fatal error 366 * occurs, the node should be considered to not be working correctly. These 367 * indicate serious problems like an inaccessible data store or a compile 368 * problem. 369 */ 370 enum ZT_ResultCode 371 { 372 /** 373 * Operation completed normally 374 */ 375 ZT_RESULT_OK = 0, 376 377 /** 378 * Call produced no error but no action was taken 379 */ 380 ZT_RESULT_OK_IGNORED = 1, 381 382 // Fatal errors (>100, <1000) 383 384 /** 385 * Ran out of memory 386 */ 387 ZT_RESULT_FATAL_ERROR_OUT_OF_MEMORY = 100, 388 389 /** 390 * Data store is not writable or has failed 391 */ 392 ZT_RESULT_FATAL_ERROR_DATA_STORE_FAILED = 101, 393 394 /** 395 * Internal error (e.g. unexpected exception indicating bug or build problem) 396 */ 397 ZT_RESULT_FATAL_ERROR_INTERNAL = 102, 398 399 // Non-fatal errors (>1000) 400 401 /** 402 * Network ID not valid 403 */ 404 ZT_RESULT_ERROR_NETWORK_NOT_FOUND = 1000, 405 406 /** 407 * The requested operation is not supported on this version or build 408 */ 409 ZT_RESULT_ERROR_UNSUPPORTED_OPERATION = 1001, 410 411 /** 412 * The requested operation was given a bad parameter or was called in an invalid state 413 */ 414 ZT_RESULT_ERROR_BAD_PARAMETER = 1002 415 }; 416 417 /** 418 * @param x Result code 419 * @return True if result code indicates a fatal error 420 */ 421 #define ZT_ResultCode_isFatal(x) ((((int)(x)) >= 100)&&(((int)(x)) < 1000)) 422 423 /** 424 * Status codes sent to status update callback when things happen 425 */ 426 enum ZT_Event 427 { 428 /** 429 * Node has been initialized 430 * 431 * This is the first event generated, and is always sent. It may occur 432 * before Node's constructor returns. 433 * 434 * Meta-data: none 435 */ 436 ZT_EVENT_UP = 0, 437 438 /** 439 * Node is offline -- network does not seem to be reachable by any available strategy 440 * 441 * Meta-data: none 442 */ 443 ZT_EVENT_OFFLINE = 1, 444 445 /** 446 * Node is online -- at least one upstream node appears reachable 447 * 448 * Meta-data: none 449 */ 450 ZT_EVENT_ONLINE = 2, 451 452 /** 453 * Node is shutting down 454 * 455 * This is generated within Node's destructor when it is being shut down. 456 * It's done for convenience, since cleaning up other state in the event 457 * handler may appear more idiomatic. 458 * 459 * Meta-data: none 460 */ 461 ZT_EVENT_DOWN = 3, 462 463 /** 464 * Your identity has collided with another node's ZeroTier address 465 * 466 * This happens if two different public keys both hash (via the algorithm 467 * in Identity::generate()) to the same 40-bit ZeroTier address. 468 * 469 * This is something you should "never" see, where "never" is defined as 470 * once per 2^39 new node initializations / identity creations. If you do 471 * see it, you're going to see it very soon after a node is first 472 * initialized. 473 * 474 * This is reported as an event rather than a return code since it's 475 * detected asynchronously via error messages from authoritative nodes. 476 * 477 * If this occurs, you must shut down and delete the node, delete the 478 * identity.secret record/file from the data store, and restart to generate 479 * a new identity. If you don't do this, you will not be able to communicate 480 * with other nodes. 481 * 482 * We'd automate this process, but we don't think silently deleting 483 * private keys or changing our address without telling the calling code 484 * is good form. It violates the principle of least surprise. 485 * 486 * You can technically get away with not handling this, but we recommend 487 * doing so in a mature reliable application. Besides, handling this 488 * condition is a good way to make sure it never arises. It's like how 489 * umbrellas prevent rain and smoke detectors prevent fires. They do, right? 490 * 491 * Meta-data: none 492 */ 493 ZT_EVENT_FATAL_ERROR_IDENTITY_COLLISION = 4, 494 495 /** 496 * Trace (debugging) message 497 * 498 * These events are only generated if this is a TRACE-enabled build. 499 * 500 * Meta-data: C string, TRACE message 501 */ 502 ZT_EVENT_TRACE = 5, 503 504 /** 505 * VERB_USER_MESSAGE received 506 * 507 * These are generated when a VERB_USER_MESSAGE packet is received via 508 * ZeroTier VL1. 509 * 510 * Meta-data: ZT_UserMessage structure 511 */ 512 ZT_EVENT_USER_MESSAGE = 6, 513 514 /** 515 * Remote trace received 516 * 517 * These are generated when a VERB_REMOTE_TRACE is received. Note 518 * that any node can fling one of these at us. It is your responsibility 519 * to filter and determine if it's worth paying attention to. If it's 520 * not just drop it. Most nodes that are not active controllers ignore 521 * these, and controllers only save them if they pertain to networks 522 * with remote tracing enabled. 523 * 524 * Meta-data: ZT_RemoteTrace structure 525 */ 526 ZT_EVENT_REMOTE_TRACE = 7 527 }; 528 529 /** 530 * Payload of REMOTE_TRACE event 531 */ 532 typedef struct 533 { 534 /** 535 * ZeroTier address of sender 536 */ 537 uint64_t origin; 538 539 /** 540 * Null-terminated Dictionary containing key/value pairs sent by origin 541 * 542 * This *should* be a dictionary, but the implementation only checks 543 * that it is a valid non-empty C-style null-terminated string. Be very 544 * careful to use a well-tested parser to parse this as it represents 545 * data received from a potentially un-trusted peer on the network. 546 * Invalid payloads should be dropped. 547 * 548 * The contents of data[] may be modified. 549 */ 550 char *data; 551 552 /** 553 * Length of dict[] in bytes, including terminating null 554 */ 555 unsigned int len; 556 } ZT_RemoteTrace; 557 558 /** 559 * User message used with ZT_EVENT_USER_MESSAGE 560 * 561 * These are direct VL1 P2P messages for application use. Encryption and 562 * authentication in the ZeroTier protocol will guarantee the origin 563 * address and message content, but you are responsible for any other 564 * levels of authentication or access control that are required. Any node 565 * in the world can send you a user message! (Unless your network is air 566 * gapped.) 567 */ 568 typedef struct 569 { 570 /** 571 * ZeroTier address of sender (least significant 40 bits) 572 */ 573 uint64_t origin; 574 575 /** 576 * User message type ID 577 */ 578 uint64_t typeId; 579 580 /** 581 * User message data (not including type ID) 582 */ 583 const void *data; 584 585 /** 586 * Length of data in bytes 587 */ 588 unsigned int length; 589 } ZT_UserMessage; 590 591 /** 592 * Current node status 593 */ 594 typedef struct 595 { 596 /** 597 * 40-bit ZeroTier address of this node 598 */ 599 uint64_t address; 600 601 /** 602 * Public identity in string-serialized form (safe to send to others) 603 * 604 * This pointer will remain valid as long as the node exists. 605 */ 606 const char *publicIdentity; 607 608 /** 609 * Full identity including secret key in string-serialized form 610 * 611 * This pointer will remain valid as long as the node exists. 612 */ 613 const char *secretIdentity; 614 615 /** 616 * True if some kind of connectivity appears available 617 */ 618 int online; 619 } ZT_NodeStatus; 620 621 /** 622 * Internal node statistics 623 * 624 * This structure is subject to change between versions. 625 */ 626 typedef struct 627 { 628 /** 629 * Number of each protocol verb (possible verbs 0..31) received 630 */ 631 uint64_t inVerbCounts[32]; 632 633 /** 634 * Number of bytes for each protocol verb received 635 */ 636 uint64_t inVerbBytes[32]; 637 } ZT_NodeStatistics; 638 639 /** 640 * Virtual network status codes 641 */ 642 enum ZT_VirtualNetworkStatus 643 { 644 /** 645 * Waiting for network configuration (also means revision == 0) 646 */ 647 ZT_NETWORK_STATUS_REQUESTING_CONFIGURATION = 0, 648 649 /** 650 * Configuration received and we are authorized 651 */ 652 ZT_NETWORK_STATUS_OK = 1, 653 654 /** 655 * Netconf master told us 'nope' 656 */ 657 ZT_NETWORK_STATUS_ACCESS_DENIED = 2, 658 659 /** 660 * Netconf master exists, but this virtual network does not 661 */ 662 ZT_NETWORK_STATUS_NOT_FOUND = 3, 663 664 /** 665 * Initialization of network failed or other internal error 666 */ 667 ZT_NETWORK_STATUS_PORT_ERROR = 4, 668 669 /** 670 * ZeroTier core version too old 671 */ 672 ZT_NETWORK_STATUS_CLIENT_TOO_OLD = 5, 673 674 /** 675 * External authentication is required (e.g. SSO) 676 */ 677 ZT_NETWORK_STATUS_AUTHENTICATION_REQUIRED = 6 678 }; 679 680 /** 681 * Virtual network type codes 682 */ 683 enum ZT_VirtualNetworkType 684 { 685 /** 686 * Private networks are authorized via certificates of membership 687 */ 688 ZT_NETWORK_TYPE_PRIVATE = 0, 689 690 /** 691 * Public networks have no access control -- they'll always be AUTHORIZED 692 */ 693 ZT_NETWORK_TYPE_PUBLIC = 1 694 }; 695 696 /** 697 * The type of a virtual network rules table entry 698 * 699 * These must be from 0 to 63 since the most significant two bits of each 700 * rule type are NOT (MSB) and AND/OR. 701 * 702 * Each rule is composed of zero or more MATCHes followed by an ACTION. 703 * An ACTION with no MATCHes is always taken. 704 */ 705 enum ZT_VirtualNetworkRuleType 706 { 707 // 0 to 15 reserved for actions 708 709 /** 710 * Drop frame 711 */ 712 ZT_NETWORK_RULE_ACTION_DROP = 0, 713 714 /** 715 * Accept and pass frame 716 */ 717 ZT_NETWORK_RULE_ACTION_ACCEPT = 1, 718 719 /** 720 * Forward a copy of this frame to an observer (by ZT address) 721 */ 722 ZT_NETWORK_RULE_ACTION_TEE = 2, 723 724 /** 725 * Exactly like TEE but mandates ACKs from observer 726 */ 727 ZT_NETWORK_RULE_ACTION_WATCH = 3, 728 729 /** 730 * Drop and redirect this frame to another node (by ZT address) 731 */ 732 ZT_NETWORK_RULE_ACTION_REDIRECT = 4, 733 734 /** 735 * Stop evaluating rule set (drops unless there are capabilities, etc.) 736 */ 737 ZT_NETWORK_RULE_ACTION_BREAK = 5, 738 739 /** 740 * Place a matching frame in the specified QoS bucket 741 */ 742 ZT_NETWORK_RULE_ACTION_PRIORITY = 6, 743 744 /** 745 * Maximum ID for an ACTION, anything higher is a MATCH 746 */ 747 ZT_NETWORK_RULE_ACTION__MAX_ID = 15, 748 749 // 16 to 63 reserved for match criteria 750 751 ZT_NETWORK_RULE_MATCH_SOURCE_ZEROTIER_ADDRESS = 24, 752 ZT_NETWORK_RULE_MATCH_DEST_ZEROTIER_ADDRESS = 25, 753 ZT_NETWORK_RULE_MATCH_VLAN_ID = 26, 754 ZT_NETWORK_RULE_MATCH_VLAN_PCP = 27, 755 ZT_NETWORK_RULE_MATCH_VLAN_DEI = 28, 756 ZT_NETWORK_RULE_MATCH_MAC_SOURCE = 29, 757 ZT_NETWORK_RULE_MATCH_MAC_DEST = 30, 758 ZT_NETWORK_RULE_MATCH_IPV4_SOURCE = 31, 759 ZT_NETWORK_RULE_MATCH_IPV4_DEST = 32, 760 ZT_NETWORK_RULE_MATCH_IPV6_SOURCE = 33, 761 ZT_NETWORK_RULE_MATCH_IPV6_DEST = 34, 762 ZT_NETWORK_RULE_MATCH_IP_TOS = 35, 763 ZT_NETWORK_RULE_MATCH_IP_PROTOCOL = 36, 764 ZT_NETWORK_RULE_MATCH_ETHERTYPE = 37, 765 ZT_NETWORK_RULE_MATCH_ICMP = 38, 766 ZT_NETWORK_RULE_MATCH_IP_SOURCE_PORT_RANGE = 39, 767 ZT_NETWORK_RULE_MATCH_IP_DEST_PORT_RANGE = 40, 768 ZT_NETWORK_RULE_MATCH_CHARACTERISTICS = 41, 769 ZT_NETWORK_RULE_MATCH_FRAME_SIZE_RANGE = 42, 770 ZT_NETWORK_RULE_MATCH_RANDOM = 43, 771 ZT_NETWORK_RULE_MATCH_TAGS_DIFFERENCE = 44, 772 ZT_NETWORK_RULE_MATCH_TAGS_BITWISE_AND = 45, 773 ZT_NETWORK_RULE_MATCH_TAGS_BITWISE_OR = 46, 774 ZT_NETWORK_RULE_MATCH_TAGS_BITWISE_XOR = 47, 775 ZT_NETWORK_RULE_MATCH_TAGS_EQUAL = 48, 776 ZT_NETWORK_RULE_MATCH_TAG_SENDER = 49, 777 ZT_NETWORK_RULE_MATCH_TAG_RECEIVER = 50, 778 ZT_NETWORK_RULE_MATCH_INTEGER_RANGE = 51, 779 780 /** 781 * Maximum ID allowed for a MATCH entry in the rules table 782 */ 783 ZT_NETWORK_RULE_MATCH__MAX_ID = 63 784 }; 785 786 /** 787 * Network flow rule 788 * 789 * Rules are stored in a table in which one or more match entries is followed 790 * by an action. If more than one match precedes an action, the rule is 791 * the AND of all matches. An action with no match is always taken since it 792 * matches anything. If nothing matches, the default action is DROP. 793 * 794 * This is designed to be a more memory-efficient way of storing rules than 795 * a wide table, yet still fast and simple to access in code. 796 */ 797 typedef struct 798 { 799 /** 800 * Type and flags 801 * 802 * Bits are: NOTTTTTT 803 * 804 * N - If true, sense of match is inverted (no effect on actions) 805 * O - If true, result is ORed with previous instead of ANDed (no effect on actions) 806 * T - Rule or action type 807 * 808 * AND with 0x3f to get type, 0x80 to get NOT bit, and 0x40 to get OR bit. 809 */ 810 uint8_t t; 811 812 /** 813 * Union containing the value of this rule -- which field is used depends on 't' 814 */ 815 union { 816 /** 817 * IPv6 address in big-endian / network byte order and netmask bits 818 */ 819 struct { 820 uint8_t ip[16]; 821 uint8_t mask; 822 } ipv6; 823 824 /** 825 * IPv4 address in big-endian / network byte order 826 */ 827 struct { 828 uint32_t ip; 829 uint8_t mask; 830 } ipv4; 831 832 /** 833 * Integer range match in packet payload 834 * 835 * This allows matching of ranges of integers up to 64 bits wide where 836 * the range is +/- INT32_MAX. It's packed this way so it fits in 16 837 * bytes and doesn't enlarge the overall size of this union. 838 */ 839 struct { 840 uint64_t start; // integer range start 841 uint32_t end; // end of integer range (relative to start, inclusive, 0 for equality w/start) 842 uint16_t idx; // index in packet of integer 843 uint8_t format; // bits in integer (range 1-64, ((format&63)+1)) and endianness (MSB 1 for little, 0 for big) 844 } intRange; 845 846 /** 847 * Packet characteristic flags being matched 848 */ 849 uint64_t characteristics; 850 851 /** 852 * IP port range -- start-end inclusive -- host byte order 853 */ 854 uint16_t port[2]; 855 856 /** 857 * 40-bit ZeroTier address (in least significant bits, host byte order) 858 */ 859 uint64_t zt; 860 861 /** 862 * 0 = never, UINT32_MAX = always 863 */ 864 uint32_t randomProbability; 865 866 /** 867 * 48-bit Ethernet MAC address in big-endian order 868 */ 869 uint8_t mac[6]; 870 871 /** 872 * VLAN ID in host byte order 873 */ 874 uint16_t vlanId; 875 876 /** 877 * VLAN PCP (least significant 3 bits) 878 */ 879 uint8_t vlanPcp; 880 881 /** 882 * VLAN DEI (single bit / boolean) 883 */ 884 uint8_t vlanDei; 885 886 /** 887 * Ethernet type in host byte order 888 */ 889 uint16_t etherType; 890 891 /** 892 * IP protocol 893 */ 894 uint8_t ipProtocol; 895 896 /** 897 * IP type of service a.k.a. DSCP field 898 */ 899 struct { 900 uint8_t mask; 901 uint8_t value[2]; 902 } ipTos; 903 904 /** 905 * Ethernet packet size in host byte order (start-end, inclusive) 906 */ 907 uint16_t frameSize[2]; 908 909 /** 910 * ICMP type and code 911 */ 912 struct { 913 uint8_t type; // ICMP type, always matched 914 uint8_t code; // ICMP code if matched 915 uint8_t flags; // flag 0x01 means also match code, otherwise only match type 916 } icmp; 917 918 /** 919 * For tag-related rules 920 */ 921 struct { 922 uint32_t id; 923 uint32_t value; 924 } tag; 925 926 /** 927 * Destinations for TEE and REDIRECT 928 */ 929 struct { 930 uint64_t address; 931 uint32_t flags; 932 uint16_t length; 933 } fwd; 934 935 /** 936 * Quality of Service (QoS) bucket we want a frame to be placed in 937 */ 938 uint8_t qosBucket; 939 } v; 940 } ZT_VirtualNetworkRule; 941 942 /** 943 * A route to be pushed on a virtual network 944 */ 945 typedef struct 946 { 947 /** 948 * Target network / netmask bits (in port field) or NULL or 0.0.0.0/0 for default 949 */ 950 struct sockaddr_storage target; 951 952 /** 953 * Gateway IP address (port ignored) or NULL (family == 0) for LAN-local (no gateway) 954 */ 955 struct sockaddr_storage via; 956 957 /** 958 * Route flags 959 */ 960 uint16_t flags; 961 962 /** 963 * Route metric (not currently used) 964 */ 965 uint16_t metric; 966 } ZT_VirtualNetworkRoute; 967 968 /** 969 * DNS configuration to be pushed on a virtual network 970 */ 971 typedef struct 972 { 973 char domain[128]; 974 struct sockaddr_storage server_addr[ZT_MAX_DNS_SERVERS]; 975 } ZT_VirtualNetworkDNS; 976 977 /** 978 * An Ethernet multicast group 979 */ 980 typedef struct 981 { 982 /** 983 * MAC address (least significant 48 bits) 984 */ 985 uint64_t mac; 986 987 /** 988 * Additional distinguishing information (usually zero) 989 */ 990 unsigned long adi; 991 } ZT_MulticastGroup; 992 993 /** 994 * Virtual network configuration update type 995 */ 996 enum ZT_VirtualNetworkConfigOperation 997 { 998 /** 999 * Network is coming up (either for the first time or after service restart) 1000 */ 1001 ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_UP = 1, 1002 1003 /** 1004 * Network configuration has been updated 1005 */ 1006 ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE = 2, 1007 1008 /** 1009 * Network is going down (not permanently) 1010 */ 1011 ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN = 3, 1012 1013 /** 1014 * Network is going down permanently (leave/delete) 1015 */ 1016 ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY = 4 1017 }; 1018 1019 /** 1020 * What trust hierarchy role does this peer have? 1021 */ 1022 enum ZT_PeerRole 1023 { 1024 ZT_PEER_ROLE_LEAF = 0, // ordinary node 1025 ZT_PEER_ROLE_MOON = 1, // moon root 1026 ZT_PEER_ROLE_PLANET = 2 // planetary root 1027 }; 1028 1029 /** 1030 * Vendor ID 1031 */ 1032 enum ZT_Vendor 1033 { 1034 ZT_VENDOR_UNSPECIFIED = 0, 1035 ZT_VENDOR_ZEROTIER = 1 1036 }; 1037 1038 /** 1039 * Platform type 1040 */ 1041 enum ZT_Platform 1042 { 1043 ZT_PLATFORM_UNSPECIFIED = 0, 1044 ZT_PLATFORM_LINUX = 1, 1045 ZT_PLATFORM_WINDOWS = 2, 1046 ZT_PLATFORM_MACOS = 3, 1047 ZT_PLATFORM_ANDROID = 4, 1048 ZT_PLATFORM_IOS = 5, 1049 ZT_PLATFORM_SOLARIS_SMARTOS = 6, 1050 ZT_PLATFORM_FREEBSD = 7, 1051 ZT_PLATFORM_NETBSD = 8, 1052 ZT_PLATFORM_OPENBSD = 9, 1053 ZT_PLATFORM_RISCOS = 10, 1054 ZT_PLATFORM_VXWORKS = 11, 1055 ZT_PLATFORM_FREERTOS = 12, 1056 ZT_PLATFORM_SYSBIOS = 13, 1057 ZT_PLATFORM_HURD = 14, 1058 ZT_PLATFORM_WEB = 15 1059 }; 1060 1061 /** 1062 * Architecture type 1063 */ 1064 enum ZT_Architecture 1065 { 1066 ZT_ARCHITECTURE_UNSPECIFIED = 0, 1067 ZT_ARCHITECTURE_X86 = 1, 1068 ZT_ARCHITECTURE_X64 = 2, 1069 ZT_ARCHITECTURE_ARM32 = 3, 1070 ZT_ARCHITECTURE_ARM64 = 4, 1071 ZT_ARCHITECTURE_MIPS32 = 5, 1072 ZT_ARCHITECTURE_MIPS64 = 6, 1073 ZT_ARCHITECTURE_POWER32 = 7, 1074 ZT_ARCHITECTURE_POWER64 = 8, 1075 ZT_ARCHITECTURE_OPENRISC32 = 9, 1076 ZT_ARCHITECTURE_OPENRISC64 = 10, 1077 ZT_ARCHITECTURE_SPARC32 = 11, 1078 ZT_ARCHITECTURE_SPARC64 = 12, 1079 ZT_ARCHITECTURE_DOTNET_CLR = 13, 1080 ZT_ARCHITECTURE_JAVA_JVM = 14, 1081 ZT_ARCHITECTURE_WEB = 15, 1082 ZT_ARCHITECTURE_S390X = 16 1083 }; 1084 1085 /** 1086 * Virtual network configuration 1087 */ 1088 typedef struct 1089 { 1090 /** 1091 * 64-bit ZeroTier network ID 1092 */ 1093 uint64_t nwid; 1094 1095 /** 1096 * Ethernet MAC (48 bits) that should be assigned to port 1097 */ 1098 uint64_t mac; 1099 1100 /** 1101 * Network name (from network configuration master) 1102 */ 1103 char name[ZT_MAX_NETWORK_SHORT_NAME_LENGTH + 1]; 1104 1105 /** 1106 * Network configuration request status 1107 */ 1108 enum ZT_VirtualNetworkStatus status; 1109 1110 /** 1111 * Network type 1112 */ 1113 enum ZT_VirtualNetworkType type; 1114 1115 /** 1116 * Maximum interface MTU 1117 */ 1118 unsigned int mtu; 1119 1120 /** 1121 * If nonzero, the network this port belongs to indicates DHCP availability 1122 * 1123 * This is a suggestion. The underlying implementation is free to ignore it 1124 * for security or other reasons. This is simply a netconf parameter that 1125 * means 'DHCP is available on this network.' 1126 */ 1127 int dhcp; 1128 1129 /** 1130 * If nonzero, this port is allowed to bridge to other networks 1131 * 1132 * This is informational. If this is false (0), bridged packets will simply 1133 * be dropped and bridging won't work. 1134 */ 1135 int bridge; 1136 1137 /** 1138 * If nonzero, this network supports and allows broadcast (ff:ff:ff:ff:ff:ff) traffic 1139 */ 1140 int broadcastEnabled; 1141 1142 /** 1143 * If the network is in PORT_ERROR state, this is the (negative) error code most recently reported 1144 */ 1145 int portError; 1146 1147 /** 1148 * Revision number as reported by controller or 0 if still waiting for config 1149 */ 1150 unsigned long netconfRevision; 1151 1152 /** 1153 * Number of assigned addresses 1154 */ 1155 unsigned int assignedAddressCount; 1156 1157 /** 1158 * ZeroTier-assigned addresses (in sockaddr_storage structures) 1159 * 1160 * For IP, the port number of the sockaddr_XX structure contains the number 1161 * of bits in the address netmask. Only the IP address and port are used. 1162 * Other fields like interface number can be ignored. 1163 * 1164 * This is only used for ZeroTier-managed address assignments sent by the 1165 * virtual network's configuration master. 1166 */ 1167 struct sockaddr_storage assignedAddresses[ZT_MAX_ZT_ASSIGNED_ADDRESSES]; 1168 1169 /** 1170 * Number of ZT-pushed routes 1171 */ 1172 unsigned int routeCount; 1173 1174 /** 1175 * Routes (excluding those implied by assigned addresses and their masks) 1176 */ 1177 ZT_VirtualNetworkRoute routes[ZT_MAX_NETWORK_ROUTES]; 1178 1179 /** 1180 * Number of multicast groups subscribed 1181 */ 1182 unsigned int multicastSubscriptionCount; 1183 1184 /** 1185 * Multicast groups to which this network's device is subscribed 1186 */ 1187 struct { 1188 uint64_t mac; /* MAC in lower 48 bits */ 1189 uint32_t adi; /* Additional distinguishing information, usually zero except for IPv4 ARP groups */ 1190 } multicastSubscriptions[ZT_MAX_MULTICAST_SUBSCRIPTIONS]; 1191 1192 /** 1193 * Network specific DNS configuration 1194 */ 1195 ZT_VirtualNetworkDNS dns; 1196 1197 /** 1198 * sso enabled 1199 */ 1200 bool ssoEnabled; 1201 1202 /** 1203 * If the status us AUTHENTICATION_REQUIRED, this may contain a URL for authentication. 1204 */ 1205 char authenticationURL[2048]; 1206 1207 /** 1208 * Time that current authentication expires. only valid if ssoEnabled is true 1209 */ 1210 uint64_t authenticationExpiryTime; 1211 } ZT_VirtualNetworkConfig; 1212 1213 /** 1214 * A list of networks 1215 */ 1216 typedef struct 1217 { 1218 ZT_VirtualNetworkConfig *networks; 1219 unsigned long networkCount; 1220 } ZT_VirtualNetworkList; 1221 1222 /** 1223 * Physical path configuration 1224 */ 1225 typedef struct { 1226 /** 1227 * If non-zero set this physical network path to be trusted to disable encryption and authentication 1228 */ 1229 uint64_t trustedPathId; 1230 1231 /** 1232 * Physical path MTU from ZT_MIN_PHYSMTU and ZT_MAX_PHYSMTU or <= 0 to use default 1233 */ 1234 int mtu; 1235 } ZT_PhysicalPathConfiguration; 1236 1237 /** 1238 * Physical network path to a peer 1239 */ 1240 typedef struct 1241 { 1242 /** 1243 * Address of endpoint 1244 */ 1245 struct sockaddr_storage address; 1246 1247 /** 1248 * Time of last send in milliseconds or 0 for never 1249 */ 1250 uint64_t lastSend; 1251 1252 /** 1253 * Time of last receive in milliseconds or 0 for never 1254 */ 1255 uint64_t lastReceive; 1256 1257 /** 1258 * Is this a trusted path? If so this will be its nonzero ID. 1259 */ 1260 uint64_t trustedPathId; 1261 1262 /** 1263 * Mean latency 1264 */ 1265 float latencyMean; 1266 1267 /** 1268 * Maximum observed latency 1269 */ 1270 float latencyMax; 1271 1272 /** 1273 * Variance of latency 1274 */ 1275 float latencyVariance; 1276 1277 /** 1278 * Packet loss ratio 1279 */ 1280 float packetLossRatio; 1281 1282 /** 1283 * Packet error ratio 1284 */ 1285 float packetErrorRatio; 1286 1287 /** 1288 * Mean throughput 1289 */ 1290 uint64_t throughputMean; 1291 1292 /** 1293 * Maximum observed throughput 1294 */ 1295 float throughputMax; 1296 1297 /** 1298 * Throughput variance 1299 */ 1300 float throughputVariance; 1301 1302 /** 1303 * Address scope 1304 */ 1305 uint8_t scope; 1306 1307 /** 1308 * Percentage of traffic allocated to this path 1309 */ 1310 float allocation; 1311 1312 /** 1313 * Name of physical interface (for monitoring) 1314 */ 1315 char ifname[32]; 1316 1317 uint64_t localSocket; 1318 1319 /** 1320 * Is path expired? 1321 */ 1322 int expired; 1323 1324 /** 1325 * Is path preferred? 1326 */ 1327 int preferred; 1328 } ZT_PeerPhysicalPath; 1329 1330 /** 1331 * Peer status result buffer 1332 */ 1333 typedef struct 1334 { 1335 /** 1336 * ZeroTier address (40 bits) 1337 */ 1338 uint64_t address; 1339 1340 /** 1341 * Remote major version or -1 if not known 1342 */ 1343 int versionMajor; 1344 1345 /** 1346 * Remote minor version or -1 if not known 1347 */ 1348 int versionMinor; 1349 1350 /** 1351 * Remote revision or -1 if not known 1352 */ 1353 int versionRev; 1354 1355 /** 1356 * Last measured latency in milliseconds or -1 if unknown 1357 */ 1358 int latency; 1359 1360 /** 1361 * What trust hierarchy role does this device have? 1362 */ 1363 enum ZT_PeerRole role; 1364 1365 /** 1366 * Whether a multi-link bond has formed 1367 */ 1368 bool isBonded; 1369 1370 /** 1371 * The bonding policy used to bond to this peer 1372 */ 1373 int bondingPolicy; 1374 1375 /** 1376 * The health status of the bond to this peer 1377 */ 1378 bool isHealthy; 1379 1380 /** 1381 * The number of links that comprise the bond to this peer that are considered alive 1382 */ 1383 int numAliveLinks; 1384 1385 /** 1386 * The number of links that comprise the bond to this peer 1387 */ 1388 int numTotalLinks; 1389 1390 /** 1391 * The user-specified bond template name 1392 */ 1393 char customBondName[32]; 1394 1395 /** 1396 * Number of paths (size of paths[]) 1397 */ 1398 unsigned int pathCount; 1399 1400 /** 1401 * Known network paths to peer 1402 */ 1403 ZT_PeerPhysicalPath paths[ZT_MAX_PEER_NETWORK_PATHS]; 1404 } ZT_Peer; 1405 1406 /** 1407 * List of peers 1408 */ 1409 typedef struct 1410 { 1411 ZT_Peer *peers; 1412 unsigned long peerCount; 1413 } ZT_PeerList; 1414 1415 /** 1416 * ZeroTier core state objects 1417 */ 1418 enum ZT_StateObjectType 1419 { 1420 /** 1421 * Null object -- ignored 1422 */ 1423 ZT_STATE_OBJECT_NULL = 0, 1424 1425 /** 1426 * Public address and public key 1427 * 1428 * Object ID: this node's address if known, or 0 if unknown (first query) 1429 * Canonical path: <HOME>/identity.public 1430 * Persistence: required 1431 */ 1432 ZT_STATE_OBJECT_IDENTITY_PUBLIC = 1, 1433 1434 /** 1435 * Full identity with secret key 1436 * 1437 * Object ID: this node's address if known, or 0 if unknown (first query) 1438 * Canonical path: <HOME>/identity.secret 1439 * Persistence: required, should be stored with restricted permissions e.g. mode 0600 on *nix 1440 */ 1441 ZT_STATE_OBJECT_IDENTITY_SECRET = 2, 1442 1443 /** 1444 * The planet (there is only one per... well... planet!) 1445 * 1446 * Object ID: world ID of planet, or 0 if unknown (first query) 1447 * Canonical path: <HOME>/planet 1448 * Persistence: recommended 1449 */ 1450 ZT_STATE_OBJECT_PLANET = 3, 1451 1452 /** 1453 * A moon (federated root set) 1454 * 1455 * Object ID: world ID of moon 1456 * Canonical path: <HOME>/moons.d/<ID>.moon (16-digit hex ID) 1457 * Persistence: required if moon memberships should persist 1458 */ 1459 ZT_STATE_OBJECT_MOON = 4, 1460 1461 /** 1462 * Peer and related state 1463 * 1464 * Object ID: peer address 1465 * Canonical path: <HOME>/peers.d/<ID> (10-digit address 1466 * Persistence: optional, can be cleared at any time 1467 */ 1468 ZT_STATE_OBJECT_PEER = 5, 1469 1470 /** 1471 * Network configuration 1472 * 1473 * Object ID: peer address 1474 * Canonical path: <HOME>/networks.d/<NETWORKID>.conf (16-digit hex ID) 1475 * Persistence: required if network memberships should persist 1476 */ 1477 ZT_STATE_OBJECT_NETWORK_CONFIG = 6 1478 }; 1479 1480 /** 1481 * An instance of a ZeroTier One node (opaque) 1482 */ 1483 typedef void ZT_Node; 1484 1485 /****************************************************************************/ 1486 /* Callbacks used by Node API */ 1487 /****************************************************************************/ 1488 1489 /** 1490 * Callback called to update virtual network port configuration 1491 * 1492 * This can be called at any time to update the configuration of a virtual 1493 * network port. The parameter after the network ID specifies whether this 1494 * port is being brought up, updated, brought down, or permanently deleted. 1495 * 1496 * This in turn should be used by the underlying implementation to create 1497 * and configure tap devices at the OS (or virtual network stack) layer. 1498 * 1499 * The supplied config pointer is not guaranteed to remain valid, so make 1500 * a copy if you want one. 1501 * 1502 * This should not call multicastSubscribe() or other network-modifying 1503 * methods, as this could cause a deadlock in multithreaded or interrupt 1504 * driven environments. 1505 * 1506 * This must return 0 on success. It can return any OS-dependent error code 1507 * on failure, and this results in the network being placed into the 1508 * PORT_ERROR state. 1509 */ 1510 typedef int (*ZT_VirtualNetworkConfigFunction)( 1511 ZT_Node *, /* Node */ 1512 void *, /* User ptr */ 1513 void *, /* Thread ptr */ 1514 uint64_t, /* Network ID */ 1515 void **, /* Modifiable network user PTR */ 1516 enum ZT_VirtualNetworkConfigOperation, /* Config operation */ 1517 const ZT_VirtualNetworkConfig *); /* Network configuration */ 1518 1519 /** 1520 * Function to send a frame out to a virtual network port 1521 * 1522 * Parameters: (1) node, (2) user ptr, (3) network ID, (4) source MAC, 1523 * (5) destination MAC, (6) ethertype, (7) VLAN ID, (8) frame data, 1524 * (9) frame length. 1525 */ 1526 typedef void (*ZT_VirtualNetworkFrameFunction)( 1527 ZT_Node *, /* Node */ 1528 void *, /* User ptr */ 1529 void *, /* Thread ptr */ 1530 uint64_t, /* Network ID */ 1531 void **, /* Modifiable network user PTR */ 1532 uint64_t, /* Source MAC */ 1533 uint64_t, /* Destination MAC */ 1534 unsigned int, /* Ethernet type */ 1535 unsigned int, /* VLAN ID (0 for none) */ 1536 const void *, /* Frame data */ 1537 unsigned int); /* Frame length */ 1538 1539 /** 1540 * Callback for events 1541 * 1542 * Events are generated when the node's status changes in a significant way 1543 * and on certain non-fatal errors and events of interest. The final void 1544 * parameter points to event meta-data. The type of event meta-data (and 1545 * whether it is present at all) is event type dependent. See the comments 1546 * in the definition of ZT_Event. 1547 */ 1548 typedef void (*ZT_EventCallback)( 1549 ZT_Node *, /* Node */ 1550 void *, /* User ptr */ 1551 void *, /* Thread ptr */ 1552 enum ZT_Event, /* Event type */ 1553 const void *); /* Event payload (if applicable) */ 1554 1555 /** 1556 * Callback for storing and/or publishing state information 1557 * 1558 * See ZT_StateObjectType docs for information about each state object type 1559 * and when and if it needs to be persisted. 1560 * 1561 * An object of length -1 is sent to indicate that an object should be 1562 * deleted. 1563 */ 1564 typedef void (*ZT_StatePutFunction)( 1565 ZT_Node *, /* Node */ 1566 void *, /* User ptr */ 1567 void *, /* Thread ptr */ 1568 enum ZT_StateObjectType, /* State object type */ 1569 const uint64_t [2], /* State object ID (if applicable) */ 1570 const void *, /* State object data */ 1571 int); /* Length of data or -1 to delete */ 1572 1573 /** 1574 * Callback for retrieving stored state information 1575 * 1576 * This function should return the number of bytes actually stored to the 1577 * buffer or -1 if the state object was not found or the buffer was too 1578 * small to store it. 1579 */ 1580 typedef int (*ZT_StateGetFunction)( 1581 ZT_Node *, /* Node */ 1582 void *, /* User ptr */ 1583 void *, /* Thread ptr */ 1584 enum ZT_StateObjectType, /* State object type */ 1585 const uint64_t [2], /* State object ID (if applicable) */ 1586 void *, /* Buffer to store state object data */ 1587 unsigned int); /* Length of data buffer in bytes */ 1588 1589 /** 1590 * Function to send a ZeroTier packet out over the physical wire (L2/L3) 1591 * 1592 * Parameters: 1593 * (1) Node 1594 * (2) User pointer 1595 * (3) Local socket or -1 for "all" or "any" 1596 * (4) Remote address 1597 * (5) Packet data 1598 * (6) Packet length 1599 * (7) Desired IP TTL or 0 to use default 1600 * 1601 * If there is only one local socket, the local socket can be ignored. 1602 * If the local socket is -1, the packet should be sent out from all 1603 * bound local sockets or a random bound local socket. 1604 * 1605 * If TTL is nonzero, packets should have their IP TTL value set to this 1606 * value if possible. If this is not possible it is acceptable to ignore 1607 * this value and send anyway with normal or default TTL. 1608 * 1609 * The function must return zero on success and may return any error code 1610 * on failure. Note that success does not (of course) guarantee packet 1611 * delivery. It only means that the packet appears to have been sent. 1612 */ 1613 typedef int (*ZT_WirePacketSendFunction)( 1614 ZT_Node *, /* Node */ 1615 void *, /* User ptr */ 1616 void *, /* Thread ptr */ 1617 int64_t, /* Local socket */ 1618 const struct sockaddr_storage *, /* Remote address */ 1619 const void *, /* Packet data */ 1620 unsigned int, /* Packet length */ 1621 unsigned int); /* TTL or 0 to use default */ 1622 1623 /** 1624 * Function to check whether a path should be used for ZeroTier traffic 1625 * 1626 * Parameters: 1627 * (1) Node 1628 * (2) User pointer 1629 * (3) ZeroTier address or 0 for none/any 1630 * (4) Local socket or -1 if unknown 1631 * (5) Remote address 1632 * 1633 * This function must return nonzero (true) if the path should be used. 1634 * 1635 * If no path check function is specified, ZeroTier will still exclude paths 1636 * that overlap with ZeroTier-assigned and managed IP address blocks. But the 1637 * use of a path check function is recommended to ensure that recursion does 1638 * not occur in cases where addresses are assigned by the OS or managed by 1639 * an out of band mechanism like DHCP. The path check function should examine 1640 * all configured ZeroTier interfaces and check to ensure that the supplied 1641 * addresses will not result in ZeroTier traffic being sent over a ZeroTier 1642 * interface (recursion). 1643 */ 1644 typedef int (*ZT_PathCheckFunction)( 1645 ZT_Node *, /* Node */ 1646 void *, /* User ptr */ 1647 void *, /* Thread ptr */ 1648 uint64_t, /* ZeroTier address */ 1649 int64_t, /* Local socket or -1 if unknown */ 1650 const struct sockaddr_storage *); /* Remote address */ 1651 1652 /** 1653 * Function to get physical addresses for ZeroTier peers 1654 * 1655 * Parameters: 1656 * (1) Node 1657 * (2) User pointer 1658 * (3) ZeroTier address (least significant 40 bits) 1659 * (4) Desired address family or -1 for any 1660 * (5) Buffer to fill with result 1661 * 1662 * If provided this function will be occasionally called to get physical 1663 * addresses that might be tried to reach a ZeroTier address. It must 1664 * return a nonzero (true) value if the result buffer has been filled 1665 * with an address. 1666 */ 1667 typedef int (*ZT_PathLookupFunction)( 1668 ZT_Node *, /* Node */ 1669 void *, /* User ptr */ 1670 void *, /* Thread ptr */ 1671 uint64_t, /* ZeroTier address (40 bits) */ 1672 int, /* Desired ss_family or -1 for any */ 1673 struct sockaddr_storage *); /* Result buffer */ 1674 1675 /****************************************************************************/ 1676 /* C Node API */ 1677 /****************************************************************************/ 1678 1679 /** 1680 * Structure for configuring ZeroTier core callback functions 1681 */ 1682 struct ZT_Node_Callbacks 1683 { 1684 /** 1685 * Struct version -- must currently be 0 1686 */ 1687 long version; 1688 1689 /** 1690 * REQUIRED: Function to store and/or replicate state objects 1691 */ 1692 ZT_StatePutFunction statePutFunction; 1693 1694 /** 1695 * REQUIRED: Function to retrieve state objects from an object store 1696 */ 1697 ZT_StateGetFunction stateGetFunction; 1698 1699 /** 1700 * REQUIRED: Function to send packets over the physical wire 1701 */ 1702 ZT_WirePacketSendFunction wirePacketSendFunction; 1703 1704 /** 1705 * REQUIRED: Function to inject frames into a virtual network's TAP 1706 */ 1707 ZT_VirtualNetworkFrameFunction virtualNetworkFrameFunction; 1708 1709 /** 1710 * REQUIRED: Function to be called when virtual networks are configured or changed 1711 */ 1712 ZT_VirtualNetworkConfigFunction virtualNetworkConfigFunction; 1713 1714 /** 1715 * REQUIRED: Function to be called to notify external code of important events 1716 */ 1717 ZT_EventCallback eventCallback; 1718 1719 /** 1720 * OPTIONAL: Function to check whether a given physical path should be used 1721 */ 1722 ZT_PathCheckFunction pathCheckFunction; 1723 1724 /** 1725 * OPTIONAL: Function to get hints to physical paths to ZeroTier addresses 1726 */ 1727 ZT_PathLookupFunction pathLookupFunction; 1728 }; 1729 1730 /** 1731 * Create a new ZeroTier node 1732 * 1733 * This will attempt to load its identity via the state get function in the 1734 * callback struct. If that fails it will generate a new identity and store 1735 * it. Identity generation can take anywhere from a few hundred milliseconds 1736 * to a few seconds depending on your CPU speed. 1737 * 1738 * @param node Result: pointer is set to new node instance on success 1739 * @param uptr User pointer to pass to functions/callbacks 1740 * @param tptr Thread pointer to pass to functions/callbacks resulting from this call 1741 * @param callbacks Callback function configuration 1742 * @param now Current clock in milliseconds 1743 * @return OK (0) or error code if a fatal error condition has occurred 1744 */ 1745 ZT_SDK_API enum ZT_ResultCode ZT_Node_new(ZT_Node **node,void *uptr,void *tptr,const struct ZT_Node_Callbacks *callbacks,int64_t now); 1746 1747 /** 1748 * Delete a node and free all resources it consumes 1749 * 1750 * If you are using multiple threads, all other threads must be shut down 1751 * first. This can crash if processXXX() methods are in progress. 1752 * 1753 * @param node Node to delete 1754 */ 1755 ZT_SDK_API void ZT_Node_delete(ZT_Node *node); 1756 1757 /** 1758 * Process a packet received from the physical wire 1759 * 1760 * @param node Node instance 1761 * @param tptr Thread pointer to pass to functions/callbacks resulting from this call 1762 * @param now Current clock in milliseconds 1763 * @param localSocket Local socket (you can use 0 if only one local socket is bound and ignore this) 1764 * @param remoteAddress Origin of packet 1765 * @param packetData Packet data 1766 * @param packetLength Packet length 1767 * @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks() 1768 * @return OK (0) or error code if a fatal error condition has occurred 1769 */ 1770 ZT_SDK_API enum ZT_ResultCode ZT_Node_processWirePacket( 1771 ZT_Node *node, 1772 void *tptr, 1773 int64_t now, 1774 int64_t localSocket, 1775 const struct sockaddr_storage *remoteAddress, 1776 const void *packetData, 1777 unsigned int packetLength, 1778 volatile int64_t *nextBackgroundTaskDeadline); 1779 1780 /** 1781 * Process a frame from a virtual network port (tap) 1782 * 1783 * @param node Node instance 1784 * @param tptr Thread pointer to pass to functions/callbacks resulting from this call 1785 * @param now Current clock in milliseconds 1786 * @param nwid ZeroTier 64-bit virtual network ID 1787 * @param sourceMac Source MAC address (least significant 48 bits) 1788 * @param destMac Destination MAC address (least significant 48 bits) 1789 * @param etherType 16-bit Ethernet frame type 1790 * @param vlanId 10-bit VLAN ID or 0 if none 1791 * @param frameData Frame payload data 1792 * @param frameLength Frame payload length 1793 * @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks() 1794 * @return OK (0) or error code if a fatal error condition has occurred 1795 */ 1796 ZT_SDK_API enum ZT_ResultCode ZT_Node_processVirtualNetworkFrame( 1797 ZT_Node *node, 1798 void *tptr, 1799 int64_t now, 1800 uint64_t nwid, 1801 uint64_t sourceMac, 1802 uint64_t destMac, 1803 unsigned int etherType, 1804 unsigned int vlanId, 1805 const void *frameData, 1806 unsigned int frameLength, 1807 volatile int64_t *nextBackgroundTaskDeadline); 1808 1809 /** 1810 * Perform periodic background operations 1811 * 1812 * @param node Node instance 1813 * @param tptr Thread pointer to pass to functions/callbacks resulting from this call 1814 * @param now Current clock in milliseconds 1815 * @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks() 1816 * @return OK (0) or error code if a fatal error condition has occurred 1817 */ 1818 ZT_SDK_API enum ZT_ResultCode ZT_Node_processBackgroundTasks(ZT_Node *node,void *tptr,int64_t now,volatile int64_t *nextBackgroundTaskDeadline); 1819 1820 /** 1821 * Join a network 1822 * 1823 * This may generate calls to the port config callback before it returns, 1824 * or these may be differed if a netconf is not available yet. 1825 * 1826 * If we are already a member of the network, nothing is done and OK is 1827 * returned. 1828 * 1829 * @param node Node instance 1830 * @param nwid 64-bit ZeroTier network ID 1831 * @param uptr An arbitrary pointer to associate with this network (default: NULL) 1832 * @return OK (0) or error code if a fatal error condition has occurred 1833 */ 1834 ZT_SDK_API enum ZT_ResultCode ZT_Node_join(ZT_Node *node,uint64_t nwid,void *uptr,void *tptr); 1835 1836 /** 1837 * Leave a network 1838 * 1839 * If a port has been configured for this network this will generate a call 1840 * to the port config callback with a NULL second parameter to indicate that 1841 * the port is now deleted. 1842 * 1843 * The uptr parameter is optional and is NULL by default. If it is not NULL, 1844 * the pointer it points to is set to this network's uptr on success. 1845 * 1846 * @param node Node instance 1847 * @param nwid 64-bit network ID 1848 * @param uptr Target pointer is set to uptr (if not NULL) 1849 * @return OK (0) or error code if a fatal error condition has occurred 1850 */ 1851 ZT_SDK_API enum ZT_ResultCode ZT_Node_leave(ZT_Node *node,uint64_t nwid,void **uptr,void *tptr); 1852 1853 /** 1854 * Subscribe to an Ethernet multicast group 1855 * 1856 * ADI stands for additional distinguishing information. This defaults to zero 1857 * and is rarely used. Right now its only use is to enable IPv4 ARP to scale, 1858 * and this must be done. 1859 * 1860 * For IPv4 ARP, the implementation must subscribe to 0xffffffffffff (the 1861 * broadcast address) but with an ADI equal to each IPv4 address in host 1862 * byte order. This converts ARP from a non-scalable broadcast protocol to 1863 * a scalable multicast protocol with perfect address specificity. 1864 * 1865 * If this is not done, ARP will not work reliably. 1866 * 1867 * Multiple calls to subscribe to the same multicast address will have no 1868 * effect. It is perfectly safe to do this. 1869 * 1870 * This does not generate an update call to networkConfigCallback(). 1871 * 1872 * @param node Node instance 1873 * @param tptr Thread pointer to pass to functions/callbacks resulting from this call 1874 * @param nwid 64-bit network ID 1875 * @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits) 1876 * @param multicastAdi Multicast ADI (least significant 32 bits only, use 0 if not needed) 1877 * @return OK (0) or error code if a fatal error condition has occurred 1878 */ 1879 ZT_SDK_API enum ZT_ResultCode ZT_Node_multicastSubscribe(ZT_Node *node,void *tptr,uint64_t nwid,uint64_t multicastGroup,unsigned long multicastAdi); 1880 1881 /** 1882 * Unsubscribe from an Ethernet multicast group (or all groups) 1883 * 1884 * If multicastGroup is zero (0), this will unsubscribe from all groups. If 1885 * you are not subscribed to a group this has no effect. 1886 * 1887 * This does not generate an update call to networkConfigCallback(). 1888 * 1889 * @param node Node instance 1890 * @param nwid 64-bit network ID 1891 * @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits) 1892 * @param multicastAdi Multicast ADI (least significant 32 bits only, use 0 if not needed) 1893 * @return OK (0) or error code if a fatal error condition has occurred 1894 */ 1895 ZT_SDK_API enum ZT_ResultCode ZT_Node_multicastUnsubscribe(ZT_Node *node,uint64_t nwid,uint64_t multicastGroup,unsigned long multicastAdi); 1896 1897 /** 1898 * Add or update a moon 1899 * 1900 * Moons are persisted in the data store in moons.d/, so this can persist 1901 * across invocations if the contents of moon.d are scanned and orbit is 1902 * called for each on startup. 1903 * 1904 * @param node Node instance 1905 * @param tptr Thread pointer to pass to functions/callbacks resulting from this call 1906 * @param moonWorldId Moon's world ID 1907 * @param moonSeed If non-zero, the ZeroTier address of any member of the moon to query for moon definition 1908 * @param len Length of moonWorld in bytes 1909 * @return Error if moon was invalid or failed to be added 1910 */ 1911 ZT_SDK_API enum ZT_ResultCode ZT_Node_orbit(ZT_Node *node,void *tptr,uint64_t moonWorldId,uint64_t moonSeed); 1912 1913 /** 1914 * Remove a moon (does nothing if not present) 1915 * 1916 * @param node Node instance 1917 * @param tptr Thread pointer to pass to functions/callbacks resulting from this call 1918 * @param moonWorldId World ID of moon to remove 1919 * @return Error if anything bad happened 1920 */ 1921 ZT_SDK_API enum ZT_ResultCode ZT_Node_deorbit(ZT_Node *node,void *tptr,uint64_t moonWorldId); 1922 1923 /** 1924 * Get this node's 40-bit ZeroTier address 1925 * 1926 * @param node Node instance 1927 * @return ZeroTier address (least significant 40 bits of 64-bit int) 1928 */ 1929 ZT_SDK_API uint64_t ZT_Node_address(ZT_Node *node); 1930 1931 /** 1932 * Get the status of this node 1933 * 1934 * @param node Node instance 1935 * @param status Buffer to fill with current node status 1936 */ 1937 ZT_SDK_API void ZT_Node_status(ZT_Node *node,ZT_NodeStatus *status); 1938 1939 /** 1940 * Get a list of known peer nodes 1941 * 1942 * The pointer returned here must be freed with freeQueryResult() 1943 * when you are done with it. 1944 * 1945 * @param node Node instance 1946 * @return List of known peers or NULL on failure 1947 */ 1948 ZT_SDK_API ZT_PeerList *ZT_Node_peers(ZT_Node *node); 1949 1950 /** 1951 * Get the status of a virtual network 1952 * 1953 * The pointer returned here must be freed with freeQueryResult() 1954 * when you are done with it. 1955 * 1956 * @param node Node instance 1957 * @param nwid 64-bit network ID 1958 * @return Network configuration or NULL if we are not a member of this network 1959 */ 1960 ZT_SDK_API ZT_VirtualNetworkConfig *ZT_Node_networkConfig(ZT_Node *node,uint64_t nwid); 1961 1962 /** 1963 * Enumerate and get status of all networks 1964 * 1965 * @param node Node instance 1966 * @return List of networks or NULL on failure 1967 */ 1968 ZT_SDK_API ZT_VirtualNetworkList *ZT_Node_networks(ZT_Node *node); 1969 1970 /** 1971 * Free a query result buffer 1972 * 1973 * Use this to free the return values of listNetworks(), listPeers(), etc. 1974 * 1975 * @param node Node instance 1976 * @param qr Query result buffer 1977 */ 1978 ZT_SDK_API void ZT_Node_freeQueryResult(ZT_Node *node,void *qr); 1979 1980 /** 1981 * Add a local interface address 1982 * 1983 * This is used to make ZeroTier aware of those local interface addresses 1984 * that you wish to use for ZeroTier communication. This is optional, and if 1985 * it is not used ZeroTier will rely upon upstream peers (and roots) to 1986 * perform empirical address discovery and NAT traversal. But the use of this 1987 * method is recommended as it improves peer discovery when both peers are 1988 * on the same LAN. 1989 * 1990 * It is the responsibility of the caller to take care that these are never 1991 * ZeroTier interface addresses, whether these are assigned by ZeroTier or 1992 * are otherwise assigned to an interface managed by this ZeroTier instance. 1993 * This can cause recursion or other undesirable behavior. 1994 * 1995 * This returns a boolean indicating whether or not the address was 1996 * accepted. ZeroTier will only communicate over certain address types 1997 * and (for IP) address classes. 1998 * 1999 * @param addr Local interface address 2000 * @return Boolean: non-zero if address was accepted and added 2001 */ 2002 ZT_SDK_API int ZT_Node_addLocalInterfaceAddress(ZT_Node *node,const struct sockaddr_storage *addr); 2003 2004 /** 2005 * Clear local interface addresses 2006 */ 2007 ZT_SDK_API void ZT_Node_clearLocalInterfaceAddresses(ZT_Node *node); 2008 2009 /** 2010 * Send a VERB_USER_MESSAGE to another ZeroTier node 2011 * 2012 * There is no delivery guarantee here. Failure can occur if the message is 2013 * too large or if dest is not a valid ZeroTier address. 2014 * 2015 * @param node Node instance 2016 * @param tptr Thread pointer to pass to functions/callbacks resulting from this call 2017 * @param dest Destination ZeroTier address 2018 * @param typeId VERB_USER_MESSAGE type ID 2019 * @param data Payload data to attach to user message 2020 * @param len Length of data in bytes 2021 * @return Boolean: non-zero on success, zero on failure 2022 */ 2023 ZT_SDK_API int ZT_Node_sendUserMessage(ZT_Node *node,void *tptr,uint64_t dest,uint64_t typeId,const void *data,unsigned int len); 2024 2025 /** 2026 * Set a network configuration master instance for this node 2027 * 2028 * Normal nodes should not need to use this. This is for nodes with 2029 * special compiled-in support for acting as network configuration 2030 * masters / controllers. 2031 * 2032 * The supplied instance must be a C++ object that inherits from the 2033 * NetworkConfigMaster base class in node/. No type checking is performed, 2034 * so a pointer to anything else will result in a crash. 2035 * 2036 * @param node ZertTier One node 2037 * @param networkConfigMasterInstance Instance of NetworkConfigMaster C++ class or NULL to disable 2038 * @return OK (0) or error code if a fatal error condition has occurred 2039 */ 2040 ZT_SDK_API void ZT_Node_setNetconfMaster(ZT_Node *node,void *networkConfigMasterInstance); 2041 2042 /** 2043 * Set configuration for a given physical path 2044 * 2045 * @param node Node instance 2046 * @param pathNetwork Network/CIDR of path or NULL to clear the cache and reset all paths to default 2047 * @param pathConfig Path configuration or NULL to erase this entry and therefore reset it to NULL 2048 * @return OK or error code 2049 */ 2050 ZT_SDK_API enum ZT_ResultCode ZT_Node_setPhysicalPathConfiguration(ZT_Node *node,const struct sockaddr_storage *pathNetwork,const ZT_PhysicalPathConfiguration *pathConfig); 2051 2052 /** 2053 * Get ZeroTier One version 2054 * 2055 * @param major Result: major version 2056 * @param minor Result: minor version 2057 * @param revision Result: revision 2058 */ 2059 ZT_SDK_API void ZT_version(int *major,int *minor,int *revision); 2060 2061 #ifdef __cplusplus 2062 } 2063 #endif 2064 2065 #endif 2066