static int print_system_info(struct re_printf *pf, void *arg) { uint32_t uptime; int err = 0; (void)arg; uptime = (uint32_t)((long long)(tmr_jiffies() - start_ticks)/1000); err |= re_hprintf(pf, "\n--- System info: ---\n"); err |= re_hprintf(pf, " Machine: %s/%s\n", sys_arch_get(), sys_os_get()); err |= re_hprintf(pf, " Version: %s (libre v%s)\n", BARESIP_VERSION, sys_libre_version_get()); err |= re_hprintf(pf, " Build: %H\n", sys_build_get, NULL); err |= re_hprintf(pf, " Kernel: %H\n", sys_kernel_get, NULL); err |= re_hprintf(pf, " Uptime: %H\n", fmt_human_time, &uptime); err |= re_hprintf(pf, " Started: %s", ctime(&start_time)); #ifdef __VERSION__ err |= re_hprintf(pf, " Compiler: %s\n", __VERSION__); #endif #ifdef USE_OPENSSL err |= re_hprintf(pf, " OpenSSL: %s\n", SSLeay_version(SSLEAY_VERSION)); #endif return err; }
int main(int argc, char *argv[]) { const char *cert = NULL; int err = 0; tlsperf.num = 1; tlsperf.proto = IPPROTO_TCP; for (;;) { const int c = getopt(argc, argv, "a:dc:e:p:n:s:hv"); if (0 > c) break; switch (c) { case 'c': cert = optarg; break; case 'd': tlsperf.proto = IPPROTO_UDP; break; case 'n': tlsperf.num = atoi(optarg); break; case 'v': tlsperf.verbose = true; break; case '?': err = EINVAL; /*@fallthrough@*/ case 'h': usage(); return err; } } err = libre_init(); if (err) goto out; re_printf("tlsperf -- TLS performance testing program\n"); re_printf("build: %H\n", sys_build_get, 0); re_printf("compiler: %s\n", __VERSION__); re_printf("libre: %s\n", sys_libre_version_get()); re_printf("os: %s\n", sys_os_get()); re_printf("arch: %s\n", sys_arch_get()); #ifdef USE_OPENSSL re_printf("openssl info: %s\n%s\n", SSLeay_version(SSLEAY_VERSION), SSLeay_version(SSLEAY_CFLAGS)); #endif re_printf("protocol: %s\n", tlsperf.proto == IPPROTO_TCP ? "TLS" : "DTLS"); err = tls_alloc(&tlsperf.tls, TLS_METHOD_SSLV23, cert, 0); if (err) goto out; if (cert) { re_printf("certificate: %s\n", cert); } else { re_printf("certificate: selfsigned RSA-1024\n"); err = tls_set_selfsigned(tlsperf.tls, "a@b"); if (err) goto out; } re_printf("starting tests now. (num=%u)\n", tlsperf.num); /* * Start timing now */ tlsperf.ts_start = tmr_jiffies(); err = start_test(); if (err) goto out; re_main(0); out: mem_deref(tlsperf.ep_srv); mem_deref(tlsperf.ep_cli); mem_deref(tlsperf.tls); libre_close(); /* check for memory leaks */ mem_debug(); tmr_debug(); return err ? err : tlsperf.err; }