]> git.sur5r.net Git - ngadmin/commitdiff
Lib: fallback to login with write request when read request fails
authordarkcoven <admin@darkcoven.tk>
Mon, 7 Apr 2014 22:27:26 +0000 (00:27 +0200)
committerdarkcoven <admin@darkcoven.tk>
Mon, 7 Apr 2014 22:27:26 +0000 (00:27 +0200)
lib/src/session.c

index 6f4a1ebbaf801c627d0c2dbaacdd7804c1f88dd1..a0357f3ba4a2d356a6639df90222ed937098c49f 100644 (file)
@@ -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);
         */
        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
        if (ret == ERR_OK ) {
                /* login succeeded */
                /* TODO: if keep broadcasting is disabled, connect() the UDP