On Thu, Aug 30, 2012 at 06:42:07PM +0200, Nikola Pajkovsky wrote:
code was so difficult to read, that I had to rewrite it from
scratch.
Original code was using list structure designed only for promisc code, and
that means it has to have its own adding / removing / traversing code.
Not smart idea. Also I removed the code which stores and loads from disk
state of promosic mode. Code does:
init path
init_promisc_list(&promisc_list);
save_promisc_list(promisc_list);
srpromisc(1, promisc_list);
destroy_promisc_list(&promisc_list);
...
...
exit/error path
load_promisc_list(&promisc_list);
srpromisc(0, promisc_list);
destroy_promisc_list(&promisc_list);
now it does
init path
init_promisc_list(&promisc_list);
^^^^^^^^^^^^^^^^^
better: promisc_init(&promisc_list, ifname)
if ifname is set, then get only promisc state of given interface
if ifname is NULL, then get promisc state of all interfaces but push on
list only those which have IFF_PROMISC cleared.
Main reason for this is not to change interfaces we are not listening on.
If you will go the way you allow only one instance of iptraf-ng in time,
you also need to rewrite instances.c.
Vita
promisc_set(promisc_list);
...
...
exit/error path
promisc_restore(promisc_list);
destroy_promisc_list(&promisc_list);