add REMOTESERVICE to port monitor peekables
authorPhilip Kovacs <pkovacs@users.sourceforge.net>
Thu, 30 Mar 2006 18:14:18 +0000 (18:14 +0000)
committerPhilip Kovacs <pkovacs@users.sourceforge.net>
Thu, 30 Mar 2006 18:14:18 +0000 (18:14 +0000)
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@615 7f574dfc-610e-0410-a909-a81674777703

AUTHORS
ChangeLog
src/conky.c
src/libtcp-portmon.c
src/libtcp-portmon.h

diff --git a/AUTHORS b/AUTHORS
index 2a5d6a3..7935438 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -155,6 +155,9 @@ Toni <bleach at users dot sourceforge dot net>
 tyir <tyir at users dot sourceforge dot net>
   MPD features patch 1319461
 
+Vivenzio Pagliari <vivenzio@web.de>
+  Some useful patches for port monitoring
+
 Walt Nelson <wnelsonjr at comcast dot net>
   $freq fix
 
index e255209..729e5bd 100644 (file)
--- 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.
 
index ff08b34..6b8652e 100644 (file)
@@ -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 )
index 5881cc9..22b2a34 100644 (file)
@@ -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;
index 56756c6..e38df41 100644 (file)
@@ -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