Vitezslav Samel vitezslav@samel.cz writes:
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.
yea, that idea comes to mine mind too, when I was rewriting it. Sad is, it was written wrong before too.
If you will go the way you allow only one instance of iptraf-ng in time, you also need to rewrite instances.c.
I will create a pid file in (/run/ or /var/run/) and check it right at the beginning of the program.