diff options
-rw-r--r-- | squark-auth.8 | 5 | ||||
-rw-r--r-- | squark-auth.c | 13 |
2 files changed, 12 insertions, 6 deletions
diff --git a/squark-auth.8 b/squark-auth.8 index 7d83c9d..ca4be00 100644 --- a/squark-auth.8 +++ b/squark-auth.8 @@ -29,8 +29,9 @@ the port and connected client. The following options are recognized: .IP "\fB\-c \fIsnmp\-communicty" -Specifies the SNMP community to be used. Currently the same community -is used for all switches. +Allows specifying SNMP community. If specified SNMPv2c mode is assumed. +To use SNMPv3 you need to configure the required version and authentication +keys using standard net-snmp configuration files. .IP "\fB\-r \fIlayer3\-root\-ip" The management IP-address of the default gateway router for the clients. diff --git a/squark-auth.c b/squark-auth.c index 73f9e0f..88f4d61 100644 --- a/squark-auth.c +++ b/squark-auth.c @@ -90,7 +90,7 @@ struct switch_info; static int num_queries = 0, running = TRUE; -static const char *snmp_community = "public"; +static const char *snmp_community = NULL; static const char *username_format = "%w"; static struct switch_info *all_switches[SWITCH_HASH_SIZE]; static struct switch_info *l3_root_dev, *l2_root_dev; @@ -524,9 +524,11 @@ struct switch_info *get_switch(sockaddr_any *addr) addr_copy(&si->addr, addr); snmp_sess_init(&config); - config.version = SNMP_VERSION_2c; - config.community = (unsigned char *) snmp_community; - config.community_len = strlen(snmp_community); + if (snmp_community != NULL) { + config.version = SNMP_VERSION_2c; + config.community = (unsigned char *) snmp_community; + config.community_len = strlen(snmp_community); + } config.peername = (char *) addr_print(addr); si->session = snmp_open(&config); @@ -1176,6 +1178,9 @@ int main(int argc, char **argv) fd_set fdset; int opt, fds, block; + setenv("MIBS", "", 1); + init_snmp("squark-auth"); + while ((opt = getopt(argc, argv, "c:r:i:R:v:f:T:")) != -1) { switch (opt) { case 'c': |