Fixed netif initialization bug, fixed typos in documentation

This commit is contained in:
Joseph Henry
2017-11-16 00:54:26 -08:00
parent aaea48a52a
commit d6fcdf5277
3 changed files with 29 additions and 28 deletions

View File

@@ -108,7 +108,7 @@ ZT_SOCKET_API int ZTCALL zts_start(const char *path, bool blocking);
ZT_SOCKET_API int ZTCALL zts_startjoin(const char *path, const uint64_t nwid); ZT_SOCKET_API int ZTCALL zts_startjoin(const char *path, const uint64_t nwid);
/** /**
* @brief Stops libzt (ZeroTier core services, stack drivers, stack threads, etc) * @brief Stops ZeroTier core services, stack drivers, stack threads, etc
* *
* @usage This should be called at the end of your program or when you do not anticipate communicating over ZeroTier * @usage This should be called at the end of your program or when you do not anticipate communicating over ZeroTier
* @return Returns 0 on success, -1 on failure * @return Returns 0 on success, -1 on failure
@@ -116,7 +116,7 @@ ZT_SOCKET_API int ZTCALL zts_startjoin(const char *path, const uint64_t nwid);
ZT_SOCKET_API void ZTCALL zts_stop(); ZT_SOCKET_API void ZTCALL zts_stop();
/** /**
* @brief Return whether libzt (specifically the ZeroTier core service) is currently running * @brief Return whether ZeroTier is currently running
* *
* @usage Call this before, during, or after zts_start() * @usage Call this before, during, or after zts_start()
* @return * @return
@@ -145,14 +145,14 @@ ZT_SOCKET_API void ZTCALL zts_leave(const uint64_t nwid);
* @brief Copies the configuration path used by ZeroTier into the provided buffer * @brief Copies the configuration path used by ZeroTier into the provided buffer
* *
* @usage * @usage
* @param homePath * @param homePath Path to ZeroTier configuration files
* @param len * @param len Length of destination buffer
* @return * @return
*/ */
ZT_SOCKET_API void ZTCALL zts_get_homepath(char *homePath, const size_t len); ZT_SOCKET_API void ZTCALL zts_get_homepath(char *homePath, const size_t len);
/** /**
* @brief Returns the ztaddress/nodeId/device ID of this instance * @brief Returns the node ID of this instance
* *
* @usage Call this after zts_start() and/or when zts_running() returns true * @usage Call this after zts_start() and/or when zts_running() returns true
* @return * @return
@@ -160,9 +160,10 @@ ZT_SOCKET_API void ZTCALL zts_get_homepath(char *homePath, const size_t len);
ZT_SOCKET_API uint64_t ZTCALL zts_get_node_id(); ZT_SOCKET_API uint64_t ZTCALL zts_get_node_id();
/** /**
* @brief Returns the ztaddress/nodeId/device ID of this instance (as read from a file) * @brief Returns the node ID of this instance (as read from a file)
* *
* @usage Call with or without starting the service with zts_start() * @usage Call with or without starting the service with zts_start()
* @param filepath Path to ZeroTier configuration files
* @return * @return
*/ */
ZT_SOCKET_API uint64_t ZTCALL zts_get_node_id_from_file(const char *filepath); ZT_SOCKET_API uint64_t ZTCALL zts_get_node_id_from_file(const char *filepath);
@@ -171,7 +172,7 @@ ZT_SOCKET_API uint64_t ZTCALL zts_get_node_id_from_file(const char *filepath);
* @brief Returns whether any address has been assigned to the SockTap for this network * @brief Returns whether any address has been assigned to the SockTap for this network
* *
* @usage This is used as an indicator of readiness for service for the ZeroTier core and stack * @usage This is used as an indicator of readiness for service for the ZeroTier core and stack
* @param nwid * @param nwid Network ID
* @return * @return
*/ */
ZT_SOCKET_API int ZTCALL zts_has_address(const uint64_t nwid); ZT_SOCKET_API int ZTCALL zts_has_address(const uint64_t nwid);
@@ -180,31 +181,31 @@ ZT_SOCKET_API int ZTCALL zts_has_address(const uint64_t nwid);
* @brief Get IP address for this device on a given network * @brief Get IP address for this device on a given network
* *
* @usage FIXME: Only returns first address found, good enough for most cases * @usage FIXME: Only returns first address found, good enough for most cases
* @param nwid * @param nwid Network ID
* @param addrstr * @param addr Destination structure for address
* @param addrlen * @param addrlen Length of destination structure
* @return * @return
*/ */
ZT_SOCKET_API void ZTCALL zts_get_address(const uint64_t nwid, struct sockaddr_storage *addr, const size_t addrlen); ZT_SOCKET_API void ZTCALL zts_get_address(const uint64_t nwid, struct sockaddr_storage *addr, const size_t addrlen);
/** /**
* @brief Copies the 6PLANE IPv6 address for the VirtualTap into the provided buffer * @brief Computes a 6PLANE IPv6 address for the given Network ID and Node ID
* *
* @usage * @usage Can call any time
* @param addr * @param addr Destination structure for address
* @param nwid * @param nwid Network ID
* @param devID * @param nodeId Node ID
* @return * @return
*/ */
ZT_SOCKET_API void ZTCALL zts_get_6plane_addr(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId); ZT_SOCKET_API void ZTCALL zts_get_6plane_addr(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId);
/** /**
* @brief Copies the RFC4193 IPv6 address for the VirtualTap into the provided buffer * @brief Computes a RFC4193 IPv6 address for the given Network ID and Node ID
* *
* @usage * @usage Can call any time
* @param addr * @param addr Destination structure for address
* @param nwid * @param nwid Network ID
* @param devID * @param nodeId Node ID
* @return * @return
*/ */
ZT_SOCKET_API void ZTCALL zts_get_rfc4193_addr(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId); ZT_SOCKET_API void ZTCALL zts_get_rfc4193_addr(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId);
@@ -213,16 +214,16 @@ ZT_SOCKET_API void ZTCALL zts_get_rfc4193_addr(struct sockaddr_storage *addr, co
* @brief Return the number of peers * @brief Return the number of peers
* *
* @usage Call this after zts_start() has succeeded * @usage Call this after zts_start() has succeeded
* @param
* @return * @return
*/ */
ZT_SOCKET_API unsigned long zts_get_peer_count(); ZT_SOCKET_API unsigned long zts_get_peer_count();
/** /**
* @brief Get the virtual address of a perr given it's ztAddress/nodeID * @brief Get the virtual address of a peer given its Node ID
* *
* @usage Call this after zts_start() has succeeded * @usage Call this after zts_start() has succeeded
* @param * @param peer Returned peer address
* @param nodeId Provided Node ID
* @return * @return
*/ */
ZT_SOCKET_API int ZTCALL zts_get_peer_address(char *peer, const uint64_t nodeId); ZT_SOCKET_API int ZTCALL zts_get_peer_address(char *peer, const uint64_t nodeId);
@@ -419,7 +420,7 @@ int zts_poll(struct pollfd *fds, nfds_t nfds, int timeout);
* @brief Monitor multiple file descriptors, waiting until one or more of the file descriptors become "ready" * @brief Monitor multiple file descriptors, waiting until one or more of the file descriptors become "ready"
* *
* @usage Call this after zts_start() has succeeded * @usage Call this after zts_start() has succeeded
* @param nfds * @param nfds
* @param readfds * @param readfds
* @param writefds * @param writefds
* @param exceptfds * @param exceptfds

View File

@@ -420,8 +420,9 @@ int zts_get_peer_address(char *peer, const uint64_t nodeId)
} }
return pl->peerCount; return pl->peerCount;
} }
else else {
return -1; return -1;
}
} }
void zts_allow_http_control(bool allowed) void zts_allow_http_control(bool allowed)

View File

@@ -215,7 +215,7 @@ void lwip_init_interface(void *tapref, const ZeroTier::MAC &mac, const ZeroTier:
lwipdev->output = etharp_output; lwipdev->output = etharp_output;
lwipdev->mtu = ZT_MAX_MTU; lwipdev->mtu = ZT_MAX_MTU;
lwipdev->name[0] = 'l'; lwipdev->name[0] = 'l';
lwipdev->name[1] = (char)lwipInterfacesCount; lwipdev->name[1] = '0'+lwipInterfacesCount;
lwipdev->linkoutput = lwip_eth_tx; lwipdev->linkoutput = lwip_eth_tx;
lwipdev->hwaddr_len = 6; lwipdev->hwaddr_len = 6;
mac.copyTo(lwipdev->hwaddr, lwipdev->hwaddr_len); mac.copyTo(lwipdev->hwaddr, lwipdev->hwaddr_len);
@@ -230,14 +230,13 @@ void lwip_init_interface(void *tapref, const ZeroTier::MAC &mac, const ZeroTier:
netif_set_up(lwipdev); netif_set_up(lwipdev);
mac2str(macbuf, ZT_MAC_ADDRSTRLEN, lwipdev->hwaddr); mac2str(macbuf, ZT_MAC_ADDRSTRLEN, lwipdev->hwaddr);
DEBUG_INFO("initialized netif as [mac=%s, addr=%s, nm=%s]", macbuf, ip.toString(ipbuf), ip.netmask().toString(nmbuf)); DEBUG_INFO("initialized netif as [mac=%s, addr=%s, nm=%s]", macbuf, ip.toString(ipbuf), ip.netmask().toString(nmbuf));
lwipInterfacesCount++;
} }
if (ip.isV6()) { if (ip.isV6()) {
static ip6_addr_t ipaddr; static ip6_addr_t ipaddr;
memcpy(&(ipaddr.addr), ip.rawIpData(), sizeof(ipaddr.addr)); memcpy(&(ipaddr.addr), ip.rawIpData(), sizeof(ipaddr.addr));
lwipdev->mtu = ZT_MAX_MTU; lwipdev->mtu = ZT_MAX_MTU;
lwipdev->name[0] = 'l'; lwipdev->name[0] = 'l';
lwipdev->name[1] = (char)lwipInterfacesCount; lwipdev->name[1] = '0'+lwipInterfacesCount;
lwipdev->hwaddr_len = 6; lwipdev->hwaddr_len = 6;
lwipdev->linkoutput = lwip_eth_tx; lwipdev->linkoutput = lwip_eth_tx;
lwipdev->ip6_autoconfig_enabled = 1; lwipdev->ip6_autoconfig_enabled = 1;