mirror of
https://github.com/reactos/reactos
synced 2025-10-08 01:12:58 +02:00
Compare commits
1 Commits
backups/ro
...
backups/re
Author | SHA1 | Date | |
---|---|---|---|
|
b549f29b90 |
@@ -46,7 +46,6 @@ Jason Weiler
|
||||
David Welch <welch@cwcom.net>
|
||||
Jonathan Wilson <jonwil@tpgi.com.au>
|
||||
Art Yerkes <ayerkes@speakeasy.net>
|
||||
Magnus Olsen (magnus@greatlord.com)
|
||||
|
||||
Graphic Design from
|
||||
|
73
INSTALL
Normal file
73
INSTALL
Normal file
@@ -0,0 +1,73 @@
|
||||
1. Build environment
|
||||
|
||||
To build the system you need either mingw32 installed on Windows or a mingw32
|
||||
cross compiler running on unix. You may obtain MinGW binaries that build
|
||||
ReactOS from http://www.reactos.com.
|
||||
|
||||
|
||||
2. Building ReactOS
|
||||
|
||||
To build from Windows run 'make' (wihout the quotes) from the top directory.
|
||||
To build from unix, edit rules.mak and change the PREFIX variable to the
|
||||
correct value for your cross-compiler. Run 'export HOST=mingw32-linux' to
|
||||
tell the ReactOS build system that it is building ReactOS on a linux machine.
|
||||
Now run 'make'.
|
||||
|
||||
|
||||
3. Installation
|
||||
|
||||
The system can only be installed on the first partition on the first harddisk.
|
||||
The partition must be formatted as FAT16 or FAT32. The system can only be
|
||||
started from DOS and not from a Windows DOS-prompt.
|
||||
|
||||
ReactOS can be installed from the source distribution or from the binary
|
||||
distribution. The two ways to install ReactOS are explained below.
|
||||
|
||||
|
||||
3.1 Installation from sources
|
||||
|
||||
To install ReactOS after building it, type 'make install'. This will create
|
||||
the directory 'reactos' in the top directory. Copy this directory to the root
|
||||
of your first partition on your first harddisk. This is usually c:\ on a
|
||||
Windows machine.
|
||||
|
||||
If you don't want to copy the files manually every time you run a 'make install',
|
||||
you can specify the directory where the files are to be copied to during
|
||||
installation.
|
||||
|
||||
In rules.mak find the variable INSTALL_DIR and change the assigned value to the
|
||||
name of the directory where the files are to be copied to. If you are using
|
||||
Windows this could be:
|
||||
|
||||
INSTALL_DIR = c:\reactos
|
||||
|
||||
If you are on linux this could be:
|
||||
|
||||
INSTALL_DIR = /mnt/windows/reactos
|
||||
|
||||
Save the changes to rules.mak and run 'make install' to install the files to
|
||||
the new location. If you don't want to change rules.mak, you can specify the
|
||||
installtion directory when invoking make. Run
|
||||
'make INSTALL_DIR=c:\reactos install' to install to c:\reactos.
|
||||
|
||||
|
||||
3.2 Installation from binany distribution
|
||||
|
||||
To install ReactOS from the binary distribution, extract the archive contents
|
||||
to c:\reactos. Remember to extract the files with full paths.
|
||||
|
||||
|
||||
4. Booting ReactOS
|
||||
|
||||
Startup in DOS mode. 'cd' to c:\reactos and type 'boot' and press <enter>.
|
||||
A simple shell is started where you can use simple commands like 'cd' and 'dir'.
|
||||
|
||||
|
||||
5. Help
|
||||
|
||||
If you run into problems or have suggestions for making ReactOS better, please
|
||||
surf to the address below and subscribe to one or more of the mailing lists.
|
||||
|
||||
http://www.reactos.com/index.php?tab=discussion§ion=lists
|
||||
|
||||
ReactOS Development Team
|
5
Jamfile
Normal file
5
Jamfile
Normal file
@@ -0,0 +1,5 @@
|
||||
# Main jamfile for ReactOS
|
||||
|
||||
SubDir ROS_TOP ;
|
||||
|
||||
SubInclude ROS_TOP Lib ;
|
54
Jamrules
Normal file
54
Jamrules
Normal file
@@ -0,0 +1,54 @@
|
||||
# customization for ReactOS goes here
|
||||
|
||||
# The SharedLibrary and SharedLibraryFromObjects rules were
|
||||
# borrowed from here:
|
||||
# http://www.differentpla.net/~roger/devel/jam/tutorial/shared_lib/index.html
|
||||
|
||||
SUFSHR = .dll ;
|
||||
RM = rm ; # rm comes with MinGW, and the default del doesn't work in some cases
|
||||
|
||||
rule SharedLibrary
|
||||
{
|
||||
SharedLibraryFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
|
||||
Objects $(>) ;
|
||||
}
|
||||
|
||||
rule SharedLibraryFromObjects
|
||||
{
|
||||
local _s _t ;
|
||||
|
||||
# Add grist to file names
|
||||
# Add suffix to dll
|
||||
|
||||
_s = [ FGristFiles $(>) ] ;
|
||||
_t = [ FAppendSuffix $(<) : $(SUFSHR) ] ;
|
||||
|
||||
if $(_t) != $(<)
|
||||
{
|
||||
DEPENDS $(<) : $(_t) ;
|
||||
NOTFILE $(<) ;
|
||||
}
|
||||
|
||||
# make compiled sources a dependency of target
|
||||
|
||||
DEPENDS exe : $(_t) ;
|
||||
DEPENDS $(_t) : $(_s) ;
|
||||
MakeLocate $(_t) : $(LOCATE_TARGET) ;
|
||||
|
||||
Clean clean : $(_t) ;
|
||||
|
||||
Link $(_t) : $(_s) ;
|
||||
}
|
||||
|
||||
# nasm needs to know the output file first, or it doesn't
|
||||
# recognize -I :(
|
||||
actions As
|
||||
{
|
||||
$(AS) -o $(<) $(ASFLAGS) -I$(HDRS) $(>)
|
||||
}
|
||||
|
||||
AS = nasm ;
|
||||
|
||||
# why isn't DEFINES working? :(
|
||||
#DEFINES += _M_IX86 ;
|
||||
CCFLAGS += -D_M_IX86 ;
|
13
apps/Makefile
Normal file
13
apps/Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
# $Id$
|
||||
#
|
||||
# ReactOS apps and tools makefile to generate Doxygen documentation
|
||||
#
|
||||
|
||||
|
||||
docu:
|
||||
doxygen Doxyfile
|
||||
|
||||
.PHONY: docu
|
||||
|
||||
|
||||
# EOF
|
162
apps/testsets/Makefile
Normal file
162
apps/testsets/Makefile
Normal file
@@ -0,0 +1,162 @@
|
||||
#
|
||||
# ReactOS system testsets makefile
|
||||
#
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
||||
# Testset applications
|
||||
TEST_SETS = loadlib
|
||||
|
||||
TEST_KERNEL32 =
|
||||
|
||||
TEST_MSVCRT =
|
||||
|
||||
TEST_COM =
|
||||
|
||||
TEST_SEH =
|
||||
|
||||
TEST_REGRESSIONS =
|
||||
|
||||
all: $(TEST_SETS) $(TEST_KERNEL32) $(TEST_MSVCRT) $(TEST_COM) $(TEST_SEH) $(TEST_REGRESSIONS)
|
||||
|
||||
depends:
|
||||
|
||||
implib: $(TEST_SETS:%=%_implib) \
|
||||
$(TEST_KERNEL32:%=%_implib) \
|
||||
$(TEST_MSVCRT:%=%_implib) \
|
||||
$(TEST_COM:%=%_implib) \
|
||||
$(TEST_SEH:%=%_implib) \
|
||||
$(TEST_REGRESSIONS:%=%_implib)
|
||||
|
||||
clean: $(TEST_SETS:%=%_clean) \
|
||||
$(TEST_KERNEL32:%=%_clean) \
|
||||
$(TEST_MSVCRT:%=%_clean) \
|
||||
$(TEST_COM:%=%_clean) \
|
||||
$(TEST_SEH:%=%_clean) \
|
||||
$(TEST_REGRESSIONS:%=%_clean)
|
||||
|
||||
install: $(TEST_SETS:%=%_install) \
|
||||
$(TEST_KERNEL32:%=%_install) \
|
||||
$(TEST_MSVCRT:%=%_install) \
|
||||
$(TEST_COM:%=%_install) \
|
||||
$(TEST_SEH:%=%_install) \
|
||||
$(TEST_REGRESSIONS:%=%_install)
|
||||
|
||||
.PHONY: all depends implib clean install
|
||||
|
||||
|
||||
#
|
||||
# Testset Applications
|
||||
#
|
||||
$(TEST_SETS): %:
|
||||
$(MAKE) -C $*
|
||||
|
||||
$(TEST_SETS:%=%_implib): %_implib:
|
||||
$(MAKE) -C $* implib
|
||||
|
||||
$(TEST_SETS:%=%_clean): %_clean:
|
||||
$(MAKE) -C $* clean
|
||||
|
||||
$(TEST_SETS:%=%_install): %_install:
|
||||
$(MAKE) -C $* install
|
||||
|
||||
.PHONY: $(TEST_SETS) $(TEST_SETS:%=%_implib) $(TEST_SETS:%=%_clean) $(TEST_SETS:%=%_install)
|
||||
|
||||
|
||||
#
|
||||
# Kernel32 Test Applications
|
||||
#
|
||||
$(TEST_KERNEL32): %:
|
||||
$(MAKE) -C kernel32/$*
|
||||
|
||||
$(TEST_KERNEL32:%=%_implib): %_implib:
|
||||
$(MAKE) -C kernel32/$* implib
|
||||
|
||||
$(TEST_KERNEL32:%=%_clean): %_clean:
|
||||
$(MAKE) -C kernel32/$* clean
|
||||
|
||||
$(TEST_KERNEL32:%=%_install): %_install:
|
||||
$(MAKE) -C kernel32/$* install
|
||||
|
||||
.PHONY: $(TEST_KERNEL32) $(TEST_KERNEL32:%=%_implib) $(TEST_KERNEL32:%=%_clean) $(TEST_KERNEL32:%=%_install)
|
||||
|
||||
|
||||
#
|
||||
# msvcrt Test Applications
|
||||
#
|
||||
$(TEST_MSVCRT): %:
|
||||
$(MAKE) -C msvcrt/$*
|
||||
|
||||
$(TEST_MSVCRT:%=%_implib): %_implib:
|
||||
$(MAKE) -C msvcrt/$* implib
|
||||
|
||||
$(TEST_MSVCRT:%=%_clean): %_clean:
|
||||
$(MAKE) -C msvcrt/$* clean
|
||||
|
||||
$(TEST_MSVCRT:%=%_install): %_install:
|
||||
$(MAKE) -C msvcrt/$* install
|
||||
|
||||
.PHONY: $(TEST_MSVCRT) $(TEST_MSVCRT:%=%_implib) $(TEST_MSVCRT:%=%_clean) $(TEST_MSVCRT:%=%_install)
|
||||
|
||||
|
||||
#
|
||||
# COM Test Applications
|
||||
#
|
||||
$(TEST_COM): %:
|
||||
$(MAKE) -C com/$*
|
||||
|
||||
$(TEST_COM:%=%_implib): %_implib:
|
||||
$(MAKE) -C com/$* implib
|
||||
|
||||
$(TEST_COM:%=%_clean): %_clean:
|
||||
$(MAKE) -C com/$* clean
|
||||
|
||||
$(TEST_COM:%=%_install): %_install:
|
||||
$(MAKE) -C com/$* install
|
||||
|
||||
.PHONY: $(TEST_COM) $(TEST_COM:%=%_implib) $(TEST_COM:%=%_clean) $(TEST_COM:%=%_install)
|
||||
|
||||
|
||||
#
|
||||
# SEH Test Applications
|
||||
#
|
||||
$(TEST_SEH): %:
|
||||
$(MAKE) -C seh/$*
|
||||
|
||||
$(TEST_SEH:%=%_implib): %_implib:
|
||||
$(MAKE) -C seh/$* implib
|
||||
|
||||
$(TEST_SEH:%=%_clean): %_clean:
|
||||
$(MAKE) -C seh/$* clean
|
||||
|
||||
$(TEST_SEH:%=%_install): %_install:
|
||||
$(MAKE) -C seh/$* install
|
||||
|
||||
.PHONY: $(TEST_SEH) $(TEST_SEH:%=%_implib) $(TEST_SEH:%=%_clean) $(TEST_SEH:%=%_install)
|
||||
|
||||
|
||||
#
|
||||
# Regression Test Applications
|
||||
#
|
||||
$(TEST_REGRESSIONS): %:
|
||||
$(MAKE) -C regres/$*
|
||||
|
||||
$(TEST_REGRESSIONS:%=%_implib): %_implib:
|
||||
$(MAKE) -C regres/$* implib
|
||||
|
||||
$(TEST_REGRESSIONS:%=%_clean): %_clean:
|
||||
$(MAKE) -C regres/$* clean
|
||||
|
||||
$(TEST_REGRESSIONS:%=%_install): %_install:
|
||||
$(MAKE) -C regres/$* install
|
||||
|
||||
.PHONY: $(TEST_REGRESSIONS) $(TEST_REGRESSIONS:%=%_implib) $(TEST_REGRESSIONS:%=%_clean) $(TEST_REGRESSIONS:%=%_install)
|
||||
|
||||
|
||||
etags:
|
||||
find . -name "*.[ch]" -print | etags --language=c -
|
||||
|
||||
# EOF
|
24
apps/testsets/loadlib/makefile
Normal file
24
apps/testsets/loadlib/makefile
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# $Id: makefile,v 1.0
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = loadlib
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror -D_USE_W32API -DUNICODE -D_UNICODE
|
||||
|
||||
TARGET_SDKLIBS = kernel32.a ntdll.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
27
apps/testsets/msvcrt/fileio/makefile
Normal file
27
apps/testsets/msvcrt/fileio/makefile
Normal file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# $Id: makefile,v 1.0
|
||||
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TEST_ROOT = $(PATH_TO_TOP)/apps/testsets/test
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = fileio
|
||||
|
||||
#TARGET_CFLAGS = -I$(TEST_ROOT) -DDBG -DUNICODE -D_UNICODE
|
||||
TARGET_CFLAGS = -I$(TEST_ROOT) -DDBG
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o wfileio.o main.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
71
apps/utils/Makefile
Normal file
71
apps/utils/Makefile
Normal file
@@ -0,0 +1,71 @@
|
||||
#
|
||||
# ReactOS system utilities makefile
|
||||
#
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
||||
# Console system utilities
|
||||
# cabman cat net objdir partinfo pice ps sc stats
|
||||
UTIL_APPS = cat objdir partinfo pnpdump sc shutdown stats tickcount ps
|
||||
|
||||
UTIL_NET_APPS = arp finger ftp ipconfig netstat ping route telnet whois
|
||||
|
||||
|
||||
all: $(UTIL_APPS) $(UTIL_NET_APPS)
|
||||
|
||||
depends:
|
||||
|
||||
implib: $(UTIL_APPS:%=%_implib) \
|
||||
$(UTIL_NET_APPS:%=%_implib)
|
||||
|
||||
clean: $(UTIL_APPS:%=%_clean) \
|
||||
$(UTIL_NET_APPS:%=%_clean)
|
||||
|
||||
install: $(UTIL_APPS:%=%_install) \
|
||||
$(UTIL_NET_APPS:%=%_install)
|
||||
|
||||
.PHONY: all depends implib clean install
|
||||
|
||||
|
||||
#
|
||||
# Utility Applications
|
||||
#
|
||||
$(UTIL_APPS): %:
|
||||
$(MAKE) -C $*
|
||||
|
||||
$(UTIL_APPS:%=%_implib): %_implib:
|
||||
$(MAKE) -C $* implib
|
||||
|
||||
$(UTIL_APPS:%=%_clean): %_clean:
|
||||
$(MAKE) -C $* clean
|
||||
|
||||
$(UTIL_APPS:%=%_install): %_install:
|
||||
$(MAKE) -C $* install
|
||||
|
||||
.PHONY: $(UTIL_APPS) $(UTIL_APPS:%=%_implib) $(UTIL_APPS:%=%_clean) $(UTIL_APPS:%=%_install)
|
||||
|
||||
#
|
||||
# GUI Utility Applications
|
||||
#
|
||||
$(UTIL_NET_APPS): %:
|
||||
$(MAKE) -C net/$*
|
||||
|
||||
$(UTIL_NET_APPS:%=%_implib): %_implib:
|
||||
$(MAKE) -C net/$* implib
|
||||
|
||||
$(UTIL_NET_APPS:%=%_clean): %_clean:
|
||||
$(MAKE) -C net/$* clean
|
||||
|
||||
$(UTIL_NET_APPS:%=%_install): %_install:
|
||||
$(MAKE) -C net/$* install
|
||||
|
||||
.PHONY: $(UTIL_NET_APPS) $(UTIL_NET_APPS:%=%_implib) $(UTIL_NET_APPS:%=%_clean) $(UTIL_NET_APPS:%=%_install)
|
||||
|
||||
|
||||
etags:
|
||||
find . -name "*.[ch]" -print | etags --language=c -
|
||||
|
||||
# EOF
|
21
apps/utils/binpatch/Makefile
Normal file
21
apps/utils/binpatch/Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = binpatch
|
||||
|
||||
TARGET_SDKLIBS =
|
||||
|
||||
TARGET_OBJECTS = patch.o
|
||||
|
||||
TARGET_CFLAGS += -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
26
apps/utils/cat/cat.c
Normal file
26
apps/utils/cat/cat.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int i;
|
||||
FILE* in;
|
||||
char ch;
|
||||
|
||||
for (i=1; i<argc; i++)
|
||||
{
|
||||
in = fopen(argv[i],"r");
|
||||
if (in == NULL)
|
||||
{
|
||||
printf("Failed to open file %s\n", argv[i]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
while ((ch = fgetc(in)) != EOF)
|
||||
{
|
||||
putchar(ch);
|
||||
}
|
||||
fclose(in);
|
||||
}
|
||||
return 0;
|
||||
}
|
21
apps/utils/cat/makefile
Normal file
21
apps/utils/cat/makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = cat
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Load a device driver
|
||||
*/
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <ntos/zw.h>
|
||||
|
21
apps/utils/driver/load/makefile
Normal file
21
apps/utils/driver/load/makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = load
|
||||
|
||||
TARGET_CFLAGS = -DUNICODE -D_UNICODE
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
21
apps/utils/driver/unload/makefile
Normal file
21
apps/utils/driver/unload/makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = unload
|
||||
|
||||
TARGET_CFLAGS = -DUNICODE -D_UNICODE
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Unload a device driver
|
||||
*/
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <ntos/zw.h>
|
||||
|
21
apps/utils/infinst/makefile
Normal file
21
apps/utils/infinst/makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = infinst
|
||||
|
||||
TARGET_SDKLIBS = comdlg32.a setupapi.a
|
||||
|
||||
TARGET_OBJECTS = infinst.o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
99
apps/utils/net/arp/arp.c
Normal file
99
apps/utils/net/arp/arp.c
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* arp - display ARP cache from the 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>
|
||||
#include <snmp.h>
|
||||
|
||||
#include "trace.h"
|
||||
|
||||
|
||||
VOID SNMP_FUNC_TYPE SnmpSvcInitUptime();
|
||||
DWORD SNMP_FUNC_TYPE SnmpSvcGetUptime();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const char szUsage[] = { "\n" \
|
||||
"Displays and modifies the IP Protocol to physical address translation tables\n" \
|
||||
"used by address resolution protocol (ARP).\n" \
|
||||
"\n" \
|
||||
"ARP -s inet_addr eth_addr [if_addr]\n" \
|
||||
"ARP -d inet_addr [if_addr]\n" \
|
||||
"ARP -a [inet_addr] [-N if_addr]\n" \
|
||||
"\n" \
|
||||
" -a Displays the active ARP table by querying the current protocol\n" \
|
||||
" data. If inet_addr is specified, the IP and physical addresses\n" \
|
||||
" for the specified address are displayed. If more than one\n" \
|
||||
" network interface is using ARP, each interfaces ARP table is\n" \
|
||||
" displayed.\n" \
|
||||
" -g Indentical to -a.\n" \
|
||||
" inet_addr Specifies the IP address.\n" \
|
||||
" -N if_addr Displays the ARP table for the specified interface only\n" \
|
||||
" -d Deletes the host entry specified by inet_addr. inet_addr may be\n" \
|
||||
" wildcarded with * to delete all host entries in the ARP table.\n" \
|
||||
" -s Adds the host and associates the IP address inet_addr with the\n" \
|
||||
" physical address eth_addr. The physical address must be specified\n" \
|
||||
" as 6 hexadecimal characters delimited by hyphens. The new entry\n" \
|
||||
" will become permanent in the ARP table.\n" \
|
||||
" eth_addr Specifies the interface physical address.\n" \
|
||||
" if_addr If present, this specifies the IP address of the interface whose\n" \
|
||||
" address translation table should be modified. If not present, the\n" \
|
||||
" first applicable interface will be used.\n" \
|
||||
"Example:\n" \
|
||||
" > arp -s 192.168.0.12 55-AA-55-01-02-03 .... Static entry creation.\n" \
|
||||
" > arp -a .... ARP table display.\n" \
|
||||
" > arp -d * .... Delete all ARP table entries.\n"
|
||||
};
|
||||
|
||||
void usage(void)
|
||||
{
|
||||
// fprintf(stderr,"USAGE:\n");
|
||||
fputs(szUsage, stderr);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
TCHAR szComputerName[50];
|
||||
DWORD dwSize = 50;
|
||||
|
||||
int nBytes = 500;
|
||||
BYTE* pCache;
|
||||
|
||||
if (argc > 1) {
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
SnmpSvcInitUptime();
|
||||
|
||||
GetComputerName(szComputerName, &dwSize);
|
||||
_tprintf(_T("ReactOS ARP cache on Computer Name: %s\n"), szComputerName);
|
||||
|
||||
pCache = (BYTE*)SnmpUtilMemAlloc(nBytes);
|
||||
|
||||
Sleep(2500);
|
||||
|
||||
if (pCache != NULL) {
|
||||
|
||||
DWORD dwUptime = SnmpSvcGetUptime();
|
||||
|
||||
_tprintf(_T("SNMP uptime: %d\n"), dwUptime);
|
||||
|
||||
SnmpUtilMemFree(pCache);
|
||||
} else {
|
||||
_tprintf(_T("ERROR: call to SnmpUtilMemAlloc() failed\n"));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
19
apps/utils/net/arp/makefile
Normal file
19
apps/utils/net/arp/makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = arp
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
TARGET_CFLAGS = -D__USE_W32API
|
||||
|
||||
TARGET_SDKLIBS = user32.a snmpapi.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
53
apps/utils/net/arp/trace.c
Normal file
53
apps/utils/net/arp/trace.c
Normal file
@@ -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
|
||||
/////////////////////////////////////////////////////////////////////////////
|
@@ -41,6 +41,16 @@
|
||||
* 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
|
||||
@@ -151,10 +161,10 @@ userlist(int argc, char **argv)
|
||||
fprintf(stderr, "Warning: Can't do local finger\n");
|
||||
}
|
||||
|
||||
/* Start winsock */
|
||||
/* Start winsock */
|
||||
wVersionRequested = MAKEWORD( 1, 1 );
|
||||
iErr = WSAStartup( wVersionRequested, &wsaData );
|
||||
if ( iErr != 0 )
|
||||
if ( iErr != 0 )
|
||||
{
|
||||
/* Tell the user that we couldn't find a usable */
|
||||
/* WinSock DLL. */
|
24
apps/utils/net/finger/makefile
Normal file
24
apps/utils/net/finger/makefile
Normal file
@@ -0,0 +1,24 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = finger
|
||||
|
||||
TARGET_SDKLIBS = ws2_32.a
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
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
|
@@ -33,6 +33,11 @@
|
||||
* 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"
|
||||
@@ -51,14 +56,14 @@ netfinger(char *name)
|
||||
struct hostent *hp, def;
|
||||
struct servent *sp;
|
||||
struct sockaddr_in sin;
|
||||
SOCKET s;
|
||||
int s;
|
||||
char *alist[1], *host;
|
||||
|
||||
/* If this is a local request */
|
||||
if (!(host = rindex(name, '@')))
|
||||
return;
|
||||
|
||||
*host++ = '\0';
|
||||
*host++ = NULL;
|
||||
if (isdigit(*host) && (defaddr.s_addr = inet_addr(host)) != -1) {
|
||||
def.h_name = host;
|
||||
def.h_addr_list = alist;
|
||||
@@ -79,7 +84,7 @@ netfinger(char *name)
|
||||
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)) == INVALID_SOCKET) {
|
||||
if ((s = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) {
|
||||
perror("finger: socket");
|
||||
return;
|
||||
}
|
||||
@@ -110,7 +115,7 @@ netfinger(char *name)
|
||||
* 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;
|
2376
apps/utils/net/ftp/cmds.c
Normal file
2376
apps/utils/net/ftp/cmds.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -36,8 +36,9 @@ void domacro(argc, argv)
|
||||
register char *cp1, *cp2;
|
||||
int count = 2, loopflg = 0;
|
||||
char line2[200];
|
||||
extern char **glob();
|
||||
extern char **glob(), *globerr;
|
||||
struct cmd *getcmd(), *c;
|
||||
extern struct cmd cmdtab[];
|
||||
|
||||
if (argc < 2) {
|
||||
(void) strcat(line, " ");
|
@@ -1,7 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <winsock.h>
|
||||
#include "fake.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
#define MAX_ASCII 100
|
||||
@@ -93,7 +92,7 @@ int fgetcSocket(int s)
|
||||
{
|
||||
static int index = 0;
|
||||
static int total = 0;
|
||||
static char buffer[4096];
|
||||
static unsigned char buffer[4096];
|
||||
|
||||
if (index == total)
|
||||
{
|
||||
@@ -143,7 +142,7 @@ int fputcSocket(int s, char putChar)
|
||||
buffer[1] = '\0';
|
||||
|
||||
if(SOCKET_ERROR==send(s, buffer, 1, 0)) {
|
||||
int iret=WSAGetLastError ();
|
||||
int iret=WSAGetLastError ();
|
||||
fprintf(stdout,"fputcSocket: %d\n",iret);
|
||||
return 0;
|
||||
}
|
||||
@@ -155,9 +154,9 @@ int fputSocket(int s, char *buffer, int len)
|
||||
{
|
||||
int iret;
|
||||
while(len) {
|
||||
if(SOCKET_ERROR==(iret=send(s, buffer, len, 0)))
|
||||
if(SOCKET_ERROR==(iret=send(s, buffer, len, 0)))
|
||||
{
|
||||
iret=WSAGetLastError ();
|
||||
iret=WSAGetLastError ();
|
||||
fprintf(stdout,"fputcSocket: %d\n",iret);
|
||||
return 0;
|
||||
}
|
||||
@@ -188,7 +187,7 @@ char *fgetsSocket(int s, char *string)
|
||||
if (count == 1)
|
||||
{
|
||||
string[i] = buffer[0];
|
||||
|
||||
|
||||
if (i == MAX_ASCII - 3)
|
||||
{
|
||||
count = 0;
|
||||
@@ -236,7 +235,7 @@ char *getpass (const char * prompt)
|
||||
static char input[256];
|
||||
HANDLE in;
|
||||
HANDLE err;
|
||||
DWORD count;
|
||||
int count;
|
||||
|
||||
in = GetStdHandle (STD_INPUT_HANDLE);
|
||||
err = GetStdHandle (STD_ERROR_HANDLE);
|
||||
@@ -306,7 +305,12 @@ int access(const char *filename, int accessmethod)
|
||||
#define EPOCHFILETIME (116444736000000000LL)
|
||||
#endif
|
||||
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
struct timezone {
|
||||
int tz_minuteswest; /* minutes W of Greenwich */
|
||||
int tz_dsttime; /* type of dst correction */
|
||||
};
|
||||
|
||||
__inline int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
{
|
||||
FILETIME ft;
|
||||
LARGE_INTEGER li;
|
10
apps/utils/net/ftp/fake.h
Normal file
10
apps/utils/net/ftp/fake.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#define bcopy(s,d,l) memcpy((d),(s),(l))
|
||||
#define bzero(cp,l) memset((cp),0,(l))
|
||||
|
||||
#define rindex strrchr
|
||||
#define index strchr
|
||||
|
||||
#define getwd getcwd
|
||||
|
||||
#define strcasecmp strcmp
|
||||
#define strncasecmp strnicmp
|
1805
apps/utils/net/ftp/ftp.c
Normal file
1805
apps/utils/net/ftp/ftp.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
#include <winsock.h>
|
||||
#include "fake.h"
|
||||
#include <winsock.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
//typedef void (*Sig_t)(int);
|
602
apps/utils/net/ftp/main.c
Normal file
602
apps/utils/net/ftp/main.c
Normal file
@@ -0,0 +1,602 @@
|
||||
/*
|
||||
* Copyright (c) 1985, 1989 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char copyright[] =
|
||||
"@(#) Copyright (c) 1985, 1989 Regents of the University of California.\n\
|
||||
All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)main.c based on 5.13 (Berkeley) 3/14/89";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* FTP User Program -- Command Interface.
|
||||
*/
|
||||
#if !defined(WIN32)
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <arpa/ftp.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#include "ftp_var.h"
|
||||
#include "prototypes.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
#if defined(sun) && !defined(FD_SET)
|
||||
typedef int uid_t;
|
||||
#endif
|
||||
|
||||
uid_t getuid();
|
||||
void intr();
|
||||
void lostpeer();
|
||||
char *getlogin();
|
||||
|
||||
short portnum;
|
||||
|
||||
char home[128];
|
||||
char *globerr;
|
||||
int autologin;
|
||||
|
||||
|
||||
|
||||
/* Lot's of options... */
|
||||
/*
|
||||
* Options and other state info.
|
||||
*/
|
||||
int trace; /* trace packets exchanged */
|
||||
int hash; /* print # for each buffer transferred */
|
||||
int sendport; /* use PORT cmd for each data connection */
|
||||
int verbose; /* print messages coming back from server */
|
||||
int connected; /* connected to server */
|
||||
int fromatty; /* input is from a terminal */
|
||||
int interactive; /* interactively prompt on m* cmds */
|
||||
int debug; /* debugging level */
|
||||
int bell; /* ring bell on cmd completion */
|
||||
int doglob; /* glob local file names */
|
||||
int proxy; /* proxy server connection active */
|
||||
int passivemode;
|
||||
int proxflag; /* proxy connection exists */
|
||||
int sunique; /* store files on server with unique name */
|
||||
int runique; /* store local files with unique name */
|
||||
int mcase; /* map upper to lower case for mget names */
|
||||
int ntflag; /* use ntin ntout tables for name translation */
|
||||
int mapflag; /* use mapin mapout templates on file names */
|
||||
int code; /* return/reply code for ftp command */
|
||||
int crflag; /* if 1, strip car. rets. on ascii gets */
|
||||
char pasv[64]; /* passive port for proxy data connection */
|
||||
char *altarg; /* argv[1] with no shell-like preprocessing */
|
||||
char ntin[17]; /* input translation table */
|
||||
char ntout[17]; /* output translation table */
|
||||
// #include <sys/param.h>
|
||||
char mapin[MAXPATHLEN]; /* input map template */
|
||||
char mapout[MAXPATHLEN]; /* output map template */
|
||||
char typename[32]; /* name of file transfer type */
|
||||
int type; /* file transfer type */
|
||||
char structname[32]; /* name of file transfer structure */
|
||||
int stru; /* file transfer structure */
|
||||
char formname[32]; /* name of file transfer format */
|
||||
int form; /* file transfer format */
|
||||
char modename[32]; /* name of file transfer mode */
|
||||
int mode; /* file transfer mode */
|
||||
char bytename[32]; /* local byte size in ascii */
|
||||
int bytesize; /* local byte size in binary */
|
||||
|
||||
jmp_buf toplevel; /* non-local goto stuff for cmd scanner */
|
||||
|
||||
char line[200]; /* input line buffer */
|
||||
char *stringbase; /* current scan point in line buffer */
|
||||
char argbuf[200]; /* argument storage buffer */
|
||||
char *argbase; /* current storage point in arg buffer */
|
||||
int margc; /* count of arguments on input line */
|
||||
char *margv[20]; /* args parsed from input line */
|
||||
int cpend; /* flag: if != 0, then pending server reply */
|
||||
int mflag; /* flag: if != 0, then active multi command */
|
||||
|
||||
int options; /* used during socket creation */
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
register char *cp;
|
||||
int top;
|
||||
struct passwd *pw = NULL;
|
||||
#if 0
|
||||
char homedir[MAXPATHLEN];
|
||||
#endif
|
||||
|
||||
int err;
|
||||
WORD wVerReq;
|
||||
|
||||
WSADATA WSAData;
|
||||
struct servent *sp; /* service spec for tcp/ftp */
|
||||
|
||||
/* Disable output buffering, for the benefit of Emacs. */
|
||||
//setbuf(stdout, NULL);
|
||||
|
||||
_fmode = O_BINARY; // This causes an error somewhere.
|
||||
|
||||
wVerReq = MAKEWORD(1,1);
|
||||
|
||||
err = WSAStartup(wVerReq, &WSAData);
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr, "Could not initialize Windows socket interface.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sp = getservbyname("ftp", "tcp");
|
||||
if (sp == 0) {
|
||||
fprintf(stderr, "ftp: ftp/tcp: unknown service\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
portnum = sp->s_port;
|
||||
|
||||
|
||||
doglob = 1;
|
||||
interactive = 1;
|
||||
autologin = 1;
|
||||
argc--, argv++;
|
||||
while (argc > 0 && **argv == '-') {
|
||||
for (cp = *argv + 1; *cp; cp++)
|
||||
switch (*cp) {
|
||||
|
||||
case 'd':
|
||||
options |= SO_DEBUG;
|
||||
debug++;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
|
||||
case 't':
|
||||
trace++;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
interactive = 0;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
autologin = 0;
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
doglob = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stdout,
|
||||
"ftp: %c: unknown option\n", *cp);
|
||||
exit(1);
|
||||
}
|
||||
argc--, argv++;
|
||||
}
|
||||
// fromatty = isatty(fileno(stdin));
|
||||
fromatty = 1; // Strengthen this test
|
||||
/*
|
||||
* Set up defaults for FTP.
|
||||
*/
|
||||
(void) strcpy(typename, "ascii"), type = TYPE_A;
|
||||
(void) strcpy(formname, "non-print"), form = FORM_N;
|
||||
(void) strcpy(modename, "stream"), mode = MODE_S;
|
||||
(void) strcpy(structname, "file"), stru = STRU_F;
|
||||
(void) strcpy(bytename, "8"), bytesize = 8;
|
||||
if (fromatty)
|
||||
verbose++;
|
||||
cpend = 0; /* no pending replies */
|
||||
proxy = 0; /* proxy not active */
|
||||
passivemode = 1; /* passive mode *is* active */
|
||||
crflag = 1; /* strip c.r. on ascii gets */
|
||||
/*
|
||||
* Set up the home directory in case we're globbing.
|
||||
*/
|
||||
#if 0
|
||||
cp = getlogin();
|
||||
if (cp != NULL) {
|
||||
pw = getpwnam(cp);
|
||||
}
|
||||
if (pw == NULL)
|
||||
pw = getpwuid(getuid());
|
||||
if (pw != NULL) {
|
||||
home = homedir;
|
||||
(void) strcpy(home, pw->pw_dir);
|
||||
}
|
||||
#endif
|
||||
strcpy(home, "C:/");
|
||||
if (argc > 0) {
|
||||
if (setjmp(toplevel))
|
||||
exit(0);
|
||||
// (void) signal(SIGINT, intr);
|
||||
// (void) signal(SIGPIPE, lostpeer);
|
||||
setpeer(argc + 1, argv - 1);
|
||||
}
|
||||
top = setjmp(toplevel) == 0;
|
||||
if (top) {
|
||||
// (void) signal(SIGINT, intr);
|
||||
// (void) signal(SIGPIPE, lostpeer);
|
||||
}
|
||||
for (;;) {
|
||||
cmdscanner(top);
|
||||
top = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
intr()
|
||||
{
|
||||
|
||||
longjmp(toplevel, 1);
|
||||
}
|
||||
|
||||
void lostpeer(void)
|
||||
{
|
||||
extern int cout;
|
||||
extern int data;
|
||||
|
||||
if (connected) {
|
||||
if (cout != (int) NULL) {
|
||||
closesocket(cout);
|
||||
cout = (int) NULL;
|
||||
}
|
||||
if (data >= 0) {
|
||||
(void) shutdown(data, 1+1);
|
||||
(void) close(data);
|
||||
data = -1;
|
||||
}
|
||||
connected = 0;
|
||||
}
|
||||
pswitch(1);
|
||||
if (connected) {
|
||||
if (cout != (int)NULL) {
|
||||
closesocket(cout);
|
||||
cout = (int) NULL;
|
||||
}
|
||||
connected = 0;
|
||||
}
|
||||
proxflag = 0;
|
||||
pswitch(0);
|
||||
}
|
||||
|
||||
/*char *
|
||||
tail(filename)
|
||||
char *filename;
|
||||
{
|
||||
register char *s;
|
||||
|
||||
while (*filename) {
|
||||
s = rindex(filename, '/');
|
||||
if (s == NULL)
|
||||
break;
|
||||
if (s[1])
|
||||
return (s + 1);
|
||||
*s = '\0';
|
||||
}
|
||||
return (filename);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* Command parser.
|
||||
*/
|
||||
void cmdscanner(top)
|
||||
int top;
|
||||
{
|
||||
register struct cmd *c;
|
||||
struct cmd *getcmd();
|
||||
extern int help();
|
||||
|
||||
if (!top)
|
||||
(void) putchar('\n');
|
||||
for (;;) {
|
||||
(void) fflush(stdout);
|
||||
if (fromatty) {
|
||||
printf("ftp> ");
|
||||
(void) fflush(stdout);
|
||||
}
|
||||
if (gets(line) == 0) {
|
||||
if (feof(stdin) || ferror(stdin))
|
||||
quit();
|
||||
break;
|
||||
}
|
||||
if (line[0] == 0)
|
||||
break;
|
||||
makeargv();
|
||||
if (margc == 0) {
|
||||
continue;
|
||||
}
|
||||
c = getcmd(margv[0]);
|
||||
if (c == (struct cmd *)-1) {
|
||||
printf("?Ambiguous command\n");
|
||||
continue;
|
||||
}
|
||||
if (c == 0) {
|
||||
printf("?Invalid command\n");
|
||||
continue;
|
||||
}
|
||||
if (c->c_conn && !connected) {
|
||||
printf ("Not connected.\n");
|
||||
continue;
|
||||
}
|
||||
(*c->c_handler)(margc, margv);
|
||||
if (bell && c->c_bell)
|
||||
(void) putchar('\007');
|
||||
if (c->c_handler != help)
|
||||
break;
|
||||
}
|
||||
(void) fflush(stdout);
|
||||
// (void) signal(SIGINT, intr);
|
||||
// (void) signal(SIGPIPE, lostpeer);
|
||||
}
|
||||
|
||||
struct cmd *
|
||||
getcmd(name)
|
||||
register char *name;
|
||||
{
|
||||
extern struct cmd cmdtab[];
|
||||
register char *p, *q;
|
||||
register struct cmd *c, *found;
|
||||
register int nmatches, longest;
|
||||
|
||||
longest = 0;
|
||||
nmatches = 0;
|
||||
found = 0;
|
||||
for (c = cmdtab; p = c->c_name; c++) {
|
||||
for (q = name; *q == *p++; q++)
|
||||
if (*q == 0) /* exact match? */
|
||||
return (c);
|
||||
if (!*q) { /* the name was a prefix */
|
||||
if (q - name > longest) {
|
||||
longest = q - name;
|
||||
nmatches = 1;
|
||||
found = c;
|
||||
} else if (q - name == longest)
|
||||
nmatches++;
|
||||
}
|
||||
}
|
||||
if (nmatches > 1)
|
||||
return ((struct cmd *)-1);
|
||||
return (found);
|
||||
}
|
||||
|
||||
/*
|
||||
* Slice a string up into argc/argv.
|
||||
*/
|
||||
|
||||
int slrflag;
|
||||
|
||||
void makeargv()
|
||||
{
|
||||
char **argp;
|
||||
char *slurpstring();
|
||||
|
||||
margc = 0;
|
||||
argp = margv;
|
||||
stringbase = line; /* scan from first of buffer */
|
||||
argbase = argbuf; /* store from first of buffer */
|
||||
slrflag = 0;
|
||||
while (*argp++ = slurpstring())
|
||||
margc++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse string into argbuf;
|
||||
* implemented with FSM to
|
||||
* handle quoting and strings
|
||||
*/
|
||||
char *
|
||||
slurpstring()
|
||||
{
|
||||
int got_one = 0;
|
||||
register char *sb = stringbase;
|
||||
register char *ap = argbase;
|
||||
char *tmp = argbase; /* will return this if token found */
|
||||
|
||||
if (*sb == '!' || *sb == '$') { /* recognize ! as a token for shell */
|
||||
switch (slrflag) { /* and $ as token for macro invoke */
|
||||
case 0:
|
||||
slrflag++;
|
||||
stringbase++;
|
||||
return ((*sb == '!') ? "!" : "$");
|
||||
/* NOTREACHED */
|
||||
case 1:
|
||||
slrflag++;
|
||||
altarg = stringbase;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
S0:
|
||||
switch (*sb) {
|
||||
|
||||
case '\0':
|
||||
goto OUT1;
|
||||
|
||||
case ' ':
|
||||
case '\t':
|
||||
sb++; goto S0;
|
||||
|
||||
default:
|
||||
switch (slrflag) {
|
||||
case 0:
|
||||
slrflag++;
|
||||
break;
|
||||
case 1:
|
||||
slrflag++;
|
||||
altarg = sb;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
goto S1;
|
||||
}
|
||||
|
||||
S1:
|
||||
switch (*sb) {
|
||||
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\0':
|
||||
goto OUT1; /* end of token */
|
||||
|
||||
case '\\':
|
||||
sb++; goto S2; /* slurp next character */
|
||||
|
||||
case '"':
|
||||
sb++; goto S3; /* slurp quoted string */
|
||||
|
||||
default:
|
||||
*ap++ = *sb++; /* add character to token */
|
||||
got_one = 1;
|
||||
goto S1;
|
||||
}
|
||||
|
||||
S2:
|
||||
switch (*sb) {
|
||||
|
||||
case '\0':
|
||||
goto OUT1;
|
||||
|
||||
default:
|
||||
*ap++ = *sb++;
|
||||
got_one = 1;
|
||||
goto S1;
|
||||
}
|
||||
|
||||
S3:
|
||||
switch (*sb) {
|
||||
|
||||
case '\0':
|
||||
goto OUT1;
|
||||
|
||||
case '"':
|
||||
sb++; goto S1;
|
||||
|
||||
default:
|
||||
*ap++ = *sb++;
|
||||
got_one = 1;
|
||||
goto S3;
|
||||
}
|
||||
|
||||
OUT1:
|
||||
if (got_one)
|
||||
*ap++ = '\0';
|
||||
argbase = ap; /* update storage pointer */
|
||||
stringbase = sb; /* update scan pointer */
|
||||
if (got_one) {
|
||||
return(tmp);
|
||||
}
|
||||
switch (slrflag) {
|
||||
case 0:
|
||||
slrflag++;
|
||||
break;
|
||||
case 1:
|
||||
slrflag++;
|
||||
altarg = (char *) 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return((char *)0);
|
||||
}
|
||||
|
||||
#define HELPINDENT (sizeof ("directory"))
|
||||
|
||||
/*
|
||||
* Help command.
|
||||
* Call each command handler with argc == 0 and argv[0] == name.
|
||||
*/
|
||||
int help(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
extern struct cmd cmdtab[];
|
||||
register struct cmd *c;
|
||||
|
||||
if (argc == 1) {
|
||||
register int i, j, w, k;
|
||||
int columns, width = 0, lines;
|
||||
extern int NCMDS;
|
||||
|
||||
printf("Commands may be abbreviated. Commands are:\n\n");
|
||||
for (c = cmdtab; c < &cmdtab[NCMDS]; c++) {
|
||||
int len = strlen(c->c_name);
|
||||
|
||||
if (len > width)
|
||||
width = len;
|
||||
}
|
||||
width = (width + 8) &~ 7;
|
||||
columns = 80 / width;
|
||||
if (columns == 0)
|
||||
columns = 1;
|
||||
lines = (NCMDS + columns - 1) / columns;
|
||||
for (i = 0; i < lines; i++) {
|
||||
for (j = 0; j < columns; j++) {
|
||||
c = cmdtab + j * lines + i;
|
||||
if (c->c_name && (!proxy || c->c_proxy)) {
|
||||
printf("%s", c->c_name);
|
||||
}
|
||||
else if (c->c_name) {
|
||||
for (k=0; k < (int) strlen(c->c_name); k++) {
|
||||
(void) putchar(' ');
|
||||
}
|
||||
}
|
||||
if (c + lines >= &cmdtab[NCMDS]) {
|
||||
printf("\n");
|
||||
break;
|
||||
}
|
||||
w = strlen(c->c_name);
|
||||
while (w < width) {
|
||||
w = (w + 8) &~ 7;
|
||||
(void) putchar('\t');
|
||||
}
|
||||
}
|
||||
}
|
||||
(void) fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
while (--argc > 0) {
|
||||
register char *arg;
|
||||
arg = *++argv;
|
||||
c = getcmd(arg);
|
||||
if (c == (struct cmd *)-1)
|
||||
printf("?Ambiguous help command %s\n", arg);
|
||||
else if (c == (struct cmd *)0)
|
||||
printf("?Invalid help command %s\n", arg);
|
||||
else
|
||||
printf("%-*s\t%s\n", HELPINDENT,
|
||||
c->c_name, c->c_help);
|
||||
}
|
||||
(void) fflush(stdout);
|
||||
return 0;
|
||||
}
|
27
apps/utils/net/ftp/makefile
Normal file
27
apps/utils/net/ftp/makefile
Normal file
@@ -0,0 +1,27 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = ftp
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
TARGET_SDKLIBS = ws2_32.a iphlpapi.a
|
||||
# ntdll.a
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
cmds.o \
|
||||
cmdtab.o \
|
||||
domacro.o \
|
||||
fake.o \
|
||||
ftp.o \
|
||||
main.o \
|
||||
ruserpass.o
|
||||
|
||||
TARGET_GCCLIBS =
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
@@ -28,4 +28,5 @@ void recvrequest(char *cmd, char *local, char *remote, char *mode,
|
||||
int confirm(char *cmd, char *file);
|
||||
void blkfree(char **av0);
|
||||
int getit(int argc, char *argv[], int restartit, char *mode);
|
||||
static int token(void);
|
||||
int sleep(int time);
|
@@ -53,18 +53,17 @@ static struct toktab {
|
||||
char *tokstr;
|
||||
int tval;
|
||||
} toktab[]= {
|
||||
{"default", DEFAULT},
|
||||
{"login", LOGIN},
|
||||
{"password", PASSWD},
|
||||
{"passwd", PASSWD},
|
||||
{"account", ACCOUNT},
|
||||
{"machine", MACH},
|
||||
{"macdef", MACDEF},
|
||||
{0, 0}
|
||||
"default", DEFAULT,
|
||||
"login", LOGIN,
|
||||
"password", PASSWD,
|
||||
"passwd", PASSWD,
|
||||
"account", ACCOUNT,
|
||||
"machine", MACH,
|
||||
"macdef", MACDEF,
|
||||
0, 0
|
||||
};
|
||||
|
||||
extern char *hostname;
|
||||
static int token(void);
|
||||
|
||||
int ruserpass(char *host, char **aname, char **apass, char **aacct)
|
||||
{
|
||||
@@ -126,15 +125,14 @@ next:
|
||||
while ((t = token()) && t != MACH && t != DEFAULT) switch(t) {
|
||||
|
||||
case LOGIN:
|
||||
if (token()) {
|
||||
if (*aname == 0) {
|
||||
if (token())
|
||||
if (*aname == 0) {
|
||||
*aname = malloc((unsigned) strlen(tokval) + 1);
|
||||
(void) strcpy(*aname, tokval);
|
||||
} else {
|
||||
if (strcmp(*aname, tokval))
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PASSWD:
|
||||
if (strcmp(*aname, "anonymous") &&
|
||||
@@ -166,7 +164,7 @@ next:
|
||||
(void) fclose(cfile);
|
||||
return(0);
|
||||
}
|
||||
while ((c=getc(cfile)) != EOF && (c == ' ' || c == '\t'));
|
||||
while ((c=getc(cfile)) != EOF && c == ' ' || c == '\t');
|
||||
if (c == EOF || c == '\n') {
|
||||
printf("Missing macdef name argument.\n");
|
||||
goto bad;
|
||||
@@ -239,7 +237,7 @@ static int token(void)
|
||||
char *cp;
|
||||
int c;
|
||||
struct toktab *t;
|
||||
|
||||
|
||||
if (feof(cfile))
|
||||
return (0);
|
||||
while ((c = getc(cfile)) != EOF &&
|
@@ -52,7 +52,7 @@ static void ShowNetworkFixedInfo()
|
||||
if (result == ERROR_BUFFER_OVERFLOW) {
|
||||
pFixedInfo = (FIXED_INFO*)malloc(OutBufLen);
|
||||
if (!pFixedInfo) {
|
||||
_tprintf(_T("ERROR: failed to allocate 0x%08lX bytes of memory\n"), OutBufLen);
|
||||
_tprintf(_T("ERROR: failed to allocate 0x%08X bytes of memory\n"), OutBufLen);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -100,7 +100,7 @@ static void ShowNetworkFixedInfo()
|
||||
_tprintf(_T("This function is not supported on the operating system in use on the local system\n"));
|
||||
break;
|
||||
default:
|
||||
_tprintf(_T("0x%08lX - Use FormatMessage to obtain the message string for the returned error\n"), result);
|
||||
_tprintf(_T("0x%08X - Use FormatMessage to obtain the message string for the returned error\n"), result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -114,10 +114,10 @@ static void ShowNetworkInterfaces()
|
||||
DWORD dwOutBufLen = 0;
|
||||
|
||||
if ((result = GetNumberOfInterfaces(&dwNumIf)) != NO_ERROR) {
|
||||
_tprintf(_T("GetNumberOfInterfaces() failed with code 0x%08lX - Use FormatMessage to obtain the message string for the returned error\n"), result);
|
||||
_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 %lu\n"), dwNumIf);
|
||||
_tprintf(_T("GetNumberOfInterfaces() returned %d\n"), dwNumIf);
|
||||
}
|
||||
|
||||
result = GetInterfaceInfo(pIfTable, &dwOutBufLen);
|
||||
@@ -127,24 +127,24 @@ static void ShowNetworkInterfaces()
|
||||
|
||||
pIfTable = (IP_INTERFACE_INFO*)malloc(dwOutBufLen);
|
||||
if (!pIfTable) {
|
||||
_tprintf(_T("ERROR: failed to allocate 0x%08lX bytes of memory\n"), dwOutBufLen);
|
||||
_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
|
||||
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
|
||||
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 %ld adaptor entries\n"), pIfTable->NumAdapters);
|
||||
_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);
|
||||
@@ -162,13 +162,13 @@ typedef struct _IP_INTERFACE_INFO {
|
||||
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: %lu\n"), dwOutBufLen);
|
||||
_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%08lX - Use FormatMessage to obtain the message string for the returned error\n"), result);
|
||||
_tprintf(_T("0x%08X - Use FormatMessage to obtain the message string for the returned error\n"), result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -194,7 +194,7 @@ typedef struct _IP_ADAPTER_INFO {
|
||||
IP_ADDR_STRING PrimaryWinsServer;
|
||||
IP_ADDR_STRING SecondaryWinsServer;
|
||||
a time_t LeaseObtained;
|
||||
b time_t LeaseExpires;
|
||||
b time_t LeaseExpires;
|
||||
} IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;
|
||||
*/
|
||||
/*
|
||||
@@ -227,8 +227,8 @@ static void ShowAdapterInfo()
|
||||
GlobalFree(pAdaptorInfo);
|
||||
pAdaptorInfo = (IP_ADAPTER_INFO*)GlobalAlloc(GPTR, ulOutBufLen);
|
||||
}
|
||||
if ((dwRetVal = GetAdaptersInfo(pAdaptorInfo, &ulOutBufLen))) {
|
||||
_tprintf(_T("Call to GetAdaptersInfo failed. Return Value: 0x%08lx\n"), dwRetVal);
|
||||
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);
|
19
apps/utils/net/ipconfig/makefile
Normal file
19
apps/utils/net/ipconfig/makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = ipconfig
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
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
|
53
apps/utils/net/ipconfig/trace.c
Normal file
53
apps/utils/net/ipconfig/trace.c
Normal file
@@ -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
|
||||
/////////////////////////////////////////////////////////////////////////////
|
22
apps/utils/net/netstat/makefile
Normal file
22
apps/utils/net/netstat/makefile
Normal file
@@ -0,0 +1,22 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = netstat
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
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
|
518
apps/utils/net/netstat/netstat.c
Normal file
518
apps/utils/net/netstat/netstat.c
Normal file
@@ -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
|
53
apps/utils/net/netstat/trace.c
Normal file
53
apps/utils/net/netstat/trace.c
Normal file
@@ -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
|
||||
/////////////////////////////////////////////////////////////////////////////
|
19
apps/utils/net/ping/makefile
Normal file
19
apps/utils/net/ping/makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = ping
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
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
|
@@ -113,7 +113,7 @@ VOID DisplayBuffer(
|
||||
UINT i;
|
||||
PCHAR p;
|
||||
|
||||
printf("Buffer (0x%p) Size (0x%lX).\n", Buffer, Size);
|
||||
printf("Buffer (0x%X) Size (0x%X).\n", Buffer, Size);
|
||||
|
||||
p = (PCHAR)Buffer;
|
||||
for (i = 0; i < Size; i++) {
|
||||
@@ -306,10 +306,10 @@ BOOL Setup(VOID)
|
||||
PHOSTENT phe;
|
||||
|
||||
wVersionRequested = MAKEWORD(2, 2);
|
||||
|
||||
|
||||
Status = WSAStartup(wVersionRequested, &WsaData);
|
||||
if (Status != 0) {
|
||||
printf("Could not initialize winsock dll.\n");
|
||||
printf("Could not initialize winsock dll.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -327,9 +327,9 @@ BOOL Setup(VOID)
|
||||
if (phe == NULL) {
|
||||
printf("Unknown host %s.\n", TargetName);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (phe != NULL) {
|
||||
CopyMemory(&Target.sin_addr, phe->h_addr, phe->h_length);
|
||||
} else {
|
||||
@@ -341,7 +341,7 @@ BOOL Setup(VOID)
|
||||
} else {
|
||||
Target.sin_family = AF_INET;
|
||||
}
|
||||
|
||||
|
||||
TargetIP = inet_ntoa(Target.sin_addr);
|
||||
CurrentSeqNum = 0;
|
||||
SentCount = 0;
|
||||
@@ -386,11 +386,12 @@ VOID QueryTime(PLARGE_INTEGER Time)
|
||||
|
||||
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, "ms");
|
||||
@@ -448,7 +449,7 @@ BOOL DecodeResponse(PCHAR buffer, UINT size, PSOCKADDR_IN from)
|
||||
}
|
||||
|
||||
|
||||
printf("Reply from %s: bytes=%d time%s%s TTL=%d\n", inet_ntoa(from->sin_addr),
|
||||
printf("Reply from %s: bytes=%d time%s%s TTL=%d\n", inet_ntoa(from->sin_addr),
|
||||
size - IphLength - sizeof(ICMP_ECHO_PACKET), Sign, Time, IpHeader->TTL);
|
||||
if (RelativeTime.QuadPart < MinRTT.QuadPart) {
|
||||
MinRTT.QuadPart = RelativeTime.QuadPart;
|
||||
@@ -466,7 +467,7 @@ BOOL Ping(VOID)
|
||||
{
|
||||
INT Status;
|
||||
SOCKADDR From;
|
||||
INT Length;
|
||||
UINT Length;
|
||||
PVOID Buffer;
|
||||
UINT Size;
|
||||
PICMP_ECHO_PACKET Packet;
|
||||
@@ -585,7 +586,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
printf("\nPinging %s [%s] with %d bytes of data:\n\n",
|
||||
TargetName, TargetIP, DataSize);
|
||||
|
||||
|
||||
Count = 0;
|
||||
while ((NeverStop) || (Count < PingCount)) {
|
||||
Ping();
|
233
apps/utils/net/roshttpd/include/list.h
Normal file
233
apps/utils/net/roshttpd/include/list.h
Normal file
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS HTTP Daemon
|
||||
* FILE: include/list.h
|
||||
*/
|
||||
#ifndef __LIST_H
|
||||
#define __LIST_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <iterator.h>
|
||||
|
||||
class CListNode {
|
||||
public:
|
||||
CListNode();
|
||||
CListNode(VOID *element, CListNode *next, CListNode *prev);
|
||||
~CListNode() {};
|
||||
void* operator new(/*size_t s*/ UINT s);
|
||||
VOID operator delete(void* p);
|
||||
|
||||
VOID SetElement(PVOID element);
|
||||
VOID SetNext(CListNode *next);
|
||||
VOID SetPrev(CListNode *prev);
|
||||
PVOID GetElement();
|
||||
CListNode *GetNext();
|
||||
CListNode *GetPrev();
|
||||
private:
|
||||
PVOID Element;
|
||||
CListNode *Next;
|
||||
CListNode *Prev;
|
||||
static HANDLE hHeap;
|
||||
static INT nRef;
|
||||
};
|
||||
|
||||
template <class Item> class CList {
|
||||
public:
|
||||
//CList(CList&);
|
||||
CList();
|
||||
~CList();
|
||||
CList& operator=(CList&);
|
||||
|
||||
CIterator<Item> *CreateIterator() const;
|
||||
LONG Count() const;
|
||||
Item& Get(const LONG index) const;
|
||||
// Can throw bad_alloc
|
||||
VOID Insert(Item& element);
|
||||
VOID Remove(Item& element);
|
||||
VOID RemoveAll();
|
||||
CListNode *GetHeader() const;
|
||||
CListNode *GetTrailer() const;
|
||||
private:
|
||||
CListNode *Search(Item& element) const;
|
||||
LONG NodeCount;
|
||||
CListNode *Header;
|
||||
CListNode *Trailer;
|
||||
};
|
||||
|
||||
template <class Item> class CListIterator : public CIterator<Item> {
|
||||
public:
|
||||
CListIterator(const CList<Item> *list);
|
||||
virtual VOID First();
|
||||
virtual VOID Next();
|
||||
virtual BOOL IsDone() const;
|
||||
virtual Item CurrentItem() const;
|
||||
private:
|
||||
const CList<Item> *List;
|
||||
CListNode *Current;
|
||||
};
|
||||
|
||||
// ****************************** CList ******************************
|
||||
|
||||
// Default constructor
|
||||
template <class Item>
|
||||
CList<Item>::CList()
|
||||
{
|
||||
// Create dummy nodes
|
||||
Trailer = new CListNode;
|
||||
Header = new CListNode;
|
||||
Header->SetNext(Trailer);
|
||||
Trailer->SetPrev(Header);
|
||||
}
|
||||
|
||||
// Default destructor
|
||||
template <class Item>
|
||||
CList<Item>::~CList()
|
||||
{
|
||||
RemoveAll();
|
||||
delete Trailer;
|
||||
delete Header;
|
||||
}
|
||||
|
||||
// Create an iterator for the list
|
||||
template <class Item>
|
||||
CIterator<Item> *CList<Item>::CreateIterator() const
|
||||
{
|
||||
return new CListIterator<Item>((CList<Item> *) this);
|
||||
}
|
||||
|
||||
// Return number of elements in list
|
||||
template <class Item>
|
||||
LONG CList<Item>::Count() const
|
||||
{
|
||||
return NodeCount;
|
||||
}
|
||||
|
||||
// Return element at index
|
||||
template <class Item>
|
||||
Item& CList<Item>::Get(const LONG index) const
|
||||
{
|
||||
CListNode *node;
|
||||
|
||||
if ((index < 0) || (index >= NodeCount))
|
||||
return NULL;
|
||||
|
||||
node = Header;
|
||||
for (int i = 0; i <= index; i++)
|
||||
node = node->GetNext();
|
||||
|
||||
return (Item *) node->GetElement();
|
||||
}
|
||||
|
||||
// Insert an element into the list
|
||||
template <class Item>
|
||||
VOID CList<Item>::Insert(Item& element)
|
||||
{
|
||||
CListNode *node;
|
||||
|
||||
node = new CListNode((PVOID)element, Trailer, Trailer->GetPrev());
|
||||
Trailer->GetPrev()->SetNext(node);
|
||||
Trailer->SetPrev(node);
|
||||
NodeCount++;
|
||||
}
|
||||
|
||||
// Remove an element from the list
|
||||
template <class Item>
|
||||
VOID CList<Item>::Remove(Item& element)
|
||||
{
|
||||
CListNode *node;
|
||||
|
||||
node = Search(element);
|
||||
if (node != NULL) {
|
||||
node->GetPrev()->SetNext(node->GetNext());
|
||||
node->GetNext()->SetPrev(node->GetPrev());
|
||||
NodeCount--;
|
||||
delete node;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all elements in list
|
||||
template <class Item>
|
||||
VOID CList<Item>::RemoveAll()
|
||||
{
|
||||
CListNode *node;
|
||||
CListNode *tmp;
|
||||
|
||||
node = Header->GetNext();
|
||||
while (node != Trailer) {
|
||||
tmp = node->GetNext();
|
||||
delete node;
|
||||
node = tmp;
|
||||
}
|
||||
Header->SetNext(Trailer);
|
||||
Trailer->SetPrev(Header);
|
||||
NodeCount = 0;
|
||||
}
|
||||
|
||||
// Return header node
|
||||
template <class Item>
|
||||
CListNode *CList<Item>::GetHeader() const
|
||||
{
|
||||
return Header;
|
||||
}
|
||||
|
||||
// Return trailer node
|
||||
template <class Item>
|
||||
CListNode *CList<Item>::GetTrailer() const
|
||||
{
|
||||
return Trailer;
|
||||
}
|
||||
|
||||
// Searches for a node that contains the element. Returns NULL if element is not found
|
||||
template <class Item>
|
||||
CListNode *CList<Item>::Search(Item& element) const
|
||||
{
|
||||
CListNode *node;
|
||||
|
||||
node = Header;
|
||||
while (((node = node->GetNext()) != Trailer) && (node->GetElement() != element));
|
||||
if (node != Trailer)
|
||||
return node;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// ************************** CListIterator **************************
|
||||
|
||||
// Default constructor
|
||||
template <class Item>
|
||||
CListIterator<Item>::CListIterator(const CList<Item> *list) : List(list)
|
||||
{
|
||||
First();
|
||||
}
|
||||
|
||||
// Go to first element in list
|
||||
template <class Item>
|
||||
VOID CListIterator<Item>::First()
|
||||
{
|
||||
Current = List->GetHeader()->GetNext();
|
||||
}
|
||||
|
||||
// Go to next element in list
|
||||
template <class Item>
|
||||
VOID CListIterator<Item>::Next()
|
||||
{
|
||||
if (!IsDone())
|
||||
Current = Current->GetNext();
|
||||
}
|
||||
|
||||
// Return FALSE when there are more elements in list and TRUE when there are no more
|
||||
template <class Item>
|
||||
BOOL CListIterator<Item>::IsDone() const
|
||||
{
|
||||
return (Current == List->GetTrailer());
|
||||
}
|
||||
|
||||
// Return current element
|
||||
template <class Item>
|
||||
Item CListIterator<Item>::CurrentItem() const
|
||||
{
|
||||
return IsDone()? NULL : (Item) Current->GetElement();
|
||||
}
|
||||
|
||||
#endif /* __LIST_H */
|
31
apps/utils/net/roshttpd/makefile
Normal file
31
apps/utils/net/roshttpd/makefile
Normal file
@@ -0,0 +1,31 @@
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_PATH = common
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = roshttpd
|
||||
|
||||
TARGET_CPPFLAGS = -I./include -DUNICODE -D_UNICODE -DDBG -D__USE_W32API -Wno-deprecated
|
||||
|
||||
TARGET_GCCLIBS = stdc++
|
||||
|
||||
TARGET_SDKLIBS = kernel32.a ws2_32.a user32.a
|
||||
|
||||
MAIN_OBJECTS = roshttpd.o config.o error.o http.o httpd.o
|
||||
|
||||
COMMON_OBJECTS = common/list.o common/socket.o common/thread.o
|
||||
|
||||
TARGET_OBJECTS = $(MAIN_OBJECTS) $(COMMON_OBJECTS)
|
||||
|
||||
TARGET_CLEAN = common/*.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
19
apps/utils/net/route/makefile
Normal file
19
apps/utils/net/route/makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = route
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
TARGET_SDKLIBS = ws2_32.a iphlpapi.a ntdll.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_GCCLIBS =
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
157
apps/utils/net/route/route.c
Normal file
157
apps/utils/net/route/route.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/* Poor man's route
|
||||
*
|
||||
* Supported commands:
|
||||
*
|
||||
* "print"
|
||||
* "add" target ["mask" mask] gw ["metric" metric]
|
||||
* "delete" target gw
|
||||
*
|
||||
* Goals:
|
||||
*
|
||||
* Flexible, simple
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
#define IPBUF 17
|
||||
#define IN_ADDR_OF(x) *((struct in_addr *)&(x))
|
||||
|
||||
int usage() {
|
||||
fprintf( stderr,
|
||||
"route usage:\n"
|
||||
"route print\n"
|
||||
" prints the route table\n"
|
||||
"route add <target> [mask <mask>] <gw> [metric <m>]\n"
|
||||
" adds a route\n"
|
||||
"route delete <target> <gw>\n"
|
||||
" deletes a route\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
int print_routes() {
|
||||
PMIB_IPFORWARDTABLE IpForwardTable;
|
||||
DWORD Error;
|
||||
ULONG Size = 0;
|
||||
char Destination[IPBUF], Gateway[IPBUF], Netmask[IPBUF],
|
||||
Index[IPBUF], Metric[IPBUF];
|
||||
int i;
|
||||
|
||||
if( (Error = GetIpForwardTable( NULL, &Size, TRUE )) ==
|
||||
ERROR_INSUFFICIENT_BUFFER ) {
|
||||
IpForwardTable = malloc( Size );
|
||||
Error = GetIpForwardTable( IpForwardTable, &Size, TRUE );
|
||||
}
|
||||
|
||||
if( Error == ERROR_SUCCESS ) {
|
||||
printf( "%-16s%-16s%-16s%-10s%-10s\n",
|
||||
"Destination",
|
||||
"Netmask",
|
||||
"Gateway",
|
||||
"Index",
|
||||
"Metric" );
|
||||
for( i = 0; i < IpForwardTable->dwNumEntries; i++ ) {
|
||||
strcpy( Destination,
|
||||
inet_ntoa( IN_ADDR_OF(IpForwardTable->table[i].
|
||||
dwForwardDest) ) );
|
||||
strcpy( Netmask,
|
||||
inet_ntoa( IN_ADDR_OF(IpForwardTable->table[i].
|
||||
dwForwardMask) ) );
|
||||
strcpy( Gateway,
|
||||
inet_ntoa( IN_ADDR_OF(IpForwardTable->table[i].
|
||||
dwForwardNextHop) ) );
|
||||
|
||||
printf( "%-16s%-16s%-16s%-10d%-10d\n",
|
||||
Destination,
|
||||
Netmask,
|
||||
Gateway,
|
||||
IpForwardTable->table[i].dwForwardIfIndex,
|
||||
IpForwardTable->table[i].dwForwardMetric1 );
|
||||
}
|
||||
|
||||
free( IpForwardTable );
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
} else {
|
||||
fprintf( stderr, "Route enumerate failed\n" );
|
||||
return Error;
|
||||
}
|
||||
}
|
||||
|
||||
int convert_add_cmd_line( PMIB_IPFORWARDROW RowToAdd,
|
||||
int argc, char **argv ) {
|
||||
int i;
|
||||
|
||||
if( argc > 1 ) RowToAdd->dwForwardDest = inet_addr( argv[0] );
|
||||
else return FALSE;
|
||||
for( i = 1; i < argc; i++ ) {
|
||||
if( !strcasecmp( argv[i], "mask" ) ) {
|
||||
i++; if( i >= argc ) return FALSE;
|
||||
RowToAdd->dwForwardMask = inet_addr( argv[i] );
|
||||
} else if( !strcasecmp( argv[i], "metric" ) ) {
|
||||
i++; if( i >= argc ) return FALSE;
|
||||
RowToAdd->dwForwardMetric1 = atoi( argv[i] );
|
||||
} else {
|
||||
RowToAdd->dwForwardNextHop = inet_addr( argv[i] );
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int add_route( int argc, char **argv ) {
|
||||
MIB_IPFORWARDROW RowToAdd = { 0 };
|
||||
DWORD Error;
|
||||
|
||||
if( argc < 2 || !convert_add_cmd_line( &RowToAdd, argc, argv ) ) {
|
||||
fprintf( stderr,
|
||||
"route add usage:\n"
|
||||
"route add <target> [mask <mask>] <gw> [metric <m>]\n"
|
||||
" Adds a route to the IP route table.\n"
|
||||
" <target> is the network or host to add a route to.\n"
|
||||
" <mask> is the netmask to use (autodetected if unspecified)\n"
|
||||
" <gw> is the gateway to use to access the network\n"
|
||||
" <m> is the metric to use (lower is preferred)\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( (Error = CreateIpForwardEntry( &RowToAdd )) == ERROR_SUCCESS )
|
||||
return 0;
|
||||
|
||||
fprintf( stderr, "Route addition failed\n" );
|
||||
return Error;
|
||||
}
|
||||
|
||||
int del_route( int argc, char **argv ) {
|
||||
MIB_IPFORWARDROW RowToDel = { 0 };
|
||||
DWORD Error;
|
||||
|
||||
if( argc < 2 || !convert_add_cmd_line( &RowToDel, argc, argv ) ) {
|
||||
fprintf( stderr,
|
||||
"route delete usage:\n"
|
||||
"route delete <target> <gw>\n"
|
||||
" Removes a route from the IP route table.\n"
|
||||
" <target> is the network or host to add a route to.\n"
|
||||
" <gw> is the gateway to remove the route from.\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( (Error = DeleteIpForwardEntry( &RowToDel )) == ERROR_SUCCESS )
|
||||
return 0;
|
||||
|
||||
fprintf( stderr, "Route addition failed\n" );
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
if( argc < 2 ) return usage();
|
||||
else if( !strcasecmp( argv[1], "print" ) )
|
||||
return print_routes();
|
||||
else if( !strcasecmp( argv[1], "add" ) )
|
||||
return add_route( argc-2, argv+2 );
|
||||
else if( !strcasecmp( argv[1], "delete" ) )
|
||||
return del_route( argc-2, argv+2 );
|
||||
else return usage();
|
||||
}
|
41
apps/utils/net/telnet/Makefile
Normal file
41
apps/utils/net/telnet/Makefile
Normal file
@@ -0,0 +1,41 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = telnet
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
TARGET_SDKLIBS = ws2_32.a
|
||||
|
||||
TARGET_CPPFLAGS = -D__REACTOS__ -D__USE_W32API -Wall
|
||||
|
||||
TARGET_GCCLIBS = stdc++
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
src/ansiprsr.o \
|
||||
src/keytrans.o \
|
||||
src/tcharmap.o \
|
||||
src/tconsole.o \
|
||||
src/tkeydef.o \
|
||||
src/tkeymap.o \
|
||||
src/tmapldr.o \
|
||||
src/tmouse.o \
|
||||
src/tnclass.o \
|
||||
src/tnclip.o \
|
||||
src/tncon.o \
|
||||
src/tnconfig.o \
|
||||
src/tnerror.o \
|
||||
src/tnetwork.o \
|
||||
src/tnmain.o \
|
||||
src/tnmisc.o \
|
||||
src/tscript.o \
|
||||
src/tscroll.o \
|
||||
src/ttelhndl.o
|
||||
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user