[netsniff-ng] Re: [PATCH] flowtop: Calc flow rate more carefully

2015-11-05 Thread Tobias Klauser
On 2015-11-04 at 20:42:15 +0100, Vadim Kochan  wrote:
> Make rate calculation more carefully by checking previous & current
> bytes/pkts counter.
> 
> Do calculation only if update time passed >= 1s.
> 
> Signed-off-by: Vadim Kochan 

Applied, thank you Vadim!

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[netsniff-ng]

2015-11-05 Thread vkochan
vadi...@gmail.com
Bcc: 
Subject: Re: [PATCH 1/6] flowtop: Make flow_list a double linked-list
Reply-To: 
In-Reply-To: <20151104160948.ga18...@distanz.ch>

On Wed, Nov 04, 2015 at 05:09:48PM +0100, Tobias Klauser wrote:
> On 2015-11-03 at 19:06:47 +0100, Vadim Kochan  wrote:
> > Added 'prev' field to make double-linked list.
> 
> Please describe _why_ this is needed (i.e. this change being needed to
> support sorting of the flow list). Also, please change the series such
> that this patch comes right before the one actually using the double
> linked list for the first time.
> 
> > 
> > Signed-off-by: Vadim Kochan 
> > ---
> >  flowtop.c | 68 
> > +++
> >  1 file changed, 38 insertions(+), 30 deletions(-)
> > 
> > diff --git a/flowtop.c b/flowtop.c
> > index 6fd3c6a..cf9ac6f 100644
> > --- a/flowtop.c
> > +++ b/flowtop.c
> > @@ -65,7 +65,7 @@ struct flow_entry {
> > char city_src[128], city_dst[128];
> > char rev_dns_src[256], rev_dns_dst[256];
> > char procname[256];
> > -   struct flow_entry *next;
> > +   struct flow_entry *next, *prev;
> 
> Could we use a kernel-style struct list_head here and use userspace
> ports of the proven and stable helpers in linux/rculist.h to
> access/manipulate the list instead of manually implementing it (which
> makes it a lot more likely to get something wrong in some corner case)?

Seems like liburcu has rculist.h header, but I'd like to make #defines for
these macros/funcs to get rid of cds_ prefix.

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[netsniff-ng] netsniff-ng: pcap to json

2015-11-05 Thread Vadim Kochan
Hi,

What do you think if it is a good idea to convert pcap to json by netsniff-ng ?
I mean to add such feature ...

Regards,

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[netsniff-ng] Re: netsniff-ng: pcap to json

2015-11-05 Thread Tobias Klauser
On 2015-11-05 at 12:28:29 +0100, Vadim Kochan  wrote:
> What do you think if it is a good idea to convert pcap to json by netsniff-ng 
> ?
> I mean to add such feature ...

What would be the use case for this? Is there a kind of standardized
representation for packets in JSON?

In any case, I think it goes a bit beyond the scope of netsniff-ng,
since we would then also need to support capturing to JSON which - as I
suspect - will be quite some overhead due to the conversion to a
text-based representation which in turn slows down capturing.

Thus I think it should rather be made into a separate tool.

Daniel, what do you think?

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[netsniff-ng] [PATCH] curvetun: Move copyright text to separate variable

2015-11-05 Thread Vadim Kochan
Use copyright text from one place when print it in version or help output.

Signed-off-by: Vadim Kochan 
---
 curvetun.c | 26 --
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/curvetun.c b/curvetun.c
index 5dbc320..cf47510 100644
--- a/curvetun.c
+++ b/curvetun.c
@@ -73,6 +73,14 @@ static const struct option long_options[] = {
{NULL, 0, NULL, 0}
 };
 
+static const char *copyright =
+   "Please report bugs to \n"
+   "Copyright (C) 2011-2013 Daniel Borkmann ,\n"
+   "Swiss federal institute of technology (ETH Zurich)\n"
+   "License: GNU GPL version 2.0\n"
+   "This is free software: you are free to change and redistribute it.\n"
+   "There is NO WARRANTY, to the extent permitted by law.";
+
 static void signal_handler(int number)
 {
switch (number) {
@@ -117,13 +125,8 @@ static void __noreturn help(void)
 "  There is no default port specified, so that you are forced\n"
 "  to select your own! For client/server status messages see 
syslog!\n"
 "  This software is an experimental prototype intended for 
researchers.\n\n"
-"Secret ingredient: 7647-14-5\n\n"
-"Please report bugs to \n"
-"Copyright (C) 2011-2013 Daniel Borkmann 
,\n"
-"Swiss federal institute of technology (ETH Zurich)\n"
-"License: GNU GPL version 2.0\n"
-"This is free software: you are free to change and redistribute 
it.\n"
-"There is NO WARRANTY, to the extent permitted by law.\n");
+"Secret ingredient: 7647-14-5\n\n");
+   puts(copyright);
die();
 }
 
@@ -132,13 +135,8 @@ static void __noreturn version(void)
printf("curvetun %s, Git id: %s\n", VERSION_LONG, GITVERSION);
puts("lightweight curve25519-based IP tunnel\n"
 "Note: Einstein-Rosen bridge not yet supported\n"
-"http://www.netsniff-ng.org\n\n";
-"Please report bugs to \n"
-"Copyright (C) 2011-2013 Daniel Borkmann 
,\n"
-"Swiss federal institute of technology (ETH Zurich)\n"
-"License: GNU GPL version 2.0\n"
-"This is free software: you are free to change and redistribute 
it.\n"
-"There is NO WARRANTY, to the extent permitted by law.\n");
+"http://www.netsniff-ng.org\n\n";);
+   puts(copyright);
die();
 }
 
-- 
2.6.1

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[netsniff-ng] [PATCH] lookup: Do not panic if conf file does not exist

2015-11-05 Thread Vadim Kochan
It is not necessary to do not allow run application if
there is no conf file for port resolving, but instead print
message to stderr.

Signed-off-by: Vadim Kochan 
---
 lookup.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lookup.c b/lookup.c
index 36d03da..7533bae 100644
--- a/lookup.c
+++ b/lookup.c
@@ -39,8 +39,10 @@ void lookup_init_ports(enum ports which)
file = lookup_port_files[which];
 
fp = fopen(file, "r");
-   if (!fp)
-   panic("No %s found!\n", file);
+   if (!fp) {
+   fprintf(stderr, "No %s found for ports resolving!\n", file);
+   return;
+   }
 
memset(buff, 0, sizeof(buff));
 
-- 
2.6.1

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[netsniff-ng] [PATCH] flowtop: Redraw screen in 1s if no key was pressed

2015-11-05 Thread Vadim Kochan
Seems like screen is updating too frequently which
may block some terminals, so lets do it once in 1s
but only if no key was pressed.

Signed-off-by: Vadim Kochan 
---
 flowtop.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/flowtop.c b/flowtop.c
index 2791a74..d4a8ad9 100644
--- a/flowtop.c
+++ b/flowtop.c
@@ -1161,6 +1161,8 @@ static void presenter_screen_update(WINDOW *screen, 
struct flow_list *fl,
 
 static void presenter(void)
 {
+   int time_sleep_us = 20;
+   int time_passed_us = 0;
int skip_lines = 0;
WINDOW *screen;
 
@@ -1170,6 +1172,8 @@ static void presenter(void)
 
rcu_register_thread();
while (!sigint) {
+   bool do_redraw = true;
+
switch (getch()) {
case 'q':
sigint = 1;
@@ -1190,11 +1194,21 @@ static void presenter(void)
break;
default:
fflush(stdin);
+   do_redraw = false;
break;
}
 
-   presenter_screen_update(screen, &flow_list, skip_lines);
-   usleep(20);
+   if (!do_redraw)
+   do_redraw = time_passed_us >= 1 * USEC_PER_SEC;
+
+   if (do_redraw) {
+   presenter_screen_update(screen, &flow_list, skip_lines);
+   time_passed_us = 0;
+   } else {
+   time_passed_us += time_sleep_us;
+   }
+
+   usleep(time_sleep_us);
}
rcu_unregister_thread();
 
-- 
2.6.1

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.