From a0ae34fef838b8b5a8d937c14be6016a3d825c31 Mon Sep 17 00:00:00 2001 From: darkcoven Date: Tue, 8 Apr 2014 00:27:26 +0200 Subject: [PATCH] Lib: fallback to login with write request when read request fails --- lib/src/session.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/src/session.c b/lib/src/session.c index 6f4a1eb..a0357f3 100644 --- a/lib/src/session.c +++ b/lib/src/session.c @@ -164,6 +164,15 @@ int ngadmin_login (struct ngadmin *nga, int id) */ pushBackList(attr, newAttr(ATTR_PASSWORD, strlen(nga->password), strdup(nga->password))); ret = readRequest(nga, attr); + + if (ret == ERR_INVOP) { + /* it seems some switches do not support login with read request + * fallback to write request, even if it has the drawback of + * the password being broadcasted back by the switch + */ + ret = writeRequest(nga, NULL); + } + if (ret == ERR_OK ) { /* login succeeded */ /* TODO: if keep broadcasting is disabled, connect() the UDP -- 2.39.2