Vitezslav Samel <vitezslav(a)samel.cz> writes:
On Mon, Jun 04, 2012 at 04:04:14PM +0200, Nikola Pajkovsky wrote:
> Vitezslav Samel <vitezslav(a)samel.cz> writes:
>
> > Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
> > ---
> > src/serv.c | 125 ++++++++++++++++++++++++++---------------------------------
> > 1 files changed, 55 insertions(+), 70 deletions(-)
>
> > - sport_listent->ocount++;
> > + update_proto_counter(&sport_listent->serv_count, 1, br);
> > + update_proto_counter(&sport_listent->span, 1, br);
> ...
> ...
> ...
> > + update_proto_counter(&dport_listent->serv_count, 0, br);
> > + update_proto_counter(&dport_listent->span, 0, br);
>
> using 1 and 0 for incoming and outgoing pkts are not good, because I
> have to dig what that means. Could you please define or enum PKT_IN and
> PKT_OUT and use them or even better you can use pkt_pkttype and values
> PACKET_OUTGOING and PACKET_HOST.
In this case the outgoing param of update_proto_counter() is
overloaded: here it means for source port it is outgoing direction (from
the port), for destination port it is incoming direction (to the port); so
we can't use pkt_pkttype for this (think of iptraf-ng on router, where the
packets are forwarded from LAN interface to the ISP interface).
we don't understand each other :) What I meant is, that we can reuse values
PACKET_OUTGOING and PACKET_HOST from pkt_pkttype to name the direction
of packet in counters.
update_proto_counter(&dport_listent->serv_count, PACKET_HOST, br);
update_proto_counter(&sport_listent->serv_count, PACKET_OUTGOING, br);
void update_proto_counter(struct proto_counter *proto_counter, int direction, int bytes)
{
if (!proto_counter)
return;
update_pkt_counter(&proto_counter->proto_total, bytes);
if (direction == PACKET_OUTGOING)
update_pkt_counter(&proto_counter->proto_out, bytes);
else
update_pkt_counter(&proto_counter->proto_in, bytes);
}
to bring more readability in code, or if you don't what to reuse
PACKET_* defines, define a new one.
hmm?
--
Nikola