summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2006-11-28 01:53:57 +0000
committerStef Walter <stef@memberwebs.com>2006-11-28 01:53:57 +0000
commitfafb8142821a34311f55971674630b674b063495 (patch)
tree58aef24fc7ce8fc093d5e477dbacf8306b412859 /common
parent9791f61c323d2769abfe0e9889b81c52ca1309af (diff)
Added SNMP v2 support.
Diffstat (limited to 'common')
-rw-r--r--common/config-parser.c24
-rw-r--r--common/config-parser.h3
2 files changed, 27 insertions, 0 deletions
diff --git a/common/config-parser.c b/common/config-parser.c
index 63c1bbb..c8f2155 100644
--- a/common/config-parser.c
+++ b/common/config-parser.c
@@ -42,6 +42,9 @@
#include <stdarg.h>
#include <dirent.h>
+#include <bsnmp/asn1.h>
+#include <bsnmp/snmp.h>
+
#include "config-parser.h"
static void
@@ -364,3 +367,24 @@ cfg_parse_uri (char *uri, char** scheme, char** host, char** user, char** path)
return NULL;
}
+
+#define CONFIG_SNMP "snmp"
+#define CONFIG_SNMP2 "snmp2"
+#define CONFIG_SNMP2C "snmp2c"
+
+/* Parsing snmp, snmp2 snmp2c etc... */
+const char*
+cfg_parse_scheme(const char *str, enum snmp_version *scheme)
+{
+ /* Currently we only support SNMP pollers */
+ if(strcmp(str, CONFIG_SNMP) == 0)
+ *scheme = SNMP_V1;
+ else if(strcmp(str, CONFIG_SNMP2) == 0)
+ *scheme = SNMP_V2c;
+ else if(strcmp(str, CONFIG_SNMP2C) == 0)
+ *scheme = SNMP_V2c;
+ else
+ return "invalid scheme";
+ return NULL;
+}
+
diff --git a/common/config-parser.h b/common/config-parser.h
index 11949a2..6af8c17 100644
--- a/common/config-parser.h
+++ b/common/config-parser.h
@@ -50,4 +50,7 @@ int cfg_parse_file(const char* filename, void* data, char** memory);
/* A helper for parsing URIs */
const char* cfg_parse_uri (char *uri, char** scheme, char** host, char** user, char** path);
+/* Parsing snmp, snmp2 snmp2c etc... */
+const char* cfg_parse_scheme (const char *input, enum snmp_version *scheme);
+
#endif /* __CONFIG_PARSER_H__ */