Control: tags 808433 + patch

Dear maintainer,

I've prepared an NMU for nethogs (versioned as 0.8.1-0.3). The diff
is attached to this message.

(This is just Arnout Engelen's package from mentors, with a tiny tweak to the
changelog)

Regards.
diff -Nru nethogs-0.8.0/Changelog nethogs-0.8.1/Changelog
--- nethogs-0.8.0/Changelog     2010-08-31 23:16:32.000000000 +0200
+++ nethogs-0.8.1/Changelog     2015-12-20 21:14:42.000000000 +0200
@@ -1,5 +1,15 @@
 Changelog
 
+12/05/13 (muzso)
+- added new command line switches:
+  -s  Sorts output by the sent column.
+  -c  Limits the number of updates (useful for tracemode and scripting the
+      output).
+  -v  Sets view mode (0 = KB/s, 1 = total KB, 2 = total B, 3 = total MB)
+- changed needrefresh default value from true to false
+  (upon startup there's no useful info on network usage, so displaying
+   any results has no use for the user)
+
 31/08/10 (Arnout)
 - support for screens wider than 80 characters, thanks to Shock
   at https://bugs.launchpad.net/ubuntu/+source/nethogs/+bug/627626
@@ -18,7 +28,7 @@
 27/08/05 (Arnout)
 - giving all unknown connections their own
   `unknown' process
-- UDP support
+- Initial work on UDP support
 - investigated memleak, turns out to be a problem in libc:
   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=273051 
   https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=103142
diff -Nru nethogs-0.8.0/connection.cpp nethogs-0.8.1/connection.cpp
--- nethogs-0.8.0/connection.cpp        2008-12-31 17:52:26.000000000 +0200
+++ nethogs-0.8.1/connection.cpp        2015-12-20 21:14:42.000000000 +0200
@@ -1,19 +1,31 @@
+/* 
+ * connection.cpp
+ *
+ * Copyright (c) 2004-2006,2008 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+
 #include <iostream>
-#include <assert.h>
+#include <cassert>
 #include <malloc.h>
 #include "nethogs.h"
 #include "connection.h"
-
-class ConnList
-{
-public:
-       ConnList (Connection * m_val = NULL, ConnList * m_next = NULL)
-       {
-           val = m_val; next = m_next;
-       }
-       Connection * val;
-       ConnList * next;
-};
+#include "process.h"
 
 ConnList * connections = NULL;
 
@@ -105,22 +117,22 @@
        ConnList * prev_conn = NULL;
        while (curr_conn != NULL)
        {
-               if (curr_conn->val == this)
+               if (curr_conn->getVal() == this)
                {
                        ConnList * todelete = curr_conn;
-                       curr_conn = curr_conn->next;
+                       curr_conn = curr_conn->getNext();
                        if (prev_conn == NULL)
                        {
                                connections = curr_conn;
                        } else {
-                               prev_conn->next = curr_conn;
+                               prev_conn->setNext(curr_conn);
                        }
                        delete (todelete);
                }
                else
                {
                        prev_conn = curr_conn;
-                       curr_conn = curr_conn->next;
+                       curr_conn = curr_conn->getNext();
                }
        }
 }
@@ -153,43 +165,55 @@
        }
 }
 
-/* 
- * finds connection to which this packet belongs.
- * a packet belongs to a connection if it matches
- * to its reference packet 
- */
-Connection * findConnection (Packet * packet)
-{
+Connection * findConnectionWithMatchingSource(Packet * packet) {
+       assert(packet->Outgoing());
+
        ConnList * current = connections;
        while (current != NULL)
        {
-               /* the reference packet is always *outgoing* */
-               if (packet->match(current->val->refpacket))
+               /* the reference packet is always outgoing */
+               if (packet->matchSource(current->getVal()->refpacket))
                {
-                       return current->val;
+                       return current->getVal();
                }
 
-               current = current->next;
+               current = current->getNext();
        }
+       return NULL;
+}
 
-       // Try again, now with the packet inverted:
-       current = connections;
-       Packet * invertedPacket = packet->newInverted();
-
+Connection * findConnectionWithMatchingRefpacketOrSource(Packet * packet) {
+       ConnList * current = connections;
        while (current != NULL)
        {
                /* the reference packet is always *outgoing* */
-               if (invertedPacket->match(current->val->refpacket))
+               if (packet->match(current->getVal()->refpacket))
                {
-                       delete invertedPacket;
-                       return current->val;
+                       return current->getVal();
                }
 
-               current = current->next;
+               current = current->getNext();
        }
+       return findConnectionWithMatchingSource(packet);
+}
 
-       delete invertedPacket;
-       return NULL;
+/* 
+ * finds connection to which this packet belongs.
+ * a packet belongs to a connection if it matches
+ * to its reference packet 
+ */
+Connection * findConnection (Packet * packet)
+{
+       if (packet->Outgoing())
+               return findConnectionWithMatchingRefpacketOrSource(packet);
+       else
+       {
+               Packet * invertedPacket = packet->newInverted();
+               Connection * result = 
findConnectionWithMatchingRefpacketOrSource(invertedPacket);
+
+               delete invertedPacket;
+               return result;
+       }
 }
 
 /*
diff -Nru nethogs-0.8.0/connection.h nethogs-0.8.1/connection.h
--- nethogs-0.8.0/connection.h  2008-12-31 17:52:26.000000000 +0200
+++ nethogs-0.8.1/connection.h  2015-12-20 21:14:42.000000000 +0200
@@ -1,3 +1,23 @@
+/*
+ * connection.h
+ *
+ * Copyright (c) 2004-2006,2008 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
 #ifndef __CONNECTION_H
 #define __CONNECTION_H
 
diff -Nru nethogs-0.8.0/conninode.cpp nethogs-0.8.1/conninode.cpp
--- nethogs-0.8.0/conninode.cpp 2009-04-30 10:13:36.000000000 +0200
+++ nethogs-0.8.1/conninode.cpp 2015-12-20 21:14:42.000000000 +0200
@@ -1,6 +1,28 @@
+/* 
+ * conninode.cpp
+ *
+ * Copyright (c) 2008,2009 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+
 #include <netinet/in.h>
 #include <map>
-#include <stdio.h>
+#include <cstdio>
 #include <stdlib.h>
 
 #include "nethogs.h"
diff -Nru nethogs-0.8.0/conninode.h nethogs-0.8.1/conninode.h
--- nethogs-0.8.0/conninode.h   2008-06-24 22:15:45.000000000 +0200
+++ nethogs-0.8.1/conninode.h   2015-12-20 21:14:42.000000000 +0200
@@ -1,2 +1,22 @@
+/*
+ * conninode.h
+ *
+ * Copyright (c) 2008 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
 // handling the connection->inode mapping
 void refreshconninode ();
diff -Nru nethogs-0.8.0/COPYING nethogs-0.8.1/COPYING
--- nethogs-0.8.0/COPYING       1970-01-01 02:00:00.000000000 +0200
+++ nethogs-0.8.1/COPYING       2015-12-20 21:14:42.000000000 +0200
@@ -0,0 +1,339 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff -Nru nethogs-0.8.0/.cproject nethogs-0.8.1/.cproject
--- nethogs-0.8.0/.cproject     1970-01-01 02:00:00.000000000 +0200
+++ nethogs-0.8.1/.cproject     2015-12-20 21:14:42.000000000 +0200
@@ -0,0 +1,624 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?>
+
+<cproject>
+<storageModule moduleId="org.eclipse.cdt.core.settings">
+<cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1525541155">
+<storageModule 
buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" 
id="cdt.managedbuild.config.gnu.exe.debug.1525541155" 
moduleId="org.eclipse.cdt.core.settings" name="Debug">
+<externalSettings/>
+<extensions>
+<extension id="org.eclipse.cdt.core.ELF" 
point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.MakeErrorParser" 
point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GCCErrorParser" 
point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GASErrorParser" 
point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GLDErrorParser" 
point="org.eclipse.cdt.core.ErrorParser"/>
+</extensions>
+</storageModule>
+<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+<configuration artifactName="nethogs" 
buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" 
buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe"
 cleanCommand="rm -rf" description="" 
id="cdt.managedbuild.config.gnu.exe.debug.1525541155" name="Debug" 
parent="cdt.managedbuild.config.gnu.exe.debug">
+<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1525541155." name="/" 
resourcePath="">
+<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.1905970360" 
name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
+<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.252418274" 
name="Debug Platform" 
superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
+<builder buildPath="${workspace_loc:/nethogs/Debug}" 
id="cdt.managedbuild.target.gnu.builder.exe.debug.1488985778" 
keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make 
Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
+<tool id="cdt.managedbuild.tool.gnu.archiver.base.1999185325" name="GCC 
Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.34731434" name="GCC 
C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
+<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.1996360575" 
name="Optimization Level" 
superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" 
value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+<option id="gnu.cpp.compiler.exe.debug.option.debugging.level.556652842" 
name="Debug Level" 
superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" 
value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.676067332" 
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1602981859" name="GCC 
C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
+<option defaultValue="gnu.c.optimization.level.none" 
id="gnu.c.compiler.exe.debug.option.optimization.level.1116042204" 
name="Optimization Level" 
superClass="gnu.c.compiler.exe.debug.option.optimization.level" 
valueType="enumerated"/>
+<option id="gnu.c.compiler.exe.debug.option.debugging.level.1963390657" 
name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" 
value="gnu.c.debugging.level.max" valueType="enumerated"/>
+<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1021274255" 
superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.242811604" name="GCC C 
Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/>
+<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1202926993" name="GCC 
C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
+<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.328037241" 
superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+<additionalInput kind="additionalinput" paths="$(LIBS)"/>
+</inputType>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1779250500" name="GCC 
Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
+<inputType id="cdt.managedbuild.tool.gnu.assembler.input.265134317" 
superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+</tool>
+</toolChain>
+</folderInfo>
+</configuration>
+</storageModule>
+<storageModule moduleId="scannerConfiguration">
+<autodiscovery enabled="true" problemReportingEnabled="true" 
selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" 
useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" 
command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" 
command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<scannerConfigBuildInfo 
instanceId="cdt.managedbuild.config.gnu.exe.debug.1525541155;cdt.managedbuild.config.gnu.exe.debug.1525541155.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.34731434;cdt.managedbuild.tool.gnu.cpp.compiler.input.1760943122">
+<autodiscovery enabled="true" problemReportingEnabled="true" 
selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" 
useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" 
command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" 
command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+</scannerConfigBuildInfo>
+<scannerConfigBuildInfo 
instanceId="cdt.managedbuild.config.gnu.exe.debug.1525541155;cdt.managedbuild.config.gnu.exe.debug.1525541155.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1602981859;cdt.managedbuild.tool.gnu.c.compiler.input.665129628">
+<autodiscovery enabled="true" problemReportingEnabled="true" 
selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" 
useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" 
command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" 
command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+</scannerConfigBuildInfo>
+</storageModule>
+<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
+<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+<buildTargets>
+<target name="all" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+<buildCommand>make</buildCommand>
+<buildArguments/>
+<buildTarget>all</buildTarget>
+<stopOnError>true</stopOnError>
+<useDefaultCommand>true</useDefaultCommand>
+<runAllBuilders>true</runAllBuilders>
+</target>
+</buildTargets>
+</storageModule>
+<storageModule 
moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
+</cconfiguration>
+<cconfiguration id="cdt.managedbuild.config.gnu.exe.release.1454475039">
+<storageModule 
buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" 
id="cdt.managedbuild.config.gnu.exe.release.1454475039" 
moduleId="org.eclipse.cdt.core.settings" name="Release">
+<externalSettings/>
+<extensions>
+<extension id="org.eclipse.cdt.core.ELF" 
point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.MakeErrorParser" 
point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GCCErrorParser" 
point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GASErrorParser" 
point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GLDErrorParser" 
point="org.eclipse.cdt.core.ErrorParser"/>
+</extensions>
+</storageModule>
+<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+<configuration artifactName="nethogs" 
buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" 
buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe"
 cleanCommand="rm -rf" description="" 
id="cdt.managedbuild.config.gnu.exe.release.1454475039" name="Release" 
parent="cdt.managedbuild.config.gnu.exe.release">
+<folderInfo id="cdt.managedbuild.config.gnu.exe.release.1454475039." name="/" 
resourcePath="">
+<toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.1169211223" 
name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
+<targetPlatform 
id="cdt.managedbuild.target.gnu.platform.exe.release.753540986" name="Debug 
Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
+<builder buildPath="${workspace_loc:/nethogs/Release}" 
id="cdt.managedbuild.target.gnu.builder.exe.release.796831900" 
keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make 
Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/>
+<tool id="cdt.managedbuild.tool.gnu.archiver.base.1527956043" name="GCC 
Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.53371738" 
name="GCC C++ Compiler" 
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
+<option id="gnu.cpp.compiler.exe.release.option.optimization.level.612748673" 
name="Optimization Level" 
superClass="gnu.cpp.compiler.exe.release.option.optimization.level" 
value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+<option id="gnu.cpp.compiler.exe.release.option.debugging.level.562100847" 
name="Debug Level" 
superClass="gnu.cpp.compiler.exe.release.option.debugging.level" 
value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
+<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1289312489" 
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.873126868" 
name="GCC C Compiler" 
superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
+<option defaultValue="gnu.c.optimization.level.most" 
id="gnu.c.compiler.exe.release.option.optimization.level.82994166" 
name="Optimization Level" 
superClass="gnu.c.compiler.exe.release.option.optimization.level" 
valueType="enumerated"/>
+<option id="gnu.c.compiler.exe.release.option.debugging.level.1888767939" 
name="Debug Level" 
superClass="gnu.c.compiler.exe.release.option.debugging.level" 
value="gnu.c.debugging.level.none" valueType="enumerated"/>
+<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.766630521" 
superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.1799920776" name="GCC 
C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"/>
+<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.1271225860" 
name="GCC C++ Linker" 
superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release">
+<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1041136489" 
superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+<additionalInput kind="additionalinput" paths="$(LIBS)"/>
+</inputType>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.337610286" name="GCC 
Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
+<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1321569256" 
superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+</tool>
+</toolChain>
+</folderInfo>
+</configuration>
+</storageModule>
+<storageModule moduleId="scannerConfiguration">
+<autodiscovery enabled="true" problemReportingEnabled="true" 
selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" 
useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" 
command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" 
command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<scannerConfigBuildInfo 
instanceId="cdt.managedbuild.config.gnu.exe.debug.1525541155;cdt.managedbuild.config.gnu.exe.debug.1525541155.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.34731434;cdt.managedbuild.tool.gnu.cpp.compiler.input.1760943122">
+<autodiscovery enabled="true" problemReportingEnabled="true" 
selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" 
useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" 
command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" 
command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+</scannerConfigBuildInfo>
+<scannerConfigBuildInfo 
instanceId="cdt.managedbuild.config.gnu.exe.debug.1525541155;cdt.managedbuild.config.gnu.exe.debug.1525541155.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1602981859;cdt.managedbuild.tool.gnu.c.compiler.input.665129628">
+<autodiscovery enabled="true" problemReportingEnabled="true" 
selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" 
useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" 
command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" 
command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile 
id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" 
command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+</scannerConfigBuildInfo>
+</storageModule>
+<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
+<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+<buildTargets>
+<target name="all" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+<buildCommand>make</buildCommand>
+<buildArguments/>
+<buildTarget>all</buildTarget>
+<stopOnError>true</stopOnError>
+<useDefaultCommand>true</useDefaultCommand>
+<runAllBuilders>true</runAllBuilders>
+</target>
+</buildTargets>
+</storageModule>
+<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+<storageModule 
moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
+</cconfiguration>
+</storageModule>
+<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+<project id="nethogs.cdt.managedbuild.target.gnu.exe.2116281487" 
name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/>
+</storageModule>
+</cproject>
diff -Nru nethogs-0.8.0/cui.cpp nethogs-0.8.1/cui.cpp
--- nethogs-0.8.0/cui.cpp       2011-08-27 15:25:22.000000000 +0200
+++ nethogs-0.8.1/cui.cpp       2015-12-20 21:14:42.000000000 +0200
@@ -1,8 +1,31 @@
+/* 
+ * cui.cpp
+ *
+ * Copyright (c) 2004-2006,2008,2010,2011 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+
 /* NetHogs console UI */
 #include <string>
 #include <pwd.h>
 #include <sys/types.h>
-#include <stdlib.h>
+#include <cstdlib>
+#include <cerrno>
 #include <cstdlib>
 #include <algorithm>
 
@@ -12,8 +35,7 @@
 
 
 std::string * caption;
-//extern char [] version;
-const char version[] = " version " VERSION "." SUBVERSION "." MINORVERSION;
+extern const char version[];
 extern ProcList * processes;
 extern timeval curtime;
 
@@ -21,15 +43,14 @@
 extern Process * unknownudp;
 extern Process * unknownip;
 
-// sort on sent or received?
-bool sortRecv = true;
-// viewMode: kb/s or total
-int VIEWMODE_KBPS = 0;
-int VIEWMODE_TOTAL_KB = 1;
-int VIEWMODE_TOTAL_B = 2;
-int VIEWMODE_TOTAL_MB = 3;
-int viewMode = VIEWMODE_KBPS;
-int nViewModes = 4;
+extern bool sortRecv;
+
+extern int viewMode;
+
+extern unsigned refreshlimit;
+extern unsigned refreshcount;
+
+#define PID_MAX 4194303
 
 class Line
 {
@@ -37,6 +58,7 @@
        Line (const char * name, double n_recv_value, double n_sent_value, 
pid_t pid, uid_t uid, const char * n_devicename)
        {
                assert (pid >= 0);
+               assert (pid <= PID_MAX);
                m_name = name;
                sent_value = n_sent_value;
                recv_value = n_recv_value;
@@ -47,6 +69,7 @@
        }
 
        void show (int row, unsigned int proglen);
+       void log ();
 
        double sent_value;
        double recv_value;
@@ -57,73 +80,83 @@
        uid_t m_uid;
 };
 
-char * uid2username (uid_t uid)
+#include <sstream>
+
+std::string itoa(int i)
+{
+       std::stringstream out;
+       out << i;
+       return out.str();
+}
+
+/**
+ * @returns the username that corresponds to this uid 
+ */
+std::string uid2username (uid_t uid)
 {
        struct passwd * pwd = NULL;
-       /* getpwuid() allocates space for this itself,
-        * which we shouldn't free */
+       errno = 0;
+
+       /* points to a static memory area, should not be freed */
        pwd = getpwuid(uid);
 
        if (pwd == NULL)
-       {
-               assert(false);
-               return strdup ("unlisted");
-       } else {
-               return strdup(pwd->pw_name);
-       }
+               if (errno == 0)
+                       return itoa(uid);
+               else
+                       forceExit(false, "Error calling getpwuid(3) for uid %d: 
%d %s", uid, errno, strerror(errno));
+       else
+               return std::string(pwd->pw_name);
 }
 
 
 void Line::show (int row, unsigned int proglen)
 {
        assert (m_pid >= 0);
-       assert (m_pid <= 100000);
-
-       if (DEBUG || tracemode)
-       {
-               std::cout << m_name << '/' << m_pid << '/' << m_uid << "\t" << 
sent_value << "\t" << recv_value << std::endl;
-               return;
-       }
+       assert (m_pid <= PID_MAX);
 
        if (m_pid == 0)
-               mvprintw (3+row, 0, "?");
+               mvprintw (row, 6, "?");
        else
-               mvprintw (3+row, 0, "%d", m_pid);
-       char * username = uid2username(m_uid);
-       mvprintw (3+row, 6, "%s", username);
-       free (username);
+               mvprintw (row, 0, "%7d", m_pid);
+       std::string username = uid2username(m_uid);
+       mvprintw (row, 8, "%s", username.c_str());
        if (strlen (m_name) > proglen) {
                // truncate oversized names
                char * tmp = strdup(m_name);
                char * start = tmp + strlen (m_name) - proglen;
                start[0] = '.';
                start[1] = '.';
-               mvprintw (3+row, 6 + 9, "%s", start);
+               mvprintw (row, 8 + 9, "%s", start);
                free (tmp);
        } else {
-               mvprintw (3+row, 6 + 9, "%s", m_name);
+               mvprintw (row, 8 + 9, "%s", m_name);
        }
-       mvprintw (3+row, 6 + 9 + proglen + 2, "%s", devicename);
-       mvprintw (3+row, 6 + 9 + proglen + 2 + 6, "%10.3f", sent_value);
-       mvprintw (3+row, 6 + 9 + proglen + 2 + 6 + 9 + 3, "%10.3f", recv_value);
+       mvprintw (row, 8 + 9 + proglen + 2, "%s", devicename);
+       mvprintw (row, 8 + 9 + proglen + 2 + 6, "%10.3f", sent_value);
+       mvprintw (row, 8 + 9 + proglen + 2 + 6 + 9 + 3, "%10.3f", recv_value);
        if (viewMode == VIEWMODE_KBPS)
        {
-               mvprintw (3+row, 6 + 9 + proglen + 2 + 6 + 9 + 3 + 11, 
"KB/sec");
+               mvprintw (row, 8 + 9 + proglen + 2 + 6 + 9 + 3 + 11, "KB/sec");
        }
        else if (viewMode == VIEWMODE_TOTAL_MB)
        {
-               mvprintw (3+row, 6 + 9 + proglen + 2 + 6 + 9 + 3 + 11, "MB    
");
+               mvprintw (row, 8 + 9 + proglen + 2 + 6 + 9 + 3 + 11, "MB    ");
        }
        else if (viewMode == VIEWMODE_TOTAL_KB)
        {
-               mvprintw (3+row, 6 + 9 + proglen + 2 + 6 + 9 + 3 + 11, "KB    
");
+               mvprintw (row, 8 + 9 + proglen + 2 + 6 + 9 + 3 + 11, "KB    ");
        }
        else if (viewMode == VIEWMODE_TOTAL_B)
        {
-               mvprintw (3+row, 6 + 9 + proglen + 2 + 6 + 9 + 3 + 11, "B     
");
+               mvprintw (row, 8 + 9 + proglen + 2 + 6 + 9 + 3 + 11, "B     ");
        }
 }
 
+void Line::log() {
+       std::cout << m_name << '/' << m_pid << '/' << m_uid << "\t" << 
sent_value << "\t" << recv_value << std::endl;
+}
+
 int GreatestFirst (const void * ma, const void * mb)
 {
        Line ** pa = (Line **)ma;
@@ -169,7 +202,7 @@
        cbreak();
        nodelay(screen, TRUE);
        caption = new std::string ("NetHogs");
-       caption->append(version);
+       caption->append(getVersion());
        //caption->append(", running at ");
 }
 
@@ -197,7 +230,7 @@
                        break;
                case 'm':
                        /* switch mode: total vs kb/s */
-                       viewMode = (viewMode + 1) % nViewModes;
+                       viewMode = (viewMode + 1) % VIEWMODE_COUNT;
                        break;
        }
 }
@@ -302,45 +335,93 @@
        *recvd = sum_recv;
 }
 
-// Display all processes and relevant network traffic using show function
-void do_refresh()
-{
-       int row; // number of terminal rows
-       int col; // number of terminal columns
+void show_trace(Line * lines[], int nproc) {
+       std::cout << "\nRefreshing:\n";
+
+       /* print them */
+       for (int i=0; i<nproc; i++)
+       {
+               lines[i]->log();
+               delete lines[i];
+       }
+
+       /* print the 'unknown' connections, for debugging */
+       ConnList * curr_unknownconn = unknowntcp->connections;
+       while (curr_unknownconn != NULL) {
+               std::cout << "Unknown connection: " <<
+                       curr_unknownconn->getVal()->refpacket->gethashstring() 
<< std::endl;
+
+               curr_unknownconn = curr_unknownconn->getNext();
+       }
+}
+
+void show_ncurses(Line * lines[], int nproc) {
+       int rows; // number of terminal rows
+       int cols; // number of terminal columns
        unsigned int proglen; // max length of the "PROGRAM" column
 
-       getmaxyx(stdscr, row, col);      /* find the boundaries of the screeen 
*/
-       if (col < 60) {
+       double sent_global = 0;
+       double recv_global = 0;
+
+       getmaxyx(stdscr, rows, cols);    /* find the boundaries of the screeen 
*/
+
+       if (cols < 62) {
                clear();
                mvprintw(0,0, "The terminal is too narrow! Please make it 
wider.\nI'll wait...");
                return;
        }
 
-       if (col > PROGNAME_WIDTH) col = PROGNAME_WIDTH;
+       if (cols > PROGNAME_WIDTH) cols = PROGNAME_WIDTH;
 
-       proglen = col - 53;
+       proglen = cols - 55;
 
-       refreshconninode();
-       if (DEBUG || tracemode)
+       clear();
+       mvprintw (0, 0, "%s", caption->c_str());
+       attron(A_REVERSE);
+       mvprintw (2, 0, "    PID USER     %-*.*s  DEV        SENT      RECEIVED 
      ", proglen, proglen, "PROGRAM");
+       attroff(A_REVERSE);
+
+       /* print them */
+       int i;
+       for (i=0; i<nproc; i++)
        {
-               std::cout << "\nRefreshing:\n";
+               if (i+3 < rows)
+                       lines[i]->show(i+3, proglen);
+               recv_global += lines[i]->recv_value;
+               sent_global += lines[i]->sent_value;
+               delete lines[i];
        }
-       else
+
+       attron(A_REVERSE);
+       int totalrow = std::min(rows-1, 3+1+i);
+       mvprintw (totalrow, 0, "  TOTAL        %-*.*s          %10.3f  %10.3f 
", proglen, proglen, " ", sent_global, recv_global);
+       if (viewMode == VIEWMODE_KBPS)
        {
-               clear();
-               mvprintw (0, 0, "%s", caption->c_str());
-               attron(A_REVERSE);
-               mvprintw (2, 0, "  PID USER     %-*.*s  DEV        SENT      
RECEIVED       ", proglen, proglen, "PROGRAM");
-               attroff(A_REVERSE);
-       }
+               mvprintw (3+1+i, cols - 7, "KB/sec ");
+       } else if (viewMode == VIEWMODE_TOTAL_B) {
+               mvprintw (3+1+i, cols - 7, "B      ");
+       } else if (viewMode == VIEWMODE_TOTAL_KB) {
+               mvprintw (3+1+i, cols - 7, "KB     ");
+       } else if (viewMode == VIEWMODE_TOTAL_MB) {
+               mvprintw (3+1+i, cols - 7, "MB     ");
+       }
+       attroff(A_REVERSE);
+       mvprintw (totalrow+1, 0, "");
+       refresh();
+}
+
+// Display all processes and relevant network traffic using show function
+void do_refresh()
+{
+       refreshconninode();
+       refreshcount++;
+
        ProcList * curproc = processes;
        ProcList * previousproc = NULL;
        int nproc = processes->size();
        /* initialise to null pointers */
        Line * lines [nproc];
-       int n = 0, i = 0;
-       double sent_global = 0;
-       double recv_global = 0;
+       int n = 0;
 
 #ifndef NDEBUG
        // initialise to null pointers
@@ -408,7 +489,7 @@
                        }
                        else
                        {
-                               forceExit("Invalid viewmode");
+                               forceExit(false, "Invalid viewMode: %d", 
viewMode);
                        }
                        uid_t uid = curproc->getVal()->getUid();
 #ifndef NDEBUG
@@ -439,42 +520,11 @@
        /* sort the accumulated lines */
        qsort (lines, nproc, sizeof(Line *), GreatestFirst);
 
-       /* print them */
-       for (i=0; i<nproc; i++)
-       {
-               lines[i]->show(i, proglen);
-               recv_global += lines[i]->recv_value;
-               sent_global += lines[i]->sent_value;
-               delete lines[i];
-       }
-       if (tracemode || DEBUG) {
-               /* print the 'unknown' connections, for debugging */
-               ConnList * curr_unknownconn = unknowntcp->connections;
-               while (curr_unknownconn != NULL) {
-                       std::cout << "Unknown connection: " <<
-                               
curr_unknownconn->getVal()->refpacket->gethashstring() << std::endl;
-
-                       curr_unknownconn = curr_unknownconn->getNext();
-               }
-       }
+       if (tracemode || DEBUG)
+               show_trace(lines, nproc);
+       else
+               show_ncurses(lines, nproc);
 
-       if ((!tracemode) && (!DEBUG)){
-               attron(A_REVERSE);
-               mvprintw (3+1+i, 0, "  TOTAL        %-*.*s        %10.3f  
%10.3f ", proglen, proglen, " ", sent_global, recv_global);
-               if (viewMode == VIEWMODE_KBPS)
-               {
-                       mvprintw (3+1+i, col - 7, "KB/sec ");
-               } else if (viewMode == VIEWMODE_TOTAL_B) {
-                       mvprintw (3+1+i, col - 7, "B      ");
-               } else if (viewMode == VIEWMODE_TOTAL_KB) {
-                       mvprintw (3+1+i, col - 7, "KB     ");
-               } else if (viewMode == VIEWMODE_TOTAL_MB) {
-                       mvprintw (3+1+i, col - 7, "MB     ");
-               }
-               attroff(A_REVERSE);
-               mvprintw (4+1+i, 0, "");
-               refresh();
-       }
+       if (refreshlimit != 0 && refreshcount >= refreshlimit)
+               quit_cb(0);
 }
-
-
diff -Nru nethogs-0.8.0/cui.h nethogs-0.8.1/cui.h
--- nethogs-0.8.0/cui.h 2004-09-17 21:23:20.000000000 +0200
+++ nethogs-0.8.1/cui.h 2015-12-20 21:14:42.000000000 +0200
@@ -1,3 +1,24 @@
+/*
+ * cui.h
+ *
+ * Copyright (c) 2004 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
 /* NetHogs console UI */
 
 void do_refresh ();
diff -Nru nethogs-0.8.0/.cvsignore nethogs-0.8.1/.cvsignore
--- nethogs-0.8.0/.cvsignore    1970-01-01 02:00:00.000000000 +0200
+++ nethogs-0.8.1/.cvsignore    2015-12-20 21:14:42.000000000 +0200
@@ -0,0 +1,2 @@
+nethogs
+decpcap_test
diff -Nru nethogs-0.8.0/debian/changelog nethogs-0.8.1/debian/changelog
--- nethogs-0.8.0/debian/changelog      2011-08-27 19:48:58.000000000 +0200
+++ nethogs-0.8.1/debian/changelog      2016-02-25 20:09:10.000000000 +0200
@@ -1,6 +1,16 @@
+nethogs (0.8.1-0.3) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * New upstream release. Closes: #808433
+  * Show '?' as PID when the PID could not be determined, instead of '0'.
+  * Allow large values for 'pid'
+  * Use a normal DGRAM (UDP) socket to determine local IPv4 IP
+
+ -- Arnout Engelen <arnou...@bzzt.net>  Wed, 17 Feb 2016 12:34:56 +0100
+
 nethogs (0.8.0-1) unstable; urgency=low
 
-  * Switch to dpkg-source 3.0 (quilt) format.
+  * Switch to dpkg-source 3.0 (quilt) format.
   * New upstream release.  Closes: #635977.
   * debian/patches/01_gcc44.diff: Removed.
   * debian/patches/03_sbin.diff: Removed.
diff -Nru nethogs-0.8.0/debian/compat nethogs-0.8.1/debian/compat
--- nethogs-0.8.0/debian/compat 2011-08-27 19:05:32.000000000 +0200
+++ nethogs-0.8.1/debian/compat 2016-02-17 18:44:58.000000000 +0200
@@ -1 +1 @@
-8
+9
diff -Nru nethogs-0.8.0/debian/control nethogs-0.8.1/debian/control
--- nethogs-0.8.0/debian/control        2011-08-27 19:08:27.000000000 +0200
+++ nethogs-0.8.1/debian/control        2016-02-17 23:38:34.000000000 +0200
@@ -2,8 +2,8 @@
 Section: net
 Priority: optional
 Maintainer: Bart Martens <ba...@debian.org>
-Build-Depends: debhelper (>= 8.0.0), libncurses5-dev, libpcap0.8-dev
-Standards-Version: 3.9.2
+Build-Depends: debhelper (>= 9.0.0), libncurses5-dev, libpcap0.8-dev
+Standards-Version: 3.9.6
 Homepage: http://nethogs.sourceforge.net/
 
 Package: nethogs
diff -Nru nethogs-0.8.0/debian/docs nethogs-0.8.1/debian/docs
--- nethogs-0.8.0/debian/docs   2011-08-27 19:17:15.000000000 +0200
+++ nethogs-0.8.1/debian/docs   2016-02-17 13:51:54.000000000 +0200
@@ -1 +1 @@
-README
+README.md
diff -Nru nethogs-0.8.0/debian/patches/02_geteuid.diff 
nethogs-0.8.1/debian/patches/02_geteuid.diff
--- nethogs-0.8.0/debian/patches/02_geteuid.diff        2011-08-27 
19:35:27.000000000 +0200
+++ nethogs-0.8.1/debian/patches/02_geteuid.diff        1970-01-01 
02:00:00.000000000 +0200
@@ -1,11 +0,0 @@
---- ../orig/nethogs-0.7.0/nethogs.cpp  2009-03-12 22:28:14.000000000 +0100
-+++ ./nethogs.cpp      2009-09-29 20:22:58.000000000 +0200
-@@ -320,7 +320,7 @@
-               init_ui();
-       }
- 
--      if (NEEDROOT && (getuid() != 0))
-+      if (NEEDROOT && (geteuid() != 0))
-               forceExit("You need to be root to run NetHogs!");
- 
-       char errbuf[PCAP_ERRBUF_SIZE];
diff -Nru nethogs-0.8.0/debian/patches/04_makefile.diff 
nethogs-0.8.1/debian/patches/04_makefile.diff
--- nethogs-0.8.0/debian/patches/04_makefile.diff       2011-08-27 
19:44:30.000000000 +0200
+++ nethogs-0.8.1/debian/patches/04_makefile.diff       1970-01-01 
02:00:00.000000000 +0200
@@ -1,17 +0,0 @@
---- ../orig/nethogs-0.8.0/Makefile     2011-08-27 17:28:50.000000000 +0000
-+++ ./Makefile 2011-08-27 17:44:00.000000000 +0000
-@@ -5,10 +5,11 @@
- #DESTDIR := /usr
- DESTDIR := /usr/local
- 
--sbin  := $(DESTDIR)/sbin
--man8 := $(DESTDIR)/share/man/man8/
-+sbin  := $(DESTDIR)/usr/sbin
-+man8 := $(DESTDIR)/usr/share/man/man8/
- 
--all: nethogs decpcap_test
-+all: nethogs
-+# decpcap_test
- # nethogs_testsum
- 
- CFLAGS=-g -Wall -Wextra
diff -Nru nethogs-0.8.0/debian/patches/makefile.diff 
nethogs-0.8.1/debian/patches/makefile.diff
--- nethogs-0.8.0/debian/patches/makefile.diff  1970-01-01 02:00:00.000000000 
+0200
+++ nethogs-0.8.1/debian/patches/makefile.diff  2016-02-17 23:42:39.000000000 
+0200
@@ -0,0 +1,22 @@
+Description: don't build tests, install to /usr
+Index: nethogs-0.8.1/Makefile
+===================================================================
+--- nethogs-0.8.1.orig/Makefile
++++ nethogs-0.8.1/Makefile
+@@ -2,13 +2,13 @@ VERSION      := 0
+ SUBVERSION   := 8
+ MINORVERSION := 1
+ 
+-#prefix := /usr
+-prefix := /usr/local
++prefix := /usr
++#prefix := /usr/local
+ 
+ sbin := $(prefix)/sbin
+ man8 := $(prefix)/share/man/man8/
+ 
+-all: nethogs decpcap_test
++all: nethogs
+ 
+ runtests: test
+       ./test
diff -Nru nethogs-0.8.0/debian/patches/series 
nethogs-0.8.1/debian/patches/series
--- nethogs-0.8.0/debian/patches/series 2011-08-27 19:44:48.000000000 +0200
+++ nethogs-0.8.1/debian/patches/series 2016-02-17 13:54:54.000000000 +0200
@@ -1,2 +1 @@
-02_geteuid.diff
-04_makefile.diff
+makefile.diff
diff -Nru nethogs-0.8.0/debian/rules nethogs-0.8.1/debian/rules
--- nethogs-0.8.0/debian/rules  2011-08-27 19:46:20.000000000 +0200
+++ nethogs-0.8.1/debian/rules  2016-02-17 18:47:31.000000000 +0200
@@ -2,5 +2,14 @@
 
 #export DH_VERBOSE=1
 
+export DEB_BUILD_MAINT_OPTIONS=hardening=+all
+
+#CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
+#CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)
+#CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS)
+#LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)
+
+override_dh_auto_test:
+
 %:
        dh $@ 
diff -Nru nethogs-0.8.0/decpcap.c nethogs-0.8.1/decpcap.c
--- nethogs-0.8.0/decpcap.c     2011-07-12 23:31:35.000000000 +0200
+++ nethogs-0.8.1/decpcap.c     2015-12-20 21:14:42.000000000 +0200
@@ -1,5 +1,28 @@
+/* 
+ * decpcap.c
+ *
+ * Copyright (c) 2004-2006,2011 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+
 #include <net/ethernet.h>
 #include <net/if.h>
+#include <netinet/in.h>
 #include <netinet/ip.h>
 #include <netinet/ip6.h>
 #include <netinet/tcp.h>
@@ -55,9 +78,9 @@
        return dp_fillhandle(temp);
 }
 
-struct dp_handle * dp_open_live(const char * device, int snaplen, int promisc, 
int to_ms, const char * ebuf)
+struct dp_handle * dp_open_live(const char * device, int snaplen, int promisc, 
int to_ms, char * errbuf)
 {
-       pcap_t * temp = pcap_open_live(device, snaplen, promisc, to_ms, ebuf); 
+       pcap_t * temp = pcap_open_live(device, snaplen, promisc, to_ms, 
errbuf); 
 
        if (temp == NULL)
        {
@@ -109,7 +132,7 @@
        }
        switch (ip->ip_p)
        {
-               case (6):
+               case IPPROTO_TCP:
                        dp_parse_tcp (handle, header, payload);
                        break;
                default:
@@ -132,7 +155,7 @@
        }
        switch ((ip6->ip6_ctlun).ip6_un1.ip6_un1_nxt)
        {
-               case (6):
+               case IPPROTO_TCP:
                        dp_parse_tcp (handle, header, payload);
                        break;
                default:
@@ -145,6 +168,7 @@
 {
        const struct ether_header * ethernet = (struct ether_header *)packet;
        u_char * payload = (u_char *) packet + sizeof (struct ether_header);
+    u_int16_t protocol = 0;
 
        /* call handle if it exists */
        if (handle->callback[dp_packet_ethernet] != NULL)
@@ -158,12 +182,13 @@
        }
 
        /* parse payload */
-       switch (ethernet->ether_type)
+    protocol = ntohs(ethernet->ether_type);
+       switch (protocol)
        {
-               case (0x0008):
+               case ETHERTYPE_IP:
                        dp_parse_ip (handle, header, payload);
                        break;
-               case (0xDD86):
+               case ETHERTYPE_IPV6:
                        dp_parse_ip6 (handle, header, payload);
                        break;
                default:
@@ -191,6 +216,7 @@
 {
        const struct ppp_header * ppp = (struct ppp_header *) packet;
        u_char * payload = (u_char *) packet + sizeof (struct ppp_header);
+    u_int16_t protocol = 0;
 
        /* call handle if it exists */
        if (handle->callback[dp_packet_ppp] != NULL)
@@ -204,12 +230,13 @@
        }
 
        /* parse payload */
-       switch (ppp->packettype)
+    protocol = ntohs(ppp->packettype);
+       switch (protocol)
        {
-               case (0x0008):
+               case ETHERTYPE_IP:
                        dp_parse_ip (handle, header, payload);
                        break;
-               case (0xDD86):
+               case ETHERTYPE_IPV6:
                        dp_parse_ip6 (handle, header, payload);
                        break;
                default:
@@ -233,6 +260,7 @@
 {
        const struct sll_header * sll = (struct sll_header *) packet;
        u_char * payload = (u_char *) packet + sizeof (struct sll_header);
+    u_int16_t protocol = 0;
 
        /* call handle if it exists */
        if (handle->callback[dp_packet_sll] != NULL)
@@ -246,12 +274,13 @@
        }
 
        /* parse payload */
-       switch (sll->sll_protocol)
+    protocol = ntohs(sll->sll_protocol);
+       switch (protocol)
        {
-               case (0x0008):
+               case ETHERTYPE_IP:
                        dp_parse_ip (handle, header, payload);
                        break;
-               case (0xDD86):
+               case ETHERTYPE_IPV6:
                        dp_parse_ip6 (handle, header, payload);
                        break;
                default:
diff -Nru nethogs-0.8.0/decpcap.h nethogs-0.8.1/decpcap.h
--- nethogs-0.8.0/decpcap.h     2011-07-12 23:31:49.000000000 +0200
+++ nethogs-0.8.1/decpcap.h     2015-12-20 21:14:42.000000000 +0200
@@ -1,3 +1,26 @@
+/* 
+ * decpcap.h
+ *
+ * Copyright (c) 2004-2006,2011 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+#ifndef __DECPCAP_H
+#define __DECPCAP_H
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <pcap.h>
@@ -40,7 +63,7 @@
 
 /* functions to set up a handle (which is basically just a pcap handle) */
 
-struct dp_handle * dp_open_live(const char * device, int snaplen, int promisc, 
int to_ms, const char * ebuf);
+struct dp_handle * dp_open_live(const char * device, int snaplen, int promisc, 
int to_ms, char * errbuf);
 struct dp_handle * dp_open_offline(char * fname, char * ebuf);
 
 /* functions to add callbacks */
@@ -62,3 +85,5 @@
 int dp_setnonblock (struct dp_handle * handle, int i, char * errbuf);
 
 char * dp_geterr (struct dp_handle * handle);
+
+#endif
Binary files /tmp/6o44MmuKTm/nethogs-0.8.0/decpcap_test and 
/tmp/cjWvwcOHTt/nethogs-0.8.1/decpcap_test differ
diff -Nru nethogs-0.8.0/decpcap_test.cpp nethogs-0.8.1/decpcap_test.cpp
--- nethogs-0.8.0/decpcap_test.cpp      2011-07-12 23:21:03.000000000 +0200
+++ nethogs-0.8.1/decpcap_test.cpp      2015-12-20 21:14:42.000000000 +0200
@@ -1,3 +1,25 @@
+/* 
+ * decpcap_test.cpp
+ *
+ * Copyright (c) 2006,2011 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+
 #include <iostream>
 
 extern "C" {
diff -Nru nethogs-0.8.0/devices.cpp nethogs-0.8.1/devices.cpp
--- nethogs-0.8.0/devices.cpp   2011-07-12 23:44:12.000000000 +0200
+++ nethogs-0.8.1/devices.cpp   2015-12-20 21:14:42.000000000 +0200
@@ -1,7 +1,76 @@
+/* 
+ * devices.cpp
+ *
+ * Copyright (c) 2011 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
 #include "devices.h"
 
-device * determine_default_device()
+#include <iostream>
+#include <cstring>
+
+#include <sys/socket.h>
+#include <net/if.h>
+#include <ifaddrs.h>
+
+device * get_default_devices()
 {
-       return new device("eth0");
+       struct ifaddrs *ifaddr, *ifa;
+
+       if (getifaddrs(&ifaddr) == -1) 
+       {
+               std::cerr << "Fail to get interface addresses" << std::endl;
+               // perror("getifaddrs");
+               return NULL;
+       }
+
+       device* devices = NULL;
+       for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) 
+       {
+               if (ifa->ifa_addr == NULL)  
+                       continue;  
+
+               // The interface is up, not a loopback and running ?
+               if ( !(ifa->ifa_flags & IFF_LOOPBACK) && 
+                        (ifa->ifa_flags & IFF_UP) &&
+                        (ifa->ifa_flags & IFF_RUNNING) )
+               {
+                       // Check if the interface is already known by going 
through all the devices
+                       bool found = false;
+                       device* pIter = devices;
+                       while(pIter != NULL)
+                       {
+                               if ( strcmp(ifa->ifa_name,pIter->name) == 0 )
+                               {
+                                       found = true;
+                               }
+                               pIter = pIter->next;
+                       }
+
+                       // We found a new interface, let's add it
+                       if ( found == false )
+                       {
+                               devices = new 
device(strdup(ifa->ifa_name),devices);
+                       }
+               }
+       }
+
+       freeifaddrs(ifaddr);
+       return devices;
 }
 
diff -Nru nethogs-0.8.0/devices.h nethogs-0.8.1/devices.h
--- nethogs-0.8.0/devices.h     2011-07-12 23:42:59.000000000 +0200
+++ nethogs-0.8.1/devices.h     2015-12-20 21:14:42.000000000 +0200
@@ -1,3 +1,27 @@
+/* 
+ * devices.h
+ *
+ * Copyright (c) 2011 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+#ifndef __DEVICES_H
+#define __DEVICES_H
+
 #include <cstddef> // NULL
 
 class device {
@@ -10,4 +34,10 @@
        device * next;
 };
 
-device * determine_default_device();
+/**
+ * This function can return null, if no good interface is found
+ * The function avoids loopback interface and down/not running interfaces
+ */
+device * get_default_devices();
+
+#endif
diff -Nru nethogs-0.8.0/.gitignore nethogs-0.8.1/.gitignore
--- nethogs-0.8.0/.gitignore    1970-01-01 02:00:00.000000000 +0200
+++ nethogs-0.8.1/.gitignore    2015-12-20 21:14:42.000000000 +0200
@@ -0,0 +1,5 @@
+nethogs
+decpcap_test
+TAGS
+*.o
+*~
diff -Nru nethogs-0.8.0/inode2prog.cpp nethogs-0.8.1/inode2prog.cpp
--- nethogs-0.8.0/inode2prog.cpp        2009-03-13 01:08:09.000000000 +0200
+++ nethogs-0.8.1/inode2prog.cpp        2015-12-20 21:14:42.000000000 +0200
@@ -1,27 +1,54 @@
+/*
+ * inode2prog.cpp
+ *
+ * Copyright (c) 2005,2006,2008,2009 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+
 #include <sys/types.h>
-#include <errno.h>
-#include <string.h>
+#include <cerrno>
+#include <cstring>
 #include <dirent.h>
 #include <ctype.h>
 #include <cstdlib>
 #include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
 #include <unistd.h>
 #include <string>
 #include <map>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <limits.h>
+#include <climits>
 
 #include "inode2prog.h"
 
 extern bool bughuntmode;
 
+// Not sure, but assuming there's no more PID's than go into 64 unsigned bits..
+const int MAX_PID_LENGTH = 20;
+
+// Max length of filenames in /proc/<pid>/fd/*. These are numeric, so 10 
digits seems like a safe assumption.
+const int MAX_FDLINK = 10;
+
 /* maps from inode to program-struct */
 std::map <unsigned long, prg_node *> inodeproc;
 
-bool is_number (char * string) {
+bool is_number (const char * string) {
        while (*string) {
                if (!isdigit (*string))
                        return false;
@@ -30,7 +57,7 @@
        return true;
 }
 
-unsigned long str2ulong (char * ptr) {
+unsigned long str2ulong (const char * ptr) {
        unsigned long retval = 0;
 
        while ((*ptr >= '0') && (*ptr <= '9')) {
@@ -40,7 +67,8 @@
        }
        return retval;
 }
-int str2int (char * ptr) {
+
+int str2int (const char * ptr) {
        int retval = 0;
 
        while ((*ptr >= '0') && (*ptr <= '9')) {
@@ -51,86 +79,83 @@
        return retval;
 }
 
-char * getprogname (char * pid) {
-       int filenamelen = 14 + strlen(pid) + 1; 
-       int bufsize = 80;
-       char buffer [bufsize];
-       char * filename = (char *) malloc (filenamelen);
-       snprintf (filename, filenamelen, "/proc/%s/cmdline", pid);
-       int fd = open(filename, O_RDONLY);
+static std::string read_file (int fd) {
+       char buf[255];
+       std::string content;
+
+       for (int length; (length = read(fd, buf, sizeof(buf))) > 0;) {
+               if (length < 0) {
+                       std::fprintf(stderr, "Error reading file: %s\n", 
std::strerror(errno));
+                       std::exit(34);
+               }
+               content.append(buf, length);
+       }
+
+       return content;
+}
+
+static std::string read_file (const char* filepath) {
+       int fd = open(filepath, O_RDONLY);
+
        if (fd < 0) {
-               fprintf (stderr, "Error opening %s: %s\n", filename, 
strerror(errno));
-               free (filename);
-               exit(3);
+               std::fprintf(stderr, "Error opening %s: %s\n", filepath, 
std::strerror(errno));
+               std::exit(3);
                return NULL;
        }
-       int length = read (fd, buffer, bufsize);
-       if (close (fd)) {
-               std::cout << "Error closing file: " << strerror(errno) << 
std::endl;
-               exit(34);
-       }
-       free (filename);
-       if (length < bufsize - 1)
-               buffer[length]='\0';
-
-       char * retval = buffer;
-
-       /* this removed directory names, but that malfunctions
-        * when the program name is like "sshd: arnouten@pts/8"
-       if ((retval = strrchr(buffer, '/')))
-               retval++;
-       else 
-               retval = buffer; 
-       */
-       // truncating is now done where it should be, in cui.cpp
 
-       return strdup(retval);
-}
+       std::string contents = read_file(fd);
 
-void setnode (unsigned long inode, prg_node * newnode)
-{
-       if (inodeproc[inode] != NULL)
-               free (inodeproc[inode]);
-       inodeproc[inode] = newnode;
+       if (close(fd)) {
+               std::fprintf(stderr, "Error opening %s: %s\n", filepath, 
std::strerror(errno));
+               std::exit(34);
+       }
+
+       return contents;
 }
 
-void get_info_by_linkname (char * pid, char * linkname) {
-       if (strncmp(linkname, "socket:[", 8) == 0) {
-               char * ptr = linkname + 8;
-               unsigned long inode = str2ulong(ptr);
+std::string getprogname (pid_t pid) {
+       const int maxfilenamelen = 14 + MAX_PID_LENGTH + 1;
+       char filename[maxfilenamelen];
+
+       std::snprintf(filename, maxfilenamelen, "/proc/%d/cmdline", pid);
+       return read_file(filename);
+}
 
-               char * progname = getprogname (pid);
+void setnode (unsigned long inode, pid_t pid) {
+       prg_node * current_value = inodeproc[inode];
 
-               //std::cout << "Found socket with inode " << inode << " and pid 
" << pid << " and progname " << progname << "\n";
-               prg_node * newnode = (prg_node *) malloc (sizeof (struct 
prg_node));
+       if (current_value == NULL || current_value->pid != pid) {
+               prg_node * newnode = new prg_node;
                newnode->inode = inode;
-               newnode->pid = str2int(pid);
-               // TODO progname could be more memory-efficient
-               strncpy (newnode->name, progname, PROGNAME_WIDTH);
-               free (progname);
-               setnode (inode, newnode);
-       } else {
-               //std::cout << "Linkname looked like: " << linkname << endl;
+               newnode->pid   = pid;
+               newnode->name  = getprogname(pid);
+
+               inodeproc[inode] = newnode;
+               delete current_value;
        }
 }
 
-/* updates the `inodeproc' inode-to-prg_node 
- * for all inodes belonging to this PID 
+void get_info_by_linkname (const char * pid, const char * linkname) {
+       if (strncmp(linkname, "socket:[", 8) == 0) {
+               setnode(str2ulong(linkname + 8), str2int(pid));
+       }
+}
+
+/* updates the `inodeproc' inode-to-prg_node
+ * for all inodes belonging to this PID
  * (/proc/pid/fd/42)
  * */
-void get_info_for_pid(char * pid) {
+void get_info_for_pid(const char * pid) {
+       char dirname[10 + MAX_PID_LENGTH];
+
        size_t dirlen = 10 + strlen(pid);
-       char * dirname = (char *) malloc (dirlen * sizeof(char));
        snprintf(dirname, dirlen, "/proc/%s/fd", pid);
 
-       //std::cout << "Getting info for pid " << pid << std::endl;
-
        DIR * dir = opendir(dirname);
 
        if (!dir)
        {
                std::cout << "Couldn't open dir " << dirname << ": " << 
strerror(errno) << "\n";
-               free (dirname);
                return;
        }
 
@@ -141,8 +166,8 @@
                        continue;
                //std::cout << "Looking at: " << entry->d_name << std::endl;
 
-               int fromlen = dirlen + strlen(entry->d_name) + 1;
-               char * fromname = (char *) malloc (fromlen * sizeof(char));
+               size_t fromlen = dirlen + strlen(entry->d_name) + 1;
+               char fromname[10 + MAX_PID_LENGTH + 1 + MAX_FDLINK];
                snprintf (fromname, fromlen, "%s/%s", dirname, entry->d_name);
 
                //std::cout << "Linking from: " << fromname << std::endl;
@@ -152,20 +177,16 @@
                int usedlen = readlink(fromname, linkname, linklen-1);
                if (usedlen == -1)
                {
-                       free (fromname);
                        continue;
                }
                assert (usedlen < linklen);
                linkname[usedlen] = '\0';
-               //std::cout << "Linking to: " << linkname << std::endl;
                get_info_by_linkname (pid, linkname);
-               free (fromname);
        }
        closedir(dir);
-       free (dirname);
 }
 
-/* updates the `inodeproc' inode-to-prg_node mapping 
+/* updates the `inodeproc' inode-to-prg_node mapping
  * for all processes in /proc */
 void reread_mapping () {
        DIR * proc = opendir ("/proc");
@@ -182,10 +203,8 @@
 
                if (! is_number (entry->d_name)) continue;
 
-               //std::cout << "Getting info for " << entry->d_name << 
std::endl;
                get_info_for_pid(entry->d_name);
        }
-       //std::cout << "End...\n";
        closedir(proc);
 }
 
@@ -193,7 +212,7 @@
 {
        /* we first look in inodeproc */
        struct prg_node * node = inodeproc[inode];
-       
+
        if (node != NULL)
        {
                if (bughuntmode)
@@ -204,7 +223,7 @@
        }
 
        reread_mapping();
-       
+
        struct prg_node * retval = inodeproc[inode];
        if (bughuntmode)
        {
diff -Nru nethogs-0.8.0/inode2prog.h nethogs-0.8.1/inode2prog.h
--- nethogs-0.8.0/inode2prog.h  2008-06-24 22:01:09.000000000 +0200
+++ nethogs-0.8.1/inode2prog.h  2015-12-20 21:14:42.000000000 +0200
@@ -1,19 +1,43 @@
+/*
+ * inode2prog.h
+ *
+ * Copyright (c) 2005,2008 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+#ifndef __INODE2PROG_h
+#define __INODE2PROG_h
+
 /* this should be called quickly after the packet
  * arrived, since the inode may disappear from the table
  * quickly, too :) */
 
 #include "nethogs.h"
-// #define PROGNAME_WIDTH 200
 
 struct prg_node {
     long inode;
-    int pid;
-    char name[PROGNAME_WIDTH];
+    pid_t pid;
+    std::string name;
 };
 
 struct prg_node * findPID (unsigned long inode);
 
 void prg_cache_clear();
- 
+
 // reread the inode-to-prg_node-mapping
 void reread_mapping ();
+
+#endif
diff -Nru nethogs-0.8.0/main.cpp nethogs-0.8.1/main.cpp
--- nethogs-0.8.0/main.cpp      1970-01-01 02:00:00.000000000 +0200
+++ nethogs-0.8.1/main.cpp      2015-12-20 21:14:42.000000000 +0200
@@ -0,0 +1,193 @@
+#include "nethogs.cpp"
+
+static void versiondisplay(void)
+{
+       std::cerr << version << "\n";
+}
+
+static void help(void)
+{
+       //std::cerr << "usage: nethogs [-V] [-b] [-d seconds] [-t] [-p] [-f 
(eth|ppp))] [device [device [device ...]]]\n";
+       std::cerr << "usage: nethogs [-V] [-b] [-d seconds] [-v mode] [-c 
count] [-t] [-p] [-s] [device [device [device ...]]]\n";
+       std::cerr << "          -V : prints version.\n";
+       std::cerr << "          -b : bughunt mode - implies tracemode.\n";
+       std::cerr << "          -d : delay for update refresh rate in seconds. 
default is 1.\n";
+       std::cerr << "          -v : view mode (0 = KB/s, 1 = total KB, 2 = 
total B, 3 = total MB). default is 0.\n";
+       std::cerr << "          -c : number of updates. default is 0 
(unlimited).\n";
+       std::cerr << "          -t : tracemode.\n";
+       //std::cerr << "                -f : format of packets on interface, 
default is eth.\n";
+       std::cerr << "          -p : sniff in promiscious mode (not 
recommended).\n";
+       std::cerr << "          -s : sort output by sent column.\n";
+       std::cerr << "          device : device(s) to monitor. default is all 
interfaces up and running excluding loopback\n";
+       std::cerr << std::endl;
+       std::cerr << "When nethogs is running, press:\n";
+       std::cerr << " q: quit\n";
+       std::cerr << " s: sort by SENT traffic\n";
+       std::cerr << " r: sort by RECEIVE traffic\n";
+       std::cerr << " m: switch between total (KB, B, MB) and KB/s mode\n";
+}
+
+int main (int argc, char** argv)
+{
+       process_init();
+
+       device * devices = NULL;
+       //dp_link_type linktype = dp_link_ethernet;
+       int promisc = 0;
+
+       int opt;
+       while ((opt = getopt(argc, argv, "Vhbtpd:v:c:s")) != -1) {
+               switch(opt) {
+                       case 'V':
+                               versiondisplay();
+                               exit(0);
+                       case 'h':
+                               help();
+                               exit(0);
+                       case 'b':
+                               bughuntmode = true;
+                               tracemode = true;
+                               break;
+                       case 't':
+                               tracemode = true;
+                               break;
+                       case 'p':
+                               promisc = 1;
+                               break;
+                       case 's':
+                               sortRecv = false;
+                               break;
+                       case 'd':
+                               refreshdelay = atoi(optarg);
+                               break;
+                       case 'v':
+                               viewMode = atoi(optarg) % VIEWMODE_COUNT;
+                               break;
+                       case 'c':
+                               refreshlimit = atoi(optarg);
+                               break;
+                       /*
+                       case 'f':
+                               argv++;
+                               if (strcmp (optarg, "ppp") == 0)
+                                       linktype = dp_link_ppp;
+                               else if (strcmp (optarg, "eth") == 0)
+                                       linktype = dp_link_ethernet;
+                               }
+                               break;
+                       */
+                       default:
+                               help();
+                               exit(EXIT_FAILURE);
+               }
+       }
+
+       while (optind < argc) {
+               devices = new device (strdup(argv[optind++]), devices);
+       }
+
+       if (devices == NULL)
+       {
+               devices = get_default_devices();
+        if ( devices == NULL )
+        {
+            std::cerr << "Not devices to monitor" << std::endl;
+            return 0;
+        }
+       }
+
+       if ((!tracemode) && (!DEBUG)){
+               init_ui();
+       }
+
+       if (NEEDROOT && (geteuid() != 0))
+               forceExit(false, "You need to be root to run NetHogs!");
+
+       char errbuf[PCAP_ERRBUF_SIZE];
+
+       handle * handles = NULL;
+       device * current_dev = devices;
+       while (current_dev != NULL) {
+               getLocal(current_dev->name, tracemode);
+
+               dp_handle * newhandle = dp_open_live(current_dev->name, BUFSIZ, 
promisc, 100, errbuf);
+               if (newhandle != NULL)
+               {
+                       dp_addcb (newhandle, dp_packet_ip, process_ip);
+                       dp_addcb (newhandle, dp_packet_ip6, process_ip6);
+                       dp_addcb (newhandle, dp_packet_tcp, process_tcp);
+                       dp_addcb (newhandle, dp_packet_udp, process_udp);
+
+                       /* The following code solves sf.net bug 1019381, but is 
only available
+                        * in newer versions (from 0.8 it seems) of libpcap
+                        *
+                        * update: version 0.7.2, which is in debian stable 
now, should be ok
+                        * also.
+                        */
+                       if (dp_setnonblock (newhandle, 1, errbuf) == -1)
+                       {
+                               fprintf(stderr, "Error putting libpcap in 
nonblocking mode\n");
+                       }
+                       handles = new handle (newhandle, current_dev->name, 
handles);
+               }
+               else
+               {
+                       fprintf(stderr, "Error opening handler for device 
%s\n", current_dev->name);
+               }
+
+               current_dev = current_dev->next;
+       }
+
+       signal (SIGALRM, &alarm_cb);
+       signal (SIGINT, &quit_cb);
+       alarm (refreshdelay);
+
+       fprintf(stderr, "Waiting for first packet to arrive (see 
sourceforge.net bug 1019381)\n");
+       struct dpargs * userdata = (dpargs *) malloc (sizeof (struct dpargs));
+
+       // Main loop:
+       //
+       //  Walks though the 'handles' list, which contains handles opened in 
non-blocking mode.
+       //  This causes the CPU utilisation to go up to 100%. This is tricky:
+       while (1)
+       {
+               bool packets_read = false;
+
+               handle * current_handle = handles;
+               while (current_handle != NULL)
+               {
+                       userdata->device = current_handle->devicename;
+                       userdata->sa_family = AF_UNSPEC;
+                       int retval = dp_dispatch (current_handle->content, -1, 
(u_char *)userdata, sizeof (struct dpargs));
+                       if (retval < 0)
+                       {
+                               std::cerr << "Error dispatching: " << retval << 
std::endl;
+                       }
+                       else if (retval != 0)
+                       {
+                               packets_read = true;
+                       }
+                       current_handle = current_handle->next;
+               }
+
+
+               if (needrefresh)
+               {
+                       if ((!DEBUG)&&(!tracemode))
+                       {
+                               // handle user input
+                               ui_tick();
+                       }
+                       do_refresh();
+                       needrefresh = false;
+               }
+
+               // If no packets were read at all this iteration, pause to 
prevent 100%
+               // CPU utilisation;
+               if (!packets_read)
+               {
+                       usleep(100);
+               }
+       }
+}
+
diff -Nru nethogs-0.8.0/Makefile nethogs-0.8.1/Makefile
--- nethogs-0.8.0/Makefile      2011-08-27 15:38:38.000000000 +0200
+++ nethogs-0.8.1/Makefile      2015-12-20 21:14:42.000000000 +0200
@@ -1,19 +1,28 @@
 VERSION      := 0
 SUBVERSION   := 8
-MINORVERSION := 0
+MINORVERSION := 1
 
-#DESTDIR := /usr
-DESTDIR := /usr/local
+#prefix := /usr
+prefix := /usr/local
 
-sbin  := $(DESTDIR)/sbin
-man8 := $(DESTDIR)/share/man/man8/
+sbin := $(prefix)/sbin
+man8 := $(prefix)/share/man/man8/
 
 all: nethogs decpcap_test
+
+runtests: test
+       ./test
+       
+       
 # nethogs_testsum
 
-CFLAGS=-g -Wall -Wextra
-#CFLAGS=-O2
+CFLAGS?=-Wall -Wextra
+CXXFLAGS?=-Wall -Wextra
+
 OBJS=packet.o connection.o process.o refresh.o decpcap.o cui.o inode2prog.o 
conninode.o devices.o
+
+NCURSES_LIBS?=-lncurses
+
 .PHONY: tgz
 
 tgz: clean
@@ -24,41 +33,46 @@
        echo "Not implemented"
 
 install: nethogs nethogs.8
-       install -d -m 755 $(sbin)
-       install -m 755 nethogs $(sbin)
-       install -d -m 755 $(man8)
-       install -m 644 nethogs.8 $(man8)
+       install -d -m 755 $(DESTDIR)$(sbin)
+       install -m 755 nethogs $(DESTDIR)$(sbin)
+       install -d -m 755 $(DESTDIR)$(man8)
+       install -m 644 nethogs.8 $(DESTDIR)$(man8)
+
+test: test.cpp 
+       $(CXX) $(CXXFLAGS) $(LDFLAGS) test.cpp -o test -lpcap -lm 
${NCURSES_LIBS} -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" 
-DMINORVERSION=\"$(MINORVERSION)\"
 
-nethogs: nethogs.cpp $(OBJS)
-       $(CXX) $(CFLAGS) nethogs.cpp $(OBJS) -o nethogs -lpcap -lm -lncurses 
-DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" 
-DMINORVERSION=\"$(MINORVERSION)\"
+nethogs: main.cpp nethogs.cpp $(OBJS)
+       $(CXX) $(CXXFLAGS) $(LDFLAGS) main.cpp $(OBJS) -o nethogs -lpcap -lm 
${NCURSES_LIBS} -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" 
-DMINORVERSION=\"$(MINORVERSION)\"
 nethogs_testsum: nethogs_testsum.cpp $(OBJS)
-       $(CXX) $(CFLAGS) -g nethogs_testsum.cpp $(OBJS) -o nethogs_testsum 
-lpcap -lm -lncurses -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" 
-DMINORVERSION=\"$(MINORVERSION)\"
+       $(CXX) $(CXXFLAGS) $(LDFLAGS) nethogs_testsum.cpp $(OBJS) -o 
nethogs_testsum -lpcap -lm ${NCURSES_LIBS} -DVERSION=\"$(VERSION)\" 
-DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\"
 
 decpcap_test: decpcap_test.cpp decpcap.o
-       $(CXX) $(CFLAGS) decpcap_test.cpp decpcap.o -o decpcap_test -lpcap -lm
+       $(CXX) $(CXXFLAGS) $(LDFLAGS) decpcap_test.cpp decpcap.o -o 
decpcap_test -lpcap -lm
 
 #-lefence
 
 refresh.o: refresh.cpp refresh.h nethogs.h
-       $(CXX) $(CFLAGS) -c refresh.cpp
+       $(CXX) $(CXXFLAGS) -c refresh.cpp
 process.o: process.cpp process.h nethogs.h
-       $(CXX) $(CFLAGS) -c process.cpp
+       $(CXX) $(CXXFLAGS) -c process.cpp
 packet.o: packet.cpp packet.h nethogs.h
-       $(CXX) $(CFLAGS) -c packet.cpp
+       $(CXX) $(CXXFLAGS) -c packet.cpp
 connection.o: connection.cpp connection.h nethogs.h
-       $(CXX) $(CFLAGS) -c connection.cpp
+       $(CXX) $(CXXFLAGS) -c connection.cpp
 decpcap.o: decpcap.c decpcap.h
        $(CC) $(CFLAGS) -c decpcap.c
 inode2prog.o: inode2prog.cpp inode2prog.h nethogs.h
-       $(CXX) $(CFLAGS) -c inode2prog.cpp
+       $(CXX) $(CXXFLAGS) -c inode2prog.cpp
 conninode.o: conninode.cpp nethogs.h conninode.h
-       $(CXX) $(CFLAGS) -c conninode.cpp
+       $(CXX) $(CXXFLAGS) -c conninode.cpp
 #devices.o: devices.cpp devices.h
-#      $(CXX) $(CFLAGS) -c devices.cpp
+#      $(CXX) $(CXXFLAGS) -c devices.cpp
 cui.o: cui.cpp cui.h nethogs.h
-       $(CXX) $(CFLAGS) -c cui.cpp -DVERSION=\"$(VERSION)\" 
-DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\"
+       $(CXX) $(CXXFLAGS) -c cui.cpp -DVERSION=\"$(VERSION)\" 
-DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\"
 
 .PHONY: clean
 clean:
        rm -f $(OBJS)
        rm -f nethogs
+       rm -f test
+       rm -f decpcap_test
diff -Nru nethogs-0.8.0/nethogs.8 nethogs-0.8.1/nethogs.8
--- nethogs-0.8.0/nethogs.8     2010-04-04 17:36:59.000000000 +0200
+++ nethogs-0.8.1/nethogs.8     2015-12-20 21:14:42.000000000 +0200
@@ -6,22 +6,31 @@
 .SH SYNOPSIS
 .ft B
 .B nethogs
-.RB [ "\-d" ]
 .RB [ "\-h" ]
-.RB [ "\-p" ]
-.RB [ "\-t" ]
 .RB [ "\-V" ] 
+.RB [ "\-d" ]
+.RB [ "\-v" ]
+.RB [ "\-t" ]
+.RB [ "\-c" ]
+.RB [ "\-p" ]
+.RB [ "\-s" ]
 .RI [device(s)]
 .SH DESCRIPTION
 NetHogs is a small 'net top' tool. Instead of breaking the traffic down per 
protocol or per subnet, like most such tools do, it groups bandwidth by process 
- and does not rely on a special kernel module to be loaded. So if there's 
suddenly a lot of network traffic, you can fire up NetHogs and immediately see 
which PID is causing this, and if it's some kind of spinning process, kill it. 
 
 .SS Options
 .TP
+\fB-h\fP
+display available commands usage.
+.TP
+\fB-V\fP
+prints Version info.
+.TP
 \fB-d\fP
 delay for refresh rate.
 .TP
-\fB-h\fP
-display available commands usage.
+\fB-v\fP
+select view mode
 .TP
 \fB-p\fP
 sniff in promiscious mode (not recommended).
@@ -29,8 +38,11 @@
 \fB-t\fP
 tracemode.
 .TP
-\fB-V\fP
-prints Version info.
+\fB-c\fP
+limit number of refreshes
+.TP
+\fB-s\fP
+sort by traffic sent
 .PP
 .I device(s)
 to monitor. By default eth0 is being used.
diff -Nru nethogs-0.8.0/nethogs.cpp nethogs-0.8.1/nethogs.cpp
--- nethogs-0.8.0/nethogs.cpp   2011-07-12 23:39:09.000000000 +0200
+++ nethogs-0.8.1/nethogs.cpp   2015-12-20 21:14:42.000000000 +0200
@@ -1,17 +1,36 @@
-/* nethogs.cpp */
+/* 
+ * nethogs.cpp
+ *
+ * Copyright (c) 2004-2006,2008,2011 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
 
 #include "nethogs.h"
 
 #include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cassert>
 #include <unistd.h>
-#include <signal.h>
+#include <csignal>
 #include <string>
-#include <string.h>
+#include <cstring>
 #include <getopt.h>
-#include <stdarg.h>
+#include <cstdarg>
 
 #include <netinet/ip.h>
 #include <netinet/ip6.h>
@@ -33,15 +52,20 @@
 extern Process * unknownudp;
 
 unsigned refreshdelay = 1;
+unsigned refreshlimit = 0;
+unsigned refreshcount = 0;
+unsigned processlimit = 0;
 bool tracemode = false;
 bool bughuntmode = false;
-bool needrefresh = true;
+bool needrefresh = false;
+// sort on sent or received?
+bool sortRecv = true;
+// viewMode: kb/s or total
+int viewMode = VIEWMODE_KBPS;
 //packet_type packettype = packet_ethernet;
 //dp_link_type linktype = dp_link_ethernet;
 const char version[] = " version " VERSION "." SUBVERSION "." MINORVERSION;
 
-const char * currentdevice = NULL;
-
 timeval curtime;
 
 bool local_addr::contains (const in_addr_t & n_addr) {
@@ -80,6 +104,7 @@
 }
 
 struct dpargs {
+       const char * device;
        int sa_family;
        in_addr ip_src;
        in_addr ip_dst;
@@ -87,6 +112,11 @@
        in6_addr ip6_dst;
 };
 
+const char* getVersion()
+{
+       return version;
+}
+
 int process_tcp (u_char * userdata, const dp_header * header, const u_char * 
m_packet) {
        struct dpargs * args = (struct dpargs *) userdata;
        struct tcphdr * tcp = (struct tcphdr *) m_packet;
@@ -114,28 +144,20 @@
        } else {
                /* else: unknown connection, create new */
                connection = new Connection (packet);
-               getProcess(connection, currentdevice);
+               getProcess(connection, args->device);
        }
        delete packet;
 
-       if (needrefresh)
-       {
-               do_refresh();
-               needrefresh = false;
-       }
-
        /* we're done now. */
        return true;
 }
 
 int process_udp (u_char * userdata, const dp_header * header, const u_char * 
m_packet) {
        struct dpargs * args = (struct dpargs *) userdata;
-       //struct tcphdr * tcp = (struct tcphdr *) m_packet;
        struct udphdr * udp = (struct udphdr *) m_packet;
 
        curtime = header->ts;
 
-       /* TODO get info from userdata, then call getPacket */
        Packet * packet;
        switch (args->sa_family)
        {
@@ -159,16 +181,10 @@
        } else {
                /* else: unknown connection, create new */
                connection = new Connection (packet);
-               getProcess(connection, currentdevice);
+               getProcess(connection, args->device);
        }
        delete packet;
 
-       if (needrefresh)
-       {
-               do_refresh();
-               needrefresh = false;
-       }
-
        /* we're done now. */
        return true;
 }
@@ -203,7 +219,7 @@
        exit(0);
 }
 
-void forceExit(const char *msg, ...)
+void forceExit(bool success, const char *msg, ...)
 {
        if ((!tracemode)&&(!DEBUG)){
                exit_ui();
@@ -215,30 +231,10 @@
        va_end(argp);
        std::cerr << std::endl;
 
-    exit(0);
-}
-
-static void versiondisplay(void)
-{
-       std::cerr << version << "\n";
-}
-
-static void help(void)
-{
-       //std::cerr << "usage: nethogs [-V] [-b] [-d seconds] [-t] [-p] [-f 
(eth|ppp))] [device [device [device ...]]]\n";
-       std::cerr << "usage: nethogs [-V] [-b] [-d seconds] [-t] [-p] [device 
[device [device ...]]]\n";
-       std::cerr << "          -V : prints version.\n";
-       std::cerr << "          -d : delay for update refresh rate in seconds. 
default is 1.\n";
-       std::cerr << "          -t : tracemode.\n";
-       //std::cerr << "                -f : format of packets on interface, 
default is eth.\n";
-       std::cerr << "          -b : bughunt mode - implies tracemode.\n";
-       std::cerr << "          -p : sniff in promiscious mode (not 
recommended).\n";
-       std::cerr << "          device : device(s) to monitor. default is 
eth0\n";
-       std::cerr << std::endl;
-       std::cerr << "When nethogs is running, press:\n";
-       std::cerr << " q: quit\n";
-       std::cerr << " m: switch between total and kb/s mode\n";
-
+       if (success)
+               exit(EXIT_SUCCESS);
+       else
+               exit(EXIT_FAILURE);
 }
 
 class handle {
@@ -252,158 +248,3 @@
        handle * next;
 };
 
-int main (int argc, char** argv)
-{
-       process_init();
-
-       device * devices = NULL;
-       //dp_link_type linktype = dp_link_ethernet;
-       int promisc = 0;
-
-       int opt;
-       while ((opt = getopt(argc, argv, "Vhbtpd:")) != -1) {
-               switch(opt) {
-                       case 'V':
-                               versiondisplay();
-                               exit(0);
-                       case 'h':
-                               help();
-                               exit(0);
-                       case 'b':
-                               bughuntmode = true;
-                               tracemode = true;
-                               break;
-                       case 't':
-                               tracemode = true;
-                               break;
-                       case 'p':
-                               promisc = 1;
-                               break;
-                       case 'd':
-                               refreshdelay=atoi(optarg);
-                               break;
-                       /*
-                       case 'f':
-                               argv++;
-                               if (strcmp (optarg, "ppp") == 0)
-                                       linktype = dp_link_ppp;
-                               else if (strcmp (optarg, "eth") == 0)
-                                       linktype = dp_link_ethernet;
-                               }
-                               break;
-                       */
-                       default:
-                               help();
-                               exit(EXIT_FAILURE);
-               }
-       }
-
-       while (optind < argc) {
-               devices = new device (strdup(argv[optind++]), devices);
-       }
-
-       if (devices == NULL)
-       {
-               devices = determine_default_device();
-       }
-
-       if ((!tracemode) && (!DEBUG)){
-               init_ui();
-       }
-
-       if (NEEDROOT && (getuid() != 0))
-               forceExit("You need to be root to run NetHogs!");
-
-       char errbuf[PCAP_ERRBUF_SIZE];
-
-       handle * handles = NULL;
-       device * current_dev = devices;
-       while (current_dev != NULL) {
-               getLocal(current_dev->name, tracemode);
-               if ((!tracemode) && (!DEBUG)){
-                       //caption->append(current_dev->name);
-                       //caption->append(" ");
-               }
-
-               dp_handle * newhandle = dp_open_live(current_dev->name, BUFSIZ, 
promisc, 100, errbuf);
-               if (newhandle != NULL)
-               {
-                       dp_addcb (newhandle, dp_packet_ip, process_ip);
-                       dp_addcb (newhandle, dp_packet_ip6, process_ip6);
-                       dp_addcb (newhandle, dp_packet_tcp, process_tcp);
-                       dp_addcb (newhandle, dp_packet_udp, process_udp);
-
-                       /* The following code solves sf.net bug 1019381, but is 
only available
-                        * in newer versions (from 0.8 it seems) of libpcap
-                        *
-                        * update: version 0.7.2, which is in debian stable 
now, should be ok
-                        * also.
-                        */
-                       if (dp_setnonblock (newhandle, 1, errbuf) == -1)
-                       {
-                               fprintf(stderr, "Error putting libpcap in 
nonblocking mode\n");
-                       }
-                       handles = new handle (newhandle, current_dev->name, 
handles);
-               }
-               else
-               {
-                       fprintf(stderr, "Error opening handler for device 
%s\n", current_dev->name);
-               }
-
-               current_dev = current_dev->next;
-       }
-
-       signal (SIGALRM, &alarm_cb);
-       signal (SIGINT, &quit_cb);
-       alarm (refreshdelay);
-
-       fprintf(stderr, "Waiting for first packet to arrive (see 
sourceforge.net bug 1019381)\n");
-
-       // Main loop:
-       //
-       //  Walks though the 'handles' list, which contains handles opened in 
non-blocking mode.
-       //  This causes the CPU utilisation to go up to 100%. This is tricky:
-       while (1)
-       {
-               bool packets_read = false;
-
-               handle * current_handle = handles;
-               while (current_handle != NULL)
-               {
-                       struct dpargs * userdata = (dpargs *) malloc (sizeof 
(struct dpargs));
-                       userdata->sa_family = AF_UNSPEC;
-                       currentdevice = current_handle->devicename;
-                       int retval = dp_dispatch (current_handle->content, -1, 
(u_char *)userdata, sizeof (struct dpargs));
-                       if (retval == -1 || retval == -2)
-                       {
-                               std::cerr << "Error dispatching" << std::endl;
-                       }
-                       else if (retval != 0)
-                       {
-                               packets_read = true;
-                       }
-                       free (userdata);
-                       current_handle = current_handle->next;
-               }
-
-               if ((!DEBUG)&&(!tracemode))
-               {
-                       // handle user input
-                       ui_tick();
-               }
-
-               if (needrefresh)
-               {
-                       do_refresh();
-                       needrefresh = false;
-               }
-
-               // If no packets were read at all this iteration, pause to 
prevent 100%
-               // CPU utilisation;
-               if (!packets_read)
-               {
-                       usleep(100);
-               }
-       }
-}
-
diff -Nru nethogs-0.8.0/nethogs.h nethogs-0.8.1/nethogs.h
--- nethogs-0.8.0/nethogs.h     2010-08-31 23:16:25.000000000 +0200
+++ nethogs-0.8.1/nethogs.h     2015-12-20 21:14:42.000000000 +0200
@@ -1,3 +1,25 @@
+/* 
+ * nethogs.h
+ *
+ * Copyright (c) 2004-2006,2008,2010 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+
 #ifndef __NETHOGS_H
 #define __NETHOGS_H
 
@@ -5,8 +27,8 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <arpa/inet.h>
-#include <assert.h>
-#include <string.h>
+#include <cassert>
+#include <cstring>
 #include <malloc.h>
 #include <iostream>
 
@@ -41,7 +63,16 @@
 
 #define PROGNAME_WIDTH 512
 
-void forceExit(const char *msg, ...);
+// viewMode: how to represent numbers
+#define VIEWMODE_KBPS     0
+#define VIEWMODE_TOTAL_KB 1
+#define VIEWMODE_TOTAL_B  2
+#define VIEWMODE_TOTAL_MB 3
+#define VIEWMODE_COUNT    4
+ 
+#define NORETURN __attribute__ ((__noreturn__))
+
+void forceExit(bool success, const char *msg, ...) NORETURN;
 
 class local_addr {
 public:
@@ -106,4 +137,6 @@
 
 void quit_cb (int i);
 
+const char* getVersion();
+
 #endif
diff -Nru nethogs-0.8.0/packet.cpp nethogs-0.8.1/packet.cpp
--- nethogs-0.8.0/packet.cpp    2008-12-31 17:52:26.000000000 +0200
+++ nethogs-0.8.1/packet.cpp    2015-12-20 21:14:42.000000000 +0200
@@ -1,16 +1,38 @@
+/* 
+ * packet.cpp
+ *
+ * Copyright (c) 2004-2006,2008 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+
 #include "nethogs.h"
 #include <iostream>
 #include "packet.h"
 #include <netinet/tcp.h>
 #include <netinet/in.h>
 #include <malloc.h>
-#include <assert.h>
+#include <cassert>
 #include <net/if.h>
 #include <net/ethernet.h>
 #include <netinet/ip.h>
 #include <netinet/ip6.h>
 #include <sys/ioctl.h>
-#include <stdio.h>
+#include <cstdio>
 // #include "inet6.c"
 
 local_addr * local_addrs = NULL;
@@ -38,13 +60,14 @@
        struct ifreq iFreq;
        struct sockaddr_in *saddr;
 
-       if((sock=socket(AF_INET, SOCK_RAW, htons(0x0806)))<0){
-               forceExit("creating socket failed while establishing local IP - 
are you root?");
-       }
+       if((sock=socket(AF_INET, SOCK_DGRAM, 0))<0)
+               forceExit(false, "creating socket failed while establishing 
local IP - are you root?");
+
        strcpy(iFreq.ifr_name, device);
-       if(ioctl(sock, SIOCGIFADDR, &iFreq)<0){
-               forceExit("ioctl failed while establishing local IP for 
selected device %s. You may specify the device on the command line.", device);
-       }
+
+       if(ioctl(sock, SIOCGIFADDR, &iFreq)<0)
+               forceExit(false, "ioctl failed while establishing local IP for 
selected device %s. You may specify the device on the command line.", device);
+
        saddr=(struct sockaddr_in*)&iFreq.ifr_addr;
        local_addrs = new local_addr (saddr->sin_addr.s_addr, local_addrs);
 
@@ -69,6 +92,9 @@
                                if (strcmp (stripspaces(ifname), device) == 0)
                                {
                                        local_addrs = new local_addr (address, 
local_addrs);
+                                       if (tracemode || DEBUG) {
+                                               printf ("Adding local address: 
%s\n", address);
+                                       }
                                }
 #if DEBUG
                                else
@@ -146,12 +172,22 @@
        hashstring = NULL;
 }
 
+direction invert(direction dir) {
+       if (dir == dir_incoming)
+               return dir_outgoing;
+       else if (dir == dir_outgoing)
+               return dir_incoming;
+       else
+               return dir_unknown;
+}
+
 Packet * Packet::newInverted () {
-       /* TODO if this is a bottleneck, we can calculate the direction */
+       direction new_direction = invert(dir);
+
        if (sa_family == AF_INET)
-               return new Packet (dip, dport, sip, sport, len, time, 
dir_unknown);
+               return new Packet (dip, dport, sip, sport, len, time, 
new_direction);
        else
-               return new Packet (dip6, dport, sip6, sport, len, time, 
dir_unknown);
+               return new Packet (dip6, dport, sip6, sport, len, time, 
new_direction);
 }
 
 /* constructs returns a new Packet() structure with the same contents as this 
one */
@@ -198,11 +234,12 @@
                        dir = dir_outgoing;
                        return true;
                } else {
-                       /*if (DEBUG) {
+                       if (DEBUG) {
                                if (sa_family == AF_INET)
                                        islocal = 
local_addrs->contains(dip.s_addr);
                                else
                                        islocal = local_addrs->contains(dip6);
+
                                if (!islocal) {
                                        std::cerr << "Neither dip nor sip are 
local: ";
                                        char addy [50];
@@ -213,7 +250,7 @@
 
                                        return false;
                                }
-                       }*/
+                       }
                        dir = dir_incoming;
                        return false;
                }
@@ -240,7 +277,7 @@
                inet_ntop(sa_family, &dip, remote_string, 49);
        } else {
                inet_ntop(sa_family, &sip6, local_string,  49);
-               inet_ntop(sa_family, &dip6, remote_string, 49);
+inet_ntop(sa_family, &dip6, remote_string, 49);
        }
        if (Outgoing()) {
                snprintf(hashstring, HASHKEYSIZE * sizeof(char), "%s:%d-%s:%d", 
local_string, sport, remote_string, dport);
@@ -261,3 +298,8 @@
        return (sport == other->sport) && (dport == other->dport)
                && (sameinaddr(sip, other->sip)) && (sameinaddr(dip, 
other->dip));
 }
+
+bool Packet::matchSource (Packet * other)
+{
+       return (sport == other->sport) && (sameinaddr(sip, other->sip)); 
+}
diff -Nru nethogs-0.8.0/packet.h nethogs-0.8.1/packet.h
--- nethogs-0.8.0/packet.h      2006-02-05 19:24:19.000000000 +0200
+++ nethogs-0.8.1/packet.h      2015-12-20 21:14:42.000000000 +0200
@@ -1,3 +1,25 @@
+/* 
+ * packet.h
+ *
+ * Copyright (c) 2004,2006 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+
 #ifndef __PACKET_H
 #define __PACKET_H
 
@@ -52,6 +74,7 @@
        bool Outgoing ();
 
        bool match (Packet * other);
+       bool matchSource (Packet * other);
        /* returns '1.2.3.4:5-1.2.3.4:6'-style string */
        char * gethashstring();
 private:
diff -Nru nethogs-0.8.0/process.cpp nethogs-0.8.1/process.cpp
--- nethogs-0.8.0/process.cpp   2011-07-12 23:35:12.000000000 +0200
+++ nethogs-0.8.1/process.cpp   2015-12-20 21:14:42.000000000 +0200
@@ -1,3 +1,25 @@
+/* 
+ * process.cpp
+ *
+ * Copyright (c) 2004,2005,2008,2011 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+
 #include <iostream>
 #include <strings.h>
 #include <string>
@@ -36,7 +58,7 @@
  * * unknown TCP traffic
  * * UDP traffic
  * * unknown IP traffic
- * We must take care this one never gets removed from the list.
+ * We must take care these never get removed from the list.
  */
 Process * unknowntcp; 
 Process * unknownudp; 
@@ -102,53 +124,6 @@
        return findProcess (node);
 }
 
-/* check if we have identified any previously unknown
- * connections are now known 
- *
- * When this is the case, something weird is going on.
- * This function is only called in bughunt-mode
- */
-void reviewUnknown ()
-{
-       ConnList * curr_conn = unknowntcp->connections;
-       ConnList * previous_conn = NULL;
-
-       while (curr_conn != NULL) {
-               unsigned long inode = 
conninode[curr_conn->getVal()->refpacket->gethashstring()];
-               if (inode != 0)
-               {
-                       Process * proc = findProcess (inode);
-                       if (proc != unknowntcp && proc != NULL)
-                       {
-                               if (DEBUG || bughuntmode)
-                                       std::cout << "FIXME: Previously unknown 
inode " << inode << " now got process - apparently it makes sense to review 
unknown connections\n";
-                               /* Yay! - but how can this happen? */
-                               assert(false);
-
-                               /* TODO: this needs some 
investigation/refactoring - we should never get here due to assert(false) */
-
-                               if (previous_conn != NULL)
-                               {
-                                       previous_conn->setNext 
(curr_conn->getNext());
-                                       proc->connections = new ConnList 
(curr_conn->getVal(), proc->connections);
-                                       delete curr_conn;
-                                       curr_conn = previous_conn;
-                               }
-                               else
-                               {
-                                       unknowntcp->connections = 
curr_conn->getNext();
-                                       proc->connections = new ConnList 
(curr_conn->getVal(), proc->connections);
-                                       delete curr_conn;
-                                       curr_conn = unknowntcp->connections;
-                               }
-                       }
-               }
-               previous_conn = curr_conn;
-               if (curr_conn != NULL)
-                       curr_conn = curr_conn->getNext();
-       }
-}
-
 int ProcList::size ()
 {
        int i=1;
@@ -171,7 +146,7 @@
 
 /* 
  * returns the process from proclist with matching pid
- * if the inode is not associated with any PID, return the unknown process
+ * if the inode is not associated with any PID, return NULL
  * if the process is not yet in the proclist, add it
  */
 Process * getProcess (unsigned long inode, const char * devicename)
@@ -182,7 +157,7 @@
        {
                if (DEBUG || bughuntmode)
                        std::cout << "No PID information for inode " << inode 
<< std::endl;
-               return unknowntcp;
+               return NULL;
        }
 
        Process * proc = findProcess (node);
@@ -190,8 +165,7 @@
        if (proc != NULL)
                return proc;
 
-       Process * newproc = new Process (inode, devicename);
-       newproc->name = strdup(node->name);
+       Process * newproc = new Process (inode, devicename, node->name.c_str());
        newproc->pid = node->pid;
 
        char procdir [100];
@@ -297,14 +271,13 @@
                std::cout << "   inode # " << inode << std::endl;
        }
 
-       Process * proc;
-       if (inode == 0) {
-               proc = new Process (0, "", 
connection->refpacket->gethashstring());
-               processes = new ProcList (proc, processes);
-       } 
-       else
-       {
+       Process * proc = NULL;
+       if (inode != 0)
                proc = getProcess(inode, devicename);
+
+       if (proc == NULL) {
+               proc = new Process (inode, "", 
connection->refpacket->gethashstring());
+               processes = new ProcList (proc, processes);
        }
 
        proc->connections = new ConnList (connection, proc->connections);
diff -Nru nethogs-0.8.0/process.h nethogs-0.8.1/process.h
--- nethogs-0.8.0/process.h     2011-07-12 23:35:22.000000000 +0200
+++ nethogs-0.8.1/process.h     2015-12-20 21:14:42.000000000 +0200
@@ -1,7 +1,29 @@
+/* 
+ * process.h
+ *
+ * Copyright (c) 2004-2006,2008,2011 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+
 #ifndef __PROCESS_H
 #define __PROCESS_H
 
-#include <assert.h>
+#include <cassert>
 #include "nethogs.h"
 #include "connection.h"
 
@@ -43,20 +65,20 @@
 class Process
 {
 public:
-       /* the process makes a copy of the device name and name. */
-       Process (unsigned long m_inode, const char * m_devicename, const char * 
m_name = NULL)
+       /* the process makes a copy of the name. the device name needs to be 
stable. */
+       Process (const unsigned long m_inode, const char * m_devicename, const 
char * m_name = NULL)
+               : inode (m_inode)
        {
                //std::cout << "ARN: Process created with dev " << m_devicename 
<< std::endl;
                if (DEBUG)
                        std::cout << "PROC: Process created at " << this << 
std::endl;
-               inode = m_inode;
 
                if (m_name == NULL)
                        name = NULL;
                else
                        name = strdup(m_name);
 
-               devicename = strdup(m_devicename);
+               devicename = m_devicename;
                connections = NULL;
                pid = 0;
                uid = 0;
@@ -68,17 +90,15 @@
        ~Process ()
        {
                free (name);
-               free (devicename);
                if (DEBUG)
                        std::cout << "PROC: Process deleted at " << this << 
std::endl;
        }
        int getLastPacket ();
 
        char * name;
-       char * devicename;
+       const char * devicename;
        int pid;
 
-       unsigned long inode;
        ConnList * connections;
        uid_t getUid()
        {
@@ -89,7 +109,13 @@
        {
                uid = m_uid;
        }
+
+       unsigned long getInode()
+       {
+               return inode;
+       }
 private:
+       const unsigned long inode;
        uid_t uid;
 };
 
diff -Nru nethogs-0.8.0/.project nethogs-0.8.1/.project
--- nethogs-0.8.0/.project      1970-01-01 02:00:00.000000000 +0200
+++ nethogs-0.8.1/.project      2015-12-20 21:14:42.000000000 +0200
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>nethogs</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+                       <triggers>clean,full,incremental,</triggers>
+                       <arguments>
+                               <dictionary>
+                                       <key>?name?</key>
+                                       <value></value>
+                               </dictionary>
+                               <dictionary>
+                                       
<key>org.eclipse.cdt.make.core.append_environment</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
+                                       <value>all</value>
+                               </dictionary>
+                               <dictionary>
+                                       
<key>org.eclipse.cdt.make.core.buildArguments</key>
+                                       <value></value>
+                               </dictionary>
+                               <dictionary>
+                                       
<key>org.eclipse.cdt.make.core.buildCommand</key>
+                                       <value>make</value>
+                               </dictionary>
+                               <dictionary>
+                                       
<key>org.eclipse.cdt.make.core.buildLocation</key>
+                                       
<value>${workspace_loc:/nethogs/Debug}</value>
+                               </dictionary>
+                               <dictionary>
+                                       
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+                                       <value>clean</value>
+                               </dictionary>
+                               <dictionary>
+                                       
<key>org.eclipse.cdt.make.core.contents</key>
+                                       
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+                               </dictionary>
+                               <dictionary>
+                                       
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+                                       <value>false</value>
+                               </dictionary>
+                               <dictionary>
+                                       
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
+                                       <value>all</value>
+                               </dictionary>
+                               <dictionary>
+                                       
<key>org.eclipse.cdt.make.core.stopOnError</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+                                       <value>true</value>
+                               </dictionary>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.cdt.core.ccnature</nature>
+               
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+               
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+               <nature>org.eclipse.cdt.core.cnature</nature>
+       </natures>
+</projectDescription>
diff -Nru nethogs-0.8.0/README nethogs-0.8.1/README
--- nethogs-0.8.0/README        2004-08-23 11:48:43.000000000 +0200
+++ nethogs-0.8.1/README        1970-01-01 02:00:00.000000000 +0200
@@ -1,23 +0,0 @@
-= NETHOGS =
-
-http://nethogs.sf.net
-
-== INTRODUCTION ==
-
-NetHogs is a small 'net top' tool. Instead of breaking the traffic down per 
protocol or per subnet, like most tools do, it groups bandwidth by process. 
NetHogs does not rely on a special kernel module to be loaded. If there's 
suddenly a lot of network traffic, you can fire up NetHogs and immediately see 
which PID is causing this. This makes it easy to indentify programs that have 
gone wild and are suddenly taking up your bandwidth.
-
-Since NetHogs heavily relies on /proc, it currently runs on Linux only. 
-
-== STATUS ==
-
-Ideas/ToDo for new releases:
-
-* Only IPv4 TCP is currently supported
-* Sort the output by other values than network usage
-* Monitor specific processes
-* Make it work correctly on machines with multiple IP addresses
-* Integrate into another tool?? 
-
-== LICENSE ==
-
-GPL.
diff -Nru nethogs-0.8.0/README.md nethogs-0.8.1/README.md
--- nethogs-0.8.0/README.md     1970-01-01 02:00:00.000000000 +0200
+++ nethogs-0.8.1/README.md     2015-12-20 21:14:42.000000000 +0200
@@ -0,0 +1,47 @@
+Nethogs
+=======
+
+[![Build 
Status](https://travis-ci.org/raboof/nethogs.svg?branch=master)](https://travis-ci.org/raboof/nethogs)
+
+http://nethogs.sf.net
+
+Introduction
+------------
+
+NetHogs is a small 'net top' tool. Instead of breaking the traffic down per 
protocol or per subnet, like most tools do, it groups bandwidth by process. 
NetHogs does not rely on a special kernel module to be loaded. If there's 
suddenly a lot of network traffic, you can fire up NetHogs and immediately see 
which PID is causing this. This makes it easy to indentify programs that have 
gone wild and are suddenly taking up your bandwidth.
+
+Since NetHogs heavily relies on /proc, it currently runs on Linux only. 
+
+Status
+------
+
+Nethogs is a mature piece of software included in most Linux distributions.
+
+Ideas for features, as well as open bugs, can be found at 
https://github.com/raboof/nethogs/issues
+
+Coding standards
+----------------
+
+Can anyone recommend a sensible set? :)
+
+For now:
+* '{' 
+ * on a new line for function definitions
+ * on a new line for enums
+ * on the same line for conditionals/loops 
+ * omitted when possible
+* use tab for indentation
+* use doxygen/javadoc-style comments.
+ * for multiline doxygen docs, add a newline after '/**'
+* case
+ * classes: camelcased, start uppercase
+ * enums: camelcased, start uppercase
+ * functions: camelcased, start lowercase
+ * local variables: camelcased, start lowercase
+
+License
+-------
+
+Copyright 2004-2005, 2008, 2010-2012, 2015 Arnout Engelen <arnou...@bzzt.net>
+License: nethogs may be redistributed under the terms of the GPLv2 or any 
+later version. See the COPYING file for the license text.
diff -Nru nethogs-0.8.0/refresh.cpp nethogs-0.8.1/refresh.cpp
--- nethogs-0.8.0/refresh.cpp   2004-06-29 15:31:04.000000000 +0200
+++ nethogs-0.8.1/refresh.cpp   2015-12-20 21:14:42.000000000 +0200
@@ -1,12 +1,34 @@
+/* 
+ * refresh.cpp
+ *
+ * Copyright (c) 2004 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+
 #include <iostream>
-#include <signal.h>
+#include <csignal>
 #include <unistd.h>
 #include "nethogs.h"
 
 extern bool needrefresh;
 extern unsigned refreshdelay;
 
-void alarm_cb (int i)
+void alarm_cb (int /*i*/)
 {
     needrefresh = true;
     //cout << "Setting needrefresh\n";
diff -Nru nethogs-0.8.0/refresh.h nethogs-0.8.1/refresh.h
--- nethogs-0.8.0/refresh.h     2004-06-29 15:31:04.000000000 +0200
+++ nethogs-0.8.1/refresh.h     2015-12-20 21:14:42.000000000 +0200
@@ -1 +1,23 @@
+/* 
+ * refresh.h
+ *
+ * Copyright (c) 2004 Arnout Engelen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+
 void alarm_cb (int i);
diff -Nru nethogs-0.8.0/.travis.yml nethogs-0.8.1/.travis.yml
--- nethogs-0.8.0/.travis.yml   1970-01-01 02:00:00.000000000 +0200
+++ nethogs-0.8.1/.travis.yml   2015-12-20 21:14:42.000000000 +0200
@@ -0,0 +1,8 @@
+language: cpp
+
+addons:
+  apt:
+    packages:
+    - libpcap0.8-dev
+
+script: make

Reply via email to