Re: sockstat tcp/udp switches

2006-11-11 Thread Giorgos Keramidas
On 2006-11-11 16:48, Giorgos Keramidas <[EMAIL PROTECTED]> wrote: > This patch still has some points which are in need of a slight > modification or rearrangement, but it works fine here. > > My comments, and a proposed patch to replace it (after some style fixes > and partial rewrite of the added

Re: sockstat tcp/udp switches

2006-11-11 Thread Giorgos Keramidas
On 2006-11-07 10:51, Josh Carroll <[EMAIL PROTECTED]> wrote: > Below is the patch using strsep instead. I also updated the > gather_inet function to print a message that a protocol is not > supported if it exists in /etc/protocols, but does not have a case in > the gather_inet function. > > patch i

Re: sockstat tcp/udp switches

2006-11-11 Thread Giorgos Keramidas
On 2006-11-10 11:15, Josh Carroll <[EMAIL PROTECTED]> wrote: >> Below is the patch using strsep instead. I also updated the >> gather_inet function to print a message that a protocol is not >> supported if it exists in /etc/protocols, but does not have a case in >> the gather_inet function. > > So,

Re: sockstat tcp/udp switches

2006-11-10 Thread Josh Carroll
Below is the patch using strsep instead. I also updated the gather_inet function to print a message that a protocol is not supported if it exists in /etc/protocols, but does not have a case in the gather_inet function. So, anyone interested in committing this? :) Do people think this would be us

Re: sockstat tcp/udp switches

2006-11-07 Thread Josh Carroll
Below is the patch using strsep instead. I also updated the gather_inet function to print a message that a protocol is not supported if it exists in /etc/protocols, but does not have a case in the gather_inet function. patch is here if you'd rather just fetch it: http://pflog.net/~floyd/sockstat

Re: sockstat tcp/udp switches

2006-11-07 Thread Josh Carroll
On other suggestion I'd have it to consider using strsep to parse the string. I'm pretty the code will be smaller and more readable. Good point. And yes, per the other mail I do need to fix the MAX_PROTO_LEN checking, but I'll make sure that is proper when I update it to use strsep. Josh

Re: sockstat tcp/udp switches

2006-11-07 Thread Brooks Davis
On Mon, Nov 06, 2006 at 03:17:17PM -0800, Josh Carroll wrote: > >I suggest you use /etc/protocols rather than hard code the protocols. > >This will make the code future-proof. See getprotoent(3) for the > >correct way to read /etc/protocols. > > Thanks Peter, that's a great idea. Below is a new p

Re: sockstat tcp/udp switches

2006-11-07 Thread Michael M. Press
Josh Carroll wrote: I included a limitation on the maximum length of a proto (mostly to avoid buffer overflows) and 20 is probably way too large, so I can lower that if need be. I'm not sure buffer overflows are prevented: static int parse_protos(const char *protospec) { ... char

Re: sockstat tcp/udp switches

2006-11-06 Thread Josh Carroll
I suggest you use /etc/protocols rather than hard code the protocols. This will make the code future-proof. See getprotoent(3) for the correct way to read /etc/protocols. Thanks Peter, that's a great idea. Below is a new patch that uses getprotoent(3). For now, to maintain backward compatibilit

Re: sockstat tcp/udp switches

2006-11-06 Thread Dmitry Frolov
* Josh Carroll <[EMAIL PROTECTED]> [04.11.2006 06:15]: > Below is an initial attempt at the -P argument implementation. [...] > if (opt_4 || opt_6) { > - gather_inet(IPPROTO_TCP); > - gather_inet(IPPROTO_UDP); > + if(protos[TCP_PROTO] == 1 || protos_defi

Re: sockstat tcp/udp switches

2006-11-03 Thread Peter Jeremy
On Fri, 2006-Nov-03 15:50:10 -0800, Josh Carroll wrote: >I'm not sure if the method used to parse out the protocol is "up to >snuff" for the FreeBSD project, but I'm welcome to >suggestions/advice/etc. I suggest you use /etc/protocols rather than hard code the protocols. This will make the code fu

Re: sockstat tcp/udp switches

2006-11-03 Thread Josh Carroll
Below is an initial attempt at the -P argument implementation. I'm not sure if the method used to parse out the protocol is "up to snuff" for the FreeBSD project, but I'm welcome to suggestions/advice/etc. I tested the previous behavior and given the exact command line, sockstat works the same p

Re: sockstat tcp/udp switches

2006-11-02 Thread Giorgos Keramidas
On 2006-11-02 20:48, Brooks Davis <[EMAIL PROTECTED]> wrote: >On Fri, Nov 03, 2006 at 04:46:21AM +0200, Giorgos Keramidas wrote: >>On 2006-11-02 18:34, Josh Carroll <[EMAIL PROTECTED]> wrote: >>> >Can we have something that doesn't need one option letter for each >>> >protocol, protocol family or s

Re: sockstat tcp/udp switches

2006-11-02 Thread Brooks Davis
On Fri, Nov 03, 2006 at 04:46:21AM +0200, Giorgos Keramidas wrote: > On 2006-11-02 18:34, Josh Carroll <[EMAIL PROTECTED]> wrote: > > >Can we have something that doesn't need one option letter for each > > >protocol, protocol family or socket type, please? :) > > > > I'd be willing to modify it to

Re: sockstat tcp/udp switches

2006-11-02 Thread Giorgos Keramidas
On 2006-11-02 18:34, Josh Carroll <[EMAIL PROTECTED]> wrote: > >Can we have something that doesn't need one option letter for each > >protocol, protocol family or socket type, please? :) > > I'd be willing to modify it to take a -P argument with one of: > > tcp > udp > tcp,udp > udp,tcp > > If t

Re: sockstat tcp/udp switches

2006-11-02 Thread Josh Carroll
Can we have something that doesn't need one option letter for each protocol, protocol family or socket type, please? :) I'd be willing to modify it to take a -P argument with one of: tcp udp tcp,udp udp,tcp If the consensus is to add -P, I'd be happy to make the changes. I assume without -P we

Re: sockstat tcp/udp switches

2006-11-02 Thread Giorgos Keramidas
On 2006-11-02 15:07, Josh Carroll <[EMAIL PROTECTED]> wrote: > >I haven't tested yet, but I think in the options structure you > >should use : > > > >+ {"ipv6", 0, NULL, '6'}, > > > >instead of: > >+ {"ipv6", 0, NULL, 0}, > > Oops, th

Re: sockstat tcp/udp switches

2006-11-02 Thread Josh Carroll
I haven't tested yet, but I think in the options structure you should use : + {"ipv6", 0, NULL, '6'}, instead of: + {"ipv6", 0, NULL, 0}, Oops, thanks for catching that. Fixed that in the new patch below. also for portability yo

Re: sockstat tcp/udp switches

2006-11-02 Thread Mohacsi Janos
Hi, I haven't tested yet, but I think in the options structure you should use : + {"ipv6", 0, NULL, '6'}, instead of: + {"ipv6", 0, NULL, 0}, also for portability you should use: no_argument or required_argument as a second field