:: Re: [DNG] simple-netaid-gtk is comm…
トップ ページ
このメッセージを削除
このメッセージに返信
著者: aitor_czr
日付:  
To: dng
題目: Re: [DNG] simple-netaid-gtk is comming soon
Hi Edward,

... and sorry for my delay.

El 09/07/18 a las 17:44, Edward Bartolo escribió:
> Aitor, aitor whose netaid is going to be preferred?


I'll follow working on the same backend you started and using also some
services of ifup, ifdown..., but a shared library would simplify the
code a lot.
Here you are, for example, some advantages of the use of this library:

1) This library removes the dependency on some services like, for
example, iwlist.

2) It also fixes an existent bug in the status icon of both
simple-netaid and wicd projects (and surelly also existent in
network-manager, i' ve not used it for a long time).

3) It solves the problem of the renamed network devices.

> What did you do to
> the 'infamous' SUID backend? Did you add functions to it? Have you
> completely revamped it with completely new code and a different
> algorithms?


I still didn't arrive to the part of the algoritms (automated_scanner?).
As i mentioned above, i'm working on the shared library and its
existence obviously will affect to the code of the backend.
Here you are an example about how to use this library in a C code file:



/***************  BEGIN  **********************/

#include <netstat.h>

int main()
{
    netstat *ns;         // struct defined in netstat.h

    ns = g_new0(netstat, 1);
    if(!ns) {
        printf("Memory failure\n");
        exit( EXIT_FAILURE );
    }

    ns->fnetd = (FNETD*)malloc(sizeof(FNETD));
    ns->fnetd->netdevlist = (NETDEVLIST*)malloc(sizeof(NETDEVLIST));


    netinfo(ns->fnetd->netdevlist);    // THIS LINE DOES THE WORK ! !


    / * *
      *  And now we can get the netdev information:

    // The name of the wired device:
    GString *wired_device =  g_string_new
(ns->fnetd->netdevlist->info.wired_device_name);

    // The name of the wireless device:
    GString *wireless_device = g_string_new
(ns->fnetd->netdevlist->info.wireless_device_name);

    // Are we connected or disconnected?
    gboolean connected = ns->fnetd->netdevlist->info.connected;

// Is the wire plugged or unplugged?
    gboolean plugged = ns->fnetd->netdevlist->info.plug;

    // The label of the status of the network connection will be
something like: "Connected to wlan2 Euskaltel-58YA (90%)"
GString *label = g_string_new (ns->fnetd->netdevlist->info.label);
     / *
       *      etc....
       *  */


     // Free the memory:

    if(ns->fnetd->netdev_fp) netproc_close(ns->fnetd->netdev_fp);
    netproc_netdevlist_clear(ns->fnetd->netdevlist);
    free(ns->fnetd->netdevlist);
//netproc_netdevlist_clear(ns->fnetd->netdevlist);
    free(ns->fnetd);

    return 0;
}

/*************** END   **********************/



SOME COMMENTS:

- The scan_active_wifis() will not be included in the shared library. It
requires granted permissions and will be included in the SUID backend.

- The function "netinfo(NETDEVLIST*)" will do the work in the
"window_main_worker_thread" class. It uses sockets following the
internet protocols, and also uses some features of Alexey Kuznetsov's
NETLINK and iproute2 projects.

- The lines above this funcion will be included in the constructor of
the "window_main_worker_thread" class, and the memory will be destroyed
only when the worker thread's standing up.

- The shared library will be written in C, but the SUID backend of
simple-netaid might be rewritten in C++


> I say 'Sorry' to Devuan for being absent almost regularly but at the
> moment I am indisposed. At least, I had quite good fruit harvests for
> this year. So, life for me is not as dark as it may seem.


I'm glad the plague of armadillos didn't affect to your fruit harvests :-P

> I am still using my dear Devuan (ASCII): I don't think I have enough
> patience to return to MS Windows, too many 'verboten' freedoms in
> that!
> ____________


Cheers,

    Aitor.