|
From: <nor...@us...> - 2007-05-09 18:37:25
|
Revision: 14
http://opencalea.svn.sourceforge.net/opencalea/?rev=14&view=rev
Author: norm_brandinger
Date: 2007-05-09 11:37:24 -0700 (Wed, 09 May 2007)
Log Message:
-----------
added df_collector.h
started adding config parser support to df_collector
Modified Paths:
--------------
src/df_collector.c
Added Paths:
-----------
src/df_collector.h
Modified: src/df_collector.c
===================================================================
--- src/df_collector.c 2007-05-09 16:47:08 UTC (rev 13)
+++ src/df_collector.c 2007-05-09 18:37:24 UTC (rev 14)
@@ -30,12 +30,13 @@
#include "msg.h"
#include "calea.h"
+#include "df_collector.h"
+
ssize_t tcp_write(int fd, const void *buf, size_t tot_len);
ssize_t tcp_read(int fd, void *buf, size_t tot_len);
void usage (void);
int PacketSend ( char *packet, int length, int *send_sock );
-#define MAXROUTES 10
#define DF_REPLY 1
char *prog_name = "df_collector";
@@ -49,6 +50,7 @@
int cmii_port = 0;
/* Routes to LEA */
+#define MAXROUTES 10
typedef struct route_t {
char protocol[8]; /* Protocol used to communicate across this route */
@@ -78,6 +80,13 @@
char addrstr[INET_ADDRSTRLEN];
+Config config;
+Config *confptr = NULL;
+char* conf_file = NULL;
+
+char *capture_path;
+char *surveillance_path;
+
void parse_commandline(int argc, char *argv[]) {
int i=0;
@@ -154,6 +163,48 @@
}
}
+ bzero (&config, sizeof(config));
+
+ /* if config file was specified, read that */
+ if (conf_file && strlen(conf_file)) {
+ if (parse_config(&config, OPENCALEA_CONF_SECTION, conf_file) < 0)
+ die("Error with config file \"%s\"", conf_file);
+ if (parse_config(&config, DF_COLLECTOR_CONF_SECTION, conf_file) < 0)
+ die("Error with config file \"%s\"", conf_file);
+ } else {
+ /* otherwise read default config files */
+ if (parse_config(&config, OPENCALEA_CONF_SECTION, DEF_OPENCALEA_CONF) < 0)
+ die("Error parsing config file: %s", DEF_OPENCALEA_CONF);
+ if (parse_config(&config, DF_COLLECTOR_CONF_SECTION, DEF_OPENCALEA_CONF) < 0)
+ die("Error parsing config file: %s", DEF_OPENCALEA_CONF);
+ if (parse_config(&config, OPENCALEA_CONF_SECTION, DEF_DF_COLLECTOR_CONF) < 0)
+ die("Error parsing config file: %s", DEF_DF_COLLECTOR_CONF);
+ if (parse_config(&config, DF_COLLECTOR_CONF_SECTION, DEF_DF_COLLECTOR_CONF) < 0)
+ die("Error parsing config file: %s", DEF_DF_COLLECTOR_CONF);
+ }
+
+ /* Get Capture_Path from config file */
+ if ((confptr = get_config(&config, "Capture_Path")) != NULL) {
+ capture_path = malloc(strlen(*confptr->nextval) + 1);
+ if (!capture_path) {
+ debug_5("df_collector: memory allocation for capture_path failed");
+ }
+ bzero(capture_path,strlen(*confptr->nextval) + 1);
+ strncpy(capture_path, *confptr->nextval, strlen(*confptr->nextval));
+ debug_5("df_collector: Capture_Path [%s]", capture_path);
+ }
+
+ /* Get Surveillance_Path from config file */
+ if ((confptr = get_config(&config, "Surveillance_Path")) != NULL) {
+ surveillance_path = malloc(strlen(*confptr->nextval) + 1);
+ if (!surveillance_path) {
+ debug_5("df_collector: memory allocation for capture_path failed");
+ }
+ bzero(surveillance_path, strlen(*confptr->nextval) + 1);
+ strncpy(surveillance_path, *confptr->nextval, strlen(*confptr->nextval));
+ debug_5("df_collector: Surveillance_Path [%s]", surveillance_path);
+ }
+
if ( cmii_file == NULL ) {
usage();
die ( "CmII file not specified (need -f)." );
Added: src/df_collector.h
===================================================================
--- src/df_collector.h (rev 0)
+++ src/df_collector.h 2007-05-09 18:37:24 UTC (rev 14)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007 Norman Brandinger <no...@go...>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _DF_COLLECTOR_H
+#define _DF_COLLECTOR_H
+
+#ifndef DEF_DF_COLLECTOR_CONF
+#define DEF_DF_COLLECTOR_CONF "/etc/opencalea/df_collector.conf"
+#endif
+
+#ifndef DF_COLLECTOR_CONF_SECTION
+#define DF_COLLECTOR_CONF_SECTION "DF_COLLECTOR"
+#endif
+
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|