#include <string.h>
#include <getopt.h>
#include <errno.h>
+#include <time.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
bool_t require_root_privileges=False;
cstring_t require_root_privileges_explanation=NULL;
+const char *const closure_type_names[] = {
+ [ CL_PURE ] = "PURE" ,
+ [ CL_RESOLVER ] = "RESOLVER" ,
+ [ CL_RANDOMSRC ] = "RANDOMSRC" ,
+ [ CL_SIGPUBKEY ] = "SIGPUBKEY" ,
+ [ CL_SIGPRIVKEY ] = "SIGPRIVKEY" ,
+ [ CL_COMM ] = "COMM" ,
+ [ CL_IPIF ] = "IPIF" ,
+ [ CL_LOG ] = "LOG" ,
+ [ CL_SITE ] = "SITE" ,
+ [ CL_TRANSFORM ] = "TRANSFORM" ,
+ [ CL_DH ] = "DH" ,
+ [ CL_HASH ] = "HASH" ,
+ [ CL_BUFFER ] = "BUFFER" ,
+ [ CL_NETLINK ] = "NETLINK" ,
+ [ CL_PRIVCACHE ] = "PRIVCACHE" ,
+};
+
+const char *closure_type_name(uint32_t ty, char buf[]) {
+ if (ty < ARRAY_SIZE(closure_type_names))
+ return closure_type_names[ty];
+ sprintf(buf, "CL#%.6u", (unsigned)ty);
+ buf[9] = 0;
+ return buf;
+}
+
static pid_t secnet_pid;
/* Structures dealing with poll() call */
int allocdfds=0, shortfall=0;
do {
+#if USE_MONOTONIC
+ struct timespec ts;
+ if (clock_gettime(CLOCK_MONOTONIC, &ts)!=0) {
+ fatal_perror("main loop: clock_gettime(CLOCK_MONOTONIC,)");
+ }
+ tv_now_global.tv_sec = ts.tv_sec;
+ tv_now_global.tv_usec = ts.tv_nsec / 1000;
+#else /* !USE_MONOTONIC */
if (gettimeofday(&tv_now_global, NULL)!=0) {
fatal_perror("main loop: gettimeofday");
}
+#endif /* !USE_MONOTONIC */
now_global=((uint64_t)tv_now_global.tv_sec*(uint64_t)1000)+
((uint64_t)tv_now_global.tv_usec/(uint64_t)1000);
idx=0;
enter_phase(PHASE_GETOPTS);
parse_options(argc,argv);
+ log_early_setlevel();
enter_phase(PHASE_READCONFIG);
config=read_conffile(configfile);