Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Feb 2002 14:13:20 +0200
From:      Ruslan Ermilov <ru@FreeBSD.ORG>
To:        Joao Carlos <jcrrbr@yahoo.com>
Cc:        questions@FreeBSD.ORG
Subject:   Re: list of active translations on natd
Message-ID:  <20020227121320.GE30220@sunbay.com>
In-Reply-To: <007b01c1b59d$567e8670$35ccb0c8@pchome>
References:  <007b01c1b59d$567e8670$35ccb0c8@pchome>

next in thread | previous in thread | raw e-mail | index | archive | help

--oyUTqETQ0mS9luUI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Thu, Feb 14, 2002 at 06:19:48PM -0300, Joao Carlos wrote:
> Is there any way to list the active translations that NATD is doing?
> Something like `ipchains -L -M` on Linux.
> 
Not, without applying some patches.


Cheers,
-- 
Ruslan Ermilov		Sysadmin and DBA,
ru@sunbay.com		Sunbay Software AG,
ru@FreeBSD.org		FreeBSD committer,
+380.652.512.251	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age

--oyUTqETQ0mS9luUI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=p

Index: libalias/alias.h
===================================================================
RCS file: /home/ncvs/src/lib/libalias/alias.h,v
retrieving revision 1.22
diff -u -p -r1.22 alias.h
--- libalias/alias.h	2001/11/03 11:34:09	1.22
+++ libalias/alias.h	2001/11/28 14:54:12
@@ -90,6 +90,7 @@ int	 PacketAliasCheckNewLink(void);
 unsigned short
 	 PacketAliasInternetChecksum(unsigned short *_ptr, int _nbytes);
 void	 PacketAliasSetTarget(struct in_addr _target_addr);
+void	 PacketAliasDumpTable(void);
 
 /* Transparent proxying routines. */
 int	 PacketAliasProxyRule(const char *_cmd);
Index: libalias/alias_db.c
===================================================================
RCS file: /home/ncvs/src/lib/libalias/alias_db.c,v
retrieving revision 1.47
diff -u -p -r1.47 alias_db.c
--- libalias/alias_db.c	2001/11/03 11:34:09	1.47
+++ libalias/alias_db.c	2001/11/28 14:54:22
@@ -2810,3 +2810,35 @@ PacketAliasSetFWBase(unsigned int base, 
     fireWallNumNums = num;
 #endif
 }
+
+static void
+DumpLink(FILE *where, const char *prefix, struct alias_link *link)
+{
+
+    if (prefix != NULL)
+	fprintf(where, "%s: ", prefix);
+    fprintf(where, "T=%d,", link->link_type);
+    fprintf(where, "S=%s:%d,",
+	inet_ntoa(link->src_addr), ntohs(link->src_port));
+    fprintf(where, "A=%s:%d,",
+	inet_ntoa(link->alias_addr), ntohs(link->alias_port));
+    fprintf(where, "D=%s:%d\n",
+	inet_ntoa(link->dst_addr), ntohs(link->dst_port));
+}
+
+void
+PacketAliasDumpTable(void)
+{
+    struct alias_link *link;
+    int i;
+
+    if (monitorFile)
+    {
+	fprintf(monitorFile, "*** Dumping aliasing table ***\n");
+	for (i=0; i<LINK_TABLE_OUT_SIZE; i++)
+	    LIST_FOREACH(link, &linkTableOut[i], list_out)
+		DumpLink(monitorFile, NULL, link);
+	fprintf(monitorFile, "*** Done dumping aliasing table ***\n");
+	fflush(monitorFile);
+    }
+}
Index: natd/natd.c
===================================================================
RCS file: /home/ncvs/src/sbin/natd/natd.c,v
retrieving revision 1.38
diff -u -p -r1.38 natd.c
--- natd/natd.c	2001/11/27 11:06:02	1.38
+++ natd/natd.c	2001/11/28 14:54:28
@@ -86,6 +86,7 @@ static void	SetAliasAddressFromIfName (c
 static void	InitiateShutdown (int);
 static void	Shutdown (int);
 static void	RefreshAddr (int);
+static void	DumpTable (int);
 static void	ParseOption (const char* option, const char* parms);
 static void	ReadConfigFile (const char* fileName);
 static void	SetupPortRedirect (const char* parms);
@@ -108,6 +109,7 @@ static	int			verbose;
 static 	int			background;
 static	int			running;
 static	int			assignAliasAddr;
+static	int			doDumpTable;
 static	char*			ifName;
 static  int			ifIndex;
 static	u_short			inPort;
@@ -156,6 +158,7 @@ int main (int argc, char** argv)
 	background		= 0;
 	running			= 1;
 	assignAliasAddr		= 0;
+	doDumpTable		= 0;
 	aliasAddr.s_addr	= INADDR_NONE;
 	aliasOverhead		= 12;
 	dynamicMode		= 0;
@@ -303,8 +306,10 @@ int main (int argc, char** argv)
  */
 	siginterrupt(SIGTERM, 1);
 	siginterrupt(SIGHUP, 1);
+	siginterrupt(SIGINFO, 1);
 	signal (SIGTERM, InitiateShutdown);
 	signal (SIGHUP, RefreshAddr);
+	signal (SIGINFO, DumpTable);
 /*
  * Set alias address if it has been given.
  */
@@ -479,6 +484,11 @@ static void DoAliasing (int fd, int dire
 		SetAliasAddressFromIfName (ifName);
 		assignAliasAddr = 0;
 	}
+
+	if (doDumpTable) {
+		PacketAliasDumpTable();
+		doDumpTable = 0;
+	}
 /*
  * Get packet from socket.
  */
@@ -836,6 +846,12 @@ static void RefreshAddr (int sig)
 {
 	if (ifName)
 		assignAliasAddr = 1;
+}
+
+static void DumpTable(int sig)
+{
+	if (PacketAliasSetMode(0, 0) & PKT_ALIAS_LOG)
+		doDumpTable = 1;
 }
 
 static void InitiateShutdown (int sig)

--oyUTqETQ0mS9luUI--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020227121320.GE30220>