Updated tests/examples
This commit is contained in:
@@ -291,7 +291,6 @@ int zts_sethostname(const char *name, size_t len)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
struct hostent *zts_gethostbyname(const char *name)
|
struct hostent *zts_gethostbyname(const char *name)
|
||||||
{
|
{
|
||||||
if (zts_ready() == false) {
|
if (zts_ready() == false) {
|
||||||
@@ -303,7 +302,7 @@ struct hostent *zts_gethostbyname(const char *name)
|
|||||||
#endif
|
#endif
|
||||||
#if defined(ZT_LWIP_SEQ_SOCKET)
|
#if defined(ZT_LWIP_SEQ_SOCKET)
|
||||||
// TODO: Test thread safety
|
// TODO: Test thread safety
|
||||||
|
/*
|
||||||
char buf[256];
|
char buf[256];
|
||||||
int buflen = 256;
|
int buflen = 256;
|
||||||
int h_err = 0;
|
int h_err = 0;
|
||||||
@@ -319,6 +318,8 @@ struct hostent *zts_gethostbyname(const char *name)
|
|||||||
return *result;
|
return *result;
|
||||||
|
|
||||||
return lwip_gethostbyname(name);
|
return lwip_gethostbyname(name);
|
||||||
|
*/
|
||||||
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(ZT_PICO_BSD_SOCKET)
|
#if defined(ZT_PICO_BSD_SOCKET)
|
||||||
#endif
|
#endif
|
||||||
@@ -326,7 +327,6 @@ struct hostent *zts_gethostbyname(const char *name)
|
|||||||
#endif
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
int zts_close(int fd)
|
int zts_close(int fd)
|
||||||
{
|
{
|
||||||
@@ -608,7 +608,7 @@ int zts_shutdown(int fd, int how)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
int zts_add_dns_nameserver(struct sockaddr *addr)
|
int zts_add_dns_nameserver(struct sockaddr *addr)
|
||||||
{
|
{
|
||||||
DEBUG_EXTRA();
|
DEBUG_EXTRA();
|
||||||
@@ -624,7 +624,7 @@ int zts_add_dns_nameserver(struct sockaddr *addr)
|
|||||||
static ip4_addr_t ipaddr;
|
static ip4_addr_t ipaddr;
|
||||||
ipaddr.addr = in4->sin_addr.s_addr;
|
ipaddr.addr = in4->sin_addr.s_addr;
|
||||||
// TODO: manage DNS server indices
|
// TODO: manage DNS server indices
|
||||||
dns_setserver(0, (const ip_addr_t*)&ipaddr);
|
//dns_setserver(0, (const ip_addr_t*)&ipaddr);
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
#if defined(ZT_PICO_BSD_SOCKET)
|
#if defined(ZT_PICO_BSD_SOCKET)
|
||||||
@@ -649,7 +649,6 @@ int zts_del_dns_nameserver(struct sockaddr *addr)
|
|||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/* The rationale for the following correctional methods is as follows:
|
/* The rationale for the following correctional methods is as follows:
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
printf("Starting ZT service");
|
printf("Starting ZT service");
|
||||||
zts_startjoin("ztp","17d709436c2c5367");
|
zts_startjoin("my_config_path",0x0000000000000000);
|
||||||
|
|
||||||
printf("Dummy. Going into infinite loop. Ping me or something\n");
|
printf("Dummy. Going into infinite loop. Ping me or something\n");
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|||||||
@@ -44,10 +44,9 @@ int main(int argc , char *argv[])
|
|||||||
|
|
||||||
// initialize library
|
// initialize library
|
||||||
printf("Starting libzt...\n");
|
printf("Starting libzt...\n");
|
||||||
zts_startjoin(argv[1], argv[2]);
|
zts_startjoin(argv[1], strtoull(argv[2], NULL, 16));
|
||||||
char device_id[11];
|
uint64_t device_id = zts_get_node_id();
|
||||||
zts_get_id(device_id);
|
fprintf(stderr, "Complete. I am %llx\n", device_id);
|
||||||
fprintf(stderr, "Complete. I am %s\n", device_id);
|
|
||||||
|
|
||||||
// create socket
|
// create socket
|
||||||
int fd;
|
int fd;
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
#include <sys/socket.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
|
|
||||||
#include "libzt.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
char *str = "welcome to the machine";
|
|
||||||
char *nwid = "c7cd7c9e1b0f52a2"; // network
|
|
||||||
char *path = "config_path"; // where this instance's keys and configs are stored
|
|
||||||
char *ip = "10.8.8.42"; // remote address
|
|
||||||
int port = 8080; // remote port
|
|
||||||
|
|
||||||
struct sockaddr_in addr;
|
|
||||||
addr.sin_family = AF_INET;
|
|
||||||
addr.sin_addr.s_addr = inet_addr(ip);
|
|
||||||
addr.sin_port = htons(port);
|
|
||||||
|
|
||||||
zts_startjoin(path, nwid);
|
|
||||||
|
|
||||||
int fd, err = 0;
|
|
||||||
if ((fd = zts_socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
|
||||||
printf("error creating socket\n");
|
|
||||||
}
|
|
||||||
if ((err = zts_connect(fd, (const struct sockaddr *)&addr, sizeof(addr))) < 0) {
|
|
||||||
printf("error connecting to remote host\n");
|
|
||||||
}
|
|
||||||
if ((err = zts_write(fd, str, strlen(str))) < 0) {
|
|
||||||
printf("error writing to socket\n");
|
|
||||||
}
|
|
||||||
if ((err = zts_close(fd)) < 0) {
|
|
||||||
printf("error closing socket\n");
|
|
||||||
}
|
|
||||||
zts_stop();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -2694,12 +2694,12 @@ int main(int argc , char *argv[])
|
|||||||
DEBUG_ERROR("invalid pathname was given");
|
DEBUG_ERROR("invalid pathname was given");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
//uint64_t nwid = strtoull(argv[2],NULL,16);
|
uint64_t nwid = strtoull(argv[2],NULL,16);
|
||||||
uint64_t nodeId = zts_get_node_id();
|
uint64_t nodeId = zts_get_node_id();
|
||||||
|
|
||||||
zts_start(argv[3], true);
|
zts_start(argv[3], true);
|
||||||
//zts_join(nwid);
|
zts_join(nwid);
|
||||||
//sleep(5);
|
sleep(2);
|
||||||
DEBUG_TEST("generated id: %llx", nodeId);
|
DEBUG_TEST("generated id: %llx", nodeId);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user