From: darkcoven Date: Mon, 7 Apr 2014 22:27:26 +0000 (+0200) Subject: Lib: fallback to login with write request when read request fails X-Git-Url: https://git.sur5r.net/?p=ngadmin;a=commitdiff_plain;h=a0ae34fef838b8b5a8d937c14be6016a3d825c31 Lib: fallback to login with write request when read request fails --- 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