static int set_details() { int n; #if (TC_ADVANCED) int len; #endif for (n = tc_pagesize; n >>= 1; tc_pagesize_shift++) { /* void */ } #if (!TC_ADVANCED) /* retrieve ip address */ if (srv_settings.raw_ip_list != NULL) { tc_log_info(LOG_NOTICE, 0, "-x para:%s", srv_settings.raw_ip_list); retrieve_ip_addr(); } #else if (srv_settings.raw_device != NULL) { tc_log_info(LOG_NOTICE, 0, "device:%s", srv_settings.raw_device); if (strcmp(srv_settings.raw_device, DEFAULT_DEVICE) == 0) { srv_settings.raw_device = NULL; } else { retrieve_devices(srv_settings.raw_device, &(srv_settings.devices)); } } if (srv_settings.user_filter != NULL) { tc_log_info(LOG_NOTICE, 0, "user filter:%s", srv_settings.user_filter); len = strlen(srv_settings.user_filter); if (len >= MAX_FILTER_LENGH) { tc_log_info(LOG_ERR, 0, "user filter is too long"); return -1; } memcpy(srv_settings.filter, srv_settings.user_filter, len); } else { fprintf(stderr, "please set filter (-F param) for capturing packets\n"); tc_log_info(LOG_ERR, 0, "not set filter (-F param)"); return -1; } #endif #if (TC_NFQUEUE) if (srv_settings.max_queue_len <= 1024) { srv_settings.max_queue_len = -1; } #endif /* daemonize */ if (srv_settings.do_daemonize) { if (sigignore(SIGHUP) == -1) { tc_log_info(LOG_ERR, errno, "failed to ignore SIGHUP"); } if (daemonize() == -1) { fprintf(stderr, "failed to daemonize() in order to daemonize\n"); return -1; } } return 0; }
static int set_details() { /* ignore SIGPIPE signals */ if (sigignore(SIGPIPE) == -1) { perror("failed to ignore SIGPIPE; sigaction"); return -1; } /* retrieve ip address */ if (srv_settings.raw_ip_list != NULL) { tc_log_info(LOG_NOTICE, 0, "-x parameter:%s", srv_settings.raw_ip_list); retrieve_ip_addr(); } if (srv_settings.timeout == 0) { srv_settings.timeout = DEFAULT_TIMEOUT; } /* daemonize */ if (srv_settings.do_daemonize) { if (sigignore(SIGHUP) == -1) { tc_log_info(LOG_ERR, errno, "Failed to ignore SIGHUP"); } if (daemonize() == -1) { fprintf(stderr, "failed to daemon() in order to daemonize\n"); return -1; } } if (tc_time_set_timer(1000) == TC_ERROR) { tc_log_info(LOG_ERR, 0, "set timer error"); return -1; } return 0; }
static int set_details() { #if (INTERCEPT_ADVANCED && TCPCOPY_PCAP) int len; #endif #if (!INTERCEPT_ADVANCED) /* retrieve ip address */ if (srv_settings.raw_ip_list != NULL) { tc_log_info(LOG_NOTICE, 0, "-x parameter:%s", srv_settings.raw_ip_list); retrieve_ip_addr(); } #endif #if (INTERCEPT_ADVANCED) if (srv_settings.raw_targets != NULL) { tc_log_info(LOG_NOTICE, 0, "-o parameter:%s", srv_settings.raw_targets); retrieve_target_addresses(srv_settings.raw_targets, &(srv_settings.targets)); } else { #if (!TCPCOPY_PCAP) tc_log_info(LOG_WARN, 0, "no raw targets for advanced mode"); return -1; #else tc_log_info(LOG_NOTICE, 0, "no raw targets for advanced mode"); #endif } #if (TCPCOPY_PCAP) if (srv_settings.raw_device != NULL) { tc_log_info(LOG_NOTICE, 0, "device:%s", srv_settings.raw_device); if (strcmp(srv_settings.raw_device, DEFAULT_DEVICE) == 0) { srv_settings.raw_device = NULL; } else { retrieve_devices(srv_settings.raw_device, &(srv_settings.devices)); } } if (srv_settings.user_filter != NULL) { tc_log_info(LOG_NOTICE, 0, "user filter:%s", srv_settings.user_filter); len = strlen(srv_settings.user_filter); if (len >= MAX_FILTER_LENGH) { tc_log_info(LOG_ERR, 0, "user filter is too long"); return -1; } memcpy(srv_settings.filter, srv_settings.user_filter, len); } else { extract_filter(); } #endif #endif /* daemonize */ if (srv_settings.do_daemonize) { if (sigignore(SIGHUP) == -1) { tc_log_info(LOG_ERR, errno, "failed to ignore SIGHUP"); } if (daemonize() == -1) { fprintf(stderr, "failed to daemonize() in order to daemonize\n"); return -1; } } return 0; }