Friday, March 27, 2015

Packeth Patch to display All interfaces ( Down and Non IP Assigned)

Src/callbacks.c
static GtkWidget *file_menu = NULL;
@@ -2167,6 +2167,11 @@ on_Interface_button_clicked
        struct ifreq        IfcBuf[512];
        struct ifreq        *pIfr;
        int num_ifreq;
+
+       struct if_nameindex *pif;
+       struct if_nameindex *head;
+       head = pif = if_nameindex();
+
        int i, fd, length;
        char buff[100];
        char *ptr;
@@ -2201,6 +2206,16 @@ on_Interface_button_clicked
        ptr = buff;
+       while (pif->if_index) {
+                       snprintf(ptr, 100, "%s", pif->if_name);
+                        glist = g_list_append(glist, ptr);
+                        ptr = ptr + strlen(pif->if_name) + 1;
+                        length = length + strlen(pif->if_name) + 1;
+                       pif++;
+
+       }
+       /*
+
        for ( pIfr = Ifc.ifc_req, i = 0, length = 0 ; i < num_ifreq; pIfr++, i++ ) {
                if ( (length + strlen(pIfr->ifr_name) + 1) < 100) {
                        snprintf(ptr, 100, "%s", pIfr->ifr_name);
@@ -2211,7 +2226,8 @@ on_Interface_button_clicked
                else
                        break;
        }
-
+       */
+       if_freenameindex(head);
        gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist) ;
        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), iftext);

No comments:

Post a Comment

Featured Post

XDP - Getting Started with XDP (Linux)