static int init_conn_table(void){ int status; int maxclients = -1; char *ip = NULL; char *name = NULL; gcqparam.dbenv = dbenv_open(); if(gcqparam.dbenv == NULL){ warn("Cannot create dbenv."); return(-1); } gcqparam.reclen = DBQ_RECLEN; gcqparam.softlimit = 0; gcqparam.hardlimit = 0; gct = conn_table_create(maxclients, handle_client_input, handle_client_hangup, handle_client_access); if(gct == NULL){ warn("Cannot create table."); return(-1); } status = conn_table_add_element(gct, gserverfd, CONN_TYPE_SERVER_NET, 0, ip, name); if(status != 0){ err(1, "Could not add element."); return(-1); } return(0); }
int main(int argc, char *argv[]) { int ret; /* etterlog copyright */ fprintf(stdout, "\n" EC_COLOR_BOLD "%s %s" EC_COLOR_END " copyright %s %s\n\n", GBL_PROGRAM, EC_VERSION, EC_COPYRIGHT, EC_AUTHORS); /* allocate the global target */ SAFE_CALLOC(GBL_TARGET, 1, sizeof(struct target_env)); /* initialize to all target */ GBL_TARGET->all_mac = 1; GBL_TARGET->all_ip = 1; GBL_TARGET->all_port = 1; /* getopt related parsing... */ parse_options(argc, argv); /* get the global header */ ret = get_header(&GBL.hdr); if (ret == -EINVALID) FATAL_ERROR("Invalid log file"); fprintf(stderr, "Log file version : %s\n", GBL.hdr.version); fprintf(stderr, "Timestamp : %s", ctime((time_t *)&GBL.hdr.tv.tv_sec)); fprintf(stderr, "Type : %s\n\n", (GBL.hdr.type == LOG_PACKET) ? "LOG_PACKET" : "LOG_INFO" ); /* analyze the logfile */ if (GBL.analyze) analyze(); /* rewind the log file and skip the global header */ gzrewind(GBL_LOG_FD); get_header(&GBL.hdr); /* create the connection table (respecting the filters) */ if (GBL.connections) conn_table_create(); /* display the connection table */ if (GBL.connections && !GBL.decode) conn_table_display(); /* extract files from the connections */ if (GBL.decode) conn_decode(); /* not interested in the content... only analysis */ if (GBL.analyze || GBL.connections) return 0; /* display the content of the logfile */ display(); return 0; }