Commit in reactos/apps/utils/net on MAIN
finger/.cvsignore+17added 1.1
      /LICENSE.txt+23added 1.1
      /err.c+180added 1.1
      /err.h+60added 1.1
      /finger.c+190added 1.1
      /finger.rc+6added 1.1
      /getopt.c+120added 1.1
      /getopt.h+7added 1.1
      /makefile+22added 1.1
      /net.c+142added 1.1
      /various.h+34added 1.1
ipconfig/.cvsignore+17added 1.1
        /ipconfig.c+299added 1.1
        /ipconfig.rc+6added 1.1
        /makefile+17added 1.1
        /trace.c+53added 1.1
        /trace.h+61added 1.1
netstat/.cvsignore+17added 1.1
       /makefile+20added 1.1
       /netstat.c+518added 1.1
       /netstat.rc+40added 1.1
       /resource.h+7added 1.1
       /trace.c+53added 1.1
       /trace.h+61added 1.1
ping/makefile+171.9 -> 1.10
    /ping.c+6331.6 -> 1.7
    /ping.rc+71.2 -> 1.3
    /.cvsignore+12-11.5 -> 1.6
+2639-1
24 added + 4 modified, total 28 files
2004-11-21  Casper S. Hornstrup  <chorns@users.sourceforge.net>

	* apps/utils/Makefile (UTIL_NET_APPS): Add arp, finger, ipconfig,
	netstat, ping, telnet, and whois.
	* bootdata/packages/reactos.dff: Add arp.exe, finger.exe, ipconfig.exe,
	netstat.exe, ping.exe, telnet.exe, and whois.exe.
	* apps\utils\net\arp: New directory; Move from rosapps.
	* apps\utils\net\finger: Ditto.
	* apps\utils\net\ipconfig: Ditto.
	* apps\utils\net\netstat: Ditto.
	* apps\utils\net\ping: Ditto.
	* apps\utils\net\telnet: Ditto.
	* apps\utils\net\whois: Ditto.

reactos/apps/utils/net/finger
.cvsignore added at 1.1
diff -N .cvsignore
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ .cvsignore	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,17 @@
+*.sys
+*.exe
+*.dll
+*.cpl
+*.a
+*.o
+*.d
+*.coff
+*.dsp
+*.dsw
+*.aps
+*.ncb
+*.opt
+*.sym
+*.plg
+*.bak
+*.map

reactos/apps/utils/net/finger
LICENSE.txt added at 1.1
diff -N LICENSE.txt
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ LICENSE.txt	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,23 @@
+July 22, 1999 
+
+To All Licensees, Distributors of Any Version of BSD: 
+
+As you know, certain of the Berkeley Software Distribution ("BSD") source code files 
+require that further distributions of products containing all or portions of the 
+software, acknowledge within their advertising materials that such products contain 
+software developed by UC Berkeley and its contributors. 
+
+Specifically, the provision reads: 
+
+      * 3. All advertising materials mentioning features or use of this software
+      *    must display the following acknowledgement:
+      *    This product includes software developed by the University of
+      *    California, Berkeley and its contributors.
+
+Effective immediately, licensees and distributors are no longer required to include 
+the acknowledgement within advertising materials. Accordingly, the foregoing paragraph 
+of those BSD Unix files containing it is hereby deleted in its entirety. 
+
+William Hoskins
+Director, Office of Technology Licensing
+University of California, Berkeley " 

reactos/apps/utils/net/finger
err.c added at 1.1
diff -N err.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ err.c	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,180 @@
+/*-
+ * Copyright (c) 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)err.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+#include "err.h"
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+extern char *__progname;		/* Program name, from crt0. */
+
+void
+#ifdef __STDC__
+err(int eval, const char *fmt, ...)
+#else
+err(eval, fmt, va_alist)
+	int eval;
+	const char *fmt;
+	va_dcl
+#endif
+{
+	va_list ap;
+#if __STDC__
+	va_start(ap, fmt);
+#else
+	va_start(ap);
+#endif
+	verr(eval, fmt, ap);
+	va_end(ap);
+}
+
+void
+verr(int eval, const char *fmt, va_list ap)
+{
+	int sverrno;
+
+	sverrno = errno;
+	(void)fprintf(stderr, "%s: ", __progname);
+	if (fmt != NULL) {
+		(void)vfprintf(stderr, fmt, ap);
+		(void)fprintf(stderr, ": ");
+	}
+	(void)fprintf(stderr, "%s\n", strerror(sverrno));
+	exit(eval);
+}
+
+void
+#if __STDC__
+errx(int eval, const char *fmt, ...)
+#else
+errx(eval, fmt, va_alist)
+	int eval;
+	const char *fmt;
+	va_dcl
+#endif
+{
+	va_list ap;
+#if __STDC__
+	va_start(ap, fmt);
+#else
+	va_start(ap);
+#endif
+	verrx(eval, fmt, ap);
+	va_end(ap);
+}
+
+void
+verrx(int eval, const char *fmt, va_list ap)
+{
+	(void)fprintf(stderr, "%s: ", __progname);
+	if (fmt != NULL)
+		(void)vfprintf(stderr, fmt, ap);
+	(void)fprintf(stderr, "\n");
+	exit(eval);
+}
+
+void
+#if __STDC__
+warn(const char *fmt, ...)
+#else
+warn(fmt, va_alist)
+	const char *fmt;
+	va_dcl
+#endif
+{
+	va_list ap;
+#if __STDC__
+	va_start(ap, fmt);
+#else
+	va_start(ap);
+#endif
+	vwarn(fmt, ap);
+	va_end(ap);
+}
+
+void
+vwarn(fmt, ap)
+	const char *fmt;
+	va_list ap;
+{
+	int sverrno;
+
+	sverrno = errno;
+	(void)fprintf(stderr, "%s: ", __progname);
+	if (fmt != NULL) {
+		(void)vfprintf(stderr, fmt, ap);
+		(void)fprintf(stderr, ": ");
+	}
+	(void)fprintf(stderr, "%s\n", strerror(sverrno));
+}
+
+void
+#ifdef __STDC__
+warnx(const char *fmt, ...)
+#else
+warnx(fmt, va_alist)
+	const char *fmt;
+	va_dcl
+#endif
+{
+	va_list ap;
+#ifdef __STDC__
+	va_start(ap, fmt);
+#else
+	va_start(ap);
+#endif
+	vwarnx(fmt, ap);
+	va_end(ap);
+}
+
+void
+vwarnx(fmt, ap)
+	const char *fmt;
+	va_list ap;
+{
+	(void)fprintf(stderr, "%s: ", __progname);
+	if (fmt != NULL)
+		(void)vfprintf(stderr, fmt, ap);
+	(void)fprintf(stderr, "\n");
+}

reactos/apps/utils/net/finger
err.h added at 1.1
diff -N err.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ err.h	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)err.h	8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _ERR_H_
+#define	_ERR_H_
+
+/*
+ * Don't use va_list in the err/warn prototypes.   Va_list is typedef'd in two
+ * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
+ * of them here we may collide with the utility's includes.  It's unreasonable
+ * for utilities to have to include one of them to include err.h, so we get
+ * _BSD_VA_LIST_ from <machine/ansi.h> and use it.
+ */
+/*#include <machine/ansi.h>*/
+/*#include <sys/cdefs.h>*/
+#include "various.h"
+#include <stdarg.h>
+
+void	err __P((int, const char *, ...));
+void	verr __P((int, const char *, va_list));
+void	errx __P((int, const char *, ...));
+void	verrx __P((int, const char *, va_list));
+void		warn __P((const char *, ...));
+void		vwarn __P((const char *, va_list));
+void		warnx __P((const char *, ...));
+void		vwarnx __P((const char *, va_list));
+
+#endif /* !_ERR_H_ */

reactos/apps/utils/net/finger
finger.c added at 1.1
diff -N finger.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ finger.c	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Tony Nardo of the Johns Hopkins University/Applied Physics Lab.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * 8/2/97 - Ted Felix <tfelix@fred.net>
+ *          Ported to Win32 from 4.4BSD-LITE2 at wcarchive.
+ *          NT Workstation already has finger, and it runs fine under
+ *          Win95.  Thought I'd do this anyways since not everyone has
+ *          access to NT.
+ *          Had to remove local handling.	 Otherwise, same as whois.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1989, 1993\n\
+	The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)finger.c	8.5 (Berkeley) 5/4/95";
+#endif /* not lint */
+
+/*
+ * Finger prints out information about users.  It is not portable since
+ * certain fields (e.g. the full user name, office, and phone numbers) are
+ * extracted from the gecos field of the passwd file which other UNIXes
+ * may not have or may use for other things.
+ *
+ * There are currently two output formats; the short format is one line
+ * per user and displays login name, tty, login time, real name, idle time,
+ * and office location/phone number.  The long format gives the same
+ * information (in a more legible format) as well as home directory, shell,
+ * mail info, and .plan/.project files.
+ */
+
+#include <winsock2.h>
+#include "err.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "unistd.h"
+
+#include "various.h"
+#include "getopt.h"
+
+char *__progname;
+
+time_t now;
+int lflag, mflag, pplan, sflag;
+
+static void userlist(int, char **);
+void usage();
+void netfinger(char *);
+
+int
+main(int argc, char **argv)
+{
+	int ch;
+
+	while ((ch = getopt(argc, argv, "lmps")) != EOF)
+		switch(ch) {
+		case 'l':
+			lflag = 1;		/* long format */
+			break;
+		case 'm':
+			mflag = 1;		/* force exact match of names */
+			break;
+		case 'p':
+			pplan = 1;		/* don't show .plan/.project */
+			break;
+		case 's':
+			sflag = 1;		/* short format */
+			break;
+		case '?':
+		default:
+			(void)fprintf(stderr,
+			    "usage: finger [-lmps] login [...]\n");
+			exit(1);
+		}
+	argc -= optind;
+	argv += optind;
+
+	(void)time(&now);
+	if (!*argv) {
+		usage();
+	} else {
+		userlist(argc, argv);
+		/*
+		 * Assign explicit "large" format if names given and -s not
+		 * explicitly stated.  Force the -l AFTER we get names so any
+		 * remote finger attempts specified won't be mishandled.
+		 */
+		if (!sflag)
+			lflag = 1;	/* if -s not explicit, force -l */
+	}
+	return 0;
+}
+
+
+static void
+userlist(int argc, char **argv)
+{
+	int *used;
+	char **ap, **nargv, **np, **p;
+	WORD wVersionRequested;
+	WSADATA wsaData;
+	int iErr;
+
+
+	if ((nargv = malloc((argc+1) * sizeof(char *))) == NULL ||
+	    (used = calloc(argc, sizeof(int))) == NULL)
+		err(1, NULL);
+
+	/* Pull out all network requests into nargv. */
+	for (ap = p = argv, np = nargv; *p; ++p)
+		if (index(*p, '@'))
+			*np++ = *p;
+		else
+			*ap++ = *p;
+
+	*np++ = NULL;
+	*ap++ = NULL;
+
+	/* If there are local requests */
+	if (*argv)
+	{
+		fprintf(stderr, "Warning: Can't do local finger\n");
+	}
+
+	/* Start winsock */ 
+	wVersionRequested = MAKEWORD( 1, 1 );
+	iErr = WSAStartup( wVersionRequested, &wsaData );
+	if ( iErr != 0 ) 
+	{
+		/* Tell the user that we couldn't find a usable */
+		/* WinSock DLL.                                  */
+		fprintf(stderr, "WSAStartup failed\n");
+		return;
+	}
+
+	/* Handle network requests. */
+	for (p = nargv; *p;)
+		netfinger(*p++);
+
+	/* Bring down winsock */
+	WSACleanup();
+	exit(0);
+}
+
+void usage()
+{
+	(void)fprintf(stderr,
+	              "usage: finger [-lmps] login [...]\n");
+	exit(1);
+}
+

reactos/apps/utils/net/finger
finger.rc added at 1.1
diff -N finger.rc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ finger.rc	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,6 @@
+/* $Id: finger.rc,v 1.1 2004/11/21 22:26:13 chorns Exp $ */
+
+#define REACTOS_STR_FILE_DESCRIPTION	"ReactOS TCP/IPv4 Win32 finger\0"
+#define REACTOS_STR_INTERNAL_NAME	"finger\0"
+#define REACTOS_STR_ORIGINAL_FILENAME	"finger.exe\0"
+#include <reactos/version.rc>

reactos/apps/utils/net/finger
getopt.c added at 1.1
diff -N getopt.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ getopt.c	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Fri Jun 13 10:39:00 1997, tfelix@fred.net:
+ *     Ported to Win32, changed index/rindex to strchr/strrchr
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getopt.c	4.13 (Berkeley) 2/23/91";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+ * get option letter from argument vector
+ */
+int	opterr = 1,		/* if error message should be printed */
+	optind = 1,		/* index into parent argv vector */
+	optopt;			/* character checked for validity */
+char	*optarg;		/* argument associated with option */
+
+#define	BADCH	(int)'?'
+#define	EMSG	""
+
+int
+getopt(int nargc, char * const *nargv, const char *ostr)
+{
+	static char *place = EMSG;		/* option letter processing */
+	register char *oli;			/* option letter list index */
+	char *p;
+
+	if (!*place) {				/* update scanning pointer */
+		if (optind >= nargc || *(place = nargv[optind]) != '-') {
+			place = EMSG;
+			return(EOF);
+		}
+		if (place[1] && *++place == '-') {	/* found "--" */
+			++optind;
+			place = EMSG;
+			return(EOF);
+		}
+	}					/* option letter okay? */
+	if ((optopt = (int)*place++) == (int)':' ||
+	    !(oli = strchr(ostr, optopt))) {
+		/*
+		 * if the user didn't specify '-' as an option,
+		 * assume it means EOF.
+		 */
+		if (optopt == (int)'-')
+			return(EOF);
+		if (!*place)
+			++optind;
+		if (opterr) {
+			if (!(p = strrchr(*nargv, '/')))
+				p = *nargv;
+			else
+				++p;
+			(void)fprintf(stderr, "%s: illegal option -- %c\n",
+			    p, optopt);
+		}
+		return(BADCH);
+	}
+	if (*++oli != ':') {			/* don't need argument */
+		optarg = NULL;
+		if (!*place)
+			++optind;
+	}
+	else {					/* need an argument */
+		if (*place)			/* no white space */
+			optarg = place;
+		else if (nargc <= ++optind) {	/* no arg */
+			place = EMSG;
+			if (!(p = strrchr(*nargv, '/')))
+				p = *nargv;
+			else
+				++p;
+			if (opterr)
+				(void)fprintf(stderr,
+				    "%s: option requires an argument -- %c\n",
+				    p, optopt);
+			return(BADCH);
+		}
+	 	else				/* white space */
+			optarg = nargv[optind];
+		place = EMSG;
+		++optind;
+	}
+	return(optopt);				/* dump back option letter */
+}

reactos/apps/utils/net/finger
getopt.h added at 1.1
diff -N getopt.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ getopt.h	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,7 @@
+/* getopt.h */
+
+extern char *optarg;
+extern int optind;
+
+int
+getopt(int nargc, char * const *nargv, const char *ostr);

reactos/apps/utils/net/finger
makefile added at 1.1
diff -N makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ makefile	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,22 @@
+PATH_TO_TOP = ../../../..
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = console
+
+TARGET_NAME = finger
+
+TARGET_SDKLIBS = ws2_32.a
+
+TARGET_CFLAGS = -D__USE_W32_SOCKETS
+
+TARGET_OBJECTS = $(TARGET_NAME).o \
+  err.o \
+  getopt.o \
+  net.o 
+
+TARGET_GCCLIBS = iberty
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk

reactos/apps/utils/net/finger
net.c added at 1.1
diff -N net.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ net.c	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Tony Nardo of the Johns Hopkins University/Applied Physics Lab.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)net.c	8.4 (Berkeley) 4/28/95";
+#endif /* not lint */
+
+#include <sys/types.h>
+#include <winsock2.h>
+#include "unistd.h"
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+#include "various.h"
+
+void
+netfinger(char *name)
+{
+	extern int lflag;
+	char c, lastc;
+	struct in_addr defaddr;
+	struct hostent *hp, def;
+	struct servent *sp;
+	struct sockaddr_in sin;
+	int s;
+	char *alist[1], *host;
+
+	/* If this is a local request */
+	if (!(host = rindex(name, '@')))
+		return;
+
+	*host++ = NULL;
+	if (isdigit(*host) && (defaddr.s_addr = inet_addr(host)) != -1) {
+		def.h_name = host;
+		def.h_addr_list = alist;
+		def.h_addr = (char *)&defaddr;
+		def.h_length = sizeof(struct in_addr);
+		def.h_addrtype = AF_INET;
+		def.h_aliases = 0;
+		hp = &def;
+	} else if (!(hp = gethostbyname(host))) {
+		(void)fprintf(stderr,
+		    "finger: unknown host: %s\n", host);
+		return;
+	}
+	if (!(sp = getservbyname("finger", "tcp"))) {
+		(void)fprintf(stderr, "finger: tcp/finger: unknown service\n");
+		return;
+	}
+	sin.sin_family = hp->h_addrtype;
+	bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length);
+	sin.sin_port = sp->s_port;
+	if ((s = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) {
+		perror("finger: socket");
+		return;
+	}
+
+	/* have network connection; identify the host connected with */
+	(void)printf("[%s]\n", hp->h_name);
+	if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
+		fprintf(stderr, "finger: connect rc = %d", WSAGetLastError());
+		(void)close(s);
+		return;
+	}
+
+	/* -l flag for remote fingerd  */
+	if (lflag)
+		send(s, "/W ", 3, 0);
+	/* send the name followed by <CR><LF> */
+	send(s, name, strlen(name), 0);
+	send(s, "\r\n", 2, 0);
+
+	/*
+	 * Read from the remote system; once we're connected, we assume some
+	 * data.  If none arrives, we hang until the user interrupts.
+	 *
+	 * If we see a <CR> or a <CR> with the high bit set, treat it as
+	 * a newline; if followed by a newline character, only output one
+	 * newline.
+	 *
+	 * Otherwise, all high bits are stripped; if it isn't printable and
+	 * it isn't a space, we can simply set the 7th bit.  Every ASCII
+	 * character with bit 7 set is printable.
+	 */ 
+	lastc = 0;
+	while (recv(s, &c, 1, 0) == 1) {
+		c &= 0x7f;
+		if (c == 0x0d) {
+			if (lastc == '\r')	/* ^M^M - skip dupes */
+				continue;
+			c = '\n';
+			lastc = '\r';
+		} else {
+			if (!isprint(c) && !isspace(c))
+				c |= 0x40;
+			if (lastc != '\r' || c != '\n')
+				lastc = c;
+			else {
+				lastc = '\n';
+				continue;
+			}
+		}
+		putchar(c);
+	}
+	if (lastc != '\n')
+		putchar('\n');
+	putchar('\n');
+}

reactos/apps/utils/net/finger
various.h added at 1.1
diff -N various.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ various.h	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,34 @@
+// Various things you need when porting BSD and GNU utilities to
+// Win32.
+
+#ifndef VARIOUS_H
+#define VARIOUS_H
+
+
+typedef float f4byte_t;
+typedef double f8byte_t;
+typedef long uid_t;  // SunOS 5.5
+
+#define __P(x) x
+
+/* utmp.h */
+#define UT_LINESIZE 8
+#define UT_HOSTSIZE 16
+
+/* stat.h */
+#define  S_ISREG(mode)   (((mode)&0xF000) == 0x8000)
+#define  S_ISDIR(mode)   (((mode)&0xF000) == 0x4000)
+
+#undef MIN //take care of windows default
+#undef MAX //take care of windows default
+#define MIN(a, b) ((a) <= (b) ? (a) : (b))
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
+#define bcopy(s1, s2, n)  memmove(s2, s1, n)
+#define bcmp(s1, s2, n)  (memcmp(s1, s2, n) != 0)
+#define bzero(s, n)  memset(s, 0, n)
+
+#define index(s, c)  strchr(s, c)
+#define rindex(s, c)  strrchr(s, c)
+
+#endif

reactos/apps/utils/net/ipconfig
.cvsignore added at 1.1
diff -N .cvsignore
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ .cvsignore	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,17 @@
+*.sys
+*.exe
+*.dll
+*.cpl
+*.a
+*.o
+*.d
+*.coff
+*.dsp
+*.dsw
+*.aps
+*.ncb
+*.opt
+*.sym
+*.plg
+*.bak
+*.map

reactos/apps/utils/net/ipconfig
ipconfig.c added at 1.1
diff -N ipconfig.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ipconfig.c	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,299 @@
+/*
+ * ipconfig - display IP stack parameters.
+ *
+ * This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
+ *
+ * Robert Dickenson <robd@reactos.org>, August 15, 2002.
+ */
+#include <stdio.h>
+#include <windows.h>
+#include <tchar.h>
+#include <time.h>
+
+#include <iptypes.h>
+#include <ipexport.h>
+#include <iphlpapi.h>
+
+#ifdef _DEBUG
+#include "trace.h"
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+
+/* imported from iphlpapi.dll
+
+GetAdapterOrderMap
+GetInterfaceInfo
+GetIpStatsFromStack
+NhGetInterfaceNameFromGuid
+NhpAllocateAndGetInterfaceInfoFromStack
+
+ */
+
+static TCHAR* GetNodeTypeName(int nNodeType)
+{
+    switch (nNodeType) {
+    case 0:  return _T("zero");
+    case 1:  return _T("one");
+    case 2:  return _T("two");
+    case 3:  return _T("three");
+    case 4:  return _T("mixed");
+    default: return _T("unknown");
+    }
+}
+
+static void ShowNetworkFixedInfo()
+{
+    FIXED_INFO* pFixedInfo = NULL;
+    ULONG OutBufLen = 0;
+    DWORD result;
+
+    result = GetNetworkParams(NULL, &OutBufLen);
+    if (result == ERROR_BUFFER_OVERFLOW) {
+        pFixedInfo = (FIXED_INFO*)malloc(OutBufLen);
+        if (!pFixedInfo) {
+            _tprintf(_T("ERROR: failed to allocate 0x%08X bytes of memory\n"), OutBufLen);
+            return;
+        }
+    } else {
+        _tprintf(_T("ERROR: GetNetworkParams() failed to report required buffer size.\n"));
+        return;
+    }
+
+    result = GetNetworkParams(pFixedInfo, &OutBufLen);
+    if (result == ERROR_SUCCESS) {
+        IP_ADDR_STRING* pIPAddr;
+
+             printf("\tHostName. . . . . . . . . . . : %s\n",  pFixedInfo->HostName);
+             printf("\tDomainName. . . . . . . . . . : %s\n",  pFixedInfo->DomainName);
+//
+             printf("\tDNS Servers . . . . . . . . . : %s\n",  pFixedInfo->DnsServerList.IpAddress.String);
+             pIPAddr = pFixedInfo->DnsServerList.Next;
+             while (pIPAddr) {
+                 printf("\t\t\t\t      : %s\n",  pIPAddr->IpAddress.String);
+                 pIPAddr = pIPAddr->Next;
+             }
+//
+        _tprintf(_T("\tNodeType. . . . . . . . . . . : %d (%s)\n"), pFixedInfo->NodeType, GetNodeTypeName(pFixedInfo->NodeType));
+             printf("\tScopeId . . . . . . . . . . . : %s\n",  pFixedInfo->ScopeId);
+        _tprintf(_T("\tEnableRouting . . . . . . . . : %s\n"), pFixedInfo->EnableRouting ? _T("yes") : _T("no"));
+        _tprintf(_T("\tEnableProxy . . . . . . . . . : %s\n"), pFixedInfo->EnableProxy ? _T("yes") : _T("no"));
+        _tprintf(_T("\tEnableDns . . . . . . . . . . : %s\n"), pFixedInfo->EnableDns ? _T("yes") : _T("no"));
+        _tprintf(_T("\n"));
+        //_tprintf(_T("\n"),);
+        //_tprintf(_T("GetNetworkParams() returned with %d\n"), pIfTable->NumAdapters);
+
+//      _tprintf(_T("\tConnection specific DNS suffix: %s\n"), pFixedInfo->EnableDns ? _T("yes") : _T("no"));
+
+    } else {
+        switch (result) {
+        case ERROR_BUFFER_OVERFLOW:
+            _tprintf(_T("The buffer size indicated by the pOutBufLen parameter is too small to hold the adapter information. The pOutBufLen parameter points to the required size\n"));
+            break;
+        case ERROR_INVALID_PARAMETER:
+            _tprintf(_T("The pOutBufLen parameter is NULL, or the calling process does not have read/write access to the memory pointed to by pOutBufLen, or the calling process does not have write access to the memory pointed to by the pAdapterInfo parameter\n"));
+            break;
+        case ERROR_NO_DATA:
+            _tprintf(_T("No adapter information exists for the local computer\n"));
+            break;
+        case ERROR_NOT_SUPPORTED:
+            _tprintf(_T("This function is not supported on the operating system in use on the local system\n"));
+            break;
+        default:
+            _tprintf(_T("0x%08X - Use FormatMessage to obtain the message string for the returned error\n"), result);
+            break;
+        }
+    }
+}
+
+static void ShowNetworkInterfaces()
+{
+    IP_INTERFACE_INFO* pIfTable = NULL;
+    DWORD result;
+    DWORD dwNumIf;
+    DWORD dwOutBufLen = 0;
+
+    if ((result = GetNumberOfInterfaces(&dwNumIf)) != NO_ERROR) {
+        _tprintf(_T("GetNumberOfInterfaces() failed with code 0x%08X - Use FormatMessage to obtain the message string for the returned error\n"), result);
+        return;
+    } else {
+        _tprintf(_T("GetNumberOfInterfaces() returned %d\n"), dwNumIf);
+    }
+
+    result = GetInterfaceInfo(pIfTable, &dwOutBufLen);
+//    dwOutBufLen = sizeof(IP_INTERFACE_INFO) + dwNumIf * sizeof(IP_ADAPTER_INDEX_MAP);
+//    _tprintf(_T("GetNumberOfInterfaces() returned %d, dwOutBufLen %d\n"), dwNumIf, dwOutBufLen);
+//    _tprintf(_T("sizeof(IP_INTERFACE_INFO) %d, sizeof(IP_ADAPTER_INDEX_MAP) %d\n"), sizeof(IP_INTERFACE_INFO), sizeof(IP_ADAPTER_INDEX_MAP));
+
+    pIfTable = (IP_INTERFACE_INFO*)malloc(dwOutBufLen);
+    if (!pIfTable) {
+        _tprintf(_T("ERROR: failed to allocate 0x%08X bytes of memory\n"), dwOutBufLen);
+        return;
+    }
+/*
+typedef struct _IP_ADAPTER_INDEX_MAP {
+  ULONG Index;                     // adapter index 
+  WCHAR Name[MAX_ADAPTER_NAME];    // name of the adapter 
+} IP_ADAPTER_INDEX_MAP, * PIP_ADAPTER_INDEX_MAP;
+
+typedef struct _IP_INTERFACE_INFO {
+  LONG NumAdapters;                 // number of adapters in array 
+  IP_ADAPTER_INDEX_MAP Adapter[1];  // adapter indices and names 
+} IP_INTERFACE_INFO,*PIP_INTERFACE_INFO;
+ */
+    result = GetInterfaceInfo(pIfTable, &dwOutBufLen);
+    if (result == NO_ERROR) {
+        int i;
+        _tprintf(_T("GetInterfaceInfo() returned with %d adaptor entries\n"), pIfTable->NumAdapters);
+        for (i = 0; i < pIfTable->NumAdapters; i++) {
+           wprintf(L"[%d] %s\n", i + 1, pIfTable->Adapter[i].Name);
+           //wprintf(L"[%d] %s\n", pIfTable->Adapter[i].Index, pIfTable->Adapter[i].Name);
+
+//  \DEVICE\TCPIP_{DB0E61C1-3498-4C5F-B599-59CDE8A1E357}
+//  \DEVICE\TCPIP_{BD445697-0945-4591-AE7F-2AB0F383CA87}
+//  \DEVICE\TCPIP_{6D87DC08-6BC5-4E78-AB5F-18CAB785CFFE}
+
+//HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Interfaces\Tcpip_{DB0E61C1-3498-4C5F-B599-59CDE8A1E357}
+        }
+    } else {
+        switch (result) {
+        case ERROR_INVALID_PARAMETER:
+            _tprintf(_T("The dwOutBufLen parameter is NULL, or GetInterfaceInterface is unable to write to the memory pointed to by the dwOutBufLen parameter\n"));
+            break;
+        case ERROR_INSUFFICIENT_BUFFER:
+            _tprintf(_T("The buffer pointed to by the pIfTable parameter is not large enough. The required size is returned in the DWORD variable pointed to by the dwOutBufLen parameter\n"));
+            _tprintf(_T("\tdwOutBufLen: %d\n"), dwOutBufLen);
+            break;
+        case ERROR_NOT_SUPPORTED:
+            _tprintf(_T("This function is not supported on the operating system in use on the local system\n"));
+            break;
+        default:
+            _tprintf(_T("0x%08X - Use FormatMessage to obtain the message string for the returned error\n"), result);
+            break;
+        }
+    }
+    free(pIfTable);
+}
+
+/*
+typedef struct _IP_ADAPTER_INFO {
+  struct _IP_ADAPTER_INFO* Next;
+  DWORD ComboIndex;
+  char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
+1  char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4];
+  UINT AddressLength;
+2  BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH];
+  DWORD Index;
+  UINT Type;
+3  UINT DhcpEnabled;
+5  PIP_ADDR_STRING CurrentIpAddress;
+  IP_ADDR_STRING IpAddressList;
+7  IP_ADDR_STRING GatewayList;
+8  IP_ADDR_STRING DhcpServer;
+  BOOL HaveWins;
+  IP_ADDR_STRING PrimaryWinsServer;
+  IP_ADDR_STRING SecondaryWinsServer;
+a  time_t LeaseObtained;
+b  time_t LeaseExpires; 
+} IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;
+ */
+/*
+Ethernet adapter VMware Virtual Ethernet Adapter (Network Address Translation (NAT) for VMnet8):
+
+        Connection-specific DNS Suffix  . :
+1        Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter (Network Address Translation (NAT) for VMnet8)
+2        Physical Address. . . . . . . . . : 00-50-56-C0-00-08
+3        DHCP Enabled. . . . . . . . . . . : Yes
+        Autoconfiguration Enabled . . . . : Yes
+5        IP Address. . . . . . . . . . . . : 192.168.136.1
+        Subnet Mask . . . . . . . . . . . : 255.255.255.0
+7        Default Gateway . . . . . . . . . :
+8        DHCP Server . . . . . . . . . . . : 192.168.136.254
+        DNS Servers . . . . . . . . . . . :
+a        Lease Obtained. . . . . . . . . . : Monday, 30 December 2002 5:56:53 PM
+b        Lease Expires . . . . . . . . . . : Monday, 30 December 2002 6:26:53 PM
+ */
+static void ShowAdapterInfo()
+{
+    IP_ADAPTER_INFO* pAdaptorInfo;
+    ULONG ulOutBufLen;
+    DWORD dwRetVal;
+
+    _tprintf(_T("\nAdaptor Information\t\n"));
+    pAdaptorInfo = (IP_ADAPTER_INFO*)GlobalAlloc(GPTR, sizeof(IP_ADAPTER_INFO));
+    ulOutBufLen = sizeof(IP_ADAPTER_INFO);
+
+    if (ERROR_BUFFER_OVERFLOW == GetAdaptersInfo(pAdaptorInfo, &ulOutBufLen)) {
+        GlobalFree(pAdaptorInfo);
+        pAdaptorInfo = (IP_ADAPTER_INFO*)GlobalAlloc(GPTR, ulOutBufLen);
+    }
+    if (dwRetVal = GetAdaptersInfo(pAdaptorInfo, &ulOutBufLen)) {
+        _tprintf(_T("Call to GetAdaptersInfo failed. Return Value: %08x\n"), dwRetVal);
+    } else {
+        while (pAdaptorInfo) {
+            printf("  AdapterName: %s\n", pAdaptorInfo->AdapterName);
+            printf("  Description: %s\n", pAdaptorInfo->Description);
+            pAdaptorInfo = pAdaptorInfo->Next;
+        }
+    }
+}
+
+const char szUsage[] = { "USAGE:\n" \
+    "   ipconfig [/? | /all | /release [adapter] | /renew [adapter]\n" \
+    "            | /flushdns | /registerdns\n" \
+    "            | /showclassid adapter\n" \
+    "            | /showclassid adapter\n" \
+    "            | /setclassid adapter [classidtoset] ]\n" \
+    "\n" \
+    "adapter    Full name or pattern with '*' and '?' to 'match',\n" \
+    "           * matches any character, ? matches one character.\n" \
+    "   Options\n" \
+    "       /?           Display this help message.\n" \
+    "       /all         Display full configuration information.\n" \
+    "       /release     Release the IP address for the specified adapter.\n" \
+    "       /renew       Renew the IP address for the specified adapter.\n" \
+    "       /flushdns    Purges the DNS Resolver cache.\n" \
+    "       /registerdns Refreshes all DHCP leases and re-registers DNS names\n" \
+    "       /displaydns  Display the contents of the DNS Resolver Cache.\n" \
+    "       /showclassid Displays all the dhcp class IDs allowed for adapter.\n" \
+    "       /setclassid  Modifies the dhcp class id.\n" \
+    "\n" \
+    "The default is to display only the IP address, subnet mask and\n" \
+    "default gateway for each adapter bound to TCP/IP.\n"
+};
+/*
+    "\n" \
+    "For Release and Renew, if no adapter name is specified, then the IP address\n" \
+    "leases for all adapters bound to TCP/IP will be released or renewed.\n" \
+    "\n" \
+    "For SetClassID, if no class id is specified, then the classid is removed.\n" \
+    "\n" \
+    "Examples:\n" \
+    "    > ipconfig                       ... Show information.\n" \
+    "    > ipconfig /all                  ... Show detailed information\n" \
+    "    > ipconfig /renew                ... renew all adapaters\n" \
+    "    > ipconfig /renew EL*            ... renew adapters named EL....\n" \
+    "    > ipconfig /release *ELINK?21*   ... release all matching adapters,\n" \
+                                         eg. ELINK-21, myELELINKi21adapter.\n"
+ */
+
+static void usage(void)
+{
+	fputs(szUsage, stderr);
+}
+
+
+int main(int argc, char *argv[])
+{
+    // 10.0.0.100    // As of build 0.0.20 this is hardcoded in the ip stack
+
+    if (argc > 1) {
+        usage();
+        return 1;
+    }
+    _tprintf(_T("ReactOS IP Configuration\n"));
+    ShowNetworkFixedInfo();
+    ShowNetworkInterfaces();
+    ShowAdapterInfo();
+	return 0;
+}

reactos/apps/utils/net/ipconfig
ipconfig.rc added at 1.1
diff -N ipconfig.rc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ipconfig.rc	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,6 @@
+/* $Id: ipconfig.rc,v 1.1 2004/11/21 22:26:13 chorns Exp $ */
+
+#define REACTOS_STR_FILE_DESCRIPTION	"ReactOS TCP/IPv4 Win32 ipconfig\0"
+#define REACTOS_STR_INTERNAL_NAME	"ipconfig\0"
+#define REACTOS_STR_ORIGINAL_FILENAME	"ipconfig.exe\0"
+#include <reactos/version.rc>

reactos/apps/utils/net/ipconfig
makefile added at 1.1
diff -N makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ makefile	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,17 @@
+PATH_TO_TOP = ../../../..
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = console
+
+TARGET_NAME = ipconfig
+
+TARGET_CFLAGS = -D__USE_W32API
+
+TARGET_SDKLIBS = user32.a iphlpapi.a
+
+TARGET_OBJECTS = $(TARGET_NAME).o
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk

reactos/apps/utils/net/ipconfig
trace.c added at 1.1
diff -N trace.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ trace.c	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,53 @@
+/////////////////////////////////////////////////////////////////////////////
+// Diagnostic Trace
+//
+#include <stdio.h> 
+#include <stdarg.h>
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <tchar.h>
+#include "trace.h"
+
+
+#ifdef _DEBUG
+
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+
+void _DebugBreak(void)
+{
+    DebugBreak();
+}
+
+void Trace(TCHAR* lpszFormat, ...)
+{
+    va_list args;
+    int nBuf;
+    TCHAR szBuffer[512];
+
+    va_start(args, lpszFormat);
+    nBuf = _vsntprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
+    OutputDebugString(szBuffer);
+    // was there an error? was the expanded string too long?
+    //ASSERT(nBuf >= 0);
+    va_end(args);
+}
+
+void Assert(void* assert, TCHAR* file, int line, void* msg)
+{
+    if (msg == NULL) {
+        printf("ASSERT -- %s occured on line %u of file %s.\n",
+               assert, line, file);
+    } else {
+        printf("ASSERT -- %s occured on line %u of file %s: Message = %s.\n",
+               assert, line, file, msg);
+    }
+}
+
+#else
+
+void Trace(TCHAR* lpszFormat, ...) { };
+void Assert(void* assert, TCHAR* file, int line, void* msg) { };
+
+#endif //_DEBUG
+/////////////////////////////////////////////////////////////////////////////

reactos/apps/utils/net/ipconfig
trace.h added at 1.1
diff -N trace.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ trace.h	21 Nov 2004 22:26:13 -0000	1.1
@@ -0,0 +1,61 @@
+/////////////////////////////////////////////////////////////////////////////
+// Diagnostic Trace
+//
+#ifndef __TRACE_H__
+#define __TRACE_H__
+
+#ifdef _DEBUG
+
+#ifdef _X86_
+#define BreakPoint()        _asm { int 3h }
+#else
+#define BreakPoint()        _DebugBreak()
+#endif
+
+#ifndef ASSERT
+#define ASSERT(exp)                                 \
+{                                                   \
+    if (!(exp)) {                                   \
+        Assert(#exp, __FILE__, __LINE__, NULL);     \
+        BreakPoint();                               \
+    }                                               \
+}                                                   \
+
+#define ASSERTMSG(exp, msg)                         \
+{                                                   \
+    if (!(exp)) {                                   \
+        Assert(#exp, __FILE__, __LINE__, msg);      \
+        BreakPoint();                               \
+    }                                               \
+}
+#endif
+
+//=============================================================================
+//  MACRO: TRACE()
+//=============================================================================
+
+#define TRACE  Trace
+
+
+#else   // _DEBUG
+
+//=============================================================================
+//  Define away MACRO's ASSERT() and TRACE() in non debug builds
+//=============================================================================
+
+#ifndef ASSERT
+#define ASSERT(exp)
+#define ASSERTMSG(exp, msg)
+#endif
+
+#define TRACE 0 ? (void)0 : Trace
+
+#endif // !_DEBUG
+
+
+void Assert(void* assert, TCHAR* file, int line, void* msg);
+void Trace(TCHAR* lpszFormat, ...);
+
+
+#endif // __TRACE_H__
+/////////////////////////////////////////////////////////////////////////////

reactos/apps/utils/net/netstat
.cvsignore added at 1.1
diff -N .cvsignore
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ .cvsignore	21 Nov 2004 22:26:14 -0000	1.1
@@ -0,0 +1,17 @@
+*.sys
+*.exe
+*.dll
+*.cpl
+*.a
+*.o
+*.d
+*.coff
+*.dsp
+*.dsw
+*.aps
+*.ncb
+*.opt
+*.sym
+*.plg
+*.bak
+*.map

reactos/apps/utils/net/netstat
makefile added at 1.1
diff -N makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ makefile	21 Nov 2004 22:26:14 -0000	1.1
@@ -0,0 +1,20 @@
+PATH_TO_TOP = ../../../..
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = console
+
+TARGET_NAME = netstat
+
+TARGET_CFLAGS = \
+	-D__USE_W32API \
+	-D_WIN32_IE=0x600 \
+	-D_WIN32_WINNT=0x501 
+
+TARGET_SDKLIBS = user32.a snmpapi.a iphlpapi.a ws2_32.a
+
+TARGET_OBJECTS = $(TARGET_NAME).o
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk

reactos/apps/utils/net/netstat
netstat.c added at 1.1
diff -N netstat.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ netstat.c	21 Nov 2004 22:26:14 -0000	1.1
@@ -0,0 +1,518 @@
+/*
+ * netstat - display IP stack statistics.
+ *
+ * This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
+ *
+ * Robert Dickenson <robd@reactos.org>, August 15, 2002.
+ */
+
+// Extensive reference made and use of source to netstatp by:
+// Copyright (C) 1998-2002 Mark Russinovich
+// www.sysinternals.com
+
+#define ANY_SIZE 1
+
+#include <windows.h>
+#include <winsock.h>
+#include <tchar.h>
+#include <stdio.h>
+#include <time.h>
+
+#include <iptypes.h>
+#include <ipexport.h>
+#include <tlhelp32.h>
+#include <iphlpapi.h>
+#include <snmp.h>
+
+#include "trace.h"
+#include "resource.h"
+
+
+#define MAX_RESLEN 4000
+
+//
+// Possible TCP endpoint states
+//
+static char TcpState[][32] = {
+	"???",
+	"CLOSED",
+	"LISTENING",
+	"SYN_SENT",
+	"SYN_RCVD",
+	"ESTABLISHED",
+	"FIN_WAIT1",
+	"FIN_WAIT2",
+	"CLOSE_WAIT",
+	"CLOSING",
+	"LAST_ACK",
+	"TIME_WAIT",
+	"DELETE_TCB"
+};
+
+VOID PrintError(DWORD ErrorCode)
+{
+	LPVOID lpMsgBuf;
+ 
+	FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+				  NULL, ErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+				  (LPTSTR)&lpMsgBuf, 0, NULL);
+	printf("%s\n", lpMsgBuf);
+	LocalFree(lpMsgBuf);
+}
+
+static void ShowTcpStatistics()
+{
+    MIB_TCPSTATS TcpStatsMIB;
+    GetTcpStatistics(&TcpStatsMIB);
+
+    _tprintf(_T("TCP/IP Statistics\t\n"));
+    _tprintf(_T("  time-out algorithm:\t\t%d\n"), TcpStatsMIB.dwRtoAlgorithm);    
+    _tprintf(_T("  minimum time-out:\t\t%d\n"), TcpStatsMIB.dwRtoMin);         
+    _tprintf(_T("  maximum time-out:\t\t%d\n"), TcpStatsMIB.dwRtoMax);         
+    _tprintf(_T("  maximum connections:\t\t%d\n"), TcpStatsMIB.dwMaxConn);        
+    _tprintf(_T("  active opens:\t\t\t%d\n"), TcpStatsMIB.dwActiveOpens);    
+    _tprintf(_T("  passive opens:\t\t\t%d\n"), TcpStatsMIB.dwPassiveOpens);   
+    _tprintf(_T("  failed attempts:\t\t%d\n"), TcpStatsMIB.dwAttemptFails);   
+    _tprintf(_T("  established connections reset:\t%d\n"), TcpStatsMIB.dwEstabResets);    
+    _tprintf(_T("  established connections:\t%d\n"), TcpStatsMIB.dwCurrEstab);      
+    _tprintf(_T("  segments received:\t\t%d\n"), TcpStatsMIB.dwInSegs);         
+    _tprintf(_T("  segment sent:\t\t\t%d\n"), TcpStatsMIB.dwOutSegs);        
+    _tprintf(_T("  segments retransmitted:\t\t%d\n"), TcpStatsMIB.dwRetransSegs);    
+    _tprintf(_T("  incoming errors:\t\t%d\n"), TcpStatsMIB.dwInErrs);         
+    _tprintf(_T("  outgoing resets:\t\t%d\n"), TcpStatsMIB.dwOutRsts);        
+    _tprintf(_T("  cumulative connections:\t\t%d\n"), TcpStatsMIB.dwNumConns);       
+}
+
+static void ShowUdpStatistics()
+{
+    MIB_UDPSTATS UDPStatsMIB;
+    GetUdpStatistics(&UDPStatsMIB);
+
+    _tprintf(_T("UDP Statistics\t\n"));
+    _tprintf(_T("  received datagrams:\t\t\t%d\n"), UDPStatsMIB.dwInDatagrams);
+    _tprintf(_T("  datagrams for which no port exists:\t%d\n"), UDPStatsMIB.dwNoPorts); 
+    _tprintf(_T("  errors on received datagrams:\t\t%d\n"), UDPStatsMIB.dwInErrors);
+    _tprintf(_T("  sent datagrams:\t\t\t\t%d\n"), UDPStatsMIB.dwOutDatagrams);
+    _tprintf(_T("  number of entries in listener table:\t%d\n"), UDPStatsMIB.dwNumAddrs);
+}
+
+static void ShowIpStatistics()
+{
+    MIB_IPSTATS IPStatsMIB;
+    GetIpStatistics(&IPStatsMIB);
+
+    _tprintf(_T("IP Statistics\t\n"));
+    _tprintf(_T("  IP forwarding enabled or disabled:\t%d\n"), IPStatsMIB.dwForwarding);      
+    _tprintf(_T("  default time-to-live:\t\t\t%d\n"), IPStatsMIB.dwDefaultTTL);      
+    _tprintf(_T("  datagrams received:\t\t\t%d\n"), IPStatsMIB.dwInReceives);      
+    _tprintf(_T("  received header errors:\t\t\t%d\n"), IPStatsMIB.dwInHdrErrors);     
+    _tprintf(_T("  received address errors:\t\t%d\n"), IPStatsMIB.dwInAddrErrors);    
+    _tprintf(_T("  datagrams forwarded:\t\t\t%d\n"), IPStatsMIB.dwForwDatagrams);   
+    _tprintf(_T("  datagrams with unknown protocol:\t%d\n"), IPStatsMIB.dwInUnknownProtos); 
+    _tprintf(_T("  received datagrams discarded:\t\t%d\n"), IPStatsMIB.dwInDiscards);      
+    _tprintf(_T("  received datagrams delivered:\t\t%d\n"), IPStatsMIB.dwInDelivers);      
+    _tprintf(_T("  sent datagrams discarded:\t\t%d\n"), IPStatsMIB.dwOutDiscards);     
+    _tprintf(_T("  datagrams for which no route exists:\t%d\n"), IPStatsMIB.dwOutNoRoutes);     
+    _tprintf(_T("  datagrams for which frags didn't arrive:%d\n"), IPStatsMIB.dwReasmTimeout);    
+    _tprintf(_T("  datagrams requiring reassembly:\t\t%d\n"), IPStatsMIB.dwReasmReqds);      
+    _tprintf(_T("  successful reassemblies:\t\t%d\n"), IPStatsMIB.dwReasmOks);        
+    _tprintf(_T("  failed reassemblies:\t\t\t%d\n"), IPStatsMIB.dwReasmFails);      
+    _tprintf(_T("  successful fragmentations:\t\t%d\n"), IPStatsMIB.dwFragOks);         
+    _tprintf(_T("  failed fragmentations:\t\t\t%d\n"), IPStatsMIB.dwFragFails);       
+    _tprintf(_T("  datagrams fragmented:\t\t\t%d\n"), IPStatsMIB.dwFragCreates);     
+    _tprintf(_T("  number of interfaces on computer:\t%d\n"), IPStatsMIB.dwNumIf);           
+    _tprintf(_T("  number of IP address on computer:\t%d\n"), IPStatsMIB.dwNumAddr);         
+    _tprintf(_T("  number of routes in routing table:\t%d\n"), IPStatsMIB.dwNumRoutes);       
+}
+
+static void ShowNetworkParams()
+{
+    FIXED_INFO* FixedInfo;
+    IP_ADDR_STRING* pIPAddr;
+    ULONG ulOutBufLen;
+    DWORD dwRetVal;
+
+    _tprintf(_T("Network Parameters\t\n"));
+
+    FixedInfo = (FIXED_INFO*)GlobalAlloc(GPTR, sizeof(FIXED_INFO));
+    ulOutBufLen = sizeof(FIXED_INFO);
+    if (ERROR_BUFFER_OVERFLOW == GetNetworkParams(FixedInfo, &ulOutBufLen)) {
+        GlobalFree(FixedInfo);
+        FixedInfo =(FIXED_INFO*)GlobalAlloc(GPTR, ulOutBufLen);
+    }
+    if (dwRetVal = GetNetworkParams(FixedInfo, &ulOutBufLen)) {
+        _tprintf(_T("Call to GetNetworkParams failed. Return Value: %08x\n"), dwRetVal);
+    } else {
+        printf("  Host Name: %s", FixedInfo->HostName);
+        printf("\n  Domain Name: %s", FixedInfo->DomainName);
+        printf("\n  DNS Servers:\t%s\n", FixedInfo->DnsServerList.IpAddress.String);
+        pIPAddr = FixedInfo->DnsServerList.Next;
+        while (pIPAddr) {
+            printf("\t\t\t%s\n", pIPAddr->IpAddress.String);
+            pIPAddr = pIPAddr->Next;
+        }
+    }
+}
+
+static void ShowAdapterInfo()
+{
+    IP_ADAPTER_INFO* pAdaptorInfo;
+    ULONG ulOutBufLen;
+    DWORD dwRetVal;
+
+    _tprintf(_T("\nAdaptor Information\t\n"));
+    pAdaptorInfo = (IP_ADAPTER_INFO*)GlobalAlloc(GPTR, sizeof(IP_ADAPTER_INFO));
+    ulOutBufLen = sizeof(IP_ADAPTER_INFO);
+
+    if (ERROR_BUFFER_OVERFLOW == GetAdaptersInfo(pAdaptorInfo, &ulOutBufLen)) {
+        GlobalFree(pAdaptorInfo);
+        pAdaptorInfo = (IP_ADAPTER_INFO*)GlobalAlloc(GPTR, ulOutBufLen);
+    }
+    if (dwRetVal = GetAdaptersInfo(pAdaptorInfo, &ulOutBufLen)) {
+        _tprintf(_T("Call to GetAdaptersInfo failed. Return Value: %08x\n"), dwRetVal);
+    } else {
+        while (pAdaptorInfo) {
+            printf("  AdapterName: %s\n", pAdaptorInfo->AdapterName);
+            printf("  Description: %s\n", pAdaptorInfo->Description);
+            pAdaptorInfo = pAdaptorInfo->Next;
+        }
+    }
+}
+
+/*
+typedef struct {
+    UINT idLength;
+    UINT* ids;
+} AsnObjectIdentifier;
+
+VOID SnmpUtilPrintAsnAny(AsnAny* pAny);  // pointer to value to print
+VOID SnmpUtilPrintOid(AsnObjectIdentifier* Oid);  // object identifier to print
+
+ */
+void test_snmp(void)
+{
+    int nBytes = 500;
+    BYTE* pCache;
+
+    pCache = (BYTE*)SnmpUtilMemAlloc(nBytes);
+    if (pCache != NULL) {
+        AsnObjectIdentifier* pOidSrc = NULL;
+        AsnObjectIdentifier AsnObId;
+        if (SnmpUtilOidCpy(&AsnObId, pOidSrc)) {
+            //
+            //
+            //
+            SnmpUtilOidFree(&AsnObId);
+        }
+        SnmpUtilMemFree(pCache);
+    } else {
+        _tprintf(_T("ERROR: call to SnmpUtilMemAlloc() failed\n"));
+    }
+}
+
+// Maximum string lengths for ASCII ip address and port names
+//
+#define HOSTNAMELEN		256
+#define PORTNAMELEN		256
+#define ADDRESSLEN		HOSTNAMELEN+PORTNAMELEN
+
+//
+// Our option flags
+//
+#define FLAG_SHOW_ALL_ENDPOINTS    1
+#define FLAG_SHOW_ETH_STATS        2
+#define FLAG_SHOW_NUMBERS          3
+#define FLAG_SHOW_PROT_CONNECTIONS 4
+#define FLAG_SHOW_ROUTE_TABLE      5
+#define FLAG_SHOW_PROT_STATS       6
+#define FLAG_SHOW_INTERVAL         7
+
+
+// Undocumented extended information structures available only on XP and higher
+
+typedef struct {
+  DWORD dwState;        // state of the connection
+  DWORD dwLocalAddr;    // address on local computer
+  DWORD dwLocalPort;    // port number on local computer
+  DWORD dwRemoteAddr;   // address on remote computer
+  DWORD dwRemotePort;   // port number on remote computer
+  DWORD	dwProcessId;
+} MIB_TCPEXROW, *PMIB_TCPEXROW;
+
+typedef struct {
+	DWORD dwNumEntries;
+	MIB_TCPEXROW table[ANY_SIZE];
+} MIB_TCPEXTABLE, *PMIB_TCPEXTABLE;
+
+typedef struct {
+  DWORD   dwLocalAddr;    // address on local computer
+  DWORD   dwLocalPort;    // port number on local computer
+  DWORD	  dwProcessId;
+} MIB_UDPEXROW, *PMIB_UDPEXROW;
+
+typedef struct {
+	DWORD dwNumEntries;
+	MIB_UDPEXROW table[ANY_SIZE];
+} MIB_UDPEXTABLE, *PMIB_UDPEXTABLE;
+
+
+//
+// GetPortName
+//
+// Translate port numbers into their text equivalent if there is one
+//
+PCHAR
+GetPortName(DWORD Flags, UINT port, PCHAR proto, PCHAR name, int namelen) 
+{
+	struct servent *psrvent;
+
+	if (Flags & FLAG_SHOW_NUMBERS) {
+		sprintf(name, "%d", htons((WORD)port));
+		return name;
+	} 
+	// Try to translate to a name
+	if (psrvent = getservbyport(port, proto)) {
+		strcpy(name, psrvent->s_name );
+	} else {
+		sprintf(name, "%d", htons((WORD)port));
+	}		
+	return name;
+}
+
+
+//
+// GetIpHostName
+//
+// Translate IP addresses into their name-resolved form if possible.
+//
+PCHAR
+GetIpHostName(DWORD Flags, BOOL local, UINT ipaddr, PCHAR name, int namelen) 
+{
+//	struct hostent *phostent;
+	UINT nipaddr;
+
+	// Does the user want raw numbers?
+	nipaddr = htonl(ipaddr);
+	if (Flags & FLAG_SHOW_NUMBERS ) {
+		sprintf(name, "%d.%d.%d.%d", 
+			(nipaddr >> 24) & 0xFF,
+			(nipaddr >> 16) & 0xFF,
+			(nipaddr >> 8) & 0xFF,
+			(nipaddr) & 0xFF);
+		return name;
+	}
+
+   	name[0] = _T('\0');
+
+	// Try to translate to a name
+	if (!ipaddr) {
+		if (!local) {
+			sprintf(name, "%d.%d.%d.%d", 
+				(nipaddr >> 24) & 0xFF,
+				(nipaddr >> 16) & 0xFF,
+				(nipaddr >> 8) & 0xFF,
+				(nipaddr) & 0xFF);
+		} else {
+			//gethostname(name, namelen);
+		}
+	} else if (ipaddr == 0x0100007f) {
+		if (local) {
+			//gethostname(name, namelen);
+		} else {
+			strcpy(name, "localhost");
+		}
+//	} else if (phostent = gethostbyaddr((char*)&ipaddr, sizeof(nipaddr), PF_INET)) {
+//		strcpy(name, phostent->h_name);
+	} else {
+#if 0
+        int i1, i2, i3, i4;
+
+		i1 = (nipaddr >> 24) & 0x000000FF;
+		i2 = (nipaddr >> 16) & 0x000000FF;
+		i3 = (nipaddr >> 8) & 0x000000FF;
+		i4 = (nipaddr) & 0x000000FF;
+
+		i1 = 10;
+		i2 = 20;
+		i3 = 30;
+		i4 = 40;
+
+		sprintf(name, "%d.%d.%d.%d", i1,i2,i3,i4);
+#else
+		sprintf(name, "%d.%d.%d.%d", 
+			((nipaddr >> 24) & 0x000000FF),
+			((nipaddr >> 16) & 0x000000FF),
+			((nipaddr >> 8) & 0x000000FF),
+			((nipaddr) & 0x000000FF));
+#endif
+	}
+	return name;
+}
+
+BOOLEAN usage(void)
+{
+    TCHAR buffer[MAX_RESLEN];
+
+    int length = LoadString(GetModuleHandle(NULL), IDS_APP_USAGE, buffer, sizeof(buffer)/sizeof(buffer[0]));
+	_fputts(buffer, stderr);
+	return FALSE;
+}
+
+//
+// GetOptions
+// 
+// Parses the command line arguments.
+//
+BOOLEAN 
+GetOptions(int argc, char *argv[], PDWORD pFlags)
+{
+	int		i, j;
+	BOOLEAN	skipArgument;
+
+	*pFlags = 0;
+	for (i = 1; i < argc; i++) {
+		skipArgument = FALSE;
+		switch (argv[i][0]) {
+		case '-':
+		case '/':
+			j = 1;
+			while (argv[i][j]) {
+				switch (toupper(argv[i][j])) {
+				case 'A':
+					*pFlags |= FLAG_SHOW_ALL_ENDPOINTS;
+					break;
+				case 'E':
+					*pFlags |= FLAG_SHOW_ETH_STATS;
+					break;
+				case 'N':
+					*pFlags |= FLAG_SHOW_NUMBERS;
+					break;
+				case 'P':
+					*pFlags |= FLAG_SHOW_PROT_CONNECTIONS;
+					break;
+				case 'R':
+					*pFlags |= FLAG_SHOW_ROUTE_TABLE;
+					break;
+				case 'S':
+					*pFlags |= FLAG_SHOW_PROT_STATS;
+					break;
+				default:
+					return usage();
+				}
+				if (skipArgument) break;
+				j++;
+			}
+			break;
+		case 'i':
+			*pFlags |= FLAG_SHOW_INTERVAL;
+			break;
+		default:
+			return usage();
+		}
+	}
+	return TRUE;
+}
+
+#if 1
+
+	CHAR localname[HOSTNAMELEN], remotename[HOSTNAMELEN];
+	CHAR remoteport[PORTNAMELEN], localport[PORTNAMELEN];
+	CHAR localaddr[ADDRESSLEN], remoteaddr[ADDRESSLEN];
+
+int main(int argc, char *argv[])
+{
+	PMIB_TCPTABLE tcpTable;
+	PMIB_UDPTABLE udpTable;
+	DWORD error, dwSize;
+	DWORD i, flags;
+
+	// Get options
+	if (!GetOptions(argc, argv, &flags)) {
+		return -1;
+    } else {
+		// Get the table of TCP endpoints
+		dwSize = 0;
+		error = GetTcpTable(NULL, &dwSize, TRUE);
+		if (error != ERROR_INSUFFICIENT_BUFFER) {
+			printf("Failed to snapshot TCP endpoints.\n");
+			PrintError(error);
+			return -1;
+		}
+		tcpTable = (PMIB_TCPTABLE)malloc(dwSize);
+		error = GetTcpTable(tcpTable, &dwSize, TRUE );
+		if (error) {
+			printf("Failed to snapshot TCP endpoints table.\n");
+			PrintError(error);
+			return -1;
+		}
+
+		// Get the table of UDP endpoints
+		dwSize = 0;
+		error = GetUdpTable(NULL, &dwSize, TRUE);
+		if (error != ERROR_INSUFFICIENT_BUFFER) {
+			printf("Failed to snapshot UDP endpoints.\n");
+			PrintError(error);
+			return -1;
+		}
+		udpTable = (PMIB_UDPTABLE)malloc(dwSize);
+		error = GetUdpTable(udpTable, &dwSize, TRUE);
+		if (error) {
+			printf("Failed to snapshot UDP endpoints table.\n");
+			PrintError(error);
+			return -1;
+		}
+
+		// Dump the TCP table
+		for (i = 0; i < tcpTable->dwNumEntries; i++) {
+			if (flags & FLAG_SHOW_ALL_ENDPOINTS ||
+				tcpTable->table[i].dwState == MIB_TCP_STATE_ESTAB) {
+				sprintf(localaddr, "%s:%s", 
+					GetIpHostName(flags, TRUE, tcpTable->table[i].dwLocalAddr, localname, HOSTNAMELEN), 
+				    GetPortName(flags, tcpTable->table[i].dwLocalPort, "tcp", localport, PORTNAMELEN));
+				sprintf(remoteaddr, "%s:%s",
+					GetIpHostName(flags, FALSE, tcpTable->table[i].dwRemoteAddr, remotename, HOSTNAMELEN), 
+				    tcpTable->table[i].dwRemoteAddr ? 
+					GetPortName(flags, tcpTable->table[i].dwRemotePort, "tcp", remoteport, PORTNAMELEN):
+					"0");
+				printf("%4s\tState:   %s\n", "[TCP]", TcpState[tcpTable->table[i].dwState]);
+				printf("       Local:   %s\n       Remote:  %s\n", localaddr, remoteaddr);
+			}
+		}
+		// Dump the UDP table
+		if (flags & FLAG_SHOW_ALL_ENDPOINTS) {
+			for (i = 0; i < udpTable->dwNumEntries; i++) {
+				sprintf(localaddr, "%s:%s", 
+					GetIpHostName(flags, TRUE, udpTable->table[i].dwLocalAddr, localname, HOSTNAMELEN), 
+					GetPortName(flags, udpTable->table[i].dwLocalPort, "tcp", localport, PORTNAMELEN));
+				printf("%4s", "[UDP]");
+				printf("       Local:   %s\n       Remote:  %s\n", localaddr, "*.*.*.*:*");
+			}
+		}
+	}	
+	printf("\n");
+	return 0;
+}
+
+#else
+
+int main(int argc, char *argv[])
+{
+    if (argc > 1) {
+        usage();
+        return 1;
+    }
+
+    _tprintf(_T("\nActive Connections\n\n")\
+             _T("  Proto  Local Address          Foreign Address        State\n\n"));
+    test_snmp();
+
+    ShowTcpStatistics();
+    ShowUdpStatistics();
+    ShowIpStatistics();
+    ShowNetworkParams();
+    ShowAdapterInfo();
+
+	return 0;
+}
+
+#endif

reactos/apps/utils/net/netstat
netstat.rc added at 1.1
diff -N netstat.rc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ netstat.rc	21 Nov 2004 22:26:14 -0000	1.1
@@ -0,0 +1,40 @@
+/* $Id: netstat.rc,v 1.1 2004/11/21 22:26:14 chorns Exp $ */
+
+#include <windows.h>
+#include "resource.h"
+
+#define REACTOS_STR_FILE_DESCRIPTION	"ReactOS TCP/IPv4 Win32 netstat\0"
+#define REACTOS_STR_INTERNAL_NAME	"netstat\0"
+#define REACTOS_STR_ORIGINAL_FILENAME	"netstat.exe\0"
+#include <reactos/version.rc>
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+#ifdef __GNUC__
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_APP_TITLE           "ReactOS netstat"
+    IDS_APP_USAGE           "\n"\
+                            "Displays current TCP/IP protocol statistics and network connections.\n\n"\
+                            "NETSTAT [-a] [-e] [-n] [-s] [-p proto] [-r] [interval]\n\n"\
+                            "  -a            Displays all connections and listening ports.\n"\
+                            "  -e            Displays Ethernet statistics. May be combined with -s\n"\
+                            "  -n            Displays address and port numbers in numeric form.\n"\
+                            "  -p proto      Shows connections for protocol 'proto' TCP or UDP.\n"\
+                            "                If used with the -s option to display\n"\
+                            "                per-protocol statistics, 'proto' may be TCP, UDP, or IP.\n"\
+                            "  -r            Displays the current routing table.\n"\
+                            "  -s            Displays per-protocol statistics. Statistics are shown for\n"\
+                            "                TCP, UDP and IP by default; use -p option to display\n"\
+                            "                information about a subset of the protocols only.\n"\
+                            "  interval      Redisplays selected statistics every 'interval' seconds.\n"\
+                            "                Press CTRL+C to stop redisplaying. By default netstat will\n"\
+                            "                print the current information only once.\n"
+END
+#endif
+

reactos/apps/utils/net/netstat
resource.h added at 1.1
diff -N resource.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ resource.h	21 Nov 2004 22:26:14 -0000	1.1
@@ -0,0 +1,7 @@
+
+#define RES_FIRST_INDEX 1
+#define RES_LAST_INDEX  25
+
+#define IDS_APP_TITLE  100
+#define IDS_APP_USAGE  101
+

reactos/apps/utils/net/netstat
trace.c added at 1.1
diff -N trace.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ trace.c	21 Nov 2004 22:26:14 -0000	1.1
@@ -0,0 +1,53 @@
+/////////////////////////////////////////////////////////////////////////////
+// Diagnostic Trace
+//
+#include <stdio.h> 
+#include <stdarg.h>
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <tchar.h>
+#include "trace.h"
+
+
+#ifdef _DEBUG
+
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+
+void _DebugBreak(void)
+{
+    DebugBreak();
+}
+
+void Trace(TCHAR* lpszFormat, ...)
+{
+    va_list args;
+    int nBuf;
+    TCHAR szBuffer[512];
+
+    va_start(args, lpszFormat);
+    nBuf = _vsntprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
+    OutputDebugString(szBuffer);
+    // was there an error? was the expanded string too long?
+    //ASSERT(nBuf >= 0);
+    va_end(args);
+}
+
+void Assert(void* assert, TCHAR* file, int line, void* msg)
+{
+    if (msg == NULL) {
+        printf("ASSERT -- %s occured on line %u of file %s.\n",
+               assert, line, file);
+    } else {
+        printf("ASSERT -- %s occured on line %u of file %s: Message = %s.\n",
+               assert, line, file, msg);
+    }
+}
+
+#else
+
+void Trace(TCHAR* lpszFormat, ...) { };
+void Assert(void* assert, TCHAR* file, int line, void* msg) { };
+
+#endif //_DEBUG
+/////////////////////////////////////////////////////////////////////////////

reactos/apps/utils/net/netstat
trace.h added at 1.1
diff -N trace.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ trace.h	21 Nov 2004 22:26:14 -0000	1.1
@@ -0,0 +1,61 @@
+/////////////////////////////////////////////////////////////////////////////
+// Diagnostic Trace
+//
+#ifndef __TRACE_H__
+#define __TRACE_H__
+
+#ifdef _DEBUG
+
+#ifdef _X86_
+#define BreakPoint()        _asm { int 3h }
+#else
+#define BreakPoint()        _DebugBreak()
+#endif
+
+#ifndef ASSERT
+#define ASSERT(exp)                                 \
+{                                                   \
+    if (!(exp)) {                                   \
+        Assert(#exp, __FILE__, __LINE__, NULL);     \
+        BreakPoint();                               \
+    }                                               \
+}                                                   \
+
+#define ASSERTMSG(exp, msg)                         \
+{                                                   \
+    if (!(exp)) {                                   \
+        Assert(#exp, __FILE__, __LINE__, msg);      \
+        BreakPoint();                               \
+    }                                               \
+}
+#endif
+
+//=============================================================================
+//  MACRO: TRACE()
+//=============================================================================
+
+#define TRACE  Trace
+
+
+#else   // _DEBUG
+
+//=============================================================================
+//  Define away MACRO's ASSERT() and TRACE() in non debug builds
+//=============================================================================
+
+#ifndef ASSERT
+#define ASSERT(exp)
+#define ASSERTMSG(exp, msg)
+#endif
+
+#define TRACE 0 ? (void)0 : Trace
+
+#endif // !_DEBUG
+
+
+void Assert(void* assert, TCHAR* file, int line, void* msg);
+void Trace(TCHAR* lpszFormat, ...);
+
+
+#endif // __TRACE_H__
+/////////////////////////////////////////////////////////////////////////////

reactos/apps/utils/net/ping
makefile 1.9 -> 1.10
diff -N makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ makefile	21 Nov 2004 22:26:14 -0000	1.10
@@ -0,0 +1,17 @@
+PATH_TO_TOP = ../../../..
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = console
+
+TARGET_NAME = ping
+
+TARGET_CFLAGS = -D__USE_W32_SOCKETS
+
+TARGET_SDKLIBS = ws2_32.a
+
+TARGET_OBJECTS = $(TARGET_NAME).o
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk

reactos/apps/utils/net/ping
ping.c 1.6 -> 1.7
diff -N ping.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ping.c	21 Nov 2004 22:26:14 -0000	1.7
@@ -0,0 +1,633 @@
+/* $Id: ping.c,v 1.7 2004/11/21 22:26:14 chorns Exp $
+ *
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS ping utility
+ * FILE:        apps/net/ping/ping.c
+ * PURPOSE:     Network test utility
+ * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * REVISIONS:
+ *   CSH  01/09/2000 Created
+ */
+//#include <windows.h>
+#include <winsock2.h>
+#include <tchar.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdio.h>
+#ifndef _MSC_VER
+
+//#define DBG
+
+/* FIXME: Where should this be? */
+#ifdef CopyMemory
+#undef CopyMemory
+#endif
+#define CopyMemory(Destination, Source, Length) memcpy(Destination, Source, Length);
+
+/* Should be in the header files somewhere (exported by ntdll.dll) */
+long atol(const char *str);
+
+#ifndef __int64
+typedef long long __int64;
+#endif
+
+char * _i64toa(__int64 value, char *string, int radix);
+
+#endif
+
+
+/* General ICMP constants */
+#define ICMP_MINSIZE		8		/* Minimum ICMP packet size */
+#define ICMP_MAXSIZE		65535	/* Maximum ICMP packet size */
+
+/* ICMP message types */
+#define ICMPMSG_ECHOREQUEST	8		/* ICMP ECHO request message */
+#define ICMPMSG_ECHOREPLY	0		/* ICMP ECHO reply message */
+
+#pragma pack(4)
+
+/* IPv4 header structure */
+typedef struct _IPv4_HEADER {
+	unsigned char	IHL:4;
+	unsigned char	Version:4;
+	unsigned char	TOS;
+	unsigned short	Length;
+	unsigned short	Id;
+	unsigned short	FragFlags;
+	unsigned char	TTL;
+	unsigned char	Protocol;
+	unsigned short	Checksum;
+	unsigned int	SrcAddress;
+	unsigned int	DstAddress;
+} IPv4_HEADER, *PIPv4_HEADER;
+
+/* ICMP echo request/reply header structure */
+typedef struct _ICMP_HEADER {
+	unsigned char	Type;
+	unsigned char	Code;
+	unsigned short	Checksum;
+	unsigned short	Id;
+	unsigned short	SeqNum;
+} ICMP_HEADER, *PICMP_HEADER;
+
+typedef struct _ICMP_ECHO_PACKET {
+	ICMP_HEADER   Icmp;
+	LARGE_INTEGER Timestamp;
+} ICMP_ECHO_PACKET, *PICMP_ECHO_PACKET;
+
+#pragma pack(1)
+
+BOOL                InvalidOption;
+BOOL                NeverStop;
+BOOL                ResolveAddresses;
+UINT                PingCount;
+UINT                DataSize;   /* ICMP echo request data size */
+BOOL                DontFragment;
+ULONG               TTLValue;
+ULONG               TOSValue;
+ULONG               Timeout;
+CHAR                TargetName[256];
+SOCKET              IcmpSock;
+SOCKADDR_IN         Target;
+LPSTR               TargetIP;
+FD_SET              Fds;
+TIMEVAL             Timeval;
+UINT                CurrentSeqNum;
+UINT                SentCount;
+UINT                LostCount;
+BOOL                MinRTTSet;
+LARGE_INTEGER       MinRTT;     /* Minimum round trip time in microseconds */
+LARGE_INTEGER       MaxRTT;
+LARGE_INTEGER       SumRTT;
+LARGE_INTEGER       AvgRTT;
+LARGE_INTEGER       TicksPerMs; /* Ticks per millisecond */
+LARGE_INTEGER       TicksPerUs; /* Ticks per microsecond */
+BOOL                UsePerformanceCounter;
+
+
+/* Display the contents of a buffer */
+VOID DisplayBuffer(
+    PVOID Buffer,
+    DWORD Size)
+{
+    UINT i;
+    PCHAR p;
+
+    printf("Buffer (0x%X)  Size (0x%X).\n", Buffer, Size);
+
+    p = (PCHAR)Buffer;
+    for (i = 0; i < Size; i++) {
+      if (i % 16 == 0) {
+        printf("\n");
+      }
+      printf("%02X ", (p[i]) & 0xFF);
+    }
+}
+
+/* Display usage information on screen */
+VOID Usage(VOID)
+{
+	printf("\nUsage: ping [-t] [-n count] [-l size] [-w timeout] destination-host\n\n");
+	printf("Options:\n");
+	printf("    -t             Ping the specified host until stopped.\n");
+	printf("                   To stop - type Control-C.\n");
+	printf("    -n count       Number of echo requests to send.\n");
+	printf("    -l size        Send buffer size.\n");
+	printf("    -w timeout     Timeout in milliseconds to wait for each reply.\n\n");
+}
+
+/* Reset configuration to default values */
+VOID Reset(VOID)
+{
+    LARGE_INTEGER PerformanceCounterFrequency;
+
+    NeverStop             = FALSE;
+    ResolveAddresses      = FALSE;
+    PingCount             = 4;
+    DataSize              = 32;
+    DontFragment          = FALSE;
+    TTLValue              = 128;
+    TOSValue              = 0;
+    Timeout               = 1000;
+    UsePerformanceCounter = QueryPerformanceFrequency(&PerformanceCounterFrequency);
+
+    if (UsePerformanceCounter) {
+        /* Performance counters may return incorrect results on some multiprocessor
+           platforms so we restrict execution on the first processor. This may fail
+           on Windows NT so we fall back to GetCurrentTick() for timing */
+        if (SetThreadAffinityMask (GetCurrentThread(), 1) == 0) {
+            UsePerformanceCounter = FALSE;
+        }
+
+        /* Convert frequency to ticks per millisecond */
+        TicksPerMs.QuadPart = PerformanceCounterFrequency.QuadPart / 1000;
+        /* And to ticks per microsecond */
+        TicksPerUs.QuadPart = PerformanceCounterFrequency.QuadPart / 1000000;
+    }
+    if (!UsePerformanceCounter) {
+        /* 1 tick per millisecond for GetCurrentTick() */
+        TicksPerMs.QuadPart = 1;
+        /* GetCurrentTick() cannot handle microseconds */
+        TicksPerUs.QuadPart = 1;
+    }
+}
+
+/* Return ULONG in a string */
+ULONG GetULONG(LPSTR String)
+{
+    UINT i, Length;
+    ULONG Value;
+
+    i = 0;
+    Length = strlen(String);
+    while ((i < Length) && ((String[i] < '0') || (String[i] > '9'))) i++;
+    if ((i >= Length) || ((String[i] < '0') || (String[i] > '9'))) {
+        InvalidOption = TRUE;
+        return 0;
+    }
+    Value = (ULONG)atol(&String[i]);
+
+    return Value;
+}
+
+/* Return ULONG in a string. Try next paramter if not successful */
+ULONG GetULONG2(LPSTR String1, LPSTR String2, PINT i)
+{
+    ULONG Value;
+
+    Value = GetULONG(String1);
+    if (InvalidOption) {
+        InvalidOption = FALSE;
+        if (String2[0] != '-') {
+            Value = GetULONG(String2);
+            if (!InvalidOption)
+                *i += 1;
+        }
+    }
+
+    return Value;
+}
+
+/* Parse command line parameters */
+BOOL ParseCmdline(int argc, char* argv[])
+{
+    INT i;
+    BOOL ShowUsage;
+    BOOL FoundTarget;
+//#if 1
+//    lstrcpy(TargetName, "127.0.0.1");
+//    PingCount = 1;
+//    return TRUE;
+//#endif
+    if (argc < 2) {
+        ShowUsage = TRUE;
+    } else {
+        ShowUsage = FALSE;
+    }
+    FoundTarget = FALSE;
+    InvalidOption = FALSE;
+
+    for (i = 1; i < argc; i++) {
+        if (argv[i][0] == '-') {
+            switch (argv[i][1]) {
+            case 't': NeverStop = TRUE; break;
+            case 'a': ResolveAddresses = TRUE; break;
+            case 'n': PingCount = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
+            case 'l':
+                DataSize = GetULONG2(&argv[i][2], argv[i + 1], &i);
+                if ((DataSize < 0) || (DataSize > ICMP_MAXSIZE - sizeof(ICMP_ECHO_PACKET))) {
+                    printf("Bad value for option -l, valid range is from 0 to %d.\n",
+                        ICMP_MAXSIZE - sizeof(ICMP_ECHO_PACKET));
+                    return FALSE;
+                }
+                break;
+            case 'f': DontFragment = TRUE; break;
+            case 'i': TTLValue = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
+            case 'v': TOSValue = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
+            case 'w': Timeout  = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
+            default:
+                printf("Bad option %s.\n", argv[i]);
+                Usage();
+                return FALSE;
+            }
+            if (InvalidOption) {
+                printf("Bad option format %s.\n", argv[i]);
+                return FALSE;
+            }
+        } else {
+            if (FoundTarget) {
+                printf("Bad parameter %s.\n", argv[i]);
+                return FALSE;
+            } else {
+				lstrcpy(TargetName, argv[i]);
+                FoundTarget = TRUE;
+            }
+        }
+    }
+
+    if ((!ShowUsage) && (!FoundTarget)) {
+        printf("Name or IP address of destination host must be specified.\n");
+        return FALSE;
+    }
+
+    if (ShowUsage) {
+        Usage();
+        return FALSE;
+    }
+    return TRUE;
+}
+
+/* Calculate checksum of data */
+WORD Checksum(PUSHORT data, UINT size)
+{
+    ULONG sum = 0;
+
+    while (size > 1) {
+        sum  += *data++;
+        size -= sizeof(USHORT);
+    }
+
+    if (size)
+        sum += *(UCHAR*)data;
+
+    sum = (sum >> 16) + (sum & 0xFFFF);
+    sum += (sum >> 16);
+
+    return (USHORT)(~sum);
+}
+
+/* Prepare to ping target */
+BOOL Setup(VOID)
+{
+    WORD     wVersionRequested;
+    WSADATA  WsaData;
+    INT	     Status;
+    ULONG    Addr;
+    PHOSTENT phe;
+
+    wVersionRequested = MAKEWORD(2, 2);
+ 
+    Status = WSAStartup(wVersionRequested, &WsaData);
+    if (Status != 0) {
+        printf("Could not initialize winsock dll.\n");	
+        return FALSE;
+    }
+
+    IcmpSock = WSASocket(AF_INET, SOCK_RAW, IPPROTO_ICMP, NULL, 0, 0);
+    if (IcmpSock == INVALID_SOCKET) {
+        printf("Could not create socket (#%d).\n", WSAGetLastError());
+        return FALSE;
+    }
+
+    ZeroMemory(&Target, sizeof(Target));
+    phe = NULL;
+    Addr = inet_addr(TargetName);
+    if (Addr == INADDR_NONE) {
+        phe = gethostbyname(TargetName);
+        if (phe == NULL) {
+            printf("Unknown host %s.\n", TargetName);
+            return FALSE;
+        } 
+    }
+	
+    if (phe != NULL) {
+        CopyMemory(&Target.sin_addr, phe->h_addr_list, phe->h_length);
+    } else {
+        Target.sin_addr.s_addr = Addr;
+    }
+
+    if (phe != NULL) {
+		Target.sin_family = phe->h_addrtype;
+    } else {
+        Target.sin_family = AF_INET;
+    }
+	
+    TargetIP		= inet_ntoa(Target.sin_addr);
+    CurrentSeqNum	= 0;
+    SentCount		= 0;
+	LostCount		= 0;
+    MinRTT.QuadPart = 0;
+    MaxRTT.QuadPart = 0;
+    SumRTT.QuadPart = 0;
+    MinRTTSet       = FALSE;
+    return TRUE;
+}
+
+/* Close socket */
+VOID Cleanup(VOID)
+{
+    if (IcmpSock != INVALID_SOCKET)
+        closesocket(IcmpSock);
+
+    WSACleanup();
+}
+
+VOID QueryTime(PLARGE_INTEGER Time)
+{
+    if (UsePerformanceCounter) {
+        if (QueryPerformanceCounter(Time) == 0) {
+            /* This should not happen, but we fall
+               back to GetCurrentTick() if it does */
+            Time->u.LowPart  = (ULONG)GetTickCount();
+            Time->u.HighPart = 0;
+
+            /* 1 tick per millisecond for GetCurrentTick() */
+            TicksPerMs.QuadPart = 1;
+            /* GetCurrentTick() cannot handle microseconds */
+            TicksPerUs.QuadPart = 1;
+
+            UsePerformanceCounter = FALSE;
+        }
+    } else {
+        Time->u.LowPart  = (ULONG)GetTickCount();
+        Time->u.HighPart = 0;
+    }
+}
+
+VOID TimeToMsString(LPSTR String, LARGE_INTEGER Time)
+{
+    UINT          i, Length;
+    CHAR          Convstr[40];
+    LARGE_INTEGER LargeTime;
+
+    LargeTime.QuadPart = Time.QuadPart / TicksPerMs.QuadPart;
+    _i64toa(LargeTime.QuadPart, Convstr, 10);
+	strcpy(String, Convstr);
+    strcat(String, ",");
+
+    LargeTime.QuadPart = (Time.QuadPart % TicksPerMs.QuadPart) / TicksPerUs.QuadPart;
+    _i64toa(LargeTime.QuadPart, Convstr, 10);
+    Length = strlen(Convstr);
+    if (Length < 4) {
+        for (i = 0; i < 4 - Length; i++)
+            strcat(String, "0");
+    }
+
+    strcat(String, Convstr);
+    strcat(String, "ms");
+}
+
+/* Locate the ICMP data and print it. Returns TRUE if the packet was good,
+   FALSE if not */
+BOOL DecodeResponse(PCHAR buffer, UINT size, PSOCKADDR_IN from)
+{
+    PIPv4_HEADER      IpHeader;
+    PICMP_ECHO_PACKET Icmp;
+  	UINT              IphLength;
+    CHAR              Time[100];
+    LARGE_INTEGER     RelativeTime;
+    LARGE_INTEGER     LargeTime;
+
+    IpHeader = (PIPv4_HEADER)buffer;
+
+    IphLength = IpHeader->IHL * 4;
+
+    if (size  < IphLength + ICMP_MINSIZE) {
+#ifdef DBG
+        printf("Bad size (0x%X < 0x%X)\n", size, IphLength + ICMP_MINSIZE);
+#endif /* DBG */
+        return FALSE;
+    }
+
+    Icmp = (PICMP_ECHO_PACKET)(buffer + IphLength);
+
+    if (Icmp->Icmp.Type != ICMPMSG_ECHOREPLY) {
+#ifdef DBG
+        printf("Bad ICMP type (0x%X should be 0x%X)\n", Icmp->Icmp.Type, ICMPMSG_ECHOREPLY);
+#endif /* DBG */
+        return FALSE;
+    }
+
+    if (Icmp->Icmp.Id != (USHORT)GetCurrentProcessId()) {
+#ifdef DBG
+        printf("Bad ICMP id (0x%X should be 0x%X)\n", Icmp->Icmp.Id, (USHORT)GetCurrentProcessId());
+#endif /* DBG */
+        return FALSE;
+    }
+
+    QueryTime(&LargeTime);
+
+    RelativeTime.QuadPart = (LargeTime.QuadPart - Icmp->Timestamp.QuadPart);
+
+    TimeToMsString(Time, RelativeTime);
+
+    printf("Reply from %s: bytes=%d time=%s TTL=%d\n", inet_ntoa(from->sin_addr), 
+      size - IphLength - sizeof(ICMP_ECHO_PACKET), Time, IpHeader->TTL);
+    if (RelativeTime.QuadPart < MinRTT.QuadPart) {
+		  MinRTT.QuadPart = RelativeTime.QuadPart;
+      MinRTTSet = TRUE;
+    }
+	  if (RelativeTime.QuadPart > MaxRTT.QuadPart)
+	      MaxRTT.QuadPart = RelativeTime.QuadPart;
+    SumRTT.QuadPart += RelativeTime.QuadPart;
+
+	return TRUE;
+}
+
+/* Send and receive one ping */
+BOOL Ping(VOID)
+{
+    INT                 Status;
+    SOCKADDR            From;
+    UINT                Length;
+    PVOID               Buffer;
+    UINT                Size;
+    PICMP_ECHO_PACKET   Packet;
+
+    /* Account for extra space for IP header when packet is received */
+    Size   = DataSize + 128;
+    Buffer = GlobalAlloc(0, Size);
+    if (!Buffer) {
+        printf("Not enough free resources available.\n");
+        return FALSE;
+    }
+
+    ZeroMemory(Buffer, Size);
+    Packet = (PICMP_ECHO_PACKET)Buffer;
+
+    /* Assemble ICMP echo request packet */
+    Packet->Icmp.Type     = ICMPMSG_ECHOREQUEST;
+    Packet->Icmp.Code     = 0;
+    Packet->Icmp.Id	      = (USHORT)GetCurrentProcessId();
+    Packet->Icmp.SeqNum   = (USHORT)CurrentSeqNum;
+    Packet->Icmp.Checksum = 0;
+
+    /* Timestamp is part of data area */
+    QueryTime(&Packet->Timestamp);
+
+    CopyMemory(Buffer, &Packet->Icmp, sizeof(ICMP_ECHO_PACKET) + DataSize);
+    /* Calculate checksum for ICMP header and data area */
+    Packet->Icmp.Checksum = Checksum((PUSHORT)&Packet->Icmp, sizeof(ICMP_ECHO_PACKET) + DataSize);
+
+    CurrentSeqNum++;
+
+	/* Send ICMP echo request */
+
+    FD_ZERO(&Fds);
+    FD_SET(IcmpSock, &Fds);
+    Timeval.tv_sec  = Timeout / 1000;
+    Timeval.tv_usec = Timeout % 1000;
+    Status = select(0, NULL, &Fds, NULL, &Timeval);
+    if ((Status != SOCKET_ERROR) && (Status != 0)) {
+
+#ifdef DBG
+        printf("Sending packet\n");
+        DisplayBuffer(Buffer, sizeof(ICMP_ECHO_PACKET) + DataSize);
+        printf("\n");
+#endif /* DBG */
+
+        Status = sendto(IcmpSock, Buffer, sizeof(ICMP_ECHO_PACKET) + DataSize,
+            0, (SOCKADDR*)&Target, sizeof(Target));
+        SentCount++;
+    }
+    if (Status == SOCKET_ERROR) {
+        if (WSAGetLastError() == WSAEHOSTUNREACH) {
+            printf("Destination host unreachable.\n");
+        } else {
+            printf("Could not transmit data (%d).\n", WSAGetLastError());
+        }
+        GlobalFree(Buffer);
+        return FALSE;
+    }
+
+    /* Expect to receive ICMP echo reply */
+    FD_ZERO(&Fds);
+    FD_SET(IcmpSock, &Fds);
+    Timeval.tv_sec  = Timeout / 1000;
+    Timeval.tv_usec = Timeout % 1000;
+
+    Status = select(0, &Fds, NULL, NULL, &Timeval);
+    if ((Status != SOCKET_ERROR) && (Status != 0)) {
+        Length = sizeof(From);
+        Status = recvfrom(IcmpSock, Buffer, Size, 0, &From, &Length);
+
+#ifdef DBG
+        printf("Received packet\n");
+        DisplayBuffer(Buffer, Status);
+        printf("\n");
+#endif /* DBG */
+    }
+    if (Status == SOCKET_ERROR) {
+        if (WSAGetLastError() != WSAETIMEDOUT) {
+            printf("Could not receive data (%d).\n", WSAGetLastError());
+            GlobalFree(Buffer);
+            return FALSE;
+        }
+        Status = 0;
+    }
+
+    if (Status == 0) {
+        printf("Request timed out.\n");
+        LostCount++;
+        GlobalFree(Buffer);
+        return TRUE;
+    }
+
+    if (!DecodeResponse(Buffer, Status, (PSOCKADDR_IN)&From)) {
+        /* FIXME: Wait again as it could be another ICMP message type */
+        printf("Request timed out (incomplete datagram received).\n");
+        LostCount++;
+    }
+
+    GlobalFree(Buffer);
+    return TRUE;
+}
+
+
+/* Program entry point */
+int main(int argc, char* argv[])
+{
+    UINT Count;
+    CHAR MinTime[20];
+    CHAR MaxTime[20];
+    CHAR AvgTime[20];
+
+    Reset();
+
+    if ((ParseCmdline(argc, argv)) && (Setup())) {
+
+        printf("\nPinging %s [%s] with %d bytes of data:\n\n",
+            TargetName, TargetIP, DataSize);
+		
+		Count = 0;
+		while ((NeverStop) || (Count < PingCount)) {
+			Ping();
+			Sleep(Timeout);
+			Count++;
+		};
+
+        Cleanup();
+
+		/* Calculate avarage round trip time */
+        if ((SentCount - LostCount) > 0) {
+            AvgRTT.QuadPart = SumRTT.QuadPart / (SentCount - LostCount);
+        } else {
+            AvgRTT.QuadPart = 0;
+        }
+
+        /* Calculate loss percent */
+        if (LostCount > 0) {
+            Count = (SentCount * 100) / LostCount;
+        } else {
+            Count = 0;
+        }
+
+        if (!MinRTTSet)
+            MinRTT = MaxRTT;
+
+        TimeToMsString(MinTime, MinRTT);
+        TimeToMsString(MaxTime, MaxRTT);
+        TimeToMsString(AvgTime, AvgRTT);
+
+        /* Print statistics */
+        printf("\nPing statistics for %s:\n", TargetIP);
+        printf("    Packets: Sent = %d, Received = %d, Lost = %d (%d%% loss),\n",
+            SentCount, SentCount - LostCount, LostCount, Count);
+        printf("Approximate round trip times in milli-seconds:\n");
+        printf("    Minimum = %s, Maximum = %s, Average = %s\n",
+            MinTime, MaxTime, AvgTime);
+    }
+	return 0;
+}
+
+/* EOF */

reactos/apps/utils/net/ping
ping.rc 1.2 -> 1.3
diff -N ping.rc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ping.rc	21 Nov 2004 22:26:14 -0000	1.3
@@ -0,0 +1,7 @@
+/* $Id: ping.rc,v 1.3 2004/11/21 22:26:14 chorns Exp $ */
+
+#define REACTOS_STR_FILE_DESCRIPTION	"ReactOS TCP/IPv4 Win32 Ping\0"
+#define REACTOS_STR_INTERNAL_NAME	"ping\0"
+#define REACTOS_STR_ORIGINAL_FILENAME	"ping.exe\0"
+#define REACTOS_STR_ORIGINAL_COPYRIGHT	"Casper S. Hornstrup (chorns@users.sourceforge.net)\0"
+#include <reactos/version.rc>

reactos/apps/utils/net/ping
.cvsignore 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- .cvsignore	29 Jun 2003 21:12:23 -0000	1.5
+++ .cvsignore	21 Nov 2004 22:26:14 -0000	1.6
@@ -1,6 +1,17 @@
+*.sys
+*.exe
+*.dll
+*.cpl
+*.a
 *.o
 *.d
-*.exe
 *.coff
+*.dsp
+*.dsw
+*.aps
+*.ncb
+*.opt
 *.sym
+*.plg
+*.bak
 *.map
CVSspam 0.2.8