]> git.sur5r.net Git - ngadmin/blobdiff - lib/src/session.c
Lib: fallback to login with write request when read request fails
[ngadmin] / lib / src / session.c
index 667464c987c17f50dd81c67a1d1abfc170da0169..a0357f3ba4a2d356a6639df90222ed937098c49f 100644 (file)
@@ -89,9 +89,10 @@ int ngadmin_scan (struct ngadmin *nga)
                if (sa == NULL)
                        return ERR_MEM;
                
-               extractSwitchAttributes(sa, attr);
+               if (extractSwitchAttributes(sa, attr) == 0)
+                       pushBackList(swiList, sa);
+               
                clearList(attr, (void(*)(void*))freeAttr);
-               pushBackList(swiList, sa);
        }
        
        nga->swi_count = swiList->count;
@@ -163,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