updated gitignore, client code added;

v0.5.xx
Alexander Vdolainen 9 years ago
parent a430edc0d7
commit 62287773c9

2
.gitignore vendored

@ -50,3 +50,5 @@ coq
*.log *.log
*.crt *.crt
lib/libsntllv2.pc lib/libsntllv2.pc
lv2sd
lv2sc

@ -0,0 +1,129 @@
#include <stdio.h>
#define __USE_GNU
#include <stdlib.h>
#include <stdarg.h>
#include <sys/types.h>
#include <pthread.h>
#include <stdint.h>
#include <getopt.h>
#include <errno.h>
#include <assert.h>
#include <time.h>
#ifdef WIN32
#include <Winsock2.h>
#include <signal.h>
#else
#include <sys/select.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/resource.h>
#include <netdb.h>
#include <unistd.h>
#include <uuid/uuid.h>
#include <execinfo.h>
#include <netinet/in.h>
#endif
#include <tdata/usrtc.h>
#include <sexpr/sexp.h>
#include <sntl/sntllv2.h>
#include <sntl/limits.h>
/* define a little bit */
#define DEFAULT_PORT 13133
#define CHANNEL_COUNT 200
#define CLIENT_COUNT 100
#define MESSAGES_PER_SESSION 10000
#define ITERATION_COUNT 1000
#define FAILS_ONLY
int main(int argc, char **argv)
{
char *rootca = NULL, *cert = NULL;
int port = DEFAULT_PORT;
char *addr = NULL, *login = NULL, *password = NULL;
int opt;
conn_sys_t *ssys;
conn_t *co;
while((opt = getopt(argc, argv, "p:r:a:u:l:w:")) != -1) {
switch(opt) {
case 'p':
port = atoi(optarg);
break;
case 'r':
rootca = strdup(optarg);
break;
case 'a':
addr = strdup(optarg);
break;
case 'u':
cert = strdup(optarg);
break;
case 'l':
login = strdup(optarg);
break;
case 'w':
password = strdup(optarg);
break;
default:
fprintf(stderr, "usage: %s [-p <PORTNUM>] -r <PATH to Root CA> -a <Server ip address> -u <PATH"
" to SSL certificate> -l <User login> -w <User password>\n", argv[0]);
return EINVAL;
}
}
if(!rootca) {
fprintf(stderr, "Root CA not pointed.\n Failure.\n");
return EINVAL;
}
if(!addr) {
fprintf(stderr, "Server address not pointed.\n Failure.\n");
return EINVAL;
}
if(!cert) {
fprintf(stderr, "User certificate not pointed.\n Failure.\n");
return EINVAL;
}
if(!login) {
fprintf(stderr, "User login not pointed.\n Failure.\n");
return EINVAL;
}
if(!password) {
fprintf(stderr, "User password not pointed.\n Failure.\n");
return EINVAL;
}
/* all is fine let's init connection subsystem */
ssys = connections_create();
if(!ssys) {
fprintf(stderr, "Subsystem init failed: %d\n", errno);
return errno;
}
/* set working certificates */
opt = connections_setsslserts(ssys, rootca, cert, cert);
if(opt) {
fprintf(stderr, "Subsystem init failed (set SSL x.509 pems): %d\n", opt);
return opt;
}
/* Tests */
/* try to open connection */
connections_set_channelcall(ssys, NULL);
co = connection_link(ssys, addr, port, cert, login, password);
if(!co) {
fprintf(stderr, "Failed to connection with %d\n", errno);
return errno;
}
return 0;
}
Loading…
Cancel
Save