From 952447be948be652f73c4d15436690df6ddb857e Mon Sep 17 00:00:00 2001 From: Philip Kovacs Date: Thu, 30 Mar 2006 18:14:18 +0000 Subject: [PATCH] add REMOTESERVICE to port monitor peekables git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@615 7f574dfc-610e-0410-a909-a81674777703 --- AUTHORS | 3 +++ ChangeLog | 3 +++ src/conky.c | 2 ++ src/libtcp-portmon.c | 13 ++++++++++++- src/libtcp-portmon.h | 2 +- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 2a5d6a3..7935438 100644 --- a/AUTHORS +++ b/AUTHORS @@ -155,6 +155,9 @@ Toni tyir MPD features patch 1319461 +Vivenzio Pagliari + Some useful patches for port monitoring + Walt Nelson $freq fix diff --git a/ChangeLog b/ChangeLog index e255209..729e5bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ # $Id$ +2006-03-30 + * Added patch to support new port monitor REMOTESERVICE peekable. + 2006-03-29 * Scan port numbers as short. Fixes debian bug# 359974. diff --git a/src/conky.c b/src/conky.c index ff08b34..6b8652e 100644 --- a/src/conky.c +++ b/src/conky.c @@ -2071,6 +2071,8 @@ static struct text_object *construct_text_object(const char *s, const char *arg, item=REMOTEHOST; else if ( strncmp(itembuf,"rport",31) == 0 ) item=REMOTEPORT; + else if ( strncmp(itembuf,"rservice",31) == 0 ) + item=REMOTESERVICE; else if ( strncmp(itembuf,"lip",31) == 0 ) item=LOCALIP; else if ( strncmp(itembuf,"lhost",31) == 0 ) diff --git a/src/libtcp-portmon.c b/src/libtcp-portmon.c index 5881cc9..22b2a34 100644 --- a/src/libtcp-portmon.c +++ b/src/libtcp-portmon.c @@ -673,7 +673,18 @@ int peek_tcp_port_monitor( snprintf( p_buffer, buffer_size, "%d", p_monitor->p_peek[ connection_index ]->remote_port ); break; - + + case REMOTESERVICE: + + p_servent = getservbyport( htons(p_monitor->p_peek[ connection_index ]->remote_port ), "tcp" ); + /* if no service name found for the port, just use the port number. */ + if ( !p_servent || !p_servent->s_name ) { + snprintf( p_buffer, buffer_size, "%d", p_monitor->p_peek[ connection_index ]->remote_port ); + } else { + snprintf( p_buffer, buffer_size, "%s", p_servent->s_name ); + } + break; + case LOCALIP: net.s_addr = p_monitor->p_peek[ connection_index ]->local_addr; diff --git a/src/libtcp-portmon.h b/src/libtcp-portmon.h index 56756c6..e38df41 100644 --- a/src/libtcp-portmon.h +++ b/src/libtcp-portmon.h @@ -83,7 +83,7 @@ * ------------------------------------------------------------------- */ /* The inventory of peekable items within the port monitor. */ -enum tcp_port_monitor_peekables { COUNT=0, REMOTEIP, REMOTEHOST, REMOTEPORT, LOCALIP, LOCALHOST, LOCALPORT, LOCALSERVICE }; +enum tcp_port_monitor_peekables { COUNT=0, REMOTEIP, REMOTEHOST, REMOTEPORT, REMOTESERVICE, LOCALIP, LOCALHOST, LOCALPORT, LOCALSERVICE }; /* ------------------------------------------------------------------------ * A single tcp connection -- 1.7.9.5