From fafb8142821a34311f55971674630b674b063495 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 28 Nov 2006 01:53:57 +0000 Subject: Added SNMP v2 support. --- common/config-parser.c | 24 ++++++++++++++++++++++++ common/config-parser.h | 3 +++ 2 files changed, 27 insertions(+) (limited to 'common') 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 #include +#include +#include + #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__ */ -- cgit v1.2.3