From 3a25369a42f3a6712f149a10bac06d7029cd63eb Mon Sep 17 00:00:00 2001 From: Ultibo Date: Thu, 2 Jun 2016 15:55:45 +1000 Subject: [PATCH] Latest commits (Ultibo core 1.2.009) See the forum announcements for more information --- source/rtl/ultibo/Makefile | 467 +++-- source/rtl/ultibo/Makefile.fpc | 131 +- source/rtl/ultibo/core/arp.pas | 39 +- source/rtl/ultibo/core/devices.pas | 284 ++- source/rtl/ultibo/core/dhcp.pas | 162 +- source/rtl/ultibo/core/dns.pas | 17 +- source/rtl/ultibo/core/dwcotg.pas | 4 + source/rtl/ultibo/core/globalconfig.pas | 11 +- source/rtl/ultibo/core/globalconst.pas | 8 +- source/rtl/ultibo/core/globaldefines.inc | 2 +- source/rtl/ultibo/core/globalsock.pas | 3 +- source/rtl/ultibo/core/icmp.pas | 4 +- source/rtl/ultibo/core/icmpv6.pas | 6 +- source/rtl/ultibo/core/igmp.pas | 2 +- source/rtl/ultibo/core/ip.pas | 421 +++- source/rtl/ultibo/core/ipv6.pas | 276 ++- source/rtl/ultibo/core/loopback.pas | 60 +- source/rtl/ultibo/core/network.pas | 2356 +++++++++++++++++++-- source/rtl/ultibo/core/platform.pas | 242 ++- source/rtl/ultibo/core/protocol.pas | 55 +- source/rtl/ultibo/core/raw.pas | 2 +- source/rtl/ultibo/core/smsc95xx.pas | 125 +- source/rtl/ultibo/core/sockets.pas | 872 +++++++- source/rtl/ultibo/core/tcp.pas | 14 +- source/rtl/ultibo/core/transport.pas | 2375 ++++++++++++++++++---- source/rtl/ultibo/core/udp.pas | 7 +- source/rtl/ultibo/core/ultibo.pas | 185 ++ source/rtl/ultibo/core/usb.pas | 114 +- source/rtl/ultibo/core/wifi.pas | 1729 ++++++++++++++-- source/rtl/ultibo/core/winsock.pas | 4 +- source/rtl/ultibo/core/winsock2.pas | 12 +- source/rtl/ultibo/drivers/rt2800lib.pas | 203 +- source/rtl/ultibo/drivers/rt2800usb.pas | 1012 ++++++--- source/rtl/ultibo/drivers/rt2x00lib.pas | 333 ++- source/rtl/ultibo/rpi3.cfg.template | 8 + 35 files changed, 9845 insertions(+), 1700 deletions(-) create mode 100644 source/rtl/ultibo/rpi3.cfg.template diff --git a/source/rtl/ultibo/Makefile b/source/rtl/ultibo/Makefile index 827d336..60cbcbb 100644 --- a/source/rtl/ultibo/Makefile +++ b/source/rtl/ultibo/Makefile @@ -573,259 +573,514 @@ endif OBJPASDIR=$(RTL)/objpas GRAPHDIR=$(INC)/graph ifeq ($(FULL_TARGET),i386-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-go32v2) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-win32) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-os2) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-freebsd) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-beos) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-haiku) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-netbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-solaris) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-qnx) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-netware) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-openbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-wdosx) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-darwin) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-emx) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-watcom) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-netwlibc) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-wince) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-symbian) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-nativent) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-iphonesim) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-android) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-aros) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i386-ultibo) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),m68k-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),m68k-freebsd) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),m68k-netbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),m68k-amiga) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),m68k-atari) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),m68k-openbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),m68k-palmos) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),m68k-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),powerpc-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),powerpc-netbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),powerpc-amiga) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),powerpc-macos) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),powerpc-darwin) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),powerpc-morphos) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),powerpc-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),powerpc-wii) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),powerpc-aix) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),sparc-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),sparc-netbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),sparc-solaris) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),sparc-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),x86_64-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),x86_64-freebsd) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),x86_64-netbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),x86_64-solaris) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),x86_64-openbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),x86_64-darwin) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),x86_64-win64) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),x86_64-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),x86_64-iphonesim) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),x86_64-aros) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),x86_64-dragonfly) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),x86_64-ultibo) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),arm-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),arm-palmos) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),arm-darwin) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),arm-wince) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),arm-gba) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),arm-nds) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),arm-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),arm-symbian) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),arm-android) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),arm-ultibo) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),powerpc64-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),powerpc64-darwin) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),powerpc64-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),powerpc64-aix) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),avr-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),armeb-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),armeb-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),mips-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),mipsel-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),mipsel-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),mipsel-android) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),jvm-java) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),jvm-android) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i8086-msdos) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),i8086-win16) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),aarch64-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) endif ifeq ($(FULL_TARGET),aarch64-darwin) -override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cp1251 cp866 cp8859_5 cp1253 cp8859_1 cp850 cp437 cp1252 cp646 cp874 cp856 cp1250 cp1254 cp1255 cp1256 cp1257 cp1258 cp852 cp8859_2 cpall sysconst $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +override TARGET_UNITS+=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas strings sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo $(ULTIBO_UNITS) $(ULTIBO_CPU_UNITS) $(ULTIBO_DRIVER_UNITS) $(ULTIBO_CODEPAGE_UNITS) dos ctypes charset cpall sysconst character fpwidestring $(ULTIBO_EXTRAS) $(ULTIBO_CPU_EXTRAS) +endif +ifeq ($(FULL_TARGET),i386-linux) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-go32v2) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-win32) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-os2) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-freebsd) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-beos) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-haiku) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-netbsd) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-solaris) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-qnx) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-netware) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-openbsd) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-wdosx) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-darwin) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-emx) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-watcom) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-netwlibc) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-wince) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-embedded) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-symbian) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-nativent) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-iphonesim) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-android) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-aros) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i386-ultibo) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),m68k-linux) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),m68k-freebsd) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),m68k-netbsd) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),m68k-amiga) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),m68k-atari) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),m68k-openbsd) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),m68k-palmos) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),m68k-embedded) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),powerpc-linux) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),powerpc-netbsd) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),powerpc-amiga) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),powerpc-macos) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),powerpc-darwin) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),powerpc-morphos) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),powerpc-embedded) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),powerpc-wii) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),powerpc-aix) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),sparc-linux) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),sparc-netbsd) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),sparc-solaris) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),sparc-embedded) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),x86_64-linux) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),x86_64-freebsd) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),x86_64-netbsd) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),x86_64-solaris) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),x86_64-openbsd) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),x86_64-darwin) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),x86_64-win64) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),x86_64-embedded) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),x86_64-iphonesim) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),x86_64-aros) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),x86_64-dragonfly) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),x86_64-ultibo) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),arm-linux) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),arm-palmos) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),arm-darwin) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),arm-wince) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),arm-gba) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),arm-nds) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),arm-embedded) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),arm-symbian) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),arm-android) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),arm-ultibo) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),powerpc64-linux) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),powerpc64-darwin) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),powerpc64-embedded) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),powerpc64-aix) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),avr-embedded) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),armeb-linux) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),armeb-embedded) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),mips-linux) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),mipsel-linux) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),mipsel-embedded) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),mipsel-android) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),jvm-java) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),jvm-android) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i8086-msdos) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),i8086-win16) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),aarch64-linux) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata +endif +ifeq ($(FULL_TARGET),aarch64-darwin) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 unicodenumtable unicodedata endif override INSTALL_FPCPACKAGE=y ifeq ($(FULL_TARGET),i386-linux) @@ -2577,6 +2832,8 @@ fgl$(PPUEXT): $(OBJPASDIR)/fgl.pp objpas$(PPUEXT) types$(PPUEXT) system$(PPUEXT) $(COMPILER) -Sg $(OBJPASDIR)/fgl.pp $(REDIR) dateutil$(PPUEXT) : $(OBJPASDIR)/dateutil.pp $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/dateutil.pp +character$(PPUEXT): sysutils$(PPUEXT) $(OBJPASDIR)/character.pas objpas$(PPUEXT) rtlconsts$(PPUEXT) + $(COMPILER) $(OBJPASDIR)/character.pas macpas$(PPUEXT) : $(INC)/macpas.pp objpas$(PPUEXT) math$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) $(INC)/macpas.pp $(REDIR) ucomplex$(PPUEXT): $(INC)/ucomplex.pp math$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) @@ -2589,50 +2846,14 @@ lineinfo$(PPUEXT) : $(INC)/lineinfo.pp strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) $(INC)/lineinfo.pp charset$(PPUEXT) : $(INC)/charset.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) $< -cp1251$(PPUEXT): $(RTL)/charmaps/cp1251.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1251.pas -cp866$(PPUEXT): $(RTL)/charmaps/cp866.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp866.pas -cp8859_5$(PPUEXT): $(RTL)/charmaps/cp8859_5.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp8859_5.pas -cp1253$(PPUEXT): $(RTL)/charmaps/cp1253.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1253.pas -cp8859_1$(PPUEXT): $(RTL)/charmaps/cp8859_1.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp8859_1.pas -cp850$(PPUEXT): $(RTL)/charmaps/cp850.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp850.pas -cp437$(PPUEXT): $(RTL)/charmaps/cp437.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp437.pas -cp1252$(PPUEXT): $(RTL)/charmaps/cp1252.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1252.pas -cp646$(PPUEXT): $(RTL)/charmaps/cp646.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp646.pas -cp874$(PPUEXT): $(RTL)/charmaps/cp874.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp874.pas -cp856$(PPUEXT): $(RTL)/charmaps/cp856.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp856.pas -cp1250$(PPUEXT): $(RTL)/charmaps/cp1250.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1250.pas -cp1254$(PPUEXT): $(RTL)/charmaps/cp1254.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1254.pas -cp1255$(PPUEXT): $(RTL)/charmaps/cp1255.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1255.pas -cp1256$(PPUEXT): $(RTL)/charmaps/cp1256.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1256.pas -cp1257$(PPUEXT): $(RTL)/charmaps/cp1257.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1257.pas -cp1258$(PPUEXT): $(RTL)/charmaps/cp1258.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1258.pas -cp852$(PPUEXT): $(RTL)/charmaps/cp852.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp852.pas -cp8859_2$(PPUEXT): $(RTL)/charmaps/cp8859_2.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp8859_2.pas cpall$(PPUEXT): $(RTL)/charmaps/cpall.pas system$(PPUEXT) charset$(PPUEXT) $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cpall.pas iso7185$(PPUEXT) : $(INC)/iso7185.pp $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) $(INC)/iso7185.pp extpas$(PPUEXT) : $(INC)/extpas.pp dos$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) $(INC)/extpas.pp +fpwidestring$(PPUEXT): $(OBJPASDIR)/fpwidestring.pp character$(PPUEXT) + $(COMPILER) $(OBJPASDIR)/fpwidestring.pp define CPU_UNITS_RULE $(1)$(PPUEXT): $(ARCH)/$(1).pp $(SYSTEMUNIT)$(PPUEXT) endef diff --git a/source/rtl/ultibo/Makefile.fpc b/source/rtl/ultibo/Makefile.fpc index 3fb053a..26c0df1 100644 --- a/source/rtl/ultibo/Makefile.fpc +++ b/source/rtl/ultibo/Makefile.fpc @@ -30,30 +30,36 @@ units=$(SYSTEMUNIT) \ dos \ ctypes \ charset \ - cp1251 \ - cp866 \ - cp8859_5 \ - cp1253 \ - cp8859_1 \ - cp850 \ - cp437 \ - cp1252 \ - cp646 \ - cp874 \ - cp856 \ - cp1250 \ - cp1254 \ - cp1255 \ - cp1256 \ - cp1257 \ - cp1258 \ - cp852 \ - cp8859_2 \ cpall \ sysconst \ + character \ + fpwidestring \ $(ULTIBO_EXTRAS) \ $(ULTIBO_CPU_EXTRAS) +implicitunits=exeinfo \ + cp1250 \ + cp1251 \ + cp1252 \ + cp1253 \ + cp1254 \ + cp1255 \ + cp1256 \ + cp1257 \ + cp1258 \ + cp437 \ + cp646 \ + cp850 \ + cp856 \ + cp866 \ + cp874 \ + cp8859_1 \ + cp8859_5 \ + cp8859_2 \ + cp852 \ + unicodenumtable \ + unicodedata + [require] nortl=y @@ -421,7 +427,11 @@ fgl$(PPUEXT): $(OBJPASDIR)/fgl.pp objpas$(PPUEXT) types$(PPUEXT) system$(PPUEXT) dateutil$(PPUEXT) : $(OBJPASDIR)/dateutil.pp $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/dateutil.pp - + +# let it depend on buildcollations to prevent simultaneous building of unicodedata +character$(PPUEXT): sysutils$(PPUEXT) $(OBJPASDIR)/character.pas objpas$(PPUEXT) rtlconsts$(PPUEXT) + $(COMPILER) $(OBJPASDIR)/character.pas + # # Mac Pascal Model # @@ -448,62 +458,62 @@ lineinfo$(PPUEXT) : $(INC)/lineinfo.pp strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) charset$(PPUEXT) : $(INC)/charset.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) $< -cp1251$(PPUEXT): $(RTL)/charmaps/cp1251.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1251.pas +#cp1251$(PPUEXT): $(RTL)/charmaps/cp1251.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1251.pas -cp866$(PPUEXT): $(RTL)/charmaps/cp866.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp866.pas +#cp866$(PPUEXT): $(RTL)/charmaps/cp866.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp866.pas -cp8859_5$(PPUEXT): $(RTL)/charmaps/cp8859_5.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp8859_5.pas +#cp8859_5$(PPUEXT): $(RTL)/charmaps/cp8859_5.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp8859_5.pas -cp1253$(PPUEXT): $(RTL)/charmaps/cp1253.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1253.pas +#cp1253$(PPUEXT): $(RTL)/charmaps/cp1253.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1253.pas -cp8859_1$(PPUEXT): $(RTL)/charmaps/cp8859_1.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp8859_1.pas +#cp8859_1$(PPUEXT): $(RTL)/charmaps/cp8859_1.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp8859_1.pas -cp850$(PPUEXT): $(RTL)/charmaps/cp850.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp850.pas +#cp850$(PPUEXT): $(RTL)/charmaps/cp850.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp850.pas -cp437$(PPUEXT): $(RTL)/charmaps/cp437.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp437.pas +#cp437$(PPUEXT): $(RTL)/charmaps/cp437.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp437.pas -cp1252$(PPUEXT): $(RTL)/charmaps/cp1252.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1252.pas +#cp1252$(PPUEXT): $(RTL)/charmaps/cp1252.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1252.pas -cp646$(PPUEXT): $(RTL)/charmaps/cp646.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp646.pas +#cp646$(PPUEXT): $(RTL)/charmaps/cp646.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp646.pas -cp874$(PPUEXT): $(RTL)/charmaps/cp874.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp874.pas +#cp874$(PPUEXT): $(RTL)/charmaps/cp874.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp874.pas -cp856$(PPUEXT): $(RTL)/charmaps/cp856.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp856.pas +#cp856$(PPUEXT): $(RTL)/charmaps/cp856.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp856.pas -cp1250$(PPUEXT): $(RTL)/charmaps/cp1250.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1250.pas +#cp1250$(PPUEXT): $(RTL)/charmaps/cp1250.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1250.pas -cp1254$(PPUEXT): $(RTL)/charmaps/cp1254.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1254.pas +#cp1254$(PPUEXT): $(RTL)/charmaps/cp1254.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1254.pas -cp1255$(PPUEXT): $(RTL)/charmaps/cp1255.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1255.pas +#cp1255$(PPUEXT): $(RTL)/charmaps/cp1255.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1255.pas -cp1256$(PPUEXT): $(RTL)/charmaps/cp1256.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1256.pas +#cp1256$(PPUEXT): $(RTL)/charmaps/cp1256.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1256.pas -cp1257$(PPUEXT): $(RTL)/charmaps/cp1257.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1257.pas +#cp1257$(PPUEXT): $(RTL)/charmaps/cp1257.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1257.pas -cp1258$(PPUEXT): $(RTL)/charmaps/cp1258.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1258.pas +#cp1258$(PPUEXT): $(RTL)/charmaps/cp1258.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp1258.pas -cp852$(PPUEXT): $(RTL)/charmaps/cp852.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp852.pas +#cp852$(PPUEXT): $(RTL)/charmaps/cp852.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp852.pas -cp8859_2$(PPUEXT): $(RTL)/charmaps/cp8859_2.pas system$(PPUEXT) charset$(PPUEXT) - $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp8859_2.pas +#cp8859_2$(PPUEXT): $(RTL)/charmaps/cp8859_2.pas system$(PPUEXT) charset$(PPUEXT) +# $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cp8859_2.pas cpall$(PPUEXT): $(RTL)/charmaps/cpall.pas system$(PPUEXT) charset$(PPUEXT) $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cpall.pas @@ -513,7 +523,10 @@ iso7185$(PPUEXT) : $(INC)/iso7185.pp $(SYSTEMUNIT)$(PPUEXT) extpas$(PPUEXT) : $(INC)/extpas.pp dos$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) $(INC)/extpas.pp - + +fpwidestring$(PPUEXT): $(OBJPASDIR)/fpwidestring.pp character$(PPUEXT) + $(COMPILER) $(OBJPASDIR)/fpwidestring.pp + # # Unit specific rules # diff --git a/source/rtl/ultibo/core/arp.pas b/source/rtl/ultibo/core/arp.pas index 38f3f5b..d15dcae 100644 --- a/source/rtl/ultibo/core/arp.pas +++ b/source/rtl/ultibo/core/arp.pas @@ -1088,10 +1088,10 @@ function TARPTransport.AddAdapter(AAdapter:TNetworkAdapter;AConfigType:Word;AAdd {Check Adapter} if AAdapter = nil then Exit; - - {Check Status} - if AAdapter.Status <> ADAPTER_STATUS_READY then Exit; - + + {Check State} + if AAdapter.State <> ADAPTER_STATE_ENABLED then Exit; + {Get Adapter} Adapter:=TARPTransportAdapter(GetAdapterByAdapter(AAdapter,True,NETWORK_LOCK_WRITE)); {Writer due to use count} if Adapter = nil then @@ -1324,13 +1324,14 @@ function TARPTransport.BindTransport(AAdapter:TNetworkAdapter):Boolean; {$IFDEF ARP_DEBUG} if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ARP: Adapter = ' + AAdapter.Name); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ARP: State = ' + AdapterStateToString(AAdapter.State)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ARP: Status = ' + AdapterStatusToString(AAdapter.Status)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ARP: Type = ' + AdapterTypeToString(AAdapter.AdapterType)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ARP: Media = ' + MediaTypeToString(AAdapter.MediaType)); {$ENDIF} - - {Check Status} - if AAdapter.Status <> ADAPTER_STATUS_READY then Exit; + + {Check State} + if AAdapter.State <> ADAPTER_STATE_ENABLED then Exit; Result:=True; finally @@ -2512,9 +2513,9 @@ function TRARPTransport.AddAdapter(AAdapter:TNetworkAdapter;AConfigType:Word;AAd {Check Adapter} if AAdapter = nil then Exit; - - {Check Status} - if AAdapter.Status <> ADAPTER_STATUS_READY then Exit; + + {Check State} + if AAdapter.State <> ADAPTER_STATE_ENABLED then Exit; {Get Adapter} Adapter:=TRARPTransportAdapter(GetAdapterByAdapter(AAdapter,True,NETWORK_LOCK_WRITE)); {Writer due to use count} @@ -2742,14 +2743,15 @@ function TRARPTransport.BindTransport(AAdapter:TNetworkAdapter):Boolean; {$IFDEF ARP_DEBUG} if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'RARP: Adapter = ' + AAdapter.Name); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'RARP: State = ' + AdapterStateToString(AAdapter.State)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'RARP: Status = ' + AdapterStatusToString(AAdapter.Status)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'RARP: Type = ' + AdapterTypeToString(AAdapter.AdapterType)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'RARP: Media = ' + MediaTypeToString(AAdapter.MediaType)); {$ENDIF} - - {Check Status} - if AAdapter.Status <> ADAPTER_STATUS_READY then Exit; + {Check State} + if AAdapter.State <> ADAPTER_STATE_ENABLED then Exit; + Result:=True; finally ReaderUnlock; @@ -3040,20 +3042,21 @@ procedure ARPInit; if ARPInitialized then Exit; {Setup ARP Transport} - if IP_TRANSPORT_ENABLED then ARP_TRANSPORT_ENABLED:=True; - if ARP_CONFIG_ENABLED then ARP_TRANSPORT_ENABLED:=True; + if NetworkSettings.GetBoolean('IP_TRANSPORT_ENABLED') then NetworkSettings.AddBoolean('ARP_TRANSPORT_ENABLED',True); + if NetworkSettings.GetBoolean('ARP_CONFIG_ENABLED') then NetworkSettings.AddBoolean('ARP_TRANSPORT_ENABLED',True); {Setup RARP Transport} - if RARP_CONFIG_ENABLED then RARP_TRANSPORT_ENABLED:=True; + if NetworkSettings.GetBoolean('IP_TRANSPORT_ENABLED') then NetworkSettings.AddBoolean('RARP_TRANSPORT_ENABLED',True); + if NetworkSettings.GetBoolean('RARP_CONFIG_ENABLED') then NetworkSettings.AddBoolean('RARP_TRANSPORT_ENABLED',True); {Create ARP Transport} - if ARP_TRANSPORT_ENABLED then + if NetworkSettings.GetBooleanDefault('ARP_TRANSPORT_ENABLED',ARP_TRANSPORT_ENABLED) then begin TARPTransport.Create(TransportManager,ARP_TRANSPORT_NAME); end; {Create RARP Transport} - if RARP_TRANSPORT_ENABLED then + if NetworkSettings.GetBooleanDefault('RARP_TRANSPORT_ENABLED',RARP_TRANSPORT_ENABLED) then begin TRARPTransport.Create(TransportManager,RARP_TRANSPORT_NAME); end; diff --git a/source/rtl/ultibo/core/devices.pas b/source/rtl/ultibo/core/devices.pas index 30eac47..b1ddaf5 100644 --- a/source/rtl/ultibo/core/devices.pas +++ b/source/rtl/ultibo/core/devices.pas @@ -452,8 +452,15 @@ interface {Timer Device Flags} TIMER_FLAG_NONE = $00000000; - TIMER_FLAG_WRAPPING = $00000001; - TIMER_FLAG_COUNTER = $00000002; + TIMER_FLAG_WRAPPING = $00000001; {Device provides a wrapping or self reloading counter} + TIMER_FLAG_COUNTER = $00000002; {Device will appear as a continuously incrementing counter when read} + TIMER_FLAG_DOWN = $00000004; {Device counts down from the starting value to zero (And optionally triggers an event)} + + {Timer Event Flags} + TIMER_EVENT_FLAG_NONE = $00000000; + TIMER_EVENT_FLAG_REPEAT = $00000001; {Event will be repeated until cancelled} + TIMER_EVENT_FLAG_INTERRUPT = $00000002; {Event will be dispatched by interrupt handler (If applicable)} + {Caution: Events called by the interrupt handler must obey interrupt rules with regard to locks, memory allocation and latency} {==============================================================================} const @@ -635,7 +642,7 @@ TClockDevice = record {Driver Properties} Lock:TMutexHandle; {Device lock} Address:Pointer; {Device register base address} - Rate:LongWord; {Device rate (MHz)} + Rate:LongWord; {Device rate (Hz)} {Internal Properties} Prev:PClockDevice; {Previous entry in Clock device table} Next:PClockDevice; {Next entry in Clock device table} @@ -644,6 +651,20 @@ TClockDevice = record {==============================================================================} type {Timer specific types} + TTimerCallback = TCounterCallback; {Counter callbck from Platform} + + {Timer Properties} + PTimerProperties = ^TTimerProperties; + TTimerProperties = record + Flags:LongWord; {Device flags (eg TIMER_FLAG_WRAPPING)} + Bits:LongWord; {Number of valid bits in timer read (eg 32 or 64)} + MinRate:LongWord; {Device minimum clock rate (Hz)} + MaxRate:LongWord; {Device maximum clock rate (Hz)} + MinInterval:LongWord; {Device minimum interval (Milliseconds)} + MaxInterval:LongWord; {Device maximum interval (Milliseconds)} + end; + + {Timer Device} PTimerDevice = ^TTimerDevice; {Timer Enumeration Callback} @@ -655,15 +676,15 @@ TClockDevice = record TTimerDeviceStart = function(Timer:PTimerDevice):LongWord; TTimerDeviceStop = function(Timer:PTimerDevice):LongWord; TTimerDeviceRead = function(Timer:PTimerDevice):LongWord; + TTimerDeviceRead64 = function(Timer:PTimerDevice):Int64; TTimerDeviceWait = function(Timer:PTimerDevice):LongWord; - TTimerDeviceEvent = function(Timer:PTimerDevice;Event:TTimerEvent;Data:Pointer):LongWord; + TTimerDeviceEvent = function(Timer:PTimerDevice;Flags:LongWord;Callback:TTimerCallback;Data:Pointer):LongWord; TTimerDeviceGetRate = function(Timer:PTimerDevice):LongWord; TTimerDeviceSetRate = function(Timer:PTimerDevice;Rate:LongWord):LongWord; - TTimerDeviceGetMaximum = function(Timer:PTimerDevice):LongWord; TTimerDeviceGetInterval = function(Timer:PTimerDevice):LongWord; TTimerDeviceSetInterval = function(Timer:PTimerDevice;Interval:LongWord):LongWord; + TTimerDeviceProperties = function(Timer:PTimerDevice;Properties:PTimerProperties):LongWord; - {Timer Device} TTimerDevice = record {Device Properties} Device:TDevice; {The Device entry for this Timer device} @@ -672,14 +693,15 @@ TTimerDevice = record TimerState:LongWord; {Timer device state (eg TIMER_STATE_ENABLED)} DeviceStart:TTimerDeviceStart; {A device specific DeviceStart method implementing a standard random device interface (Manadatory)} DeviceStop:TTimerDeviceStop; {A device specific DeviceStop method implementing a standard random device interface (Manadatory)} - DeviceRead:TTimerDeviceRead; {A device specific DeviceRead method implementing a standard random device interface (Manadatory)} + DeviceRead:TTimerDeviceRead; {A device specific DeviceRead method implementing a standard random device interface (Or nil if the default method is suitable)} + DeviceRead64:TTimerDeviceRead64; {A device specific DeviceRead64 method implementing a standard random device interface (Manadatory)} DeviceWait:TTimerDeviceWait; {A device specific DeviceWait method implementing a standard random device interface (Manadatory)} DeviceEvent:TTimerDeviceEvent; {A device specific DeviceEvent method implementing a standard random device interface (Manadatory)} DeviceGetRate:TTimerDeviceGetRate; {A device specific DeviceGetRate method implementing a standard random device interface (Or nil if the default method is suitable)} DeviceSetRate:TTimerDeviceSetRate; {A device specific DeviceSetRate method implementing a standard random device interface (Or nil if the default method is suitable)} - DeviceGetMaximum:TTimerDeviceGetMaximum; {A device specific DeviceGetMaximum method implementing a standard random device interface (Or nil if the default method is suitable)} DeviceGetInterval:TTimerDeviceGetInterval; {A device specific DeviceGetInterval method implementing a standard random device interface (Or nil if the default method is suitable)} DeviceSetInterval:TTimerDeviceSetInterval; {A device specific DeviceSetInterval method implementing a standard random device interface (Or nil if the default method is suitable)} + DeviceProperties:TTimerDeviceProperties; {A device specific DeviceProperties method implementing a standard random device interface (Or nil if the default method is suitable)} {Statistics Properties} ReadCount:LongWord; WaitCount:LongWord; @@ -687,9 +709,9 @@ TTimerDevice = record {Driver Properties} Lock:TMutexHandle; {Device lock} Address:Pointer; {Device register base address} - Rate:LongWord; {Device rate (MHz)} - Maximum:LongWord; {Device maximum interval (Milliseconds)} + Rate:LongWord; {Device rate (Hz)} Interval:LongWord; {Device interval (Milliseconds)} + Properties:TTimerProperties; {Device properties} {Internal Properties} Prev:PTimerDevice; {Previous entry in Timer device table} Next:PTimerDevice; {Next entry in Timer device table} @@ -930,13 +952,14 @@ function ClockDeviceNotification(Clock:PClockDevice;Callback:TClockNotification; function TimerDeviceStart(Timer:PTimerDevice):LongWord; function TimerDeviceStop(Timer:PTimerDevice):LongWord; function TimerDeviceRead(Timer:PTimerDevice):LongWord; +function TimerDeviceRead64(Timer:PTimerDevice):Int64; function TimerDeviceWait(Timer:PTimerDevice):LongWord; -function TimerDeviceEvent(Timer:PTimerDevice;Event:TTimerEvent;Data:Pointer):LongWord; +function TimerDeviceEvent(Timer:PTimerDevice;Flags:LongWord;Callback:TTimerCallback;Data:Pointer):LongWord; function TimerDeviceGetRate(Timer:PTimerDevice):LongWord; function TimerDeviceSetRate(Timer:PTimerDevice;Rate:LongWord):LongWord; -function TimerDeviceGetMaximum(Timer:PTimerDevice):LongWord; function TimerDeviceGetInterval(Timer:PTimerDevice):LongWord; function TimerDeviceSetInterval(Timer:PTimerDevice;Interval:LongWord):LongWord; +function TimerDeviceProperties(Timer:PTimerDevice;Properties:PTimerProperties):LongWord; function TimerDeviceCreate:PTimerDevice; function TimerDeviceCreateEx(Size:LongWord):PTimerDevice; @@ -1024,8 +1047,19 @@ function SysClockRead:LongWord; function SysClockRead64:Int64; {==============================================================================} -{RTL Timer Functions} -//To Do +{RTL Timer (Counter) Functions} +function SysTimerAvailable:Boolean; + +function SysTimerRead:LongWord; +function SysTimerRead64:Int64; +function SysTimerWait:LongWord; +function SysTimerEvent(Callback:TTimerCallback;Data:Pointer):LongWord; + +function SysTimerGetRate:LongWord; +function SysTimerSetRate(Rate:LongWord):LongWord; + +function SysTimerGetInterval:LongWord; +function SysTimerSetInterval(Interval:LongWord):LongWord; {==============================================================================} {RTL Random Functions} @@ -1290,7 +1324,15 @@ procedure DevicesInit; {Register Platform Timer Handlers} if DEVICE_REGISTER_TIMER then begin - //To Do + CounterAvailableHandler:=SysTimerAvailable; + CounterReadHandler:=SysTimerRead; + CounterRead64Handler:=SysTimerRead64; + CounterWaitHandler:=SysTimerWait; + CounterEventHandler:=SysTimerEvent; + CounterGetRateHandler:=SysTimerGetRate; + CounterSetRateHandler:=SysTimerSetRate; + CounterGetIntervalHandler:=SysTimerGetInterval; + CounterSetIntervalHandler:=SysTimerSetInterval; end; {Register Platform Random Handlers} @@ -3204,11 +3246,43 @@ function TimerDeviceRead(Timer:PTimerDevice):LongWord; if Assigned(Timer.DeviceRead) then begin Result:=Timer.DeviceRead(Timer); + end + else + begin + Result:=TimerDeviceRead64(Timer); end; end; {==============================================================================} +function TimerDeviceRead64(Timer:PTimerDevice):Int64; +begin + {} + Result:=0; + + {Check Timer} + if Timer = nil then Exit; + if Timer.Device.Signature <> DEVICE_SIGNATURE then Exit; + + {$IFDEF DEVICE_DEBUG} + if DEVICE_LOG_ENABLED then DeviceLogDebug(nil,'Timer Device Read64'); + {$ENDIF} + + {Check Enabled} + if Timer.TimerState <> TIMER_STATE_ENABLED then Exit; + + if Assigned(Timer.DeviceRead64) then + begin + Result:=Timer.DeviceRead64(Timer); + end + else + begin + Result:=TimerDeviceRead(Timer); + end; +end; + +{==============================================================================} + function TimerDeviceWait(Timer:PTimerDevice):LongWord; begin {} @@ -3234,7 +3308,7 @@ function TimerDeviceWait(Timer:PTimerDevice):LongWord; {==============================================================================} -function TimerDeviceEvent(Timer:PTimerDevice;Event:TTimerEvent;Data:Pointer):LongWord; +function TimerDeviceEvent(Timer:PTimerDevice;Flags:LongWord;Callback:TTimerCallback;Data:Pointer):LongWord; begin {} Result:=ERROR_INVALID_PARAMETER; @@ -3247,8 +3321,8 @@ function TimerDeviceEvent(Timer:PTimerDevice;Event:TTimerEvent;Data:Pointer):Lon if DEVICE_LOG_ENABLED then DeviceLogDebug(nil,'Timer Device Event'); {$ENDIF} - {Check Event} - if not Assigned(Event) then Exit; + {Check Callback} + if not Assigned(Callback) then Exit; {Check Enabled} Result:=ERROR_NOT_SUPPORTED; @@ -3256,7 +3330,7 @@ function TimerDeviceEvent(Timer:PTimerDevice;Event:TTimerEvent;Data:Pointer):Lon if Assigned(Timer.DeviceEvent) then begin - Result:=Timer.DeviceEvent(Timer,Event,Data); + Result:=Timer.DeviceEvent(Timer,Flags,Callback,Data); end; end; @@ -3328,7 +3402,7 @@ function TimerDeviceSetRate(Timer:PTimerDevice;Rate:LongWord):LongWord; {==============================================================================} -function TimerDeviceGetMaximum(Timer:PTimerDevice):LongWord; +function TimerDeviceGetInterval(Timer:PTimerDevice):LongWord; begin {} Result:=0; @@ -3338,21 +3412,21 @@ function TimerDeviceGetMaximum(Timer:PTimerDevice):LongWord; if Timer.Device.Signature <> DEVICE_SIGNATURE then Exit; {$IFDEF DEVICE_DEBUG} - if DEVICE_LOG_ENABLED then DeviceLogDebug(nil,'Timer Device Get Maximum'); + if DEVICE_LOG_ENABLED then DeviceLogDebug(nil,'Timer Device Get Interval'); {$ENDIF} {Check Enabled} {if Timer.TimerState <> TIMER_STATE_ENABLED then Exit;} {Allow when disabled} - if Assigned(Timer.DeviceGetMaximum) then + if Assigned(Timer.DeviceGetInterval) then begin - Result:=Timer.DeviceGetMaximum(Timer); + Result:=Timer.DeviceGetInterval(Timer); end else begin if MutexLock(Timer.Lock) <> ERROR_SUCCESS then Exit; - Result:=Timer.Maximum; + Result:=Timer.Interval; MutexUnlock(Timer.Lock); end; @@ -3360,31 +3434,33 @@ function TimerDeviceGetMaximum(Timer:PTimerDevice):LongWord; {==============================================================================} -function TimerDeviceGetInterval(Timer:PTimerDevice):LongWord; +function TimerDeviceSetInterval(Timer:PTimerDevice;Interval:LongWord):LongWord; begin {} - Result:=0; + Result:=ERROR_INVALID_PARAMETER; {Check Timer} if Timer = nil then Exit; if Timer.Device.Signature <> DEVICE_SIGNATURE then Exit; {$IFDEF DEVICE_DEBUG} - if DEVICE_LOG_ENABLED then DeviceLogDebug(nil,'Timer Device Get Interval'); + if DEVICE_LOG_ENABLED then DeviceLogDebug(nil,'Timer Device Set Interval'); {$ENDIF} {Check Enabled} {if Timer.TimerState <> TIMER_STATE_ENABLED then Exit;} {Allow when disabled} - if Assigned(Timer.DeviceGetInterval) then + if Assigned(Timer.DeviceSetInterval) then begin - Result:=Timer.DeviceGetInterval(Timer); + Result:=Timer.DeviceSetInterval(Timer,Interval); end else begin if MutexLock(Timer.Lock) <> ERROR_SUCCESS then Exit; - Result:=Timer.Interval; + Timer.Interval:=Interval; + + Result:=ERROR_SUCCESS; MutexUnlock(Timer.Lock); end; @@ -3392,32 +3468,34 @@ function TimerDeviceGetInterval(Timer:PTimerDevice):LongWord; {==============================================================================} -function TimerDeviceSetInterval(Timer:PTimerDevice;Interval:LongWord):LongWord; +function TimerDeviceProperties(Timer:PTimerDevice;Properties:PTimerProperties):LongWord; begin {} - Result:=ERROR_INVALID_PARAMETER; + Result:=0; {Check Timer} if Timer = nil then Exit; if Timer.Device.Signature <> DEVICE_SIGNATURE then Exit; {$IFDEF DEVICE_DEBUG} - if DEVICE_LOG_ENABLED then DeviceLogDebug(nil,'Timer Device Set Interval'); + if DEVICE_LOG_ENABLED then DeviceLogDebug(nil,'Timer Device Properties'); {$ENDIF} {Check Enabled} {if Timer.TimerState <> TIMER_STATE_ENABLED then Exit;} {Allow when disabled} - if Assigned(Timer.DeviceSetInterval) then + if Assigned(Timer.DeviceProperties) then begin - Result:=Timer.DeviceSetInterval(Timer,Interval); + Result:=Timer.DeviceProperties(Timer,Properties); end else begin if MutexLock(Timer.Lock) <> ERROR_SUCCESS then Exit; - Timer.Interval:=Interval; - + {Get Properties} + System.Move(Timer.Properties,Properties^,SizeOf(TTimerProperties)); + + {Return Result} Result:=ERROR_SUCCESS; MutexUnlock(Timer.Lock); @@ -3463,17 +3541,17 @@ function TimerDeviceCreateEx(Size:LongWord):PTimerDevice; Result.DeviceStart:=nil; Result.DeviceStop:=nil; Result.DeviceRead:=nil; + Result.DeviceRead64:=nil; Result.DeviceWait:=nil; Result.DeviceEvent:=nil; Result.DeviceGetRate:=nil; Result.DeviceSetRate:=nil; - Result.DeviceGetMaximum:=nil; Result.DeviceGetInterval:=nil; Result.DeviceSetInterval:=nil; + Result.DeviceProperties:=nil; Result.Lock:=INVALID_HANDLE_VALUE; Result.Address:=nil; Result.Rate:=0; - Result.Maximum:=0; Result.Interval:=0; {Create Lock} @@ -3534,9 +3612,7 @@ function TimerDeviceRegister(Timer:PTimerDevice):LongWord; {Check Interfaces} if not(Assigned(Timer.DeviceStart)) then Exit; if not(Assigned(Timer.DeviceStop)) then Exit; - if not(Assigned(Timer.DeviceRead)) then Exit; - if not(Assigned(Timer.DeviceWait)) then Exit; - if not(Assigned(Timer.DeviceEvent)) then Exit; + if not(Assigned(Timer.DeviceRead)) and not(Assigned(Timer.DeviceRead64)) then Exit; {Check Timer} Result:=ERROR_ALREADY_EXISTS; @@ -5503,7 +5579,129 @@ function SysClockRead64:Int64; {==============================================================================} {==============================================================================} -{RTL Timer Functions} +{RTL Timer (Counter) Functions} +function SysTimerAvailable:Boolean; +{Check if a timer device is available} +begin + {} + Result:=(TimerDeviceDefault <> nil); +end; + +{==============================================================================} + +function SysTimerRead:LongWord; +{Read the current value of the default counter} +{Return: The 32 bit current value of the current or 0 on failure} +begin + {} + Result:=0; + + if TimerDeviceDefault = nil then Exit; + + Result:=TimerDeviceRead(TimerDeviceDefault); +end; + +{==============================================================================} + +function SysTimerRead64:Int64; +{Read the current value of the default counter} +{Return: The 64 bit current value of the current or 0 on failure} +begin + {} + Result:=0; + + if TimerDeviceDefault = nil then Exit; + + Result:=TimerDeviceRead64(TimerDeviceDefault); +end; + +{==============================================================================} + +function SysTimerWait:LongWord; +{Wait for the current interval to expire on the default counter} +{Return: ERROR_SUCCESS if the interval expired or another error code on failure} +begin + {} + Result:=ERROR_INVALID_PARAMETER; + + if TimerDeviceDefault = nil then Exit; + + Result:=TimerDeviceWait(TimerDeviceDefault); +end; + +{==============================================================================} + +function SysTimerEvent(Callback:TTimerCallback;Data:Pointer):LongWord; +{Schedule a function to be called when the current interval expires on the default counter} +{Callback: The function to be called when the interval expires} +{Data: A pointer to be pass to the function when the interval expires (Optional)} +{Return: ERROR_SUCCESS if the callback was scheduled successfully or another error code on failure} +begin + {} + Result:=ERROR_INVALID_PARAMETER; + + if TimerDeviceDefault = nil then Exit; + + Result:=TimerDeviceEvent(TimerDeviceDefault,TIMER_EVENT_FLAG_NONE,Callback,Data); +end; + +{==============================================================================} + +function SysTimerGetRate:LongWord; +{Get the current clock rate in Hz of the default counter} +{Return: The current clock rate in Hz or 0 on failure} +begin + {} + Result:=0; + + if TimerDeviceDefault = nil then Exit; + + Result:=TimerDeviceGetRate(TimerDeviceDefault); +end; + +{==============================================================================} + +function SysTimerSetRate(Rate:LongWord):LongWord; +{Set the current clock rate in Hz of the default counter} +{Rate: The clock rate in Hz to set} +{Return: ERROR_SUCCESS if the clock rate was set or another error code on failure} +begin + {} + Result:=ERROR_INVALID_PARAMETER; + + if TimerDeviceDefault = nil then Exit; + + Result:=TimerDeviceSetRate(TimerDeviceDefault,Rate); +end; + +{==============================================================================} + +function SysTimerGetInterval:LongWord; +{Get the current interval in milliseconds of the default counter} +{Return: The current interval in milliseconds or 0 on failure (or not set)} +begin + {} + Result:=0; + + if TimerDeviceDefault = nil then Exit; + + Result:=TimerDeviceGetInterval(TimerDeviceDefault); +end; + +{==============================================================================} + +function SysTimerSetInterval(Interval:LongWord):LongWord; +{Set the current interval in milliseconds of the default counter} +{Interval: The interval in milliseconds to set} +{Return: ERROR_SUCCESS if the interval was set or another error code on failure} +begin + {} + Result:=ERROR_INVALID_PARAMETER; + + if TimerDeviceDefault = nil then Exit; + + Result:=TimerDeviceSetInterval(TimerDeviceDefault,Interval); +end; {==============================================================================} {==============================================================================} diff --git a/source/rtl/ultibo/core/dhcp.pas b/source/rtl/ultibo/core/dhcp.pas index 125bd90..4fd9c4a 100644 --- a/source/rtl/ultibo/core/dhcp.pas +++ b/source/rtl/ultibo/core/dhcp.pas @@ -45,11 +45,6 @@ interface uses GlobalConfig,GlobalConst,GlobalTypes,GlobalSock,SysUtils,Classes,Network,Transport,Protocol,IP,IPv6,ARP,UDP,Ultibo,UltiboClasses; -//To Do //Look for: - -//ReaderConvert -//WriterConvert - {==============================================================================} {Global definitions} {$INCLUDE GlobalDefines.inc} @@ -58,7 +53,7 @@ interface const {DHCP specific constants} {BOOTP/DHCP Constants} - BOOTP_DELAY = 0; + BOOTP_DELAY = 1000; {Previously 0} BOOTP_TIMEOUT = 8000; {Previously 4000} {We wait for 8 seconds for a BOOTP reply} BOOTP_RETRIES = 6; {Previously 4} {Try the request 6 times} @@ -69,7 +64,7 @@ interface BOOTP_MIN_RETRIES = 1; BOOTP_MAX_RETRIES = 100; - DHCP_DELAY = 0; + DHCP_DELAY = 1000; {Previously 0} DHCP_TIMEOUT = 8000; {Previously 4000} {We wait for 8 seconds for a DHCP reply} DHCP_RETRIES = 6; {Previously 4} {Try the request 6 times} @@ -597,15 +592,11 @@ function TDHCPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;AC if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'DHCPConfig: Attempting DHCP Configuration - Discover'); {$ENDIF} - //To Do //ReaderConvert //No - {Set Configuring} AAdapter.Configuring:=True; - - //To Do //WriterConvert //No try {Delay Init} - Sleep(FInitDelay); //To Do + Sleep(FInitDelay); {Check the Adapter} if AAdapter.Configured then Exit; @@ -694,12 +685,8 @@ function TDHCPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;AC FARP.UnloadAddress(AAdapter.Adapter,IP_DEFAULT_ADDRESS); end; finally - //To Do //ReaderConvert - {Reset Configuring} AAdapter.Configuring:=False; - - //To Do //WriterConvert end; end; CONFIG_ADAPTER_REBOOT:begin @@ -708,15 +695,11 @@ function TDHCPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;AC if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'DHCPConfig: Attempting DHCP Configuration - Reboot'); {$ENDIF} - //To Do //ReaderConvert - {Set Configuring} AAdapter.Configuring:=True; - - //To Do //WriterConvert try {Delay Init} - Sleep(FInitDelay); //To Do + Sleep(FInitDelay); {Check the Adapter} if AAdapter.Configured then Exit; @@ -792,12 +775,8 @@ function TDHCPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;AC FARP.UnloadAddress(AAdapter.Adapter,IP_DEFAULT_ADDRESS); end; finally - //To Do //ReaderConvert - {Reset Configuring} AAdapter.Configuring:=False; - - //To Do //WriterConvert end; end; CONFIG_ADAPTER_RELEASE,CONFIG_ADAPTER_RENEW,CONFIG_ADAPTER_REBIND,CONFIG_ADAPTER_INFORM:begin @@ -806,12 +785,8 @@ function TDHCPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;AC if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'DHCPConfig: Attempting DHCP Configuration - Release/Renew/Rebind/Inform'); {$ENDIF} - //To Do //ReaderConvert - {Set Configuring} AAdapter.Configuring:=True; - - //To Do //WriterConvert try Randomize; @@ -890,12 +865,8 @@ function TDHCPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;AC Socket.ReaderUnlock; end; finally - //To Do //ReaderConvert - {Reset Configuring} AAdapter.Configuring:=False; - - //To Do //WriterConvert end; end; end; @@ -1109,13 +1080,9 @@ function TDHCPConfig.HandleDHCPReply(AHeader:PDHCPHeader;ATransport:TDHCPConfigT {Check Message Type} if PByte(Option)^ <> DHCP_OFFER then Exit; - //To Do //ReaderConvert //etc throughout here - {Get the Address} TIPTransportAdapter(AAdapter).Address:=InAddrToHost(AHeader.YourIP); - //To Do //WriterConvert - {Get the Netmask} if not ExtractDHCPOption(SUBNET_MASK,AHeader,Option,Length) then Exit; if Length <> SizeOf(TInAddr) then Exit; @@ -1161,7 +1128,8 @@ function TDHCPConfig.HandleDHCPReply(AHeader:PDHCPHeader;ATransport:TDHCPConfigT if Length >= 1 then begin PByte(PtrUInt(Option) + PtrUInt(Length + 1))^:=0; - TIPTransport(ATransport.Transport).DomainName:=PChar(Option); + Manager.Settings.DomainName:=PChar(Option); + {TIPTransport(ATransport.Transport).DomainName:=PChar(Option);} end; end; @@ -1219,13 +1187,9 @@ function TDHCPConfig.HandleDHCPReply(AHeader:PDHCPHeader;ATransport:TDHCPConfigT {Check Message Type} if PByte(Option)^ <> DHCP_ACK then Exit; - //To Do //ReaderConvert //etc throughout here - {Get the Address} TIPTransportAdapter(AAdapter).Address:=InAddrToHost(AHeader.YourIP); - //To Do //WriterConvert - {Get the Netmask} if not ExtractDHCPOption(SUBNET_MASK,AHeader,Option,Length) then Exit; if Length <> SizeOf(TInAddr) then Exit; @@ -1271,7 +1235,8 @@ function TDHCPConfig.HandleDHCPReply(AHeader:PDHCPHeader;ATransport:TDHCPConfigT if Length >= 1 then begin PByte(PtrUInt(Option) + PtrUInt(Length + 1))^:=0; - TIPTransport(ATransport.Transport).DomainName:=PChar(Option); + Manager.Settings.DomainName:=PChar(Option); + {TIPTransport(ATransport.Transport).DomainName:=PChar(Option);} end; end; @@ -1328,12 +1293,8 @@ function TDHCPConfig.HandleDHCPReply(AHeader:PDHCPHeader;ATransport:TDHCPConfigT if not ExtractDHCPOption(DHCP_IP_ADDR_LEASE_TIME,AHeader,Option,Length) then Exit; if Length <> SizeOf(LongWord) then Exit; - //To Do //ReaderConvert //etc throughout here - TIPTransportAdapter(AAdapter).LeaseTime:=(LongWordBEtoN(PLongWord(Option)^) * 1000); - //To Do //WriterConvert - {Get the Expiry Time} TIPTransportAdapter(AAdapter).ExpiryTime:=GetTickCount64 + TIPTransportAdapter(AAdapter).LeaseTime; @@ -1367,8 +1328,6 @@ function TDHCPConfig.HandleDHCPReply(AHeader:PDHCPHeader;ATransport:TDHCPConfigT {Check Message Type} if PByte(Option)^ <> DHCP_ACK then Exit; - //To Do //ReaderConvert //etc throughout here - {Get the Gateway} if ExtractDHCPOption(ROUTERS_ON_SNET,AHeader,Option,Length) then begin @@ -1378,8 +1337,6 @@ function TDHCPConfig.HandleDHCPReply(AHeader:PDHCPHeader;ATransport:TDHCPConfigT end; end; - //To Do //WriterConvert - {Get the Nameservers} if ExtractDHCPOption(DNS_SRV,AHeader,Option,Length) then begin @@ -1401,7 +1358,8 @@ function TDHCPConfig.HandleDHCPReply(AHeader:PDHCPHeader;ATransport:TDHCPConfigT if Length >= 1 then begin PByte(PtrUInt(Option) + PtrUInt(Length + 1))^:=0; - TIPTransport(ATransport.Transport).DomainName:=PChar(Option); + Manager.Settings.DomainName:=PChar(Option); + {TIPTransport(ATransport.Transport).DomainName:=PChar(Option);} end; end; @@ -1429,6 +1387,7 @@ function TDHCPConfig.SendDHCPDiscover(ASocket:TProtocolSocket;ATransport:TDHCPCo var Size:Integer; Option:Pointer; + HostName:String; SockAddr:TSockAddr; Header:TDHCPHeader; ClientId:TDHCPClientId; @@ -1467,6 +1426,10 @@ function TDHCPConfig.SendDHCPDiscover(ASocket:TProtocolSocket;ATransport:TDHCPCo ClientId:=GetDHCPClientId(AAdapter); if not InsertDHCPOption(DHCP_CLIENT_ID,@Header,@ClientId,SizeOf(TDHCPClientId)) then Exit; + {Host Name} + HostName:=Manager.Settings.HostName; + if Length(HostName) <> 0 then if not InsertDHCPOption(HOST_NAME,@Header,PChar(HostName),Length(HostName)) then Exit; + {Requested Options} PByte(Option)^:=SUBNET_MASK; PByte(LongWord(Option) + 1)^:=ROUTERS_ON_SNET; @@ -1505,6 +1468,7 @@ function TDHCPConfig.SendDHCPRequest(ASocket:TProtocolSocket;ATransport:TDHCPCon var Size:Integer; Option:Pointer; + HostName:String; SockAddr:TSockAddr; Header:TDHCPHeader; ClientId:TDHCPClientId; @@ -1543,6 +1507,10 @@ function TDHCPConfig.SendDHCPRequest(ASocket:TProtocolSocket;ATransport:TDHCPCon ClientId:=GetDHCPClientId(AAdapter); if not InsertDHCPOption(DHCP_CLIENT_ID,@Header,@ClientId,SizeOf(TDHCPClientId)) then Exit; + {Host Name} + HostName:=Manager.Settings.HostName; + if Length(HostName) <> 0 then if not InsertDHCPOption(HOST_NAME,@Header,PChar(HostName),Length(HostName)) then Exit; + {Requested Options} PByte(Option)^:=SUBNET_MASK; PByte(LongWord(Option) + 1)^:=ROUTERS_ON_SNET; @@ -1725,6 +1693,7 @@ function TDHCPConfig.SendDHCPInform(ASocket:TProtocolSocket;ATransport:TDHCPConf var Size:Integer; Option:Pointer; + HostName:String; SockAddr:TSockAddr; Header:TDHCPHeader; ClientId:TDHCPClientId; @@ -1763,6 +1732,10 @@ function TDHCPConfig.SendDHCPInform(ASocket:TProtocolSocket;ATransport:TDHCPConf ClientId:=GetDHCPClientId(AAdapter); if not InsertDHCPOption(DHCP_CLIENT_ID,@Header,@ClientId,SizeOf(TDHCPClientId)) then Exit; + {Host Name} + HostName:=Manager.Settings.HostName; + if Length(HostName) <> 0 then if not InsertDHCPOption(HOST_NAME,@Header,PChar(HostName),Length(HostName)) then Exit; + {Requested Options} PByte(Option)^:=SUBNET_MASK; PByte(LongWord(Option) + 1)^:=ROUTERS_ON_SNET; @@ -1940,6 +1913,7 @@ function TDHCPConfig.SendDHCPReboot(ASocket:TProtocolSocket;ATransport:TDHCPConf var Size:Integer; Option:Pointer; + HostName:String; SockAddr:TSockAddr; Header:TDHCPHeader; ClientId:TDHCPClientId; @@ -1978,6 +1952,10 @@ function TDHCPConfig.SendDHCPReboot(ASocket:TProtocolSocket;ATransport:TDHCPConf ClientId:=GetDHCPClientId(AAdapter); if not InsertDHCPOption(DHCP_CLIENT_ID,@Header,@ClientId,SizeOf(TDHCPClientId)) then Exit; + {Host Name} + HostName:=Manager.Settings.HostName; + if Length(HostName) <> 0 then if not InsertDHCPOption(HOST_NAME,@Header,PChar(HostName),Length(HostName)) then Exit; + {Requested Options} PByte(Option)^:=SUBNET_MASK; PByte(LongWord(Option) + 1)^:=ROUTERS_ON_SNET; @@ -2569,7 +2547,7 @@ function TBOOTPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;A {Check Adapter} if AAdapter = nil then Exit; - + {Get Transport} Transport:=TBOOTPConfigTransport(GetTransportByHandle(AHandle,True,NETWORK_LOCK_READ)); if Transport = nil then Exit; @@ -2588,18 +2566,14 @@ function TBOOTPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;A if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'BOOTPConfig: Attempting BOOTP Configuration'); {$ENDIF} - //To Do //ReaderConvert - {Set Configuring} AAdapter.Configuring:=True; - - //To Do //WriterConvert try {Check Address Family} case Transport.Transport.Family of AF_INET:begin {Delay Init} - Sleep(FInitDelay); //To Do + Sleep(FInitDelay); {Check the Adapter} if AAdapter.Configured then Exit; @@ -2674,12 +2648,8 @@ function TBOOTPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;A end; end; finally - //To Do //ReaderConvert - {Reset Configuring} AAdapter.Configuring:=False; - - //To Do //WriterConvert end; end; CONFIG_ADAPTER_RELEASE:begin @@ -2803,13 +2773,9 @@ function TBOOTPConfig.HandleBOOTPReply(AHeader:PBOOTPHeader;ATransport:TBOOTPCon {Check Address Family} case ATransport.Transport.Family of AF_INET:begin - //To Do //ReaderConvert //etc throughout here - {Get the Address} TIPTransportAdapter(AAdapter).Address:=InAddrToHost(AHeader.YourIP); - //To Do //WriterConvert - {Get the Netmask} if ExtractBOOTPOption(SUBNET_MASK,AHeader,Option,Length) then begin @@ -2851,7 +2817,8 @@ function TBOOTPConfig.HandleBOOTPReply(AHeader:PBOOTPHeader;ATransport:TBOOTPCon if Length >= 1 then begin PByte(PtrUInt(Option) + PtrUInt(Length + 1))^:=0; - TIPTransport(ATransport.Transport).DomainName:=PChar(Option); + Manager.Settings.DomainName:=PChar(Option); + {TIPTransport(ATransport.Transport).DomainName:=PChar(Option);} end; end; @@ -3328,12 +3295,8 @@ function TARPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;ACo if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ARPConfig: Attempting ARP Configuration'); {$ENDIF} - //To Do //ReaderConvert - {Set Configuring} AAdapter.Configuring:=True; - - //To Do //WriterConvert try {Check Address Family} case Transport.Transport.Family of @@ -3365,20 +3328,12 @@ function TARPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;ACo if LongWord(Address.S_addr) > LongWord(Range.S_addr) then Exit; end; - //To Do //ReaderConvert - {Return the Address} TIPTransportAdapter(AAdapter).Address:=Address; - //To Do //WriterConvert - - //To Do //ReaderConvert - {Return the Netmask} if TIPTransport(Transport.Transport).CompareDefault(TIPTransportAdapter(AAdapter).Netmask) then TIPTransportAdapter(AAdapter).Netmask:=IP_CLASSC_NETMASK; - //To Do //WriterConvert - {Return Result} Result:=True; finally @@ -3388,12 +3343,8 @@ function TARPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;ACo end; end; finally - //To Do //ReaderConvert - {Reset Configuring} AAdapter.Configuring:=False; - - //To Do //WriterConvert end; end; CONFIG_ADAPTER_RELEASE:begin @@ -3684,12 +3635,8 @@ function TRARPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;AC if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'RARPConfig: Attempting RARP Configuration'); {$ENDIF} - //To Do //ReaderConvert - {Set Configuring} AAdapter.Configuring:=True; - - //To Do //WriterConvert try {Check Address Family} case Transport.Transport.Family of @@ -3700,27 +3647,19 @@ function TRARPConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter;AC {Request Address} if not FRARP.ResolveHardware(AAdapter.Adapter,Address) then Exit; - //To Do //ReaderConvert - {Return the Address} TIPTransportAdapter(AAdapter).Address:=Address; {Return the Netmask (Guessed)} if TIPTransport(Transport.Transport).CompareDefault(TIPTransportAdapter(AAdapter).Netmask) then TIPTransportAdapter(AAdapter).Netmask:=IP_CLASSC_NETMASK; - //To Do //WriterConvert - {Return Result} Result:=True; end; end; finally - //To Do //ReaderConvert - {Reset Configuring} AAdapter.Configuring:=False; - - //To Do //WriterConvert end; end; CONFIG_ADAPTER_RELEASE:begin @@ -4010,12 +3949,8 @@ function TStaticConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'StaticConfig: Attempting Static Configuration'); {$ENDIF} - //To Do //ReaderConvert - {Set Configuring} AAdapter.Configuring:=True; - - //To Do //WriterConvert try {Check Address Family} case Transport.Transport.Family of @@ -4053,12 +3988,8 @@ function TStaticConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapter; end; end; finally - //To Do //ReaderConvert - {Reset Configuring} AAdapter.Configuring:=False; - - //To Do //WriterConvert end; end; CONFIG_ADAPTER_RELEASE:begin @@ -4409,12 +4340,8 @@ function TLoopbackConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapte if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'LoopbackConfig: Attempting Loopback Configuration'); {$ENDIF} - //To Do //ReaderConvert - {Set Configuring} AAdapter.Configuring:=True; - - //To Do //WriterConvert try {Check Address Family} case Transport.Transport.Family of @@ -4442,12 +4369,8 @@ function TLoopbackConfig.ConfigHandler(AHandle:THandle;AAdapter:TTransportAdapte end; end; finally - //To Do //ReaderConvert - {Reset Configuring} AAdapter.Configuring:=False; - - //To Do //WriterConvert end; end; CONFIG_ADAPTER_RELEASE:begin @@ -4746,39 +4669,42 @@ procedure DHCPInit; {} {Check Initialized} if DHCPInitialized then Exit; - + + {Setup Loopback Config} + if NetworkSettings.GetBoolean('LOOPBACK_NETWORK_ENABLED') then NetworkSettings.AddBoolean('LOOPBACK_CONFIG_ENABLED',True); + {Create Loopback Config} - if LOOPBACK_CONFIG_ENABLED then + if NetworkSettings.GetBooleanDefault('LOOPBACK_CONFIG_ENABLED',LOOPBACK_CONFIG_ENABLED) then begin TLoopbackConfig.Create(ProtocolManager); end; {Create Static Config} - if STATIC_CONFIG_ENABLED then + if NetworkSettings.GetBooleanDefault('STATIC_CONFIG_ENABLED',STATIC_CONFIG_ENABLED) then begin TStaticConfig.Create(ProtocolManager); end; {Create DHCP Config} - if DHCP_CONFIG_ENABLED then + if NetworkSettings.GetBooleanDefault('DHCP_CONFIG_ENABLED',DHCP_CONFIG_ENABLED) then begin TDHCPConfig.Create(ProtocolManager); end; {Create BOOTP Config} - if BOOTP_CONFIG_ENABLED then + if NetworkSettings.GetBooleanDefault('BOOTP_CONFIG_ENABLED',BOOTP_CONFIG_ENABLED) then begin TBOOTPConfig.Create(ProtocolManager); end; {Create RARP Config} - if RARP_CONFIG_ENABLED then + if NetworkSettings.GetBooleanDefault('RARP_CONFIG_ENABLED',RARP_CONFIG_ENABLED) then begin TRARPConfig.Create(ProtocolManager); end; {Create ARP Config} - if ARP_CONFIG_ENABLED then + if NetworkSettings.GetBooleanDefault('ARP_CONFIG_ENABLED',ARP_CONFIG_ENABLED) then begin TARPConfig.Create(ProtocolManager); end; diff --git a/source/rtl/ultibo/core/dns.pas b/source/rtl/ultibo/core/dns.pas index 8c2dde3..35a7ea2 100644 --- a/source/rtl/ultibo/core/dns.pas +++ b/source/rtl/ultibo/core/dns.pas @@ -1814,7 +1814,7 @@ function TDNSClient.GetHostByName(AName:PChar):PHostEnt; NameBuffer:=StripTrailingDot(AName); {Check for Blank} - if (NameBuffer = '') or (Lowercase(NameBuffer) = '..localmachine') or (Lowercase(NameBuffer) = Lowercase(Transport.HostName)) then + if (NameBuffer = '') or (Lowercase(NameBuffer) = '..localmachine') or (Lowercase(NameBuffer) = Lowercase(FProtocol.Manager.Settings.HostName)) then begin {Check the Addresses} Count:=0; @@ -1827,7 +1827,7 @@ function TDNSClient.GetHostByName(AName:PChar):PHostEnt; Inc(Count); {Return Address Entry if found} - Result:=AddressEntryToHostEnt(AddressEntry,Transport.HostName + AddLeadingDot(Transport.DomainName),Count); + Result:=AddressEntryToHostEnt(AddressEntry,FProtocol.Manager.Settings.HostName + AddLeadingDot(FProtocol.Manager.Settings.DomainName),Count); SetLastError(ERROR_SUCCESS); end else if AddressEntry.AddressType = ADDRESS_TYPE_SECONDARY then @@ -1835,7 +1835,7 @@ function TDNSClient.GetHostByName(AName:PChar):PHostEnt; Inc(Count); {Return Address Entry if found} - Result:=AddressEntryToHostEnt(AddressEntry,Transport.HostName + AddLeadingDot(Transport.DomainName),Count); + Result:=AddressEntryToHostEnt(AddressEntry,FProtocol.Manager.Settings.HostName + AddLeadingDot(FProtocol.Manager.Settings.DomainName),Count); SetLastError(ERROR_SUCCESS); end; @@ -1867,7 +1867,7 @@ function TDNSClient.GetHostByName(AName:PChar):PHostEnt; else begin {Check the Domain} - if Pos('.',NameBuffer) = 0 then NameBuffer:=NameBuffer + AddLeadingDot(Transport.DomainName); + if Pos('.',NameBuffer) = 0 then NameBuffer:=NameBuffer + AddLeadingDot(FProtocol.Manager.Settings.DomainName); {Check the Cache} HostEntry:=Transport.GetHostByName(NameBuffer,True); @@ -1981,8 +1981,8 @@ function TDNSClient.GetHostName(AName:PChar;ALength:Integer):Integer; {Get the Host Name} SetLastError(WSAEFAULT); if AName = nil then Exit; - if ALength < Length(Transport.HostName) then Exit; - StrLCopy(AName,PChar(Transport.HostName),ALength); + if ALength < Length(FProtocol.Manager.Settings.HostName) then Exit; + StrLCopy(AName,PChar(FProtocol.Manager.Settings.HostName),ALength); {Return Result} Result:=NO_ERROR; @@ -2337,7 +2337,10 @@ procedure DNSInit; if DNSInitialized then Exit; {Create DNS Client} - DNSClient:=TDNSClient.Create(ProtocolManager.GetProtocolByType(IPPROTO_UDP,SOCK_DGRAM,False,NETWORK_LOCK_NONE)); //To Do //Pass Manager //Move to StartClient ? + if NetworkSettings.GetBooleanDefault('DNS_CLIENT_ENABLED',DNS_CLIENT_ENABLED) then + begin + DNSClient:=TDNSClient.Create(ProtocolManager.GetProtocolByType(IPPROTO_UDP,SOCK_DGRAM,False,NETWORK_LOCK_NONE)); //To Do //Pass Manager //Move to StartClient + end; DNSInitialized:=True; end; diff --git a/source/rtl/ultibo/core/dwcotg.pas b/source/rtl/ultibo/core/dwcotg.pas index 897972c..da3bb9c 100644 --- a/source/rtl/ultibo/core/dwcotg.pas +++ b/source/rtl/ultibo/core/dwcotg.pas @@ -2651,6 +2651,7 @@ function DWCChannelStartTransfer(Host:PDWCUSBHost;Channel:LongWord;Request:PUSBR {For OUT endpoints, flush the data to send into the DMA buffer} if ((Characteristics and DWC_HOST_CHANNEL_CHARACTERISTICS_ENDPOINT_DIRECTION) shr 15) = USB_DIRECTION_OUT then begin + //To Do //Change this to not(DWCOTG_DMA_CACHE_COHERENT) ? if not(DWCOTG_DMA_SHARED_MEMORY) and not(DWCOTG_DMA_NOCACHE_MEMORY) then begin {Flush the data cache} @@ -2697,6 +2698,7 @@ function DWCChannelStartTransfer(Host:PDWCUSBHost;Channel:LongWord;Request:PUSBR {Copy the data to the DMA buffer} System.Move(Data^,Host.DMABuffers[Channel]^,((Transfer and DWC_HOST_CHANNEL_TRANSFER_SIZE) shr 0)); + //To Do //Change this to not(DWCOTG_DMA_CACHE_COHERENT) ? if not(DWCOTG_DMA_SHARED_MEMORY) and not(DWCOTG_DMA_NOCACHE_MEMORY) then begin {Flush the data cache} @@ -4643,6 +4645,7 @@ function DWCChannelCompleted(Host:PDWCUSBHost;Request:PUSBRequest;Channel,Interr {Check the DMA compatibility} if (Request.Flags and USB_REQUEST_FLAG_COMPATIBLE) = USB_REQUEST_FLAG_COMPATIBLE then begin + //To Do //Change this to not(DWCOTG_DMA_CACHE_COHERENT) ? if not(DWCOTG_DMA_SHARED_MEMORY) and not(DWCOTG_DMA_NOCACHE_MEMORY) then begin {Invalidate the data cache} @@ -4659,6 +4662,7 @@ function DWCChannelCompleted(Host:PDWCUSBHost;Request:PUSBRequest;Channel,Interr {Update Statistics} Inc(Host.DMABufferReadCount); + //To Do //Change this to not(DWCOTG_DMA_CACHE_COHERENT) ? if not(DWCOTG_DMA_SHARED_MEMORY) and not(DWCOTG_DMA_NOCACHE_MEMORY) then begin {Invalidate the data cache} diff --git a/source/rtl/ultibo/core/globalconfig.pas b/source/rtl/ultibo/core/globalconfig.pas index 94e194c..024e41a 100644 --- a/source/rtl/ultibo/core/globalconfig.pas +++ b/source/rtl/ultibo/core/globalconfig.pas @@ -870,27 +870,30 @@ interface SOCKETS_AUTOSTART:LongBool = True; {If True then auto start the sockets layer on boot (Only if Sockets unit included)} SOCKETS_ASYNCSTART:LongBool = True; {If True then auto start asynchronously using a worker thread instead of the main thread} + {Client configuration} + DNS_CLIENT_ENABLED:LongBool = True; {DNS client is enabled if True} + {Protocol configuration} RAW_PROTOCOL_ENABLED:LongBool = True; {Raw socket protocol is enabled if True} UDP_PROTOCOL_ENABLED:LongBool = True; {UDP protocol is enabled if True} TCP_PROTOCOL_ENABLED:LongBool = True; {TCP protocol is enabled if True} ICMP_PROTOCOL_ENABLED:LongBool = True; {ICMP protocol is enabled if True} - ICMP6_PROTOCOL_ENABLED:LongBool = False; //True; {ICMPv6 protocol is enabled if True} + ICMP6_PROTOCOL_ENABLED:LongBool = False; {ICMPv6 protocol is enabled if True} IGMP_PROTOCOL_ENABLED:LongBool = True; {IGMP protocol is enabled if True} TCP_RECEIVE_BACKLOG:LongWord = SIZE_1K; {Queue length for SYN received connections (per listening socket)} TCP_MESSAGESLOT_MAXIMUM:LongWord = SIZE_2K; {Maximum number of messages for TCP socket thread messageslot} ARP_CONFIG_ENABLED:LongBool = True; {ARP configuration is enabled if True} - RARP_CONFIG_ENABLED:LongBool = True; {RARP configuration is enabled if True} - BOOTP_CONFIG_ENABLED:LongBool = False; //True; {BOOTP configuration is enabled if True} + RARP_CONFIG_ENABLED:LongBool = False; {RARP configuration is enabled if True} + BOOTP_CONFIG_ENABLED:LongBool = False; {BOOTP configuration is enabled if True} DHCP_CONFIG_ENABLED:LongBool = True; {DHCP configuration is enabled if True} STATIC_CONFIG_ENABLED:LongBool = True; {Static configuration is enabled if True} LOOPBACK_CONFIG_ENABLED:LongBool = True; {Loopback configuration is enabled if True} {Transport configuration} IP_TRANSPORT_ENABLED:LongBool = True; {IP transport is enabled if True} - IP6_TRANSPORT_ENABLED:LongBool = False; //True; {IPv6 transport is enabled if True} + IP6_TRANSPORT_ENABLED:LongBool = False; {IPv6 transport is enabled if True} ARP_TRANSPORT_ENABLED:LongBool = True; {ARP transport is enabled if True} RARP_TRANSPORT_ENABLED:LongBool = True; {RARP transport is enabled if True} diff --git a/source/rtl/ultibo/core/globalconst.pas b/source/rtl/ultibo/core/globalconst.pas index af4f64e..04ae3e0 100644 --- a/source/rtl/ultibo/core/globalconst.pas +++ b/source/rtl/ultibo/core/globalconst.pas @@ -50,12 +50,12 @@ interface {Global constants} const {Version constants} - ULTIBO_RELEASE_DATE = '11/5/2016'; + ULTIBO_RELEASE_DATE = '2/6/2016'; ULTIBO_RELEASE_NAME = 'Cucumber'; - ULTIBO_RELEASE_VERSION = '1.1.145'; + ULTIBO_RELEASE_VERSION = '1.2.009'; ULTIBO_RELEASE_VERSION_MAJOR = 1; - ULTIBO_RELEASE_VERSION_MINOR = 1; - ULTIBO_RELEASE_VERSION_REVISION = 145; + ULTIBO_RELEASE_VERSION_MINOR = 2; + ULTIBO_RELEASE_VERSION_REVISION = 009; {==============================================================================} const diff --git a/source/rtl/ultibo/core/globaldefines.inc b/source/rtl/ultibo/core/globaldefines.inc index d07d163..13c166a 100644 --- a/source/rtl/ultibo/core/globaldefines.inc +++ b/source/rtl/ultibo/core/globaldefines.inc @@ -170,7 +170,7 @@ Global Defines {$DEFINE RTL8188EU_DEBUG} {Enable debug output/counters for RTL8188EU driver (Default: Off)} {$DEFINE RTL8192CU_DEBUG} {Enable debug output/counters for RTL8192CU driver (Default: Off)} -{$DEFINE RT2800USB_DEBUG} {Enable debug output/counters for RT2800USB driver (Default: Off)} +{--$DEFINE RT2800USB_DEBUG} {Enable debug output/counters for RT2800USB driver (Default: Off)} {--$DEFINE PL2303_DEBUG} {Enable debug output/counters for PL2303 driver (Default: Off)} diff --git a/source/rtl/ultibo/core/globalsock.pas b/source/rtl/ultibo/core/globalsock.pas index a32024d..f113692 100644 --- a/source/rtl/ultibo/core/globalsock.pas +++ b/source/rtl/ultibo/core/globalsock.pas @@ -342,7 +342,7 @@ interface MSG_PEEK = $2; {peek at incoming message } MSG_DONTROUTE = $4; {send without using routing tables } - MSG_INTERRUPT = $10; {/* send/recv in the interrupt context */} + MSG_INTERRUPT = $10; {send/recv in the interrupt context} MSG_MAXIOVLEN = 16; MSG_PARTIAL = $8000; {partial send or recv for message xport } @@ -766,6 +766,7 @@ in_addr = record 0: (S_un_b: SunB); 1: (S_un_w: SunW); 2: (S_addr: u_long); + 3: (S_bytes: packed array[1..4] of Byte); end; TInAddr = in_addr; diff --git a/source/rtl/ultibo/core/icmp.pas b/source/rtl/ultibo/core/icmp.pas index a943a00..d931a46 100644 --- a/source/rtl/ultibo/core/icmp.pas +++ b/source/rtl/ultibo/core/icmp.pas @@ -4117,10 +4117,10 @@ procedure ICMPInit; if ICMPInitialized then Exit; {Setup ICMP Protocol} - if IP_TRANSPORT_ENABLED then ICMP_PROTOCOL_ENABLED:=True; + if NetworkSettings.GetBoolean('IP_TRANSPORT_ENABLED') then NetworkSettings.AddBoolean('ICMP_PROTOCOL_ENABLED',True); {Create ICMP Protocol} - if ICMP_PROTOCOL_ENABLED then + if NetworkSettings.GetBooleanDefault('ICMP_PROTOCOL_ENABLED',ICMP_PROTOCOL_ENABLED) then begin TICMPProtocol.Create(ProtocolManager,ICMP_PROTOCOL_NAME); end; diff --git a/source/rtl/ultibo/core/icmpv6.pas b/source/rtl/ultibo/core/icmpv6.pas index fd31392..ed287eb 100644 --- a/source/rtl/ultibo/core/icmpv6.pas +++ b/source/rtl/ultibo/core/icmpv6.pas @@ -2677,10 +2677,10 @@ procedure ICMP6Init; if ICMP6Initialized then Exit; {Setup ICMP Protocol} - if IP6_TRANSPORT_ENABLED then ICMP6_PROTOCOL_ENABLED:=True; - + if NetworkSettings.GetBoolean('IP6_TRANSPORT_ENABLED') then NetworkSettings.AddBoolean('ICMP6_PROTOCOL_ENABLED',True); + {Create ICMPv6 Protocol} - if ICMP6_PROTOCOL_ENABLED then + if NetworkSettings.GetBooleanDefault('ICMP6_PROTOCOL_ENABLED',ICMP6_PROTOCOL_ENABLED) then begin TICMP6Protocol.Create(ProtocolManager,ICMP6_PROTOCOL_NAME); end; diff --git a/source/rtl/ultibo/core/igmp.pas b/source/rtl/ultibo/core/igmp.pas index b1c7c35..441c1d7 100644 --- a/source/rtl/ultibo/core/igmp.pas +++ b/source/rtl/ultibo/core/igmp.pas @@ -3678,7 +3678,7 @@ procedure IGMPInit; if IGMPInitialized then Exit; {Create IGMP Protocol} - if IGMP_PROTOCOL_ENABLED then + if NetworkSettings.GetBooleanDefault('IGMP_PROTOCOL_ENABLED',IGMP_PROTOCOL_ENABLED) then begin TIGMPProtocol.Create(ProtocolManager,IGMP_PROTOCOL_NAME); end; diff --git a/source/rtl/ultibo/core/ip.pas b/source/rtl/ultibo/core/ip.pas index dc70eb4..13f3bf8 100644 --- a/source/rtl/ultibo/core/ip.pas +++ b/source/rtl/ultibo/core/ip.pas @@ -68,10 +68,6 @@ interface uses GlobalConfig,GlobalConst,GlobalTypes,GlobalSock,Platform,Threads,SysUtils,Classes,Network,Transport,Protocol,ARP,Ultibo,UltiboUtils,UltiboClasses; -//To Do //Look for: - -//-- - {==============================================================================} {Global definitions} {$INCLUDE GlobalDefines.inc} @@ -260,6 +256,7 @@ TIPTransportAdapter = class(TTransportAdapter) RenewalTime:Int64; {DHCP Renewal Time} RebindingTime:Int64; {DHCP Rebinding Time} + ConfigDefault:Word; {BOOTP/DHCP/RARP/STATIC/PSEUDO/LOOPBACK} ConfigAddress:TInAddr; ConfigNetmask:TInAddr; ConfigGateway:TInAddr; @@ -286,6 +283,7 @@ TIPTransportBinding = class(TTransportBinding) RenewalTime:Int64; {DHCP Renewal Time} RebindingTime:Int64; {DHCP Rebinding Time} + ConfigDefault:Word; {BOOTP/DHCP/RARP/STATIC/PSEUDO/LOOPBACK} ConfigAddress:TInAddr; ConfigNetmask:TInAddr; ConfigGateway:TInAddr; @@ -345,8 +343,6 @@ TIPTransport = class(TNetworkTransport) FAddresses:TNetworkList; {Status Variables} - FHostName:String; //To Do //Locking around HostName/DomainName (Maybe a TNameEntry object in Transport ?) - FDomainName:String; //Or does the reference count on strings provide enough protection ? FNameservers:TIPNameservers; //To Do //Change Nameservers to an object type (eg Transport.TNameserverEntry and TIPNameserverEntry) (Part of TNetworkList) FNameserverLock:TMutexHandle; //Then do Add/Remove/GetNameserverByNext etc) @@ -361,14 +357,20 @@ TIPTransport = class(TNetworkTransport) function CheckFragment(ABuffer:Pointer):Boolean; function GetNextIPId(AIncrement:Boolean):Word; + + function GetIPNameserver(ACount:LongWord):TInAddr; + + function GetAdapterConfigType(const AName:String):Word; + function GetAdapterConfigAddress(const AName:String):TInAddr; + function GetAdapterConfigNetmask(const AName:String):TInAddr; + function GetAdapterConfigGateway(const AName:String):TInAddr; + function GetAdapterConfigServer(const AName:String):TInAddr; protected {Inherited Methods} function FilterPacket(ASource,ADest,APacket:Pointer;ASize:Integer;ABroadcast:Boolean):Boolean; override; function ForwardPacket(AAdapter:TTransportAdapter;ASource,ADest,APacket:Pointer;ASize:Integer;ABroadcast:Boolean):Boolean; override; public {Public Properties} - property HostName:String read FHostName write FHostName; - property DomainName:String read FDomainName write FDomainName; property Nameservers:TIPNameservers read FNameservers; property Forwarding:LongWord read FForwarding write FForwarding; @@ -1167,6 +1169,7 @@ constructor TIPTransportAdapter.Create; RenewalTime:=0; RebindingTime:=0; + ConfigDefault:=CONFIG_TYPE_AUTO; LongWord(ConfigAddress.S_addr):=INADDR_ANY; LongWord(ConfigNetmask.S_addr):=INADDR_ANY; LongWord(ConfigGateway.S_addr):=INADDR_ANY; @@ -1193,6 +1196,7 @@ constructor TIPTransportBinding.Create; RenewalTime:=0; RebindingTime:=0; + ConfigDefault:=CONFIG_TYPE_AUTO; LongWord(ConfigAddress.S_addr):=INADDR_ANY; LongWord(ConfigNetmask.S_addr):=INADDR_ANY; LongWord(ConfigGateway.S_addr):=INADDR_ANY; @@ -1223,8 +1227,6 @@ constructor TIPTransport.Create(AManager:TTransportManager;const AName:String); FNetworks:=TNetworkList.Create; FAddresses:=TNetworkList.Create; - FHostName:=Platform.HostGetName; - FDomainName:=Platform.HostGetDomain; FillChar(FNameservers,SizeOf(TIPNameservers),0); FNameserverLock:=MutexCreate; @@ -1601,6 +1603,135 @@ function TIPTransport.GetNextIPId(AIncrement:Boolean):Word; {==============================================================================} +function TIPTransport.GetIPNameserver(ACount:LongWord):TInAddr; +{Get the nameserver address from the network settings} +var + Value:String; +begin + {} + LongWord(Result.S_addr):=INADDR_NONE; + + Value:=Uppercase(Manager.Settings.GetString('IP_NAMESERVER' + IntToStr(ACount))); + if Length(Value) <> 0 then + begin + Result:=InAddrToHost(StringToInAddr(Value)); + end; +end; + +{==============================================================================} + +function TIPTransport.GetAdapterConfigType(const AName:String):Word; +{Get the adapter config type from the network settings} +var + Value:String; +begin + {} + Result:=CONFIG_TYPE_AUTO; + + Value:=Uppercase(Manager.Settings.GetString(AName + '_IP_CONFIG')); + if Length(Value) <> 0 then + begin + Result:=StrToIntDef(Value,CONFIG_TYPE_UNKNOWN); + if Result > CONFIG_TYPE_PSEUDO then {CONFIG_TYPE_LOOPBACK not allowed} + begin + if Value = 'STATIC' then + begin + Result:=CONFIG_TYPE_STATIC; + end + else if Value = 'RARP' then + begin + Result:=CONFIG_TYPE_RARP; + end + else if Value = 'BOOTP' then + begin + Result:=CONFIG_TYPE_BOOTP; + end + else if Value = 'DHCP' then + begin + Result:=CONFIG_TYPE_DHCP; + end + else if Value = 'PSEUDO' then + begin + Result:=CONFIG_TYPE_PSEUDO; + end + else + begin + Result:=CONFIG_TYPE_AUTO; + end; + end; + end; +end; + +{==============================================================================} + +function TIPTransport.GetAdapterConfigAddress(const AName:String):TInAddr; +{Get the adapter address from the network settings} +var + Value:String; +begin + {} + LongWord(Result.S_addr):=INADDR_NONE; + + Value:=Uppercase(Manager.Settings.GetString(AName + '_IP_ADDRESS')); + if Length(Value) <> 0 then + begin + Result:=InAddrToHost(StringToInAddr(Value)); + end; +end; + +{==============================================================================} + +function TIPTransport.GetAdapterConfigNetmask(const AName:String):TInAddr; +{Get the adapter netmask from the network settings} +var + Value:String; +begin + {} + LongWord(Result.S_addr):=INADDR_NONE; + + Value:=Uppercase(Manager.Settings.GetString(AName + '_IP_NETMASK')); + if Length(Value) <> 0 then + begin + Result:=InAddrToHost(StringToInAddr(Value)); + end; +end; + +{==============================================================================} + +function TIPTransport.GetAdapterConfigGateway(const AName:String):TInAddr; +{Get the adapter gateway from the network settings} +var + Value:String; +begin + {} + LongWord(Result.S_addr):=INADDR_NONE; + + Value:=Uppercase(Manager.Settings.GetString(AName + '_IP_GATEWAY')); + if Length(Value) <> 0 then + begin + Result:=InAddrToHost(StringToInAddr(Value)); + end; +end; + +{==============================================================================} + +function TIPTransport.GetAdapterConfigServer(const AName:String):TInAddr; +{Get the adapter server from the network settings} +var + Value:String; +begin + {} + LongWord(Result.S_addr):=INADDR_NONE; + + Value:=Uppercase(Manager.Settings.GetString(AName + '_IP_SERVER')); + if Length(Value) <> 0 then + begin + Result:=InAddrToHost(StringToInAddr(Value)); + end; +end; + +{==============================================================================} + function TIPTransport.FilterPacket(ASource,ADest,APacket:Pointer;ASize:Integer;ABroadcast:Boolean):Boolean; {Filter a received packet} {Source: The source IP address of the received fragment (Set by Packet or Fragment Handler)} @@ -1853,8 +1984,8 @@ function TIPTransport.AddAdapter(AAdapter:TNetworkAdapter;AConfigType:Word;AAddr {Check Adapter} if AAdapter = nil then Exit; - {Check Status} - if AAdapter.Status <> ADAPTER_STATUS_READY then Exit; + {Check State} + if AAdapter.State <> ADAPTER_STATE_ENABLED then Exit; {Get Adapter} Adapter:=TIPTransportAdapter(GetAdapterByAdapter(AAdapter,True,NETWORK_LOCK_READ)); @@ -1888,6 +2019,7 @@ function TIPTransport.AddAdapter(AAdapter:TNetworkAdapter;AConfigType:Word;AAddr Adapter.ConfigType:=AConfigType; Adapter.Configured:=False; Adapter.Configuring:=False; + Adapter.ConfigDefault:=AConfigType; if AAddress <> nil then Adapter.ConfigAddress:=TInAddr(AAddress^); if ANetmask <> nil then Adapter.ConfigNetmask:=TInAddr(ANetmask^); if AGateway <> nil then Adapter.ConfigGateway:=TInAddr(AGateway^); @@ -2031,9 +2163,6 @@ function TIPTransport.RemoveAdapter(AAdapter:TNetworkAdapter):Boolean; {Check for Release} if FAutoRelease then begin - - //To Do //WriterConvert ? - {Call Config Handler} if Config.ConfigHandler(THandle(Config),Adapter,CONFIG_ADAPTER_RELEASE) then begin @@ -3115,6 +3244,9 @@ function TIPTransport.SetSockOpt(ASocket:TTransportSocket;ALevel,AOptName:Intege function TIPTransport.StartTransport:Boolean; {Start this transport ready for sending and receiving} +var + Count:LongWord; + Nameserver:TInAddr; begin {} ReaderLock; @@ -3136,6 +3268,16 @@ function TIPTransport.StartTransport:Boolean; FRARP:=TRARPTransport(Manager.GetTransportByType(AF_UNSPEC,PACKET_TYPE_RARP,False,NETWORK_LOCK_NONE)); {Do not lock} //To Do //AddTransport (TTransportTransport/TIPTransportTransport ?) //Client ? if FRARP = nil then Exit; + {Add Nameservers} + for Count:=1 to MAX_NAME_SERVERS do + begin + Nameserver:=GetIPNameserver(Count); + if not CompareDefault(Nameserver) and not CompareBroadcast(Nameserver) then + begin + AddNameserver(Nameserver); + end; + end; + {Return Result} Result:=True; finally @@ -3172,7 +3314,7 @@ function TIPTransport.StopTransport:Boolean; Adapter:=TIPTransportAdapter(GetAdapterByNext(Current,True,True,NETWORK_LOCK_READ)); {Remove Adapter} - RemoveAdapter(Adapter.Adapter); + RemoveAdapter(Current.Adapter); end; {Flush all Addresses} @@ -3234,16 +3376,15 @@ function TIPTransport.ProcessTransport:Boolean; {Get Current} Current:=Adapter; Adapter:=nil; - + + {Note: No need to convert to write lock as this function is serialized by the caller} + {Check for Unconfigured} - if (not Current.Configured) and (not Current.Configuring) then + if not(Current.Configured) and not(Current.Configuring) and (Current.Adapter.Status = ADAPTER_STATUS_UP) then begin {Check for Retry} if (Current.RetryTime <> 0) and (Current.RetryTime < CurrentTime) then begin - - //To Do //ReaderConvert ? - {Configure Adapter} case Current.ConfigType of CONFIG_TYPE_STATIC:begin @@ -3528,68 +3669,84 @@ function TIPTransport.ProcessTransport:Boolean; end; end; - {Check for Lease} - if (Current.Configured) and (Current.LeaseTime <> 0) then + {Check for Configured} + if Current.Configured then begin - {Check for Renew} - if (Current.RenewalTime <> 0) and (Current.RenewalTime < CurrentTime) then + {Check Status} + if Current.Adapter.Status = ADAPTER_STATUS_UP then begin - {Call Config Handlers} - Config:=TIPTransportConfig(GetConfigByNext(nil,True,False,NETWORK_LOCK_READ)); - while Config <> nil do + {Check for Lease} + if Current.LeaseTime <> 0 then begin - if Config.ConfigType = Current.ConfigType then {Note: Cannot be Auto if Configured} + {Check for Renew} + if (Current.RenewalTime <> 0) and (Current.RenewalTime < CurrentTime) then begin - if Assigned(Config.ConfigHandler) then + {Call Config Handlers} + Config:=TIPTransportConfig(GetConfigByNext(nil,True,False,NETWORK_LOCK_READ)); + while Config <> nil do begin + if Config.ConfigType = Current.ConfigType then {Note: Cannot be Auto if Configured} + begin + if Assigned(Config.ConfigHandler) then + begin + + //To Do //Must implement a Retry Count and/or a Timeout backoff + + Config.ConfigHandler(THandle(Config),Current,CONFIG_ADAPTER_RENEW); + + end; + end; - //To Do //Must implement a Retry Count and/or a Timeout backoff - - Config.ConfigHandler(THandle(Config),Current,CONFIG_ADAPTER_RENEW); - + {Get Next} + Config:=TIPTransportConfig(GetConfigByNext(Config,True,True,NETWORK_LOCK_READ)); end; end; - - {Get Next} - Config:=TIPTransportConfig(GetConfigByNext(Config,True,True,NETWORK_LOCK_READ)); - end; - end; - - {Check for Rebind} - if (Current.RebindingTime <> 0) and (Current.RebindingTime < CurrentTime) then - begin - {Call Config Handlers} - Config:=TIPTransportConfig(GetConfigByNext(nil,True,False,NETWORK_LOCK_READ)); - while Config <> nil do - begin - if Config.ConfigType = Current.ConfigType then {Note: Cannot be Auto if Configured} + + {Check for Rebind} + if (Current.RebindingTime <> 0) and (Current.RebindingTime < CurrentTime) then begin - if Assigned(Config.ConfigHandler) then + {Call Config Handlers} + Config:=TIPTransportConfig(GetConfigByNext(nil,True,False,NETWORK_LOCK_READ)); + while Config <> nil do begin + if Config.ConfigType = Current.ConfigType then {Note: Cannot be Auto if Configured} + begin + if Assigned(Config.ConfigHandler) then + begin + + //To Do //Must implement a Retry Count and/or a Timeout backoff + + Config.ConfigHandler(THandle(Config),Current,CONFIG_ADAPTER_REBIND); + + end; + end; - //To Do //Must implement a Retry Count and/or a Timeout backoff - - Config.ConfigHandler(THandle(Config),Current,CONFIG_ADAPTER_REBIND); - + {Get Next} + Config:=TIPTransportConfig(GetConfigByNext(Config,True,True,NETWORK_LOCK_READ)); end; end; - - {Get Next} - Config:=TIPTransportConfig(GetConfigByNext(Config,True,True,NETWORK_LOCK_READ)); + + {Check for Expire} + if (Current.ExpiryTime <> 0) and (Current.ExpiryTime < CurrentTime) then + begin + {Get Next} + Adapter:=TIPTransportAdapter(GetAdapterByNext(Current,True,True,NETWORK_LOCK_READ)); + + {Remove Adapter} + RemoveAdapter(Current.Adapter); + + //To Do //This should unconfigure the adapter and start again instead of removing it + end; end; - end; - - {Check for Expire} - if (Current.ExpiryTime <> 0) and (Current.ExpiryTime < CurrentTime) then + end + else begin - {Get Next} - Adapter:=TIPTransportAdapter(GetAdapterByNext(Current,True,True,NETWORK_LOCK_READ)); - - {Remove Adapter} - RemoveAdapter(Current.Adapter); - end; + //To do //Unconfigure + + //Current.ConfigType:=Current.ConfigDefault; + end; end; - + {Get Next} if Adapter = nil then Adapter:=TIPTransportAdapter(GetAdapterByNext(Current,True,True,NETWORK_LOCK_READ)); end; @@ -3604,6 +3761,17 @@ function TIPTransport.BindTransport(AAdapter:TNetworkAdapter):Boolean; {Bind this transport to an adapter if appropriate} {Adapter: The adapter to bind to} var + Address:PInAddr; + Netmask:PInAddr; + Gateway:PInAddr; + Server:PInAddr; + + ConfigType:Word; + ConfigAddress:TInAddr; + ConfigNetmask:TInAddr; + ConfigGateway:TInAddr; + ConfigServer:TInAddr; + Adapter:TIPTransportAdapter; begin {} @@ -3620,13 +3788,14 @@ function TIPTransport.BindTransport(AAdapter:TNetworkAdapter):Boolean; {$IFDEF IP_DEBUG} if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: Adapter = ' + AAdapter.Name); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: State = ' + AdapterStateToString(AAdapter.State)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: Status = ' + AdapterStatusToString(AAdapter.Status)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: Type = ' + AdapterTypeToString(AAdapter.AdapterType)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: Media = ' + MediaTypeToString(AAdapter.MediaType)); {$ENDIF} - {Check Status} - if AAdapter.Status <> ADAPTER_STATUS_READY then Exit; + {Check State} + if AAdapter.State <> ADAPTER_STATE_ENABLED then Exit; Result:=True; @@ -3642,19 +3811,111 @@ function TIPTransport.BindTransport(AAdapter:TNetworkAdapter):Boolean; Adapter:=TIPTransportAdapter(GetAdapterByAdapter(AAdapter,True,NETWORK_LOCK_READ)); if Adapter = nil then begin + {Set Addresses} + Address:=nil; + Netmask:=nil; + Gateway:=nil; + Server:=nil; + {Check Type} case AAdapter.AdapterType of ADAPTER_TYPE_LOOPBACK:begin {Add Adapter} - Result:=AddAdapter(AAdapter,CONFIG_TYPE_LOOPBACK,nil,nil,nil,nil); + Result:=AddAdapter(AAdapter,CONFIG_TYPE_LOOPBACK,Address,Netmask,Gateway,Server); end; ADAPTER_TYPE_WIRED:begin + {Get Settings} + {IP_CONFIG} + ConfigType:=GetAdapterConfigType(AAdapter.Name); + if ConfigType <> CONFIG_TYPE_AUTO then + begin + {IP_ADDRESS} + Address:=nil; + ConfigAddress:=GetAdapterConfigAddress(AAdapter.Name); + if not CompareDefault(ConfigAddress) and not CompareBroadcast(ConfigAddress) then + begin + Address:=@ConfigAddress; + end; + {IP_NETMASK} + Netmask:=nil; + ConfigNetmask:=GetAdapterConfigNetmask(AAdapter.Name); + if not CompareDefault(ConfigNetmask) and not CompareBroadcast(ConfigNetmask) then + begin + Netmask:=@ConfigNetmask; + end; + {IP_GATEWAY} + Gateway:=nil; + ConfigGateway:=GetAdapterConfigGateway(AAdapter.Name); + if not CompareDefault(ConfigGateway) and not CompareBroadcast(ConfigGateway) then + begin + Gateway:=@ConfigGateway; + end; + {IP_SERVER} + Server:=nil; + ConfigServer:=GetAdapterConfigServer(AAdapter.Name); + if not CompareDefault(ConfigServer) and not CompareBroadcast(ConfigServer) then + begin + Server:=@ConfigServer; + end; + end; + + {$IFDEF IP_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: ConfigType = ' + ConfigTypeToString(ConfigType)); + if NETWORK_LOG_ENABLED and (Address <> nil) then NetworkLogDebug(nil,'IP: Address = ' + InAddrToString(InAddrToNetwork(Address^))); + if NETWORK_LOG_ENABLED and (Netmask <> nil) then NetworkLogDebug(nil,'IP: Netmask = ' + InAddrToString(InAddrToNetwork(Netmask^))); + if NETWORK_LOG_ENABLED and (Gateway <> nil) then NetworkLogDebug(nil,'IP: Gateway = ' + InAddrToString(InAddrToNetwork(Gateway^))); + if NETWORK_LOG_ENABLED and (Server <> nil) then NetworkLogDebug(nil,'IP: Server = ' + InAddrToString(InAddrToNetwork(Server^))); + {$ENDIF} + {Add Adapter} - Result:=AddAdapter(AAdapter,CONFIG_TYPE_AUTO,nil,nil,nil,nil); + Result:=AddAdapter(AAdapter,ConfigType,Address,Netmask,Gateway,Server); end; ADAPTER_TYPE_WIRELESS:begin + {Get Settings} + {IP_CONFIG} + ConfigType:=GetAdapterConfigType(AAdapter.Name); + if ConfigType <> CONFIG_TYPE_AUTO then + begin + {IP_ADDRESS} + Address:=nil; + ConfigAddress:=GetAdapterConfigAddress(AAdapter.Name); + if not CompareDefault(ConfigAddress) and not CompareBroadcast(ConfigAddress) then + begin + Address:=@ConfigAddress; + end; + {IP_NETMASK} + Netmask:=nil; + ConfigNetmask:=GetAdapterConfigNetmask(AAdapter.Name); + if not CompareDefault(ConfigNetmask) and not CompareBroadcast(ConfigNetmask) then + begin + Netmask:=@ConfigNetmask; + end; + {IP_GATEWAY} + Gateway:=nil; + ConfigGateway:=GetAdapterConfigGateway(AAdapter.Name); + if not CompareDefault(ConfigGateway) and not CompareBroadcast(ConfigGateway) then + begin + Gateway:=@ConfigGateway; + end; + {IP_SERVER} + Server:=nil; + ConfigServer:=GetAdapterConfigServer(AAdapter.Name); + if not CompareDefault(ConfigServer) and not CompareBroadcast(ConfigServer) then + begin + Server:=@ConfigServer; + end; + end; + + {$IFDEF IP_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: ConfigType = ' + ConfigTypeToString(ConfigType)); + if NETWORK_LOG_ENABLED and (Address <> nil) then NetworkLogDebug(nil,'IP: Address = ' + InAddrToString(InAddrToNetwork(Address^))); + if NETWORK_LOG_ENABLED and (Netmask <> nil) then NetworkLogDebug(nil,'IP: Netmask = ' + InAddrToString(InAddrToNetwork(Netmask^))); + if NETWORK_LOG_ENABLED and (Gateway <> nil) then NetworkLogDebug(nil,'IP: Gateway = ' + InAddrToString(InAddrToNetwork(Gateway^))); + if NETWORK_LOG_ENABLED and (Server <> nil) then NetworkLogDebug(nil,'IP: Server = ' + InAddrToString(InAddrToNetwork(Server^))); + {$ENDIF} + {Add Adapter} - Result:=AddAdapter(AAdapter,CONFIG_TYPE_AUTO,nil,nil,nil,nil); + Result:=AddAdapter(AAdapter,ConfigType,Address,Netmask,Gateway,Server); end; end; end @@ -3834,7 +4095,7 @@ function TIPTransport.GetHostByName(const AName:String;ALock:Boolean):TIPHostEnt Result:=Host; Exit; end - else if Lowercase(Name + AddLeadingDot(FDomainName)) = Lowercase(AName) then + else if Lowercase(Name + AddLeadingDot(Manager.Settings.DomainName)) = Lowercase(AName) then begin {Lock Host} if ALock then Host.AcquireLock; @@ -4109,8 +4370,8 @@ procedure TIPTransport.FlushHosts(All:Boolean); begin {} {$IFDEF IP_DEBUG} - //--if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: FlushHosts'); - //--if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: All = ' + BoolToStr(All)); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: FlushHosts'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: All = ' + BoolToStr(All)); {$ENDIF} {Get Tick Count} @@ -4444,8 +4705,8 @@ procedure TIPTransport.FlushRoutes(All:Boolean); begin {} {$IFDEF IP_DEBUG} - //--if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: FlushRoutes'); - //--if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: All = ' + BoolToStr(All)); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: FlushRoutes'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: All = ' + BoolToStr(All)); {$ENDIF} {Get Tick Count} @@ -4760,8 +5021,8 @@ procedure TIPTransport.FlushAddresses(All:Boolean); begin {} {$IFDEF IP_DEBUG} - //--if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: FlushAddresses'); - //--if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: All = ' + BoolToStr(All)); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: FlushAddresses'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IP: All = ' + BoolToStr(All)); {$ENDIF} {Get Address} @@ -6083,7 +6344,7 @@ procedure IPInit; if IPInitialized then Exit; {Create IP Transport} - if IP_TRANSPORT_ENABLED then + if NetworkSettings.GetBooleanDefault('IP_TRANSPORT_ENABLED',IP_TRANSPORT_ENABLED) then begin TIPTransport.Create(TransportManager,IP_TRANSPORT_NAME); end; diff --git a/source/rtl/ultibo/core/ipv6.pas b/source/rtl/ultibo/core/ipv6.pas index ac554d5..1614817 100644 --- a/source/rtl/ultibo/core/ipv6.pas +++ b/source/rtl/ultibo/core/ipv6.pas @@ -219,6 +219,7 @@ TIP6TransportAdapter = class(TTransportAdapter) RenewalTime:Int64; {DHCP Renewal Time} RebindingTime:Int64; {DHCP Rebinding Time} + ConfigDefault:Word; {BOOTP/DHCP/RARP/STATIC/PSEUDO/LOOPBACK} ConfigAddress:TIn6Addr; ConfigNetmask:TIn6Addr; ConfigGateway:TIn6Addr; @@ -245,6 +246,7 @@ TIP6TransportBinding = class(TTransportBinding) RenewalTime:Int64; {DHCP Renewal Time} RebindingTime:Int64; {DHCP Rebinding Time} + ConfigDefault:Word; {BOOTP/DHCP/RARP/STATIC/PSEUDO/LOOPBACK} ConfigAddress:TIn6Addr; ConfigNetmask:TIn6Addr; ConfigGateway:TIn6Addr; @@ -302,8 +304,6 @@ TIP6Transport = class(TNetworkTransport) FAddresses:TNetworkList; {Status Variables} - FHostName:String; - FDomainName:String; FDefaultAddress:TIn6Addr; FLoopbackAddress:TIn6Addr; FBroadcastAddress:TIn6Addr; @@ -321,14 +321,20 @@ TIP6Transport = class(TNetworkTransport) function CheckFragment(ABuffer:Pointer):Boolean; function GetNextIP6Id(AIncrement:Boolean):Word; + + function GetIP6Nameserver(ACount:LongWord):TIn6Addr; + + function GetAdapterConfigType(const AName:String):Word; + function GetAdapterConfigAddress(const AName:String):TIn6Addr; + function GetAdapterConfigNetmask(const AName:String):TIn6Addr; + function GetAdapterConfigGateway(const AName:String):TIn6Addr; + function GetAdapterConfigServer(const AName:String):TIn6Addr; protected {Inherited Methods} function FilterPacket(ASource,ADest,APacket:Pointer;ASize:Integer;ABroadcast:Boolean):Boolean; override; function ForwardPacket(AAdapter:TTransportAdapter;ASource,ADest,APacket:Pointer;ASize:Integer;ABroadcast:Boolean):Boolean; override; public {Public Properties} - property HostName:String read FHostName write FHostName; - property DomainName:String read FDomainName write FDomainName; property Nameservers:TIP6Nameservers read FNameservers; property DefaultHopLimit:LongWord read FDefaultHopLimit write FDefaultHopLimit; @@ -1002,6 +1008,7 @@ constructor TIP6TransportAdapter.Create; //LongWord(Network.S_addr):=INADDR_ANY; //LongWord(Directed.S_addr):=INADDR_BROADCAST; + ConfigDefault:=CONFIG_TYPE_AUTO; //LongWord(ConfigAddress.S_addr):=INADDR_ANY; //LongWord(ConfigNetmask.S_addr):=INADDR_ANY; //LongWord(ConfigGateway.S_addr):=INADDR_ANY; @@ -1023,6 +1030,7 @@ constructor TIP6TransportBinding.Create; //LongWord(Network.S_addr):=INADDR_ANY; //LongWord(Directed.S_addr):=INADDR_BROADCAST; + ConfigDefault:=CONFIG_TYPE_AUTO; //LongWord(ConfigAddress.S_addr):=INADDR_ANY; //LongWord(ConfigNetmask.S_addr):=INADDR_ANY; //LongWord(ConfigGateway.S_addr):=INADDR_ANY; @@ -1051,8 +1059,6 @@ constructor TIP6Transport.Create(AManager:TTransportManager;const AName:String); FNetworks:=TNetworkList.Create; FAddresses:=TNetworkList.Create; - FHostName:=Platform.HostGetName; - FDomainName:=Platform.HostGetDomain; FillChar(FNameservers,SizeOf(TIP6Nameservers),0); FNameserverLock:=MutexCreate; @@ -1217,6 +1223,93 @@ function TIP6Transport.GetNextIP6Id(AIncrement:Boolean):Word; {==============================================================================} +function TIP6Transport.GetIP6Nameserver(ACount:LongWord):TIn6Addr; +{Get the nameserver address from the network settings} +begin + {} + Result:=IN6ADDR_ANY; + + //To Do +end; + +{==============================================================================} + +function TIP6Transport.GetAdapterConfigType(const AName:String):Word; +{Get the adapter config type from the network settings} +var + Value:String; +begin + {} + Result:=CONFIG_TYPE_AUTO; + + Value:=Uppercase(Manager.Settings.GetString(AName + '_IP6_CONFIG')); + if Length(Value) <> 0 then + begin + Result:=StrToIntDef(Value,CONFIG_TYPE_UNKNOWN); + if (Result <> CONFIG_TYPE_STATIC) and (Result <> CONFIG_TYPE_DHCP) then + begin + if Value = 'STATIC' then + begin + Result:=CONFIG_TYPE_STATIC; + end + else if Value = 'DHCP' then + begin + Result:=CONFIG_TYPE_DHCP; + end + else + begin + Result:=CONFIG_TYPE_AUTO; + end; + end; + end; +end; + +{==============================================================================} + +function TIP6Transport.GetAdapterConfigAddress(const AName:String):TIn6Addr; +{Get the adapter address from the network settings} +begin + {} + Result:=IN6ADDR_ANY; + + //To Do +end; + +{==============================================================================} + +function TIP6Transport.GetAdapterConfigNetmask(const AName:String):TIn6Addr; +{Get the adapter netmask from the network settings} +begin + {} + Result:=IN6ADDR_ANY; + + //To Do +end; + +{==============================================================================} + +function TIP6Transport.GetAdapterConfigGateway(const AName:String):TIn6Addr; +{Get the adapter gateway from the network settings} +begin + {} + Result:=IN6ADDR_ANY; + + //To Do +end; + +{==============================================================================} + +function TIP6Transport.GetAdapterConfigServer(const AName:String):TIn6Addr; +{Get the adapter server from the network settings} +begin + {} + Result:=IN6ADDR_ANY; + + //To Do +end; + +{==============================================================================} + function TIP6Transport.FilterPacket(ASource,ADest,APacket:Pointer;ASize:Integer;ABroadcast:Boolean):Boolean; {Filter a received packet} {Source: The source IP6 address of the received fragment (Set by Packet or Fragment Handler)} @@ -1342,8 +1435,8 @@ function TIP6Transport.AddAdapter(AAdapter:TNetworkAdapter;AConfigType:Word;AAdd {Check Adapter} if AAdapter = nil then Exit; - {Check Status} - if AAdapter.Status <> ADAPTER_STATUS_READY then Exit; + {Check State} + if AAdapter.State <> ADAPTER_STATE_ENABLED then Exit; {Get Adapter} Adapter:=TIP6TransportAdapter(GetAdapterByAdapter(AAdapter,True,NETWORK_LOCK_READ)); @@ -1365,6 +1458,7 @@ function TIP6Transport.AddAdapter(AAdapter:TNetworkAdapter;AConfigType:Word;AAdd Adapter.ConfigType:=AConfigType; Adapter.Configured:=False; Adapter.Configuring:=False; + Adapter.ConfigDefault:=AConfigType; if AAddress <> nil then Adapter.ConfigAddress:=TIn6Addr(AAddress^); if ANetmask <> nil then Adapter.ConfigNetmask:=TIn6Addr(ANetmask^); if AGateway <> nil then Adapter.ConfigGateway:=TIn6Addr(AGateway^); @@ -1476,9 +1570,6 @@ function TIP6Transport.RemoveAdapter(AAdapter:TNetworkAdapter):Boolean; {Check for Release} if FAutoRelease then begin - - //To Do //WriterConvert ? - {Call Config Handler} if Config.ConfigHandler(THandle(Config),Adapter,CONFIG_ADAPTER_RELEASE) then begin @@ -1995,6 +2086,9 @@ function TIP6Transport.SetSockOpt(ASocket:TTransportSocket;ALevel,AOptName:Integ function TIP6Transport.StartTransport:Boolean; {Start this transport ready for sending and receiving} +var + Count:LongWord; + Nameserver:TIn6Addr; begin {} ReaderLock; @@ -2007,6 +2101,12 @@ function TIP6Transport.StartTransport:Boolean; {Check Manager} if Manager = nil then Exit; + {Add Nameservers} + for Count:=1 to MAX_NAME_SERVERS do + begin + //To Do + end; + {Return Result} Result:=True; finally @@ -2043,7 +2143,7 @@ function TIP6Transport.StopTransport:Boolean; Adapter:=TIP6TransportAdapter(GetAdapterByNext(Current,True,True,NETWORK_LOCK_READ)); {Remove Adapter} - RemoveAdapter(Adapter.Adapter); + RemoveAdapter(Current.Adapter); end; {Flush all Addresses} @@ -2100,8 +2200,10 @@ function TIP6Transport.ProcessTransport:Boolean; Current:=Adapter; Adapter:=nil; + {Note: No need to convert to write lock as this function is serialized by the caller} + {Check for Unconfigured} - if (not Current.Configured) and (not Current.Configuring) then + if not(Current.Configured) and not(Current.Configuring) and (Current.Adapter.Status = ADAPTER_STATUS_UP) then begin {Check for Retry} if (Current.RetryTime <> 0) and (Current.RetryTime < CurrentTime) then @@ -2113,60 +2215,74 @@ function TIP6Transport.ProcessTransport:Boolean; end; end; - {Check for Lease} - if (Current.Configured) and (Current.LeaseTime <> 0) then + {Check for Configured} + if Current.Configured then begin - {Check for Renew} - if (Current.RenewalTime <> 0) and (Current.RenewalTime < CurrentTime) then + {Check Status} + if Current.Adapter.Status = ADAPTER_STATUS_UP then begin - {Call Config Handlers} - Config:=TIP6TransportConfig(GetConfigByNext(nil,True,False,NETWORK_LOCK_READ)); - while Config <> nil do + {Check for Lease} + if Current.LeaseTime <> 0 then begin - if Config.ConfigType = Current.ConfigType then {Note: Cannot be Auto if Configured} + {Check for Renew} + if (Current.RenewalTime <> 0) and (Current.RenewalTime < CurrentTime) then begin - if Assigned(Config.ConfigHandler) then + {Call Config Handlers} + Config:=TIP6TransportConfig(GetConfigByNext(nil,True,False,NETWORK_LOCK_READ)); + while Config <> nil do begin - - //To Do //Must implement a Retry Count and/or a Timeout backoff - - Config.ConfigHandler(THandle(Config),Current,CONFIG_ADAPTER_RENEW); + if Config.ConfigType = Current.ConfigType then {Note: Cannot be Auto if Configured} + begin + if Assigned(Config.ConfigHandler) then + begin + + //To Do //Must implement a Retry Count and/or a Timeout backoff + + Config.ConfigHandler(THandle(Config),Current,CONFIG_ADAPTER_RENEW); + end; + end; + Config:=TIP6TransportConfig(GetConfigByNext(Config,True,True,NETWORK_LOCK_READ)); end; end; - Config:=TIP6TransportConfig(GetConfigByNext(Config,True,True,NETWORK_LOCK_READ)); - end; - end; - - {Check for Rebind} - if (Current.RebindingTime <> 0) and (Current.RebindingTime < CurrentTime) then - begin - {Call Config Handlers} - Config:=TIP6TransportConfig(GetConfigByNext(nil,True,False,NETWORK_LOCK_READ)); - while Config <> nil do - begin - if Config.ConfigType = Current.ConfigType then {Note: Cannot be Auto if Configured} + + {Check for Rebind} + if (Current.RebindingTime <> 0) and (Current.RebindingTime < CurrentTime) then begin - if Assigned(Config.ConfigHandler) then + {Call Config Handlers} + Config:=TIP6TransportConfig(GetConfigByNext(nil,True,False,NETWORK_LOCK_READ)); + while Config <> nil do begin - - //To Do //Must implement a Retry Count and/or a Timeout backoff - - Config.ConfigHandler(THandle(Config),Current,CONFIG_ADAPTER_REBIND); + if Config.ConfigType = Current.ConfigType then {Note: Cannot be Auto if Configured} + begin + if Assigned(Config.ConfigHandler) then + begin + + //To Do //Must implement a Retry Count and/or a Timeout backoff + + Config.ConfigHandler(THandle(Config),Current,CONFIG_ADAPTER_REBIND); + end; + end; + Config:=TIP6TransportConfig(GetConfigByNext(Config,True,True,NETWORK_LOCK_READ)); end; end; - Config:=TIP6TransportConfig(GetConfigByNext(Config,True,True,NETWORK_LOCK_READ)); + + {Check for Expire} + if (Current.ExpiryTime <> 0) and (Current.ExpiryTime < CurrentTime) then + begin + {Get Next} + Adapter:=TIP6TransportAdapter(GetAdapterByNext(Current,True,True,NETWORK_LOCK_READ)); + + {Remove Adapter} + RemoveAdapter(Current.Adapter); + end; end; - end; - - {Check for Expire} - if (Current.ExpiryTime <> 0) and (Current.ExpiryTime < CurrentTime) then + end + else begin - {Get Next} - Adapter:=TIP6TransportAdapter(GetAdapterByNext(Current,True,True,NETWORK_LOCK_READ)); - - {Remove Adapter} - RemoveAdapter(Current.Adapter); - end; + //To do //Unconfigure + + //Current.ConfigType:=Current.ConfigDefault; + end; end; {Get Next} @@ -2183,6 +2299,17 @@ function TIP6Transport.BindTransport(AAdapter:TNetworkAdapter):Boolean; {Bind this transport to an adapter if appropriate} {Adapter: The adapter to bind to} var + Address:PIn6Addr; + Netmask:PIn6Addr; + Gateway:PIn6Addr; + Server:PIn6Addr; + + ConfigType:Word; + ConfigAddress:TIn6Addr; + ConfigNetmask:TIn6Addr; + ConfigGateway:TIn6Addr; + ConfigServer:TIn6Addr; + Adapter:TIP6TransportAdapter; begin {} @@ -2199,13 +2326,14 @@ function TIP6Transport.BindTransport(AAdapter:TNetworkAdapter):Boolean; {$IFDEF IP6_DEBUG} if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IPv6: Adapter = ' + AAdapter.Name); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IPv6: State = ' + AdapterStateToString(AAdapter.State)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IPv6: Status = ' + AdapterStatusToString(AAdapter.Status)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IPv6: Type = ' + AdapterTypeToString(AAdapter.AdapterType)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'IPv6: Media = ' + MediaTypeToString(AAdapter.MediaType)); {$ENDIF} - - {Check Status} - if AAdapter.Status <> ADAPTER_STATUS_READY then Exit; + + {Check State} + if AAdapter.State <> ADAPTER_STATE_ENABLED then Exit; Result:=True; @@ -2221,19 +2349,43 @@ function TIP6Transport.BindTransport(AAdapter:TNetworkAdapter):Boolean; Adapter:=TIP6TransportAdapter(GetAdapterByAdapter(AAdapter,True,NETWORK_LOCK_READ)); if Adapter = nil then begin + {Set Addresses} + Address:=nil; + Netmask:=nil; + Gateway:=nil; + Server:=nil; + {Check Type} case AAdapter.AdapterType of ADAPTER_TYPE_LOOPBACK:begin {Add Adapter} - Result:=AddAdapter(AAdapter,CONFIG_TYPE_LOOPBACK,nil,nil,nil,nil); + Result:=AddAdapter(AAdapter,CONFIG_TYPE_LOOPBACK,Address,Netmask,Gateway,Server); end; ADAPTER_TYPE_WIRED:begin + {Get Settings} + {IP6_CONFIG} + ConfigType:=GetAdapterConfigType(AAdapter.Name); + if ConfigType <> CONFIG_TYPE_AUTO then + begin + //To Do + + end; + {Add Adapter} - Result:=AddAdapter(AAdapter,CONFIG_TYPE_AUTO,nil,nil,nil,nil); + Result:=AddAdapter(AAdapter,ConfigType,Address,Netmask,Gateway,Server); end; ADAPTER_TYPE_WIRELESS:begin + {Get Settings} + {IP6_CONFIG} + ConfigType:=GetAdapterConfigType(AAdapter.Name); + if ConfigType <> CONFIG_TYPE_AUTO then + begin + //To Do + + end; + {Add Adapter} - Result:=AddAdapter(AAdapter,CONFIG_TYPE_AUTO,nil,nil,nil,nil); + Result:=AddAdapter(AAdapter,ConfigType,Address,Netmask,Gateway,Server); end; end; end @@ -2413,7 +2565,7 @@ function TIP6Transport.GetHostByName(const AName:String;ALock:Boolean):TIP6HostE Result:=Host; Exit; end - else if Lowercase(Name + AddLeadingDot(FDomainName)) = Lowercase(AName) then + else if Lowercase(Name + AddLeadingDot(Manager.Settings.DomainName)) = Lowercase(AName) then begin {Lock Host} if ALock then Host.AcquireLock; @@ -4476,7 +4628,7 @@ procedure IP6Init; if IP6Initialized then Exit; {Create IPv6 Transport} - if IP6_TRANSPORT_ENABLED then + if NetworkSettings.GetBooleanDefault('IP6_TRANSPORT_ENABLED',IP6_TRANSPORT_ENABLED) then begin TIP6Transport.Create(TransportManager,IP6_TRANSPORT_NAME); end; diff --git a/source/rtl/ultibo/core/loopback.pas b/source/rtl/ultibo/core/loopback.pas index 8e03d63..d1234c2 100644 --- a/source/rtl/ultibo/core/loopback.pas +++ b/source/rtl/ultibo/core/loopback.pas @@ -161,8 +161,8 @@ function TLoopbackAdapter.AddTransport(APacketType,AFrameType:Word;const APacket if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'LoopbackAdapter: Name = ' + APacketName); {$ENDIF} - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Get Transport} Transport:=TLoopbackAdapterTransport(GetTransportByType(APacketType,AFrameType,False,NETWORK_LOCK_NONE)); {Do not lock} @@ -209,10 +209,10 @@ function TLoopbackAdapter.RemoveTransport(AHandle:THandle;APacketType:Word):Bool if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'LoopbackAdapter: Handle = ' + IntToHex(AHandle,8)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'LoopbackAdapter: Packet = ' + PacketTypeToString(APacketType)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; + {Get Transport} Transport:=TLoopbackAdapterTransport(GetTransportByHandle(AHandle,True,NETWORK_LOCK_WRITE)); {Writer due to remove} if Transport = nil then Exit; @@ -261,9 +261,9 @@ function TLoopbackAdapter.GetMTU(AHandle:THandle):Word; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'LoopbackAdapter: GetMTU (' + Name + ')'); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'LoopbackAdapter: Handle = ' + IntToHex(AHandle,8)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Return Result} Result:=MAX_ETHERNET_PACKET - ETHERNET_HEADER_SIZE; @@ -296,9 +296,9 @@ function TLoopbackAdapter.SendPacket(AHandle:THandle;ADest:Pointer;APacket:PPack {Check Packet} if APacket = nil then Exit; - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Thread} if FThread = nil then Exit; @@ -347,9 +347,9 @@ function TLoopbackAdapter.GetHardwareAddress(AHandle:THandle):THardwareAddress; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'LoopbackAdapter: GetHardwareAddress (' + Name + ')'); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'LoopbackAdapter: Handle = ' + IntToHex(AHandle,8)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Return Result} Result:=FHardwareAddress; @@ -370,12 +370,15 @@ function TLoopbackAdapter.StartAdapter:Boolean; {$IFDEF LOOPBACK_DEBUG} if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'LoopbackAdapter: StartAdapter (' + Name + ')'); {$ENDIF} - - {Check Status} - if FStatus <> ADAPTER_STATUS_UNKNOWN then Exit; - + + {Check State} + if FState <> ADAPTER_STATE_DISABLED then Exit; + + {Set State} + FState:=ADAPTER_STATE_ENABLED; + {Set Status} - FStatus:=ADAPTER_STATUS_READY; + FStatus:=ADAPTER_STATUS_UP; {Set Hardware Address} FHardwareAddress:=HARDWARE_LOOPBACK; @@ -409,8 +412,8 @@ function TLoopbackAdapter.StopAdapter:Boolean; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'LoopbackAdapter: StopAdapter (' + Name + ')'); {$ENDIF} - {Check Status} - if FStatus <> ADAPTER_STATUS_READY then Exit; + {Check State} + if FState <> ADAPTER_STATE_ENABLED then Exit; {Check Thread} if FThread = nil then Exit; @@ -437,11 +440,14 @@ function TLoopbackAdapter.StopAdapter:Boolean; Transport:=TLoopbackAdapterTransport(GetTransportByNext(Current,True,True,NETWORK_LOCK_READ)); {Remove Transport} - RemoveTransport(THandle(Transport),Transport.PacketType); + RemoveTransport(THandle(Current),Current.PacketType); end; + {Reset State} + FState:=ADAPTER_STATE_DISABLED; + {Reset Status} - FStatus:=ADAPTER_STATUS_UNKNOWN; + FStatus:=ADAPTER_STATUS_DOWN; {Reset Hardware Address} FillChar(FHardwareAddress,SizeOf(THardwareAddress),0); @@ -465,8 +471,8 @@ function TLoopbackAdapter.ProcessAdapter:Boolean; {} Result:=False; - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Thread} if FThread = nil then Exit; @@ -535,9 +541,9 @@ procedure LoopbackInit; if LoopbackInitialized then Exit; {Create Loopback Adapter} - if LOOPBACK_NETWORK_ENABLED then + if NetworkSettings.GetBooleanDefault('LOOPBACK_NETWORK_ENABLED',LOOPBACK_NETWORK_ENABLED) then begin - TLoopbackAdapter.Create(AdapterManager,nil,'Loopback Adapter'); + TLoopbackAdapter.Create(AdapterManager,nil,'Loopback'); end; LoopbackInitialized:=True; diff --git a/source/rtl/ultibo/core/network.pas b/source/rtl/ultibo/core/network.pas index 91c63c5..cb07636 100644 --- a/source/rtl/ultibo/core/network.pas +++ b/source/rtl/ultibo/core/network.pas @@ -43,10 +43,6 @@ interface //To Do //For Ethernet Frame and VLAN tagging etc see: https://en.wikipedia.org/wiki/Ethernet_frame -//To Do //Look for: - -//-- - {==============================================================================} {Global definitions} {$INCLUDE GlobalDefines.inc} @@ -99,7 +95,8 @@ interface {Network Device Flags} NETWORK_FLAG_NONE = $00000000; - //To Do //Link/Duplex/Speed others / WPA ? + NETWORK_FLAG_RX_BUFFER = $00000001; {Device supports Receive Buffer (NetworkBufferReceive/NetworkBufferRelease)} + NETWORK_FLAG_TX_BUFFER = $00000002; {Device supports Transmit Buffer (NetworkBufferAllocate/NetworkBufferTransmit)} {Network Device Control Codes} NETWORK_CONTROL_CLEAR_STATS = 1; {Clear Statistics} @@ -117,7 +114,6 @@ interface //To Do //Get DeviceId/VendorId/Stats etc //To Do //Get Overhead //To Do //Get/Set VLAN tags - //To Do //WPA information {Network Lock States} NETWORK_LOCK_NONE = 0; @@ -148,18 +144,26 @@ interface {Network Event Flags} NETWORK_EVENT_FLAG_NONE = $00000000; - //To Do ////////////////////////////////////////////////////////////// - const - {These items must also be included in Winsock.pas/Winsock2.pas} //To Do //No longer true since the addition of GlobalSock ? and other structure changes ? + {Adapter Types} ADAPTER_TYPE_UNKNOWN = 0; ADAPTER_TYPE_WIRED = 1; ADAPTER_TYPE_LOOPBACK = 2; ADAPTER_TYPE_WIRELESS = 3; + {Adapter Threads} ADAPTER_THREAD_NAME = 'Network Adapter'; {Thread name for Network adapter threads} ADAPTER_THREAD_PRIORITY = THREAD_PRIORITY_HIGHER; {Thread priority for Network adapter threads} + {Adapter State} + ADAPTER_STATE_DISABLED = 0; + ADAPTER_STATE_ENABLED = 1; + + {Adapter Status} + ADAPTER_STATUS_DOWN = 0; + ADAPTER_STATUS_UP = 1; + + {Configuration Types} CONFIG_TYPE_AUTO = 0; //To Do //Why aren't these in Transport ? CONFIG_TYPE_STATIC = 1; CONFIG_TYPE_RARP = 2; @@ -168,8 +172,15 @@ interface CONFIG_TYPE_PSEUDO = 5; CONFIG_TYPE_LOOPBACK = 6; + CONFIG_TYPE_UNKNOWN = Word(-1); + + {Authentication Types} + AUTH_TYPE_UNKNOWN = 0; + AUTH_TYPE_EAP = 1; + AUTH_TYPE_RSN = 2; + const - {Generic Network} + {Frame Types} FRAME_TYPE_UNKNOWN = 0; FRAME_TYPE_ETHERNET_II = 1; {Blue Book} FRAME_TYPE_TOKEN_RING = 3; {IEEE 802.5} @@ -180,11 +191,6 @@ interface FRAME_START_ETHERNET_SNAP = $AAAA; FRAME_START_ETHERNET_8023 = $FFFF; - - ADAPTER_STATUS_UNKNOWN = 0; //To Do //Change to Open/Close/Up/Down etc ? - ADAPTER_STATUS_READY = 1; - ADAPTER_STATUS_LINKDOWN = 2; - ADAPTER_STATUS_SHUTDOWN = 3; ADAPTER_MODE_NONE = 1; //To Do //Remove ?? //Maybe not, seem to be for Get/SetReceiveMode ? //Use for Filtering ADAPTER_MODE_LOCAL = 2; @@ -193,6 +199,7 @@ interface ADAPTER_MODE_BROADCAST_MULTI = 5; {Mode 3 plus all Multicast} ADAPTER_MODE_PROMISCUOUS = 6; {Promiscuous mode} + {Configuration Commands} //To Do //Why aren't these in Transport ? //To Do //Change these to ADAPTER_CONFIG_ instead ? (or CONFIG_COMMAND_ ? //this one) CONFIG_ADAPTER_DISCOVER = 0; {Discover an Address from the ConfigHandler} @@ -207,6 +214,12 @@ interface CONFIG_RENEW_TIMEOUT = 60000; {1 min Config Renew Timeout} CONFIG_REBIND_TIMEOUT = 60000; {1 min Config Rebind Timeout} + {Authentication Commands} + AUTH_COMMAND_ASSOCIATE = 0; + AUTH_COMMAND_DISASSOCIATE = 1; + AUTH_COMMAND_AUTHENTICATE = 2; + AUTH_COMMAND_UNAUTHENTICATE = 3; + {Multicast Addressing} MAX_MULTICAST_ADDRESS = 8; {Maximum number of addresses per adapter} @@ -222,16 +235,18 @@ interface MEDIA_TYPE_TOKENRING = $0006; {ARP type of Token-Ring Hardware (These values must not change, they are the actual values used by ARP packets)} {Packet Types} - PACKET_MIN_TYPE = $0600; - + PACKET_MIN_TYPE = $0600; {If the value Ethernet header TypeLength field is greater than this the frame is Ethernet II} + PACKET_TYPE_IP = $0800; PACKET_TYPE_IP6 = $86DD; PACKET_TYPE_ARP = $0806; PACKET_TYPE_RARP = $8035; + PACKET_TYPE_8021Q = $8100; {802.1Q with extended Ethernet header} PACKET_TYPE_IPX = $8137; {IPX on EII} PACKET_TYPE_EAPOL = $888E; {EAP-over-LAN (EAPOL)} PACKET_TYPE_RSN = $88C7; {RSN pre-authentication} + PACKET_TYPE_TDLS = $890D; {Tunneled direct-link setup} PACKET_TYPE_RAW = $FFFF; {IPX on 802.3} //To Do //$00 //See: https://en.wikipedia.org/wiki/Ethernet_frame PACKET_TYPE_LLC = $0001; {IPX on 802.2} //To Do //$E0 ?? //See: https://en.wikipedia.org/wiki/Ethernet_frame @@ -256,6 +271,13 @@ interface //To Do //////////////////////////////////////////////////////////////// + {Service Sets} + SERVICE_SET_UNKNOWN = 0; + SERVICE_SET_BSS = 1; {Basic Service Set} + SERVICE_SET_ESS = 2; {Extended Service Set} + SERVICE_SET_IBSS = 3; {Independent Basic Service Set} + SERVICE_SET_MBSS = 4; {Mesh Basic Service Set} + {Network logging} NETWORK_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG; {Network debugging messages} NETWORK_LOG_LEVEL_INFO = LOG_LEVEL_INFO; {Network informational messages, such as a device being attached or detached} @@ -298,9 +320,10 @@ interface {Network Packet} PNetworkPacket = ^TNetworkPacket; TNetworkPacket = record - Buffer:Pointer; {Pointer to buffer} - Data:Pointer; {Start of data within buffer} - Length:LongInt; {Length of packet data} + Buffer:Pointer; {Pointer to buffer (Set by driver that owns this packet)} + Data:Pointer; {Start of data within buffer (Set by driver that owns this packet)} + Length:LongInt; {Length of packet data (Set by driver on Receive / Set by caller on Transmit, contains maximum length on Allocate)} + Flags:LongWord; {Packet specific flags (eg Error, Broadcast etc) (Dependant on network type)} end; {Network Buffer} @@ -315,23 +338,23 @@ TNetworkBuffer = record {Network Entry} PNetworkEntry = ^TNetworkEntry; TNetworkEntry = record - Buffer:Pointer; {Pointer to buffer} - Size:LongWord; {Size of the buffer} - Offset:LongWord; {Offset to start of data} - Count:LongWord; {Number of packets in the entry} - DriverData:Pointer; {Driver private data} - Packets:array of PNetworkPacket; + Buffer:Pointer; {Pointer to buffer (Allocated by driver that owns this entry)} + Size:LongWord; {Size of the buffer (Total size, usable size is Size minus Offset)} + Offset:LongWord; {Offset to start of data (Data for first packet will be at Buffer plus Offset, must be less than size)} + Count:LongWord; {Number of packets in the entry (Set by driver that owns this entry, must be at least one)} + DriverData:Pointer; {Driver private data (Managed by driver that owns this entry)} + Packets:array of TNetworkPacket; {Array of 0 to Count - 1 packets in this entry (Allocated by driver that owns this entry, must be at least one)} end; {Network Queue} PNetworkQueue = ^TNetworkQueue; TNetworkQueue = record - Buffer:TBufferHandle; {Handle for buffers} - Wait:TSemaphoreHandle; {Entry ready semaphore} - Start:LongWord; {Index of first entry ready} - Count:LongWord; {Number of entries ready in queue} - Flags:LongWord; {Queue specific flags} - Entries:array of PNetworkEntry; + Buffer:TBufferHandle; {Handle for entry buffers} + Wait:TSemaphoreHandle; {Entry ready semaphore} + Start:LongWord; {Index of first entry ready} + Count:LongWord; {Number of entries ready in queue} + Flags:LongWord; {Queue specific flags (eg Paused, Halted etc) (Managed by driver)} + Entries:array of PNetworkEntry; {Array of 0 to Total - 1 entries in this queue (Allocated by driver that owns this queue)} end; {Network Device} @@ -378,13 +401,14 @@ TNetworkDevice = record TransmitBuffer:TBufferHandle; {Buffer for transmit packets} ReceiveQueue:TNetworkQueue; {Queue for receive packets} - TransmitQueue:TNetworkQueue; {Queue for transmit packets} + TransmitQueue:TNetworkQueue; {Queue for transmit packets (If applicable)} {Statistics Properties} ReceiveCount:LongWord; ReceiveErrors:LongWord; TransmitCount:LongWord; TransmitErrors:LongWord; BufferOverruns:LongWord; + BufferUnavailable:LongWord; {Internal Properties} Prev:PNetworkDevice; {Previous entry in Network table} Next:PNetworkDevice; {Next entry in Network table} @@ -465,7 +489,7 @@ TNetworkEvent = record type {Generic Adapter} - PAdapterParams = ^TAdapterParams; //To Do //Adjust for new model + PAdapterParams = ^TAdapterParams; //To Do //Adjust for new model //Remove ? TAdapterParams = packed record Version:Word; { Driver version } FrameType:Byte; { Driver class } @@ -475,7 +499,7 @@ TNetworkEvent = record Functionality:Byte; { How good is this driver } end; - PNetworkParams = ^TNetworkParams; //To Do //Adjust for new model + PNetworkParams = ^TNetworkParams; //To Do //Adjust for new model //Remove ? TNetworkParams = packed record MajorRevision:Byte; { Major revision ID of packet specs } MinorRevision:Byte; { Minor revision ID of packet specs } @@ -488,19 +512,17 @@ TNetworkEvent = record IntNo:Word; { Interrupt No to hook for post-EOI processing, 0 = none } end; - PAdapterStatistics = ^TAdapterStatistics; //To Do //Adjust for new model - TAdapterStatistics = packed record - PacketsIn:LongInt; //To Do //LongWord/Int64 ? - PacketsOut:LongInt; - BytesIn:LongInt; //To Do //Int64 - BytesOut:LongInt; //To Do //Int64 - ErrorsIn:LongInt; - ErrorsOut:LongInt; - PacketsLost:LongInt; + PAdapterStatistics = ^TAdapterStatistics; + TAdapterStatistics = record + PacketsIn:Int64; + PacketsOut:Int64; + BytesIn:Int64; + BytesOut:Int64; + ErrorsIn:Int64; + ErrorsOut:Int64; + PacketsLost:Int64; end; -//To Do /////////////////////////////////////////////////////////////////////////// - {==============================================================================} const {Network specific constants} @@ -539,13 +561,16 @@ TNetworkEvent = record TNetworkList = class; TNetworkAdapter = class; TAdapterCallback = function(AAdapter:TNetworkAdapter):Boolean of object; + + TNetworkSettings = class; TAdapterManager = class(TObject) - constructor Create; + constructor Create(ASettings:TNetworkSettings); destructor Destroy; override; private {Internal Variables} FLock:TSynchronizerHandle; + FSettings:TNetworkSettings; {Status Variables} FAdapters:TNetworkList; {List of TNetworkAdapter objects} @@ -558,6 +583,9 @@ TAdapterManager = class(TObject) function WriterLock:Boolean; function WriterUnlock:Boolean; public + {Public Properties} + property Settings:TNetworkSettings read FSettings; + {Public Methods} function AddAdapter(AAdapter:TNetworkAdapter):Boolean; function RemoveAdapter(AAdapter:TNetworkAdapter):Boolean; @@ -576,7 +604,9 @@ TAdapterManager = class(TObject) end; TAdapterPacketHandler = function(AHandle:THandle;ASource,ADest,APacket:Pointer;ASize:Integer;ABroadcast:Boolean):Boolean of object; - + TAdapterMonitorHandler = function(AHandle:THandle;APacket:Pointer;ASize:Integer;AStatus:Pointer):Boolean of object; + TAdapterAuthenticatorHandler = function(AHandle:THandle;ACommand:Word):Boolean of object; + TAdapterTransport = class(TListObject) {Upstream} constructor Create; destructor Destroy; override; @@ -616,6 +646,41 @@ TAdapterBinding = class(TListObject) {Upstream} function WriterUnlock:Boolean; end; + TAdapterMonitor = class(TListObject) {Upstream} + constructor Create; + destructor Destroy; override; + private + {Internal Variables} + FLock:TSynchronizerHandle; + public + {Status Variables} + MonitorHandler:TAdapterMonitorHandler; + + {Public Methods} + function ReaderLock:Boolean; + function ReaderUnlock:Boolean; + function WriterLock:Boolean; + function WriterUnlock:Boolean; + end; + + TAdapterAuthenticator = class(TListObject) {Upstream} + constructor Create; + destructor Destroy; override; + private + {Internal Variables} + FLock:TSynchronizerHandle; + public + {Status Variables} + AuthType:Word; {EAP/RSN} + AuthenticatorHandler:TAdapterAuthenticatorHandler; + + {Public Methods} + function ReaderLock:Boolean; + function ReaderUnlock:Boolean; + function WriterLock:Boolean; + function WriterUnlock:Boolean; + end; + TNetworkList = class(TLinkedObjList) constructor Create; destructor Destroy; override; @@ -648,14 +713,19 @@ TNetworkAdapter = class(TListObject) FName:String; {Status Variables} + FState:Integer; FStatus:Integer; FMediaType:Word; {Physical Media type (Ethernet/Tokenring etc)} FAdapterType:Word; FLastError:Integer; FThread:TAdapterThread; {Thread for adapter receiving} FBindings:TNetworkList; {List of TAdapterBinding objects} - FTransports:TNetworkList; {List of TAdapterTranport objects} - + FTransports:TNetworkList; {List of TAdapterTransport objects} + FMonitors:TNetworkList; {List of TAdapterMonitor objects} + FAuthenticators:TNetworkList; {List of TAdapterAuthenticator objects} + + FStatistics:TAdapterStatistics; + {Event Methods} {Internal Methods} @@ -672,6 +742,15 @@ TNetworkAdapter = class(TListObject) function GetBindingByBinding(ABinding:TAdapterBinding;ALock:Boolean;AState:LongWord):TAdapterBinding; function GetBindingByNext(APrevious:TAdapterBinding;ALock,AUnlock:Boolean;AState:LongWord):TAdapterBinding; + function GetMonitorByHandle(AHandle:THandle;ALock:Boolean;AState:LongWord):TAdapterMonitor; + function GetMonitorByMonitor(AMonitor:TAdapterMonitor;ALock:Boolean;AState:LongWord):TAdapterMonitor; + function GetMonitorByNext(APrevious:TAdapterMonitor;ALock,AUnlock:Boolean;AState:LongWord):TAdapterMonitor; + + function GetAuthenticatorByHandle(AHandle:THandle;ALock:Boolean;AState:LongWord):TAdapterAuthenticator; + function GetAuthenticatorByType(AAuthType:Word;ALock:Boolean;AState:LongWord):TAdapterAuthenticator; + function GetAuthenticatorByAuthenticator(AAuthenticator:TAdapterAuthenticator;ALock:Boolean;AState:LongWord):TAdapterAuthenticator; + function GetAuthenticatorByNext(APrevious:TAdapterAuthenticator;ALock,AUnlock:Boolean;AState:LongWord):TAdapterAuthenticator; + {Protected Methods} function AddBinding(ATransport:TAdapterTransport;APacketType,AFrameType:Word):THandle; virtual; function RemoveBinding(AHandle:THandle;APacketType:Word):Boolean; virtual; @@ -681,6 +760,7 @@ TNetworkAdapter = class(TListObject) property Device:PNetworkDevice read FDevice; property Name:String read FName; //To Do //Does this need lock protection and UniqueString ? //Yes //LocalLock(Mutex) + property State:Integer read FState; property Status:Integer read FStatus; property MediaType:Word read FMediaType; property AdapterType:Word read FAdapterType; @@ -696,6 +776,12 @@ TNetworkAdapter = class(TListObject) function AddTransport(APacketType,AFrameType:Word;const APacketName:String;APacketHandler:TAdapterPacketHandler):THandle; virtual; function RemoveTransport(AHandle:THandle;APacketType:Word):Boolean; virtual; + function AddMonitor(AMonitorHandler:TAdapterMonitorHandler):THandle; virtual; + function RemoveMonitor(AHandle:THandle):Boolean; virtual; + + function AddAuthenticator(AAuthType:Word;AAuthenticatorHandler:TAdapterAuthenticatorHandler):THandle; virtual; + function RemoveAuthenticator(AHandle:THandle;AAuthType:Word):Boolean; virtual; + function GetMTU(AHandle:THandle):Word; virtual; function SendPacket(AHandle:THandle;ADest:Pointer;APacket:PPacketFragment;ASize:Integer):Boolean; virtual; @@ -814,10 +900,151 @@ TWiredAdapter = class(TNetworkAdapter) function ProcessAdapter:Boolean; override; end; + TNetworkSetting = class(TListObject) + private + {Internal Variables} + FName:String; + FValue:String; + + FHash:LongWord; + + {Internal Methods} + procedure SetName(const AName:String); + public + {Public Properties} + property Name:String read FName write SetName; + property Value:String read FValue write FValue; + + property Hash:LongWord read FHash; + end; + + TNetworkSettings = class(TObject) + constructor Create; + destructor Destroy; override; + private + {Internal Variables} + FLock:TSynchronizerHandle; + FLocalLock:TMutexHandle; + + {Status Variables} + FHostName:String; + FDomainName:String; + FList:TLinkedObjList; + + {Event Variables} + + {Internal Methods} + function ReaderLock:Boolean; + function ReaderUnlock:Boolean; + function WriterLock:Boolean; + function WriterUnlock:Boolean; + + function AcquireLock:Boolean; + function ReleaseLock:Boolean; + + function GetHostName:String; + procedure SetHostName(const AHostName:String); + + function GetDomainName:String; + procedure SetDomainName(const ADomainName:String); + + function ExtractName(const AValue,AToken:String):String; + function ExtractValue(const AValue,AToken:String):String; + function ExtractPrefix(const AValue:String):String; + + function SplitName(const AName:String):String; + function SplitPrefix(const AName:String):String; + + function MergePrefix(const APrefix,AName:String):String; + + function TranslateString(const AValue,ADefault:String):String; + function TranslateInteger(const AValue:String;ADefault:Integer):Integer; + function TranslateBoolean(const AValue:String;ADefault:Boolean):Boolean; + + function GetFromList(const AName:String):TNetworkSetting; + + function FindFromList(const AName:String):String; + function FindFromEnvironment(const AName:String):String; + public + {Public Properties} + property HostName:String read GetHostName write SetHostName; + property DomainName:String read GetDomainName write SetDomainName; + + {Public Methods} + function GetString(const AName:String):String; + function GetStringDefault(const AName,ADefault:String):String; + + function GetInteger(const AName:String):Integer; + function GetIntegerDefault(const AName:String;ADefault:Integer):Integer; + + function GetBoolean(const AName:String):Boolean; + function GetBooleanDefault(const AName:String;ADefault:Boolean):Boolean; + + function AddString(const AName,AValue:String):Boolean; + function AddInteger(const AName:String;AValue:Integer):Boolean; + function AddBoolean(const AName:String;AValue:Boolean):Boolean; + + function Remove(const AName:String):Boolean; + + function LoadFromFile(const AFileName:String;AFlat:Boolean):Boolean; + function LoadFromStream(AStream:TStream;AFlat:Boolean):Boolean; + function LoadFromStrings(AStrings:TStrings;AFlat:Boolean):Boolean; + + function SaveToFile(const AFileName:String;AFlat:Boolean):Boolean; + function SaveToStream(AStream:TStream;AFlat:Boolean):Boolean; + function SaveToStrings(AStrings:TStrings;AFlat:Boolean):Boolean; + + function LoadFromEnvironment:Boolean; + end; + + TServiceSet = class(TListObject) + constructor Create; + destructor Destroy; override; + private + {Internal Variables} + FLock:TSynchronizerHandle; + FLocalLock:TMutexHandle; + + {Internal Methods} + function GetName:String; + procedure SetName(const AName:String); + procedure SetServiceSetType(AServiceSetType:LongWord); + procedure SetServiceSetTime(const AServiceSetTime:Int64); + procedure SetAddress(const AAddress:THardwareAddress); + procedure SetAdapter(AAdapter:TNetworkAdapter); + protected + {Status Variables} + FName:String; + FServiceSetType:LongWord; {BSS/ESS/IBSS} + FServiceSetTime:Int64; {Flush time} + FAddress:THardwareAddress; {Address of service set} + FAdapter:TNetworkAdapter; + + {Internal Methods} + function AcquireLock:Boolean; + function ReleaseLock:Boolean; + public + {Public Properties} + property Name:String read GetName write SetName; + property ServiceSetType:LongWord read FServiceSetType write SetServiceSetType; + property ServiceSetTime:Int64 read FServiceSetTime write SetServiceSetTime; + property Address:THardwareAddress read FAddress write SetAddress; + property Adapter:TNetworkAdapter read FAdapter write SetAdapter; + + {Public Methods} + function ReaderLock:Boolean; + function ReaderUnlock:Boolean; + function ReaderConvert:Boolean; + function WriterLock:Boolean; + function WriterUnlock:Boolean; + function WriterConvert:Boolean; + end; + {==============================================================================} var {Network specific variables} AdapterManager:TAdapterManager; + NetworkSettings:TNetworkSettings; {==============================================================================} {var} @@ -868,7 +1095,12 @@ function NetworkEventDeregister(Handle:THandle):LongWord; function NetworkEventNotify(Event:LongWord):LongWord; {==============================================================================} -{Ethernet Functions} +{RTL Network Functions} +function SysHostGetName:String; +function SysHostSetName(const AName:String):Boolean; + +function SysHostGetDomain:String; +function SysHostSetDomain(const ADomain:String):Boolean; {==============================================================================} {Network Helper Functions} @@ -901,6 +1133,7 @@ function CompareHardwareMulticast(const AAddress:THardwareAddress):Boolean; function AdapterTypeToString(AType:Word):String; function AdapterModeToString(AMode:Word):String; function AdapterConfigToString(AConfig:Word):String; +function AdapterStateToString(AState:Integer):String; function AdapterStatusToString(AStatus:Integer):String; function FrameTypeToString(AType:Word):String; @@ -910,8 +1143,8 @@ function PacketTypetoString(AType:Word):String; function ConfigTypeToString(AType:Word):String; function ConfigCommandToString(ACommand:Word):String; -{==============================================================================} -{Ethernet Helper Functions} +function AuthTypeToString(AType:Word):String; +function AuthCommandToString(ACommand:Word):String; {==============================================================================} {==============================================================================} @@ -942,11 +1175,12 @@ implementation {==============================================================================} {==============================================================================} {TAdapterManager} -constructor TAdapterManager.Create; +constructor TAdapterManager.Create(ASettings:TNetworkSettings); begin {} inherited Create; FLock:=SynchronizerCreate; + FSettings:=ASettings; FAdapters:=TNetworkList.Create; end; @@ -959,6 +1193,7 @@ destructor TAdapterManager.Destroy; WriterLock; try FAdapters.Free; + FSettings:=nil; inherited Destroy; finally {WriterUnlock;} {Can destroy Synchronizer while holding lock} @@ -1215,8 +1450,12 @@ function TAdapterManager.StartAdapters:Boolean; Adapter:=TNetworkAdapter(GetAdapterByNext(nil,True,False,NETWORK_LOCK_READ)); while Adapter <> nil do begin - {Start Adapter} - if not(Adapter.StartAdapter) then Result:=False; + {Check Adapter} + if not Settings.GetBoolean(Adapter.Name + '_DISABLED') then + begin + {Start Adapter} + if not(Adapter.StartAdapter) then Result:=False; + end; {Get Next} Adapter:=TNetworkAdapter(GetAdapterByNext(Adapter,True,True,NETWORK_LOCK_READ)); @@ -1268,7 +1507,7 @@ function TAdapterManager.ProcessStatus:Boolean; Result:=True; {$IFDEF NETWORK_DEBUG} - //--if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'AdapterManager: ProcessStatus'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'AdapterManager: ProcessStatus'); {$ENDIF} {Get Adapter} @@ -1298,7 +1537,7 @@ function TAdapterManager.ProcessAdapters:Boolean; Result:=True; {$IFDEF NETWORK_DEBUG} - //--if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'AdapterManager: ProcessAdapters'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'AdapterManager: ProcessAdapters'); {$ENDIF} {Get Adapter} @@ -1474,6 +1713,125 @@ function TAdapterBinding.WriterUnlock:Boolean; Result:=(SynchronizerWriterUnlock(FLock) = ERROR_SUCCESS); end; +{==============================================================================} +{==============================================================================} +{TAdapterMonitor} +constructor TAdapterMonitor.Create; +begin + {} + inherited Create; + FLock:=SynchronizerCreate; + + MonitorHandler:=nil; +end; + +{==============================================================================} + +destructor TAdapterMonitor.Destroy; +begin + {} + WriterLock; + try + MonitorHandler:=nil; + inherited Destroy; + finally + {WriterUnlock;} {Can destroy Synchronizer while holding lock} + SynchronizerDestroy(FLock); + end; +end; + +{==============================================================================} + +function TAdapterMonitor.ReaderLock:Boolean; +begin + {} + Result:=(SynchronizerReaderLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TAdapterMonitor.ReaderUnlock:Boolean; +begin + {} + Result:=(SynchronizerReaderUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TAdapterMonitor.WriterLock:Boolean; +begin + {} + Result:=(SynchronizerWriterLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TAdapterMonitor.WriterUnlock:Boolean; +begin + {} + Result:=(SynchronizerWriterUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} +{==============================================================================} +{TAdapterAuthenticator} +constructor TAdapterAuthenticator.Create; +begin + {} + inherited Create; + FLock:=SynchronizerCreate; + + AuthType:=AUTH_TYPE_UNKNOWN; + AuthenticatorHandler:=nil; +end; + +{==============================================================================} + +destructor TAdapterAuthenticator.Destroy; +begin + {} + WriterLock; + try + AuthenticatorHandler:=nil; + inherited Destroy; + finally + {WriterUnlock;} {Can destroy Synchronizer while holding lock} + SynchronizerDestroy(FLock); + end; +end; + +{==============================================================================} + +function TAdapterAuthenticator.ReaderLock:Boolean; +begin + {} + Result:=(SynchronizerReaderLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TAdapterAuthenticator.ReaderUnlock:Boolean; +begin + {} + Result:=(SynchronizerReaderUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TAdapterAuthenticator.WriterLock:Boolean; +begin + {} + Result:=(SynchronizerWriterLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TAdapterAuthenticator.WriterUnlock:Boolean; +begin + {} + Result:=(SynchronizerWriterUnlock(FLock) = ERROR_SUCCESS); +end; + {==============================================================================} {==============================================================================} {TNetworkList} @@ -1590,14 +1948,18 @@ constructor TNetworkAdapter.Create(AManager:TAdapterManager;ADevice:PNetworkDevi FManager:=AManager; FDevice:=ADevice; FName:=AName; - - FStatus:=ADAPTER_STATUS_UNKNOWN; + + FState:=ADAPTER_STATE_DISABLED; + FStatus:=ADAPTER_STATUS_DOWN; FMediaType:=MEDIA_TYPE_UNKNOWN; FAdapterType:=ADAPTER_TYPE_UNKNOWN; FLastError:=0; FThread:=nil; FBindings:=TNetworkList.Create; FTransports:=TNetworkList.Create; + FMonitors:=TNetworkList.Create; + FAuthenticators:=TNetworkList.Create; + FillChar(FStatistics,SizeOf(TAdapterStatistics),0); if FManager <> nil then FManager.AddAdapter(Self); end; @@ -1609,10 +1971,13 @@ destructor TNetworkAdapter.Destroy; WriterLock; try if FManager <> nil then FManager.RemoveAdapter(Self); + FAuthenticators.Free; + FMonitors.Free; FTransports.Free; FBindings.Free; FThread:=nil; - FStatus:=ADAPTER_STATUS_UNKNOWN; + FState:=ADAPTER_STATE_DISABLED; + FStatus:=ADAPTER_STATUS_DOWN; FDevice:=nil; FManager:=nil; inherited Destroy; @@ -1970,21 +2335,283 @@ function TNetworkAdapter.GetBindingByNext(APrevious:TAdapterBinding;ALock,AUnloc {==============================================================================} -function TNetworkAdapter.AddBinding(ATransport:TAdapterTransport;APacketType,AFrameType:Word):THandle; -begin - {Virtual Base Method} - Result:=INVALID_HANDLE_VALUE; -end; - -{==============================================================================} - -function TNetworkAdapter.RemoveBinding(AHandle:THandle;APacketType:Word):Boolean; +function TNetworkAdapter.GetMonitorByHandle(AHandle:THandle;ALock:Boolean;AState:LongWord):TAdapterMonitor; +var + Monitor:TAdapterMonitor; begin - {Virtual Base Method} - Result:=False; -end; + {} + FMonitors.ReaderLock; + try + Result:=nil; -{==============================================================================} + {Get Monitor} + Monitor:=TAdapterMonitor(FMonitors.First); + while Monitor <> nil do + begin + {Check Monitor} + if THandle(Monitor) = AHandle then + begin + {Lock Monitor} + if ALock then if AState = NETWORK_LOCK_READ then Monitor.ReaderLock else Monitor.WriterLock; + + {Return Result} + Result:=Monitor; + Exit; + end; + + {Get Next} + Monitor:=TAdapterMonitor(Monitor.Next); + end; + finally + FMonitors.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkAdapter.GetMonitorByMonitor(AMonitor:TAdapterMonitor;ALock:Boolean;AState:LongWord):TAdapterMonitor; +var + Monitor:TAdapterMonitor; +begin + {} + FMonitors.ReaderLock; + try + Result:=nil; + + {Get Monitor} + Monitor:=TAdapterMonitor(FMonitors.First); + while Monitor <> nil do + begin + {Check Monitor} + if Monitor = AMonitor then + begin + {Lock Monitor} + if ALock then if AState = NETWORK_LOCK_READ then Monitor.ReaderLock else Monitor.WriterLock; + + {Return Result} + Result:=Monitor; + Exit; + end; + + {Get Next} + Monitor:=TAdapterMonitor(Monitor.Next); + end; + finally + FMonitors.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkAdapter.GetMonitorByNext(APrevious:TAdapterMonitor;ALock,AUnlock:Boolean;AState:LongWord):TAdapterMonitor; +var + Monitor:TAdapterMonitor; +begin + {} + FMonitors.ReaderLock; + try + Result:=nil; + + {Check Previous} + if APrevious = nil then + begin + {Get First} + Monitor:=TAdapterMonitor(FMonitors.First); + if Monitor <> nil then + begin + {Lock Monitor} + if ALock then if AState = NETWORK_LOCK_READ then Monitor.ReaderLock else Monitor.WriterLock; + + {Return Result} + Result:=Monitor; + end; + end + else + begin + {Get Next} + Monitor:=TAdapterMonitor(APrevious.Next); + if Monitor <> nil then + begin + {Lock Monitor} + if ALock then if AState = NETWORK_LOCK_READ then Monitor.ReaderLock else Monitor.WriterLock; + + {Return Result} + Result:=Monitor; + end; + + {Unlock Previous} + if AUnlock then if AState = NETWORK_LOCK_READ then APrevious.ReaderUnlock else APrevious.WriterUnlock; + end; + finally + FMonitors.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkAdapter.GetAuthenticatorByHandle(AHandle:THandle;ALock:Boolean;AState:LongWord):TAdapterAuthenticator; +var + Authenticator:TAdapterAuthenticator; +begin + {} + FAuthenticators.ReaderLock; + try + Result:=nil; + + {Get Authenticator} + Authenticator:=TAdapterAuthenticator(FAuthenticators.First); + while Authenticator <> nil do + begin + {Check Authenticator} + if THandle(Authenticator) = AHandle then + begin + {Lock Authenticator} + if ALock then if AState = NETWORK_LOCK_READ then Authenticator.ReaderLock else Authenticator.WriterLock; + + {Return Result} + Result:=Authenticator; + Exit; + end; + + {Get Next} + Authenticator:=TAdapterAuthenticator(Authenticator.Next); + end; + finally + FAuthenticators.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkAdapter.GetAuthenticatorByType(AAuthType:Word;ALock:Boolean;AState:LongWord):TAdapterAuthenticator; +var + Authenticator:TAdapterAuthenticator; +begin + {} + FAuthenticators.ReaderLock; + try + Result:=nil; + + {Get Authenticator} + Authenticator:=TAdapterAuthenticator(FAuthenticators.First); + while Authenticator <> nil do + begin + {Check Authenticator} + if Authenticator.AuthType = AAuthType then + begin + {Lock Authenticator} + if ALock then if AState = NETWORK_LOCK_READ then Authenticator.ReaderLock else Authenticator.WriterLock; + + {Return Result} + Result:=Authenticator; + Exit; + end; + + {Get Next} + Authenticator:=TAdapterAuthenticator(Authenticator.Next); + end; + finally + FAuthenticators.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkAdapter.GetAuthenticatorByAuthenticator(AAuthenticator:TAdapterAuthenticator;ALock:Boolean;AState:LongWord):TAdapterAuthenticator; +var + Authenticator:TAdapterAuthenticator; +begin + {} + FAuthenticators.ReaderLock; + try + Result:=nil; + + {Get Authenticator} + Authenticator:=TAdapterAuthenticator(FAuthenticators.First); + while Authenticator <> nil do + begin + {Check Authenticator} + if Authenticator = AAuthenticator then + begin + {Lock Authenticator} + if ALock then if AState = NETWORK_LOCK_READ then Authenticator.ReaderLock else Authenticator.WriterLock; + + {Return Result} + Result:=Authenticator; + Exit; + end; + + {Get Next} + Authenticator:=TAdapterAuthenticator(Authenticator.Next); + end; + finally + FAuthenticators.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkAdapter.GetAuthenticatorByNext(APrevious:TAdapterAuthenticator;ALock,AUnlock:Boolean;AState:LongWord):TAdapterAuthenticator; +var + Authenticator:TAdapterAuthenticator; +begin + {} + FAuthenticators.ReaderLock; + try + Result:=nil; + + {Check Previous} + if APrevious = nil then + begin + {Get First} + Authenticator:=TAdapterAuthenticator(FAuthenticators.First); + if Authenticator <> nil then + begin + {Lock Authenticator} + if ALock then if AState = NETWORK_LOCK_READ then Authenticator.ReaderLock else Authenticator.WriterLock; + + {Return Result} + Result:=Authenticator; + end; + end + else + begin + {Get Next} + Authenticator:=TAdapterAuthenticator(APrevious.Next); + if Authenticator <> nil then + begin + {Lock Authenticator} + if ALock then if AState = NETWORK_LOCK_READ then Authenticator.ReaderLock else Authenticator.WriterLock; + + {Return Result} + Result:=Authenticator; + end; + + {Unlock Previous} + if AUnlock then if AState = NETWORK_LOCK_READ then APrevious.ReaderUnlock else APrevious.WriterUnlock; + end; + finally + FAuthenticators.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkAdapter.AddBinding(ATransport:TAdapterTransport;APacketType,AFrameType:Word):THandle; +begin + {Virtual Base Method} + Result:=INVALID_HANDLE_VALUE; +end; + +{==============================================================================} + +function TNetworkAdapter.RemoveBinding(AHandle:THandle;APacketType:Word):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} function TNetworkAdapter.ReaderLock:Boolean; begin @@ -2034,6 +2661,38 @@ function TNetworkAdapter.RemoveTransport(AHandle:THandle;APacketType:Word):Boole {==============================================================================} +function TNetworkAdapter.AddMonitor(AMonitorHandler:TAdapterMonitorHandler):THandle; +begin + {Virtual Base Method} + Result:=INVALID_HANDLE_VALUE; +end; + +{==============================================================================} + +function TNetworkAdapter.RemoveMonitor(AHandle:THandle):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkAdapter.AddAuthenticator(AAuthType:Word;AAuthenticatorHandler:TAdapterAuthenticatorHandler):THandle; +begin + {Virtual Base Method} + Result:=INVALID_HANDLE_VALUE; +end; + +{==============================================================================} + +function TNetworkAdapter.RemoveAuthenticator(AHandle:THandle;AAuthType:Word):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + function TNetworkAdapter.GetMTU(AHandle:THandle):Word; begin {Virtual Base Method} @@ -2520,8 +3179,8 @@ function TWiredAdapter.AddTransport(APacketType,AFrameType:Word;const APacketNam if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Name = ' + APacketName); {$ENDIF} - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2540,6 +3199,11 @@ function TWiredAdapter.AddTransport(APacketType,AFrameType:Word;const APacketNam {Check Media Type} if FMediaType <> MEDIA_TYPE_TOKENRING then Exit; end; + else + begin + {Invalid} + Exit; + end; end; {Create Transport} @@ -2582,9 +3246,9 @@ function TWiredAdapter.RemoveTransport(AHandle:THandle;APacketType:Word):Boolean if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Handle = ' + IntToHex(AHandle,8)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Packet = ' + PacketTypeToString(APacketType)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Get Transport} Transport:=TAdapterTransport(GetTransportByHandle(AHandle,True,NETWORK_LOCK_WRITE)); {Writer due to remove} @@ -2637,8 +3301,8 @@ function TWiredAdapter.GetMTU(AHandle:THandle):Word; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Handle = ' + IntToHex(AHandle,8)); {$ENDIF} - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2680,9 +3344,9 @@ function TWiredAdapter.SendPacket(AHandle:THandle;ADest:Pointer;APacket:PPacketF {Check Packet} if APacket = nil then Exit; - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2787,9 +3451,9 @@ function TWiredAdapter.GetDefaultAddress(AHandle:THandle):THardwareAddress; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: GetDefaultAddress (' + Name + ')'); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Handle = ' + IntToHex(AHandle,8)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2816,9 +3480,9 @@ function TWiredAdapter.GetHardwareAddress(AHandle:THandle):THardwareAddress; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: GetHardwareAddress (' + Name + ')'); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Handle = ' + IntToHex(AHandle,8)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2846,9 +3510,9 @@ function TWiredAdapter.SetHardwareAddress(AHandle:THandle;const AAddress:THardwa if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Handle = ' + IntToHex(AHandle,8)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Address = ' + HardwareAddressToString(AAddress)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2881,9 +3545,9 @@ function TWiredAdapter.GetBroadcastAddress(AHandle:THandle):THardwareAddress; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: GetBroadcastAddress (' + Name + ')'); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Handle = ' + IntToHex(AHandle,8)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2908,9 +3572,9 @@ function TWiredAdapter.GetMulticastAddresses(AHandle:THandle):TMulticastAddresse if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: GetMulticastAddresses (' + Name + ')'); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Handle = ' + IntToHex(AHandle,8)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2935,9 +3599,9 @@ function TWiredAdapter.AddMulticastAddress(AHandle:THandle;const AAddress:THardw if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Handle = ' + IntToHex(AHandle,8)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Address = ' + HardwareAddressToString(AAddress)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2962,9 +3626,9 @@ function TWiredAdapter.RemoveMulticastAddress(AHandle:THandle;const AAddress:THa if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Handle = ' + IntToHex(AHandle,8)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Address = ' + HardwareAddressToString(AAddress)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2987,10 +3651,10 @@ function TWiredAdapter.StartAdapter:Boolean; {$IFDEF NETWORK_DEBUG} if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: StartAdapter (' + Name + ')'); {$ENDIF} - - {Check Status} - if FStatus <> ADAPTER_STATUS_UNKNOWN then Exit; - + + {Check State} + if FState <> ADAPTER_STATE_DISABLED then Exit; + {Check Device} if FDevice = nil then Exit; @@ -3004,8 +3668,11 @@ function TWiredAdapter.StartAdapter:Boolean; {Open Device} if FDevice.DeviceOpen(FDevice) = ERROR_SUCCESS then begin - {Set Status} - FStatus:=ADAPTER_STATUS_READY; + {Set State} + FState:=ADAPTER_STATE_ENABLED; + + {Get Status} + FStatus:=ADAPTER_STATUS_UP; //To Do //Get status from Device (DeviceControl) {Get Properties} FDefaultAddress:=GetDefaultAddress(INVALID_HANDLE_VALUE); @@ -3045,8 +3712,8 @@ function TWiredAdapter.StopAdapter:Boolean; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: StopAdapter (' + Name + ')'); {$ENDIF} - {Check Status} - if FStatus <> ADAPTER_STATUS_READY then Exit; + {Check State} + if FState <> ADAPTER_STATE_ENABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -3077,12 +3744,15 @@ function TWiredAdapter.StopAdapter:Boolean; Transport:=TAdapterTransport(GetTransportByNext(Current,True,True,NETWORK_LOCK_READ)); {Remove Transport} - RemoveTransport(THandle(Transport),Transport.PacketType); + RemoveTransport(THandle(Current),Current.PacketType); end; + {Reset State} + FState:=ADAPTER_STATE_DISABLED; + {Reset Status} - FStatus:=ADAPTER_STATUS_UNKNOWN; - + FStatus:=ADAPTER_STATUS_DOWN; + {Reset Properties} FillChar(FDefaultAddress,SizeOf(THardwareAddress),0); FillChar(FHardwareAddress,SizeOf(THardwareAddress),0); @@ -3117,8 +3787,8 @@ function TWiredAdapter.ProcessAdapter:Boolean; {} Result:=False; - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -3162,6 +3832,8 @@ function TWiredAdapter.ProcessAdapter:Boolean; {Determine Frame Type} FrameType:=FRAME_TYPE_UNKNOWN; + //To Do //Check for 802.1Q tag here, TypeLength = 0x8100 if tagged, real TypeLength is after the 4 byte 802.1Q tag + {Check Type Length} if WordBEtoN(Ethernet.TypeLength) > PACKET_MIN_TYPE then begin @@ -3223,43 +3895,1137 @@ function TWiredAdapter.ProcessAdapter:Boolean; {Get Frame Type} FrameType:=FRAME_TYPE_ETHERNET_8022; - {Get LLC} - LLC:=PLLCHeader(@Ethernet.Data); - - Exit; //To Do - end; - end; - end; - MEDIA_TYPE_TOKENRING:begin - Exit; //To Do - end; - end; - - {$IFDEF NETWORK_DEBUG} - if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Packet = ' + PacketTypeToString(PacketType)); - if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Size = ' + IntToStr(Size)); - {$ENDIF} - - {Get Transport} - Transport:=TAdapterTransport(GetTransportByType(PacketType,FrameType,True,NETWORK_LOCK_READ)); - if Transport = nil then Exit; - try - {Check Handler} - if not(Assigned(Transport.PacketHandler)) then Exit; - - {Call the Packet Handler} - Transport.PacketHandler(THandle(Transport),Source,Dest,Data,Size,CompareBroadcast(THandle(Transport),Dest^)); - - {Return Result} - Result:=True; - finally - Transport.ReaderUnlock; - end; - end; - finally - {Release Buffer} //To Do //Call Device to Release for non copy - FreeMem(Buffer); - end; + {Get LLC} + LLC:=PLLCHeader(@Ethernet.Data); + + Exit; //To Do + end; + end; + end; + MEDIA_TYPE_TOKENRING:begin + Exit; //To Do + end; + end; + + {$IFDEF NETWORK_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Packet = ' + PacketTypeToString(PacketType)); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiredAdapter: Size = ' + IntToStr(Size)); + {$ENDIF} + + {Get Transport} + Transport:=TAdapterTransport(GetTransportByType(PacketType,FrameType,True,NETWORK_LOCK_READ)); + if Transport = nil then Exit; + try + {Check Handler} + if not(Assigned(Transport.PacketHandler)) then Exit; + + {Call the Packet Handler} + Transport.PacketHandler(THandle(Transport),Source,Dest,Data,Size,CompareBroadcast(THandle(Transport),Dest^)); + + {Return Result} + Result:=True; + finally + Transport.ReaderUnlock; + end; + end; + finally + {Release Buffer} //To Do //Call Device to Release for non copy + FreeMem(Buffer); + end; +end; + +{==============================================================================} +{==============================================================================} +{TNetworkSetting} +procedure TNetworkSetting.SetName(const AName:String); +begin + {} + FName:=AName; + FHash:=GenerateNameHash(FName,stringHashSize); +end; + +{==============================================================================} +{==============================================================================} +{TNetworkSettings} +constructor TNetworkSettings.Create; +begin + {} + inherited Create; + FLock:=SynchronizerCreate; + FLocalLock:=MutexCreate; + + FList:=TLinkedObjList.Create; +end; + +{==============================================================================} + +destructor TNetworkSettings.Destroy; +begin + {} + WriterLock; + try + FList.Free; + MutexDestroy(FLocalLock); + inherited Destroy; + finally + {WriterUnlock;} {Can destroy Synchronizer while holding lock} + SynchronizerDestroy(FLock); + end; +end; + +{==============================================================================} + +function TNetworkSettings.ReaderLock:Boolean; +begin + {} + Result:=(SynchronizerReaderLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkSettings.ReaderUnlock:Boolean; +begin + {} + Result:=(SynchronizerReaderUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkSettings.WriterLock:Boolean; +begin + {} + Result:=(SynchronizerWriterLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkSettings.WriterUnlock:Boolean; +begin + {} + Result:=(SynchronizerWriterUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkSettings.AcquireLock:Boolean; +begin + {} + Result:=(MutexLock(FLocalLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkSettings.ReleaseLock:Boolean; +begin + {} + Result:=(MutexUnlock(FLocalLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkSettings.GetHostName:String; +begin + {} + Result:=''; + + if not AcquireLock then Exit; + + {Check Host Name} + if Length(FHostName) = 0 then + begin + {Get Host Name} + FHostName:=GetString('HOST_NAME'); + UniqueString(FHostName); + end; + + {Return Host Name} + Result:=FHostName; + UniqueString(Result); + + ReleaseLock; +end; + +{==============================================================================} + +procedure TNetworkSettings.SetHostName(const AHostName:String); +begin + {} + if Length(AHostName) = 0 then Exit; + + if not AcquireLock then Exit; + + {Set Host Name} + FHostName:=AHostName; + UniqueString(FHostName); + + {Update Host Name} + AddString('HOST_NAME',AHostName); + + ReleaseLock; +end; + +{==============================================================================} + +function TNetworkSettings.GetDomainName:String; +begin + {} + Result:=''; + + if not AcquireLock then Exit; + + {Check Domain Name} + if Length(FDomainName) = 0 then + begin + {Get Domain Name} + FDomainName:=GetString('HOST_DOMAIN'); + UniqueString(FDomainName); + end; + + {Return Domain Name} + Result:=FDomainName; + UniqueString(Result); + + ReleaseLock; +end; + +{==============================================================================} + +procedure TNetworkSettings.SetDomainName(const ADomainName:String); +begin + {} + if Length(ADomainName) = 0 then Exit; + + if not AcquireLock then Exit; + + {Set Host Name} + FDomainName:=ADomainName; + UniqueString(FDomainName); + + {Update Host Name} + AddString('HOST_DOMAIN',ADomainName); + + ReleaseLock; +end; + +{==============================================================================} + +function TNetworkSettings.ExtractName(const AValue,AToken:String):String; +{Extract the name from a name value pair} +var + PosIdx:Integer; +begin + {} + PosIdx:=Pos(AToken,AValue); + if PosIdx = 0 then + begin + Result:=AValue; + end + else + begin + Result:=Copy(AValue,1,PosIdx - 1); + end; +end; + +{==============================================================================} + +function TNetworkSettings.ExtractValue(const AValue,AToken:String):String; +{Extract the value from a name value pair} +var + PosIdx:Integer; +begin + {} + PosIdx:=Pos(AToken,AValue); + if PosIdx = 0 then + begin + Result:=''; + end + else + begin + Result:=Copy(AValue,PosIdx + 1,Length(AValue)); + end; +end; + +{==============================================================================} + +function TNetworkSettings.ExtractPrefix(const AValue:String):String; +{Extract the prefix from the section header} +begin + {} + Result:=AValue; + if Length(Result) <> 0 then + begin + if Result[1] = '[' then + begin + Delete(Result,1,1); + end; + if Length(Result) > 0 then + begin + if Result[Length(Result)] = ']' then + begin + Delete(Result,Length(Result),1); + end; + end; + end; +end; + +{==============================================================================} + +function TNetworkSettings.SplitName(const AName:String):String; +{Split name only portion from the complete name} +var + PosIdx:Integer; +begin + {} + PosIdx:=Pos('_',AName); + if PosIdx = 0 then + begin + Result:=AName; + end + else + begin + Result:=Copy(AName,PosIdx + 1,Length(AName)); + end; +end; + +{==============================================================================} + +function TNetworkSettings.SplitPrefix(const AName:String):String; +{Split prefix from the complete name} +var + PosIdx:Integer; +begin + {} + PosIdx:=Pos('_',AName); + if PosIdx = 0 then + begin + Result:=''; + end + else + begin + Result:=Copy(AName,1,PosIdx - 1); + end; +end; + +{==============================================================================} + +function TNetworkSettings.MergePrefix(const APrefix,AName:String):String; +{Add prefix to name to make a complete name} +begin + {} + if Length(APrefix) <> 0 then + begin + if Length(AName) <> 0 then + begin + Result:=APrefix; + + {Check Prefix} + if APrefix[Length(APrefix)] = '_' then + begin + Delete(Result,Length(Result),1); + end; + + {Check Name} + if AName[1] <> '_' then + begin + Result:=Result + '_'; + end; + + Result:=Result + AName; + end + else + begin + Result:=APrefix; + end; + end + else + begin + Result:=AName; + end; +end; + +{==============================================================================} + +function TNetworkSettings.TranslateString(const AValue,ADefault:String):String; +begin + {} + if Length(AValue) <> 0 then + begin + Result:=AValue; + end + else + begin + Result:=ADefault; + end; +end; + +{==============================================================================} + +function TNetworkSettings.TranslateInteger(const AValue:String;ADefault:Integer):Integer; +begin + {} + if Length(AValue) <> 0 then + begin + Result:=StrToIntDef(AValue,ADefault); + end + else + begin + Result:=ADefault; + end; +end; + +{==============================================================================} + +function TNetworkSettings.TranslateBoolean(const AValue:String;ADefault:Boolean):Boolean; +var + WorkInt:Integer; +begin + {} + if Length(AValue) <> 0 then + begin + if ADefault then + begin + WorkInt:=StrToIntDef(AValue,1); + end + else + begin + WorkInt:=StrToIntDef(AValue,0); + end; + if WorkInt = 0 then Result:=False else Result:=True; + end + else + begin + Result:=ADefault; + end; +end; + +{==============================================================================} + +function TNetworkSettings.GetFromList(const AName:String):TNetworkSetting; +var + Hash:LongWord; + Setting:TNetworkSetting; +begin + {} + Result:=nil; + + if Length(AName) = 0 then Exit; + + Hash:=GenerateNameHash(AName,stringHashSize); + Setting:=TNetworkSetting(FList.First); + while Setting <> nil do + begin + if Setting.Hash = Hash then + begin + if Setting.Name = AName then + begin + Result:=Setting; + Exit; + end; + end; + + Setting:=TNetworkSetting(Setting.Next); + end; +end; + +{==============================================================================} + +function TNetworkSettings.FindFromList(const AName:String):String; +var + Setting:TNetworkSetting; +begin + {} + Setting:=GetFromList(AName); + if Setting <> nil then + begin + Result:=Setting.Value; + end + else + begin + Result:=''; + end; +end; + +{==============================================================================} + +function TNetworkSettings.FindFromEnvironment(const AName:String):String; +begin + {} + Result:=SysUtils.GetEnvironmentVariable(AName); +end; + +{==============================================================================} + +function TNetworkSettings.GetString(const AName:String):String; +begin + {} + Result:=GetStringDefault(AName,''); +end; + +{==============================================================================} + +function TNetworkSettings.GetStringDefault(const AName,ADefault:String):String; +var + Value:String; +begin + {} + Result:=ADefault; + + if not ReaderLock then Exit; + + Value:=FindFromList(AName); + if Length(Value) <> 0 then + begin + Result:=Value; + end + else + begin + Result:=TranslateString(FindFromEnvironment(AName),ADefault); + end; + + ReaderUnlock; +end; + +{==============================================================================} + +function TNetworkSettings.GetInteger(const AName:String):Integer; +begin + {} + Result:=GetIntegerDefault(AName,0); +end; + +{==============================================================================} + +function TNetworkSettings.GetIntegerDefault(const AName:String;ADefault:Integer):Integer; +var + Value:String; +begin + {} + Result:=ADefault; + + if not ReaderLock then Exit; + + Value:=FindFromList(AName); + if Length(Value) <> 0 then + begin + Result:=TranslateInteger(Value,ADefault); + end + else + begin + Result:=TranslateInteger(FindFromEnvironment(AName),ADefault); + end; + + ReaderUnlock; +end; + +{==============================================================================} + +function TNetworkSettings.GetBoolean(const AName:String):Boolean; +begin + {} + Result:=GetBooleanDefault(AName,False); +end; + +{==============================================================================} + +function TNetworkSettings.GetBooleanDefault(const AName:String;ADefault:Boolean):Boolean; +var + Value:String; +begin + {} + Result:=ADefault; + + if not ReaderLock then Exit; + + Value:=FindFromList(AName); + if Length(Value) <> 0 then + begin + Result:=TranslateBoolean(Value,ADefault); + end + else + begin + Result:=TranslateBoolean(FindFromEnvironment(AName),ADefault); + end; + + ReaderUnlock; +end; + +{==============================================================================} + +function TNetworkSettings.AddString(const AName,AValue:String):Boolean; +var + Setting:TNetworkSetting; +begin + {} + Result:=False; + + if Length(AName) = 0 then Exit; + + if not WriterLock then Exit; + + {Get Setting} + Setting:=GetFromList(AName); + if Setting = nil then + begin + {Add Setting} + Setting:=TNetworkSetting.Create; + Setting.Name:=Uppercase(AName); + Setting.Value:=AValue; + + Result:=FList.Add(Setting); + end + else + begin + {Update Setting} + Setting.Value:=AValue; + + Result:=True; + end; + + WriterUnlock; +end; + +{==============================================================================} + +function TNetworkSettings.AddInteger(const AName:String;AValue:Integer):Boolean; +begin + {} + Result:=AddString(AName,IntToStr(AValue)); +end; + +{==============================================================================} + +function TNetworkSettings.AddBoolean(const AName:String;AValue:Boolean):Boolean; +begin + {} + if AValue then + begin + Result:=AddString(AName,'1'); + end + else + begin + Result:=AddString(AName,'0'); + end; +end; + +{==============================================================================} + +function TNetworkSettings.Remove(const AName:String):Boolean; +var + Setting:TNetworkSetting; +begin + {} + Result:=False; + + if Length(AName) = 0 then Exit; + + if not WriterLock then Exit; + + {Get Setting} + Setting:=GetFromList(AName); + if Setting <> nil then + begin + {Remove Setting} + Result:=FList.Remove(Setting); + + {Destroy Setting} + Setting.Free; + end; + + WriterUnlock; +end; + +{==============================================================================} + +function TNetworkSettings.LoadFromFile(const AFileName:String;AFlat:Boolean):Boolean; +var + FileStream:TFileStream; +begin + {} + Result:=False; + try + {Check Filename} + if Length(AFileName) = 0 then Exit; + + {Check File} + if FileExists(AFileName) then + begin + {Open File} + FileStream:=TFileStream.Create(AFileName,fmOpenRead or fmShareDenyNone); + try + {Load from Stream} + Result:=LoadFromStream(FileStream,AFlat); + finally + FileStream.Free; + end; + end; + except + {} + end; +end; + +{==============================================================================} + +function TNetworkSettings.LoadFromStream(AStream:TStream;AFlat:Boolean):Boolean; +var + StringList:TStringList; +begin + {} + Result:=False; + + {Check Stream} + if AStream = nil then Exit; + + {Create Strings} + StringList:=TStringList.Create; + try + {Load Strings} + StringList.LoadFromStream(AStream); + + {Load from Strings} + Result:=LoadFromStrings(StringList,AFlat); + finally + StringList.Free; + end; +end; + +{==============================================================================} + +function TNetworkSettings.LoadFromStrings(AStrings:TStrings;AFlat:Boolean):Boolean; +var + Count:Integer; + Prefix:String; + WorkBuffer:String; +begin + {} + Result:=False; + + {Check Strings} + if AStrings = nil then Exit; + + if not WriterLock then Exit; + + {Load Strings} + Prefix:=''; + for Count:=0 to AStrings.Count - 1 do + begin + {Get String} + WorkBuffer:=AStrings.Strings[Count]; + if (Length(WorkBuffer) <> 0) and (WorkBuffer[1] <> '#') then + begin + {Check Flat} + if AFlat then + begin + {Flat file} + AddString(ExtractName(WorkBuffer,' '),ExtractValue(WorkBuffer,' ')); + end + else + begin + {INI file} + if WorkBuffer[1] = '[' then + begin + Prefix:=ExtractPrefix(WorkBuffer); + end + else + begin + AddString(MergePrefix(Prefix,ExtractName(WorkBuffer,'=')),ExtractValue(WorkBuffer,' ')); + end; + end; + end; + end; + + WriterUnlock; +end; + +{==============================================================================} + +function TNetworkSettings.SaveToFile(const AFileName:String;AFlat:Boolean):Boolean; +var + FileStream:TFileStream; +begin + {} + Result:=False; + try + {Check Filename} + if Length(AFileName) = 0 then Exit; + + {Check File} + if FileExists(AFileName) then + begin + {Delete File} + SysUtils.DeleteFile(AFileName); + end; + + {Check File} + if not FileExists(AFileName) then + begin + {Create File} + FileStream:=TFileStream.Create(AFileName,fmCreate); + try + {Save to Stream} + Result:=SaveToStream(FileStream,AFlat); + finally + FileStream.Free; + end; + end; + except + {} + end; +end; + +{==============================================================================} + +function TNetworkSettings.SaveToStream(AStream:TStream;AFlat:Boolean):Boolean; +var + StringList:TStringList; +begin + {} + Result:=False; + + {Check Stream} + if AStream = nil then Exit; + + {Create Strings} + StringList:=TStringList.Create; + try + {Save to Strings} + Result:=SaveToStrings(StringList,AFlat); + + {Save Strings} + StringList.SaveToStream(AStream); + finally + StringList.Free; + end; +end; + +{==============================================================================} + +function TNetworkSettings.SaveToStrings(AStrings:TStrings;AFlat:Boolean):Boolean; +var + Count:Integer; + WorkBuffer:String; +begin + {} + Result:=False; + + {Check Strings} + if AStrings = nil then Exit; + + if not WriterLock then Exit; + + //To Do //Continuing + + WriterUnlock; +end; + +{==============================================================================} + +function TNetworkSettings.LoadFromEnvironment:Boolean; +begin + {} + Result:=False; + + {Host configuration} + {HOST_NAME} + HOST_NAME:=TranslateString(FindFromEnvironment('HOST_NAME'),HOST_NAME); + AddString('HOST_NAME',HOST_NAME); + + {HOST_DOMAIN} + HOST_DOMAIN:=TranslateString(FindFromEnvironment('HOST_DOMAIN'),HOST_DOMAIN); + AddString('HOST_DOMAIN',HOST_DOMAIN); + + {Winsock configuration} + {WINSOCK_AUTOSTART} + WINSOCK_AUTOSTART:=TranslateBoolean(FindFromEnvironment('WINSOCK_AUTOSTART'),WINSOCK_AUTOSTART); + {WINSOCK_ASYNCSTART} + WINSOCK_ASYNCSTART:=TranslateBoolean(FindFromEnvironment('WINSOCK_ASYNCSTART'),WINSOCK_ASYNCSTART); + + {Winsock2 configuration} + {WINSOCK2_AUTOSTART} + WINSOCK2_AUTOSTART:=TranslateBoolean(FindFromEnvironment('WINSOCK2_AUTOSTART'),WINSOCK2_AUTOSTART); + {WINSOCK2_ASYNCSTART} + WINSOCK2_ASYNCSTART:=TranslateBoolean(FindFromEnvironment('WINSOCK2_ASYNCSTART'),WINSOCK2_ASYNCSTART); + + {Sockets configuration} + {SOCKETS_AUTOSTART} + SOCKETS_AUTOSTART:=TranslateBoolean(FindFromEnvironment('SOCKETS_AUTOSTART'),SOCKETS_AUTOSTART); + {SOCKETS_ASYNCSTART} + SOCKETS_ASYNCSTART:=TranslateBoolean(FindFromEnvironment('SOCKETS_ASYNCSTART'),SOCKETS_ASYNCSTART); + + {Client configuration} + {DNS_CLIENT_ENABLED} + DNS_CLIENT_ENABLED:=TranslateBoolean(FindFromEnvironment('DNS_CLIENT_ENABLED'),DNS_CLIENT_ENABLED); + AddBoolean('DNS_CLIENT_ENABLED',DNS_CLIENT_ENABLED); + + {Protocol configuration} + {RAW_PROTOCOL_ENABLED} + RAW_PROTOCOL_ENABLED:=TranslateBoolean(FindFromEnvironment('RAW_PROTOCOL_ENABLED'),RAW_PROTOCOL_ENABLED); + AddBoolean('RAW_PROTOCOL_ENABLED',RAW_PROTOCOL_ENABLED); + + {UDP_PROTOCOL_ENABLED} + UDP_PROTOCOL_ENABLED:=TranslateBoolean(FindFromEnvironment('UDP_PROTOCOL_ENABLED'),UDP_PROTOCOL_ENABLED); + AddBoolean('UDP_PROTOCOL_ENABLED',UDP_PROTOCOL_ENABLED); + + {TCP_PROTOCOL_ENABLED} + TCP_PROTOCOL_ENABLED:=TranslateBoolean(FindFromEnvironment('TCP_PROTOCOL_ENABLED'),TCP_PROTOCOL_ENABLED); + AddBoolean('TCP_PROTOCOL_ENABLED',TCP_PROTOCOL_ENABLED); + + {ICMP_PROTOCOL_ENABLED} + ICMP_PROTOCOL_ENABLED:=TranslateBoolean(FindFromEnvironment('ICMP_PROTOCOL_ENABLED'),ICMP_PROTOCOL_ENABLED); + AddBoolean('ICMP_PROTOCOL_ENABLED',ICMP_PROTOCOL_ENABLED); + + {ICMP6_PROTOCOL_ENABLED} + ICMP6_PROTOCOL_ENABLED:=TranslateBoolean(FindFromEnvironment('ICMP6_PROTOCOL_ENABLED'),ICMP6_PROTOCOL_ENABLED); + AddBoolean('ICMP6_PROTOCOL_ENABLED',ICMP6_PROTOCOL_ENABLED); + + {IGMP_PROTOCOL_ENABLED} + IGMP_PROTOCOL_ENABLED:=TranslateBoolean(FindFromEnvironment('IGMP_PROTOCOL_ENABLED'),IGMP_PROTOCOL_ENABLED); + AddBoolean('IGMP_PROTOCOL_ENABLED',IGMP_PROTOCOL_ENABLED); + + {ARP_CONFIG_ENABLED} + ARP_CONFIG_ENABLED:=TranslateBoolean(FindFromEnvironment('ARP_CONFIG_ENABLED'),ARP_CONFIG_ENABLED); + AddBoolean('ARP_CONFIG_ENABLED',ARP_CONFIG_ENABLED); + + {RARP_CONFIG_ENABLED} + RARP_CONFIG_ENABLED:=TranslateBoolean(FindFromEnvironment('RARP_CONFIG_ENABLED'),RARP_CONFIG_ENABLED); + AddBoolean('RARP_CONFIG_ENABLED',RARP_CONFIG_ENABLED); + + {BOOTP_CONFIG_ENABLED} + BOOTP_CONFIG_ENABLED:=TranslateBoolean(FindFromEnvironment('BOOTP_CONFIG_ENABLED'),BOOTP_CONFIG_ENABLED); + AddBoolean('BOOTP_CONFIG_ENABLED',BOOTP_CONFIG_ENABLED); + + {DHCP_CONFIG_ENABLED} + DHCP_CONFIG_ENABLED:=TranslateBoolean(FindFromEnvironment('DHCP_CONFIG_ENABLED'),DHCP_CONFIG_ENABLED); + AddBoolean('DHCP_CONFIG_ENABLED',DHCP_CONFIG_ENABLED); + + {STATIC_CONFIG_ENABLED} + STATIC_CONFIG_ENABLED:=TranslateBoolean(FindFromEnvironment('STATIC_CONFIG_ENABLED'),STATIC_CONFIG_ENABLED); + AddBoolean('STATIC_CONFIG_ENABLED',STATIC_CONFIG_ENABLED); + + {LOOPBACK_CONFIG_ENABLED} + LOOPBACK_CONFIG_ENABLED:=TranslateBoolean(FindFromEnvironment('LOOPBACK_CONFIG_ENABLED'),LOOPBACK_CONFIG_ENABLED); + AddBoolean('LOOPBACK_CONFIG_ENABLED',LOOPBACK_CONFIG_ENABLED); + + {Transport configuration} + {IP_TRANSPORT_ENABLED} + IP_TRANSPORT_ENABLED:=TranslateBoolean(FindFromEnvironment('IP_TRANSPORT_ENABLED'),IP_TRANSPORT_ENABLED); + AddBoolean('IP_TRANSPORT_ENABLED',IP_TRANSPORT_ENABLED); + + {IP6_TRANSPORT_ENABLED} + IP6_TRANSPORT_ENABLED:=TranslateBoolean(FindFromEnvironment('IP6_TRANSPORT_ENABLED'),IP6_TRANSPORT_ENABLED); + AddBoolean('IP6_TRANSPORT_ENABLED',IP6_TRANSPORT_ENABLED); + + {ARP_TRANSPORT_ENABLED} + ARP_TRANSPORT_ENABLED:=TranslateBoolean(FindFromEnvironment('ARP_TRANSPORT_ENABLED'),ARP_TRANSPORT_ENABLED); + AddBoolean('ARP_TRANSPORT_ENABLED',ARP_TRANSPORT_ENABLED); + + {RARP_TRANSPORT_ENABLED} + RARP_TRANSPORT_ENABLED:=TranslateBoolean(FindFromEnvironment('RARP_TRANSPORT_ENABLED'),RARP_TRANSPORT_ENABLED); + AddBoolean('RARP_TRANSPORT_ENABLED',RARP_TRANSPORT_ENABLED); + + {RSN_TRANSPORT_ENABLED} + RSN_TRANSPORT_ENABLED:=TranslateBoolean(FindFromEnvironment('RSN_TRANSPORT_ENABLED'),RSN_TRANSPORT_ENABLED); + AddBoolean('RSN_TRANSPORT_ENABLED',RSN_TRANSPORT_ENABLED); + + {EAPOL_TRANSPORT_ENABLED} + EAPOL_TRANSPORT_ENABLED:=TranslateBoolean(FindFromEnvironment('EAPOL_TRANSPORT_ENABLED'),EAPOL_TRANSPORT_ENABLED); + AddBoolean('EAPOL_TRANSPORT_ENABLED',EAPOL_TRANSPORT_ENABLED); + + {Network configuration} + {WIRED_NETWORK_ENABLED} + WIRED_NETWORK_ENABLED:=TranslateBoolean(FindFromEnvironment('WIRED_NETWORK_ENABLED'),WIRED_NETWORK_ENABLED); + AddBoolean('WIRED_NETWORK_ENABLED',WIRED_NETWORK_ENABLED); + + {LOOPBACK_NETWORK_ENABLED} + LOOPBACK_NETWORK_ENABLED:=TranslateBoolean(FindFromEnvironment('LOOPBACK_NETWORK_ENABLED'),LOOPBACK_NETWORK_ENABLED); + AddBoolean('LOOPBACK_NETWORK_ENABLED',LOOPBACK_NETWORK_ENABLED); + + {WIRELESS_NETWORK_ENABLED} + WIRELESS_NETWORK_ENABLED:=TranslateBoolean(FindFromEnvironment('WIRELESS_NETWORK_ENABLED'),WIRELESS_NETWORK_ENABLED); + AddBoolean('WIRELESS_NETWORK_ENABLED',WIRELESS_NETWORK_ENABLED); + + {TCP configuration} + {TCP_RECEIVE_BACKLOG} + TCP_RECEIVE_BACKLOG:=TranslateInteger(FindFromEnvironment('TCP_RECEIVE_BACKLOG'),TCP_RECEIVE_BACKLOG); + AddInteger('TCP_RECEIVE_BACKLOG',TCP_RECEIVE_BACKLOG); + + {TCP_MESSAGESLOT_MAXIMUM} + TCP_MESSAGESLOT_MAXIMUM:=TranslateInteger(FindFromEnvironment('TCP_MESSAGESLOT_MAXIMUM'),TCP_MESSAGESLOT_MAXIMUM); + AddInteger('TCP_MESSAGESLOT_MAXIMUM',TCP_MESSAGESLOT_MAXIMUM); + + Result:=True; +end; + +{==============================================================================} +{==============================================================================} +{TServiceSet} +constructor TServiceSet.Create; +begin + {} + inherited Create; + FLock:=SynchronizerCreate; + FLocalLock:=MutexCreate; + + FServiceSetType:=SERVICE_SET_UNKNOWN; + FServiceSetTime:=GetTickCount64; + FillChar(FAddress,SizeOf(THardwareAddress),0); + FAdapter:=nil; +end; + +{==============================================================================} + +destructor TServiceSet.Destroy; +begin + {} + WriterLock; + try + MutexDestroy(FLocalLock); + inherited Destroy; + finally + {WriterUnlock;} {Can destroy Synchronizer while holding lock} + SynchronizerDestroy(FLock); + end; +end; + +{==============================================================================} + +function TServiceSet.GetName:String; +begin + {} + Result:=''; + + if not AcquireLock then Exit; + + Result:=FName; + UniqueString(Result); + + ReleaseLock; +end; + +{==============================================================================} + +procedure TServiceSet.SetName(const AName:String); +begin + {} + if not AcquireLock then Exit; + + FName:=AName; + UniqueString(FName); + + ReleaseLock; +end; + +{==============================================================================} + +procedure TServiceSet.SetServiceSetType(AServiceSetType:LongWord); +begin + {} + if not AcquireLock then Exit; + + FServiceSetType:=AServiceSetType; + + ReleaseLock; +end; + +{==============================================================================} + +procedure TServiceSet.SetServiceSetTime(const AServiceSetTime:Int64); +begin + {} + if not AcquireLock then Exit; + + FServiceSetTime:=AServiceSetTime; + + ReleaseLock; +end; + +{==============================================================================} + +procedure TServiceSet.SetAddress(const AAddress:THardwareAddress); +begin + {} + if not AcquireLock then Exit; + + FAddress:=AAddress; + + ReleaseLock; +end; + +{==============================================================================} + +procedure TServiceSet.SetAdapter(AAdapter:TNetworkAdapter); +begin + {} + if not AcquireLock then Exit; + + FAdapter:=AAdapter; + + ReleaseLock; +end; + +{==============================================================================} + +function TServiceSet.AcquireLock:Boolean; +begin + {} + Result:=(MutexLock(FLocalLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TServiceSet.ReleaseLock:Boolean; +begin + {} + Result:=(MutexUnlock(FLocalLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TServiceSet.ReaderLock:Boolean; +begin + {} + Result:=(SynchronizerReaderLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TServiceSet.ReaderUnlock:Boolean; +begin + {} + Result:=(SynchronizerReaderUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TServiceSet.ReaderConvert:Boolean; +{Convert a Reader lock to a Writer lock} +begin + {} + Result:=(SynchronizerReaderConvert(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TServiceSet.WriterLock:Boolean; +begin + {} + Result:=(SynchronizerWriterLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TServiceSet.WriterUnlock:Boolean; +begin + {} + Result:=(SynchronizerWriterUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TServiceSet.WriterConvert:Boolean; +{Convert a Writer lock to a Reader lock} +begin + {} + Result:=(SynchronizerWriterConvert(FLock) = ERROR_SUCCESS); end; {==============================================================================} @@ -3293,18 +5059,24 @@ procedure NetworkInit; begin if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to create event table lock'); end; - + + {Create Network Settings} + NetworkSettings:=TNetworkSettings.Create; + {Create Adapter Manager} - AdapterManager:=TAdapterManager.Create; + AdapterManager:=TAdapterManager.Create(NetworkSettings); {Check Environment Variables (Network)} - {HOST_NAME} - WorkBuffer:=SysUtils.GetEnvironmentVariable('HOST_NAME'); - if Length(WorkBuffer) <> 0 then HOST_NAME:=WorkBuffer; - - {HOST_DOMAIN} - WorkBuffer:=SysUtils.GetEnvironmentVariable('HOST_DOMAIN'); - if Length(WorkBuffer) <> 0 then HOST_DOMAIN:=WorkBuffer; + {Done by NetworkSettings.LoadFromEnvironment} + + {Load Environment Settings} + NetworkSettings.LoadFromEnvironment; + + {Register Platform Network Handlers} + HostGetNameHandler:=SysHostGetName; + HostSetNameHandler:=SysHostSetName; + HostGetDomainHandler:=SysHostGetDomain; + HostSetDomainHandler:=SysHostSetDomain; NetworkInitialized:=True; end; @@ -3323,7 +5095,7 @@ function NetworkStart:LongWord; {Check Manager} if AdapterManager = nil then Exit; - + {Notify Event} NetworkEventNotify(NETWORK_EVENT_SYSTEM_START); @@ -3420,37 +5192,128 @@ function NetworkDeviceClose(Network:PNetworkDevice):LongWord; {==============================================================================} function NetworkDeviceRead(Network:PNetworkDevice;Buffer:Pointer;Size:LongWord;var Length:LongWord):LongWord; +var + Entry:PNetworkEntry; + Packet:PNetworkPacket; begin {} Result:=ERROR_INVALID_PARAMETER; + {Setup Length} + Length:=0; + {Check Network} if Network = nil then Exit; if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; {Check Method} - if not Assigned(Network.DeviceRead) then Exit; - - {Call Read} - Result:=Network.DeviceRead(Network,Buffer,Size,Length); + if Assigned(Network.DeviceRead) then + begin + {Call Read} + Result:=Network.DeviceRead(Network,Buffer,Size,Length); + end + else + begin + {Default Method} + {Check Buffer} + if Buffer = nil then Exit; + + {Check Size} + if Size = 0 then Exit; + + {Check State} + Result:=ERROR_NOT_READY; + if Network.NetworkState <> NETWORK_STATE_OPEN then Exit; + + {Receive Buffer} + Result:=NetworkBufferReceive(Network,Entry); + if Result <> ERROR_SUCCESS then Exit; + + {Get First Packet} + Packet:=@Entry.Packets[0]; + + {Get Size} + if Packet.Length < Size then + begin + Size:=Packet.Length; + end; + + {Copy Data} + System.Move(Packet.Data^,Buffer^,Size); + + {Release Buffer} + Result:=NetworkBufferRelease(Network,Entry); + if Result = ERROR_SUCCESS then + begin + {Return Length} + Length:=Size; + end; + end; end; {==============================================================================} function NetworkDeviceWrite(Network:PNetworkDevice;Buffer:Pointer;Size:LongWord;var Length:LongWord):LongWord; +var + Entry:PNetworkEntry; + Packet:PNetworkPacket; begin {} Result:=ERROR_INVALID_PARAMETER; + {Setup Length} + Length:=0; + {Check Network} if Network = nil then Exit; if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; {Check Method} - if not Assigned(Network.DeviceWrite) then Exit; + if Assigned(Network.DeviceWrite) then + begin + {Call Write} + Result:=Network.DeviceWrite(Network,Buffer,Size,Length); + end + else + begin + {Default Method} + {Check Buffer} + if Buffer = nil then Exit; + + {Check Size} + if Size = 0 then Exit; + + {Check State} + Result:=ERROR_NOT_READY; + if Network.NetworkState <> NETWORK_STATE_OPEN then Exit; + + {Allocate Buffer} + Result:=NetworkBufferAllocate(Network,Entry); + if Result <> ERROR_SUCCESS then Exit; + + {Get First Packet} + Packet:=@Entry.Packets[0]; - {Call Write} - Result:=Network.DeviceWrite(Network,Buffer,Size,Length); + {Get Size} + if Packet.Length < Size then + begin + Size:=Packet.Length; + end; + + {Update Packet} + Packet.Length:=Size; + + {Copy Data} + System.Move(Buffer^,Packet.Data^,Size); + + {Transmit Buffer} + Result:=NetworkBufferTransmit(Network,Entry); + if Result = ERROR_SUCCESS then + begin + {Return Length} + Length:=Size; + end; + end; end; {==============================================================================} @@ -3465,6 +5328,7 @@ function NetworkDeviceControl(Network:PNetworkDevice;Request:Integer;Argument1:L if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; {Check Method} + Result:=ERROR_NOT_SUPPORTED; if not Assigned(Network.DeviceControl) then Exit; {Call Control} @@ -3484,11 +5348,15 @@ function NetworkBufferAllocate(Network:PNetworkDevice;var Entry:PNetworkEntry):L {} Result:=ERROR_INVALID_PARAMETER; + {Setup Entry} + Entry:=nil; + {Check Network} if Network = nil then Exit; if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; {Check Method} + Result:=ERROR_NOT_SUPPORTED; if not Assigned(Network.BufferAllocate) then Exit; {Call Allocate} @@ -3510,6 +5378,7 @@ function NetworkBufferRelease(Network:PNetworkDevice;Entry:PNetworkEntry):LongWo if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; {Check Method} + Result:=ERROR_NOT_SUPPORTED; if not Assigned(Network.BufferRelease) then Exit; {Call Release} @@ -3522,18 +5391,22 @@ function NetworkBufferReceive(Network:PNetworkDevice;var Entry:PNetworkEntry):Lo {Receive a completed receive buffer from the specified network device. The returned entry will contain a one or more packets of data to read from. - When the data has been processed pas the returned buffer to NetworkBufferRelease} + When the data has been processed pass the returned buffer to NetworkBufferRelease} {Return: ERROR_SUCCESS if completed or another error code on failure} begin {} Result:=ERROR_INVALID_PARAMETER; + {Setup Entry} + Entry:=nil; + {Check Network} if Network = nil then Exit; if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; {Check Method} + Result:=ERROR_NOT_SUPPORTED; if not Assigned(Network.BufferReceive) then Exit; {Call Release} @@ -3555,6 +5428,7 @@ function NetworkBufferTransmit(Network:PNetworkDevice;Entry:PNetworkEntry):LongW if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; {Check Method} + Result:=ERROR_NOT_SUPPORTED; if not Assigned(Network.BufferTransmit) then Exit; {Call Release} @@ -3787,7 +5661,17 @@ function NetworkDeviceRegister(Network:PNetworkDevice):LongWord; {Check Functions} if not Assigned(Network.DeviceOpen) then Exit; if not Assigned(Network.DeviceClose) then Exit; - + if not Assigned(Network.DeviceRead) then + begin + if not Assigned(Network.BufferReceive) then Exit; + if not Assigned(Network.BufferRelease) then Exit; + end; + if not Assigned(Network.DeviceWrite) then + begin + if not Assigned(Network.BufferAllocate) then Exit; + if not Assigned(Network.BufferTransmit) then Exit; + end; + {Check Network} Result:=ERROR_ALREADY_EXISTS; if NetworkDeviceCheck(Network) = Network then Exit; @@ -4261,7 +6145,66 @@ function NetworkEventNotify(Event:LongWord):LongWord; {==============================================================================} {==============================================================================} -{Ethernet Functions} +{RTL Network Functions} +function SysHostGetName:String; +begin + {} + Result:=''; + + {Check Settings} + if NetworkSettings = nil then Exit; + + Result:=NetworkSettings.HostName; +end; + +{==============================================================================} + +function SysHostSetName(const AName:String):Boolean; +begin + {} + Result:=False; + + {Check Name} + if Length(AName) = 0 then Exit; + + {Check Settings} + if NetworkSettings = nil then Exit; + + NetworkSettings.HostName:=AName; + + Result:=True; +end; + +{==============================================================================} + +function SysHostGetDomain:String; +begin + {} + Result:=''; + + {Check Settings} + if NetworkSettings = nil then Exit; + + Result:=NetworkSettings.DomainName; +end; + +{==============================================================================} + +function SysHostSetDomain(const ADomain:String):Boolean; +begin + {} + Result:=False; + + {Check Domain} + if Length(ADomain) = 0 then Exit; + + {Check Settings} + if NetworkSettings = nil then Exit; + + NetworkSettings.DomainName:=ADomain; + + Result:=True; +end; {==============================================================================} {==============================================================================} @@ -4511,7 +6454,10 @@ function StringToHardwareAddress(const AAddress:String):THardwareAddress; end else if Length(AAddress) = ((2 * HARDWARE_ADDRESS_SIZE) + 5) then {Colon separated Form 12:34:56:78:90:AB} begin - //To Do + for Count:=0 to HARDWARE_ADDRESS_SIZE - 1 do + begin + Result[Count]:=StrToIntDef('$' + Copy(AAddress,(Count * 3) + 1,2),0); + end; end; end; @@ -4559,11 +6505,10 @@ function CompareHardwareMulticast(const AAddress:THardwareAddress):Boolean; function AdapterTypeToString(AType:Word):String; begin {} - Result:=''; + Result:='ADAPTER_TYPE_UNKNOWN'; {Check Type} case AType of - ADAPTER_TYPE_UNKNOWN:Result:='ADAPTER_TYPE_UNKNOWN'; ADAPTER_TYPE_WIRED:Result:='ADAPTER_TYPE_WIRED'; ADAPTER_TYPE_LOOPBACK:Result:='ADAPTER_TYPE_LOOPBACK'; ADAPTER_TYPE_WIRELESS:Result:='ADAPTER_TYPE_WIRELESS'; @@ -4609,6 +6554,20 @@ function AdapterConfigToString(AConfig:Word):String; {==============================================================================} +function AdapterStateToString(AState:Integer):String; +begin + {} + Result:=''; + + {Check State} + case AState of + ADAPTER_STATE_DISABLED:Result:='ADAPTER_STATE_DISABLED'; + ADAPTER_STATE_ENABLED:Result:='ADAPTER_STATE_ENABLED'; + end; +end; + +{==============================================================================} + function AdapterStatusToString(AStatus:Integer):String; begin {} @@ -4616,10 +6575,8 @@ function AdapterStatusToString(AStatus:Integer):String; {Check Status} case AStatus of - ADAPTER_STATUS_UNKNOWN:Result:='ADAPTER_STATUS_UNKNOWN'; - ADAPTER_STATUS_READY:Result:='ADAPTER_STATUS_READY'; - ADAPTER_STATUS_LINKDOWN:Result:='ADAPTER_STATUS_LINKDOWN'; - ADAPTER_STATUS_SHUTDOWN:Result:='ADAPTER_STATUS_SHUTDOWN'; + ADAPTER_STATUS_DOWN:Result:='ADAPTER_STATUS_DOWN'; + ADAPTER_STATUS_UP:Result:='ADAPTER_STATUS_UP'; end; end; @@ -4628,11 +6585,10 @@ function AdapterStatusToString(AStatus:Integer):String; function FrameTypeToString(AType:Word):String; begin {} - Result:=''; + Result:='FRAME_TYPE_UNKNOWN'; {Check Type} case AType of - FRAME_TYPE_UNKNOWN:Result:='FRAME_TYPE_UNKNOWN'; FRAME_TYPE_ETHERNET_II:Result:='FRAME_TYPE_ETHERNET_II'; FRAME_TYPE_TOKEN_RING:Result:='FRAME_TYPE_TOKEN_RING'; FRAME_TYPE_APPLETALK:Result:='FRAME_TYPE_APPLETALK'; @@ -4680,7 +6636,7 @@ function PacketTypetoString(AType:Word):String; function ConfigTypeToString(AType:Word):String; begin {} - Result:=''; + Result:='CONFIG_TYPE_UNKNOWN'; {Check Type} case AType of @@ -4712,11 +6668,37 @@ function ConfigCommandToString(ACommand:Word):String; CONFIG_ADAPTER_REBOOT:Result:='CONFIG_ADAPTER_REBOOT'; end; end; - + {==============================================================================} + +function AuthTypeToString(AType:Word):String; +begin + {} + Result:='AUTH_TYPE_UNKNOWN'; + + {Check Type} + case AType of + AUTH_TYPE_EAP:Result:='AUTH_TYPE_EAP'; + AUTH_TYPE_RSN:Result:='AUTH_TYPE_RSN'; + end; +end; + {==============================================================================} -{Ethernet Helper Functions} +function AuthCommandToString(ACommand:Word):String; +begin + {} + Result:=''; + + {Check Command} + case ACommand of + AUTH_COMMAND_ASSOCIATE:Result:='AUTH_COMMAND_ASSOCIATE'; + AUTH_COMMAND_DISASSOCIATE:Result:='AUTH_COMMAND_DISASSOCIATE'; + AUTH_COMMAND_AUTHENTICATE:Result:='AUTH_COMMAND_AUTHENTICATE'; + AUTH_COMMAND_UNAUTHENTICATE:Result:='AUTH_COMMAND_UNAUTHENTICATE'; + end; +end; + {==============================================================================} {==============================================================================} diff --git a/source/rtl/ultibo/core/platform.pas b/source/rtl/ultibo/core/platform.pas index 28e0c9b..2189339 100644 --- a/source/rtl/ultibo/core/platform.pas +++ b/source/rtl/ultibo/core/platform.pas @@ -312,6 +312,10 @@ TPlatformSemaphore = record TWorkerTask = procedure(Data:Pointer); TWorkerCallback = procedure(Data:Pointer); +type + {Prototype for Counter Callback Handlers} + TCounterCallback = procedure(Data:Pointer); + type {Prototype for GPIO Callback Handlers} TGPIOCallback = procedure(Data:Pointer;Pin,Trigger:LongWord); @@ -330,6 +334,21 @@ TPlatformSemaphore = record TActivityLEDOn = procedure; TActivityLEDOff = procedure; +type + {Prototypes for Counter Handlers} + TCounterAvailable = function:Boolean; + + TCounterRead = function:LongWord; + TCounterRead64 = function:Int64; + TCounterWait = function:LongWord; + TCounterEvent = function(Callback:TCounterCallback;Data:Pointer):LongWord; + + TCounterGetRate = function:LongWord; + TCounterSetRate = function(Rate:LongWord):LongWord; + + TCounterGetInterval = function:LongWord; + TCounterSetInterval = function(Interval:LongWord):LongWord; + type {Prototypes for Mailbox Handlers} TMailboxReceive = function(Mailbox,Channel:LongWord):LongWord; @@ -593,6 +612,14 @@ TPlatformSemaphore = record TVirtualGPIOOutputClear = function(Pin:LongWord):LongWord; TVirtualGPIOFunctionSelect = function(Pin,Mode:LongWord):LongWord; +//type + {Prototypes for SPI Handlers} + //To Do + +//type + {Prototypes for I2C Handlers} + //To Do + //type {Prototypes for PWM Handlers} //To Do @@ -906,6 +933,21 @@ EUndefinedInstruction = class(EHardwareException); ActivityLEDOnHandler:TActivityLEDOn; ActivityLEDOffHandler:TActivityLEDOff; +var + {Counter Handlers} + CounterAvailableHandler:TCounterAvailable; + + CounterReadHandler:TCounterRead; + CounterRead64Handler:TCounterRead64; + CounterWaitHandler:TCounterWait; + CounterEventHandler:TCounterEvent; + + CounterGetRateHandler:TCounterGetRate; + CounterSetRateHandler:TCounterSetRate; + + CounterGetIntervalHandler:TCounterGetInterval; + CounterSetIntervalHandler:TCounterSetInterval; + var {Mailbox Handlers} MailboxReceiveHandler:TMailboxReceive; @@ -1169,6 +1211,14 @@ EUndefinedInstruction = class(EHardwareException); VirtualGPIOOutputClearHandler:TVirtualGPIOOutputClear; VirtualGPIOFunctionSelectHandler:TVirtualGPIOFunctionSelect; +//var + {SPI Handlers} + //To Do + +//var + {I2C Handlers} + //To Do + //var {PWM Handlers} //To Do @@ -1387,8 +1437,19 @@ procedure ActivityLEDOn; inline; procedure ActivityLEDOff; inline; {==============================================================================} -{Timer Functions} -//To Do //See Timer device +{Counter Functions (Timer device)} +function CounterAvailable:Boolean; inline; + +function CounterRead:LongWord; inline; +function CounterRead64:Int64; inline; +function CounterWait:LongWord; inline; +function CounterEvent(Callback:TCounterCallback;Data:Pointer):LongWord; inline; + +function CounterGetRate:LongWord; inline; +function CounterSetRate(Rate:LongWord):LongWord; inline; + +function CounterGetInterval:LongWord; inline; +function CounterSetInterval(Interval:LongWord):LongWord; inline; {==============================================================================} {Mailbox Functions} @@ -1678,6 +1739,14 @@ function VirtualGPIOOutputSet(Pin:LongWord):LongWord; inline; function VirtualGPIOOutputClear(Pin:LongWord):LongWord; inline; function VirtualGPIOFunctionSelect(Pin,Mode:LongWord):LongWord; inline; +{==============================================================================} +{SPI Functions} +//To Do + +{==============================================================================} +{I2C Functions} +//To Do + {==============================================================================} {PWM Functions} //To Do @@ -2471,6 +2540,163 @@ procedure ActivityLEDOff; inline; end; end; +{==============================================================================} +{==============================================================================} +{Counter Functions (Timer device)} +function CounterAvailable:Boolean; inline; +{Check if a counter is currently available} +begin + {} + if Assigned(CounterAvailableHandler) then + begin + Result:=CounterAvailableHandler; + end + else + begin + Result:=False; + end; +end; + +{==============================================================================} + +function CounterRead:LongWord; inline; +{Read the current value of the default counter} +{Return: The 32 bit current value of the current or 0 on failure} +begin + {} + if Assigned(CounterReadHandler) then + begin + Result:=CounterReadHandler; + end + else + begin + Result:=0; + end; +end; + +{==============================================================================} + +function CounterRead64:Int64; inline; +{Read the current value of the default counter} +{Return: The 64 bit current value of the current or 0 on failure} +begin + {} + if Assigned(CounterRead64Handler) then + begin + Result:=CounterRead64Handler; + end + else + begin + Result:=0; + end; +end; + +{==============================================================================} + +function CounterWait:LongWord; inline; +{Wait for the current interval to expire on the default counter} +{Return: ERROR_SUCCESS if the interval expired or another error code on failure} +begin + {} + if Assigned(CounterWaitHandler) then + begin + Result:=CounterWaitHandler; + end + else + begin + Result:=ERROR_CALL_NOT_IMPLEMENTED; + end; +end; + +{==============================================================================} + +function CounterEvent(Callback:TCounterCallback;Data:Pointer):LongWord; inline; +{Schedule a function to be called when the current interval expires on the default counter} +{Callback: The function to be called when the interval expires} +{Data: A pointer to be pass to the function when the interval expires (Optional)} +{Return: ERROR_SUCCESS if the callback was scheduled successfully or another error code on failure} +begin + {} + if Assigned(CounterEventHandler) then + begin + Result:=CounterEventHandler(Callback,Data); + end + else + begin + Result:=ERROR_CALL_NOT_IMPLEMENTED; + end; +end; + +{==============================================================================} + +function CounterGetRate:LongWord; inline; +{Get the current clock rate in Hz of the default counter} +{Return: The current clock rate in Hz or 0 on failure} +begin + {} + if Assigned(CounterGetRateHandler) then + begin + Result:=CounterGetRateHandler; + end + else + begin + Result:=0; + end; +end; + +{==============================================================================} + +function CounterSetRate(Rate:LongWord):LongWord; inline; +{Set the current clock rate in Hz of the default counter} +{Rate: The clock rate in Hz to set} +{Return: ERROR_SUCCESS if the clock rate was set or another error code on failure} +begin + {} + if Assigned(CounterSetRateHandler) then + begin + Result:=CounterSetRateHandler(Rate); + end + else + begin + Result:=ERROR_CALL_NOT_IMPLEMENTED; + end; +end; + +{==============================================================================} + +function CounterGetInterval:LongWord; inline; +{Get the current interval in milliseconds of the default counter} +{Return: The current interval in milliseconds or 0 on failure (or not set)} +begin + {} + if Assigned(CounterGetIntervalHandler) then + begin + Result:=CounterGetIntervalHandler; + end + else + begin + Result:=0; + end; +end; + +{==============================================================================} + +function CounterSetInterval(Interval:LongWord):LongWord; inline; +{Set the current interval in milliseconds of the default counter} +{Interval: The interval in milliseconds to set} +{Return: ERROR_SUCCESS if the interval was set or another error code on failure} +begin + {} + if Assigned(CounterSetIntervalHandler) then + begin + Result:=CounterSetIntervalHandler(Interval); + end + else + begin + Result:=ERROR_CALL_NOT_IMPLEMENTED; + end; +end; + {==============================================================================} {==============================================================================} {Mailbox Functions} @@ -5228,6 +5454,18 @@ function VirtualGPIOFunctionSelect(Pin,Mode:LongWord):LongWord; inline; end; end; +{==============================================================================} +{==============================================================================} +{SPI Functions} + +{==============================================================================} +{==============================================================================} +{I2C Functions} + +{==============================================================================} +{==============================================================================} +{PWM Functions} + {==============================================================================} {==============================================================================} {RTC Functions} diff --git a/source/rtl/ultibo/core/protocol.pas b/source/rtl/ultibo/core/protocol.pas index e775119..e5e5aa8 100644 --- a/source/rtl/ultibo/core/protocol.pas +++ b/source/rtl/ultibo/core/protocol.pas @@ -52,12 +52,6 @@ interface uses GlobalConfig,GlobalConst,GlobalTypes,GlobalSock,Platform,Threads,Devices,SysUtils,Classes,Network,Transport,Ultibo,UltiboClasses; -//To Do //Look for: - -//-- - -//Timers - {==============================================================================} {Global definitions} {$INCLUDE GlobalDefines.inc} @@ -65,7 +59,6 @@ interface {==============================================================================} {const} {Protocol specific constants} - {These items must also be included in Winsock.pas/Winsock2.pas} //To Do //No longer true since the addition of GlobalSock ? and other structure changes ? const {Generic Protocol} @@ -144,14 +137,14 @@ interface {Protocol specific types} {Generic Protocol} PProtocolStatistics = ^TProtocolStatistics; - TProtocolStatistics = packed record - PacketsIn:LongInt; //To Do //LongWord/Int64 ? - PacketsOut:LongInt; - BytesIn:LongInt; //To Do //Int64 - BytesOut:LongInt; //To Do //Int64 - ErrorsIn:LongInt; - ErrorsOut:LongInt; - PacketsLost:LongInt; + TProtocolStatistics = record + PacketsIn:Int64; + PacketsOut:Int64; + BytesIn:Int64; + BytesOut:Int64; + ErrorsIn:Int64; + ErrorsOut:Int64; + PacketsLost:Int64; end; {Protocol Timer} @@ -188,13 +181,14 @@ TNetworkConfig = class; TConfigCallback = function(AConfig:TNetworkConfig):Boolean of object; TProtocolManager = class(TObject) - constructor Create(ATransports:TTransportManager); + constructor Create(ASettings:TNetworkSettings;ATransports:TTransportManager); destructor Destroy; override; private {Internal Variables} FLock:TSynchronizerHandle; + FSettings:TNetworkSettings; FTransports:TTransportManager; - + {Status Variables} FProtocols:TNetworkList; {List of TNetworkProtocol objects} FFilters:TNetworkList; {List of TNetworkFilter objects} @@ -210,8 +204,9 @@ TProtocolManager = class(TObject) function WriterUnlock:Boolean; public {Public Properties} + property Settings:TNetworkSettings read FSettings; property Transports:TTransportManager read FTransports; - + {Public Methods} function AddProtocol(AProtocol:TNetworkProtocol):Boolean; function RemoveProtocol(AProtocol:TNetworkProtocol):Boolean; @@ -770,13 +765,14 @@ implementation {==============================================================================} {==============================================================================} {TProtocolManager} -constructor TProtocolManager.Create(ATransports:TTransportManager); +constructor TProtocolManager.Create(ASettings:TNetworkSettings;ATransports:TTransportManager); begin {} inherited Create; FLock:=SynchronizerCreate; - + FSettings:=ASettings; FTransports:=ATransports; + FProtocols:=TNetworkList.Create; FFilters:=TNetworkList.Create; FConfigs:=TNetworkList.Create; @@ -792,6 +788,7 @@ destructor TProtocolManager.Destroy; FConfigs.Free; FFilters.Free; FProtocols.Free; + FSettings:=nil; FTransports:=nil; inherited Destroy; finally @@ -1422,7 +1419,7 @@ function TProtocolManager.ProcessSockets:Boolean; Result:=True; {$IFDEF PROTOCOL_DEBUG} - //--if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ProtocolManager: ProcessSockets'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ProtocolManager: ProcessSockets'); {$ENDIF} {Get Protocol} @@ -1452,7 +1449,7 @@ function TProtocolManager.ProcessProtocols:Boolean; Result:=True; {$IFDEF PROTOCOL_DEBUG} - //--if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ProtocolManager: ProcessProtocols'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ProtocolManager: ProcessProtocols'); {$ENDIF} {Get Protocol} @@ -1665,7 +1662,7 @@ function TProtocolManager.ProcessFilters:Boolean; Result:=True; {$IFDEF PROTOCOL_DEBUG} - //--if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ProtocolManager: ProcessFilters'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ProtocolManager: ProcessFilters'); {$ENDIF} {Get Filter} @@ -1855,7 +1852,7 @@ function TProtocolManager.StopConfigs:Boolean; Config:=TNetworkConfig(GetConfigByNext(nil,True,False,NETWORK_LOCK_READ)); while Config <> nil do begin - {Stp Config} + {Stop Config} if not(Config.StopConfig) then Result:=False; {Get Next} @@ -1878,7 +1875,7 @@ function TProtocolManager.ProcessConfigs:Boolean; Result:=True; {$IFDEF PROTOCOL_DEBUG} - //--if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ProtocolManager: ProcessConfigs'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'ProtocolManager: ProcessConfigs'); {$ENDIF} {Get Config} @@ -4597,7 +4594,7 @@ procedure ProtocolInit; if ProtocolInitialized then Exit; {Create Protocol Manager} - ProtocolManager:=TProtocolManager.Create(TransportManager); + ProtocolManager:=TProtocolManager.Create(NetworkSettings,TransportManager); ProtocolInitialized:=True; end; @@ -4635,7 +4632,7 @@ function ProtocolStart:LongWord; if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to start one or more network configs'); end; - //To Do + //To Do //Clients {Set Started} ProtocolStarted:=True; @@ -4659,6 +4656,8 @@ function ProtocolStop:LongWord; {Check Manager} if ProtocolManager = nil then Exit; + //To Do //Clients + {Stop Configs} if not ProtocolManager.StopConfigs then begin @@ -4677,8 +4676,6 @@ function ProtocolStop:LongWord; if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to stop one or more network protocols'); end; - //To Do - {Set Started} ProtocolStarted:=False; diff --git a/source/rtl/ultibo/core/raw.pas b/source/rtl/ultibo/core/raw.pas index f22c22a..c652817 100644 --- a/source/rtl/ultibo/core/raw.pas +++ b/source/rtl/ultibo/core/raw.pas @@ -2965,7 +2965,7 @@ procedure RAWInit; if RAWInitialized then Exit; {Create RAW Protocol} - if RAW_PROTOCOL_ENABLED then + if NetworkSettings.GetBooleanDefault('RAW_PROTOCOL_ENABLED',RAW_PROTOCOL_ENABLED) then begin TRAWProtocol.Create(ProtocolManager,RAW_PROTOCOL_NAME); end; diff --git a/source/rtl/ultibo/core/smsc95xx.pas b/source/rtl/ultibo/core/smsc95xx.pas index d71af54..a0cf989 100644 --- a/source/rtl/ultibo/core/smsc95xx.pas +++ b/source/rtl/ultibo/core/smsc95xx.pas @@ -491,7 +491,10 @@ function SMSC95XXDeviceRead(Network:PNetworkDevice;Buffer:Pointer;Size:LongWord; function SMSC95XXDeviceWrite(Network:PNetworkDevice;Buffer:Pointer;Size:LongWord;var Length:LongWord):LongWord; function SMSC95XXDeviceControl(Network:PNetworkDevice;Request:Integer;Argument1:LongWord;var Argument2:LongWord):LongWord; -//To Do //BufferAllocate/BufferRelease/BufferReceive/BufferTransmit +function SMSC95XXBufferAllocate(Network:PNetworkDevice;var Entry:PNetworkEntry):LongWord; +function SMSC95XXBufferRelease(Network:PNetworkDevice;Entry:PNetworkEntry):LongWord; +function SMSC95XXBufferReceive(Network:PNetworkDevice;var Entry:PNetworkEntry):LongWord; +function SMSC95XXBufferTransmit(Network:PNetworkDevice;Entry:PNetworkEntry):LongWord; {==============================================================================} {SMSC95XX USB Functions} @@ -645,7 +648,7 @@ function SMSC95XXDeviceOpen(Network:PNetworkDevice):LongWord; Request:=BufferGet(Network.TransmitBuffer); {Initialize Request} - USBRequestInitialize(Request); //Remove //Critical + USBRequestInitializeOld(Request); //To Do //Remove {Initialize Request} Request.Device:=Device; @@ -1073,6 +1076,10 @@ function SMSC95XXDeviceControl(Network:PNetworkDevice;Request:Integer;Argument1: Device:=PUSBDevice(Network.Device.DeviceData); if Device = nil then Exit; + {$IFDEF SMSC95XX_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(Network,'SMSC95XX: Device Control'); + {$ENDIF} + {Acquire the Lock} if MutexLock(Network.Lock) = ERROR_SUCCESS then begin @@ -1152,6 +1159,110 @@ function SMSC95XXDeviceControl(Network:PNetworkDevice;Request:Integer;Argument1: end; end; +{==============================================================================} + +function SMSC95XXBufferAllocate(Network:PNetworkDevice;var Entry:PNetworkEntry):LongWord; +{Implementation of NetworkBufferAllocate for the SMSC95XX device} +begin + {} + Result:=ERROR_INVALID_PARAMETER; + + {Setup Entry} + Entry:=nil; + + {Check Network} + if Network = nil then Exit; + if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; + + {$IFDEF SMSC95XX_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(Network,'SMSC95XX: Buffer Allocate'); + {$ENDIF} + + {Check State} + Result:=ERROR_NOT_READY; + if Network.NetworkState <> NETWORK_STATE_OPEN then Exit; + + //To Do +end; + +{==============================================================================} + +function SMSC95XXBufferRelease(Network:PNetworkDevice;Entry:PNetworkEntry):LongWord; +{Implementation of NetworkBufferRelease for the SMSC95XX device} +begin + {} + Result:=ERROR_INVALID_PARAMETER; + + {Check Entry} + if Entry = nil then Exit; + + {Check Network} + if Network = nil then Exit; + if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; + + {$IFDEF SMSC95XX_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(Network,'SMSC95XX: Buffer Release'); + {$ENDIF} + + {Check State} + Result:=ERROR_NOT_READY; + if Network.NetworkState <> NETWORK_STATE_OPEN then Exit; + + //To Do +end; + +{==============================================================================} + +function SMSC95XXBufferReceive(Network:PNetworkDevice;var Entry:PNetworkEntry):LongWord; +{Implementation of NetworkBufferReceive for the SMSC95XX device} +begin + {} + Result:=ERROR_INVALID_PARAMETER; + + {Setup Entry} + Entry:=nil; + + {Check Network} + if Network = nil then Exit; + if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; + + {$IFDEF SMSC95XX_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(Network,'SMSC95XX: Buffer Receive'); + {$ENDIF} + + {Check State} + Result:=ERROR_NOT_READY; + if Network.NetworkState <> NETWORK_STATE_OPEN then Exit; + + //To Do +end; + +{==============================================================================} + +function SMSC95XXBufferTransmit(Network:PNetworkDevice;Entry:PNetworkEntry):LongWord; +{Implementation of NetworkBufferTransmit for the SMSC95XX device} +begin + {} + Result:=ERROR_INVALID_PARAMETER; + + {Check Entry} + if Entry = nil then Exit; + + {Check Network} + if Network = nil then Exit; + if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; + + {$IFDEF SMSC95XX_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(Network,'SMSC95XX: Buffer Transmit'); + {$ENDIF} + + {Check State} + Result:=ERROR_NOT_READY; + if Network.NetworkState <> NETWORK_STATE_OPEN then Exit; + + //To Do +end; + {==============================================================================} {==============================================================================} {SMSC95XX USB Functions} @@ -1309,16 +1420,20 @@ function SMSC95XXDriverBind(Device:PUSBDevice;Interrface:PUSBInterface):LongWord {Device} Network.Network.Device.DeviceBus:=DEVICE_BUS_USB; Network.Network.Device.DeviceType:=NETWORK_TYPE_ETHERNET; - Network.Network.Device.DeviceFlags:=NETWORK_FLAG_NONE; + Network.Network.Device.DeviceFlags:=NETWORK_FLAG_NONE; //To Do //NETWORK_FLAG_RX_BUFFER or NETWORK_FLAG_TX_BUFFER Network.Network.Device.DeviceData:=Device; {Network} Network.Network.NetworkState:=NETWORK_STATE_CLOSED; Network.Network.NetworkStatus:=NETWORK_STATUS_DOWN; Network.Network.DeviceOpen:=SMSC95XXDeviceOpen; Network.Network.DeviceClose:=SMSC95XXDeviceClose; - Network.Network.DeviceRead:=SMSC95XXDeviceRead; - Network.Network.DeviceWrite:=SMSC95XXDeviceWrite; + Network.Network.DeviceRead:=SMSC95XXDeviceRead; //To Do //Remove + Network.Network.DeviceWrite:=SMSC95XXDeviceWrite; //To Do //Remove Network.Network.DeviceControl:=SMSC95XXDeviceControl; + Network.Network.BufferAllocate:=SMSC95XXBufferAllocate; + Network.Network.BufferRelease:=SMSC95XXBufferRelease; + Network.Network.BufferReceive:=SMSC95XXBufferReceive; + Network.Network.BufferTransmit:=SMSC95XXBufferTransmit; {Driver} {USB} Network.ReceiveEndpoint:=ReceiveEndpoint; diff --git a/source/rtl/ultibo/core/sockets.pas b/source/rtl/ultibo/core/sockets.pas index 6e90ebe..ce3a2c8 100644 --- a/source/rtl/ultibo/core/sockets.pas +++ b/source/rtl/ultibo/core/sockets.pas @@ -34,6 +34,12 @@ Notes: All BSD functions that accept an Address or Port expect them to be in Network order. All other functions that take an Address or Port expect them to be in Host order + + This unit includes the interface normally provided by the sockets unit + in the FPC package rtl-extras. The rtl-extras package does not build + the sockets unit for target Ultibo as this unit will always be available + to provide the required functionality for any other package that uses + it. } @@ -47,10 +53,6 @@ interface uses GlobalConfig,GlobalConst,GlobalTypes,GlobalSock,Platform,Threads,Devices,SysUtils,Classes,Network,Transport,Protocol,Loopback,ARP,IP,IPv6,UDP,TCP,ICMP,ICMPv6,IGMP,RAW,DHCP,DNS; -//To Do //See also: \source\packages\rtl-extra\src\win\sockets.pp -//To Do //See also: \source\packages\rtl-extra\src\inc\sockets.inc -//To Do //See also: \source\packages\rtl-extra\src\inc\socketsh.inc - {==============================================================================} {Global definitions} {$INCLUDE GlobalDefines.inc} @@ -63,6 +65,8 @@ interface SOCKETS_CONFIG_TIMER_INTERVAL = 1000; SOCKETS_FILTER_TIMER_INTERVAL = 1000; SOCKETS_PROTOCOL_TIMER_INTERVAL = 250; {Previously 100} + SOCKETS_AUTH_TIMER_INTERVAL = 1000; + SOCKETS_MONITOR_TIMER_INTERVAL = 1000; SOCKETS_TRANSPORT_TIMER_INTERVAL = 1000; SOCKETS_ADAPTER_TIMER_INTERVAL = 1000; @@ -79,7 +83,8 @@ interface EsockENOTSOCK = WSAENOTSOCK; EsockEPROTONOSUPPORT = WSAEPROTONOSUPPORT; EsockEWOULDBLOCK = WSAEWOULDBLOCK; - + EsockADDRINUSE = WSAEADDRINUSE; + SHUT_RD = SD_RECEIVE; {Aliases so we are cross-platform} SHUT_WR = SD_SEND; SHUT_RDWR = SD_BOTH; @@ -313,6 +318,7 @@ interface MSG_PEEK = GlobalSock.MSG_PEEK; MSG_DONTROUTE = GlobalSock.MSG_DONTROUTE; + MSG_INTERRUPT = GlobalSock.MSG_INTERRUPT; MSG_MAXIOVLEN = GlobalSock.MSG_MAXIOVLEN; MSG_PARTIAL = GlobalSock.MSG_PARTIAL; @@ -372,6 +378,12 @@ interface IN6ADDR_ANY_INIT:TIn6Addr = (u6_addr16: (0, 0, 0, 0, 0, 0, 0, 0)); IN6ADDR_LOOPBACK_INIT:TIn6Addr = (u6_addr8: (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1)); +const + NoAddress : in_addr = (s_addr:0); + NoNet : in_addr = (s_addr:0); + NoAddress6: in6_addr = (u6_addr16:(0,0,0,0,0,0,0,0)); + NoNet6 : in6_addr = (u6_addr16:(0,0,0,0,0,0,0,0)); + {==============================================================================} type {Sockets specific types} @@ -472,11 +484,11 @@ function Send(Sock:Longint;const Buf;BufLen,Flags:Longint):Longint; function SendTo(Sock:Longint;const Buf;BufLen,Flags:Longint;var Addr; AddrLen : Longint):Longint; function Recv(Sock:Longint;var Buf;BufLen,Flags:Longint):Longint; function RecvFrom(Sock : Longint; var Buf; Buflen,Flags : Longint; var Addr; var AddrLen : longint) : longint; -function Connect(Sock:Longint;const Addr;Addrlen:Longint):Boolean; +function Connect(Sock:Longint;const Addr;Addrlen:Longint):Boolean; overload; function Shutdown(Sock:Longint;How:Longint):Longint; function Bind(Sock:Longint;const Addr;AddrLen:Longint):Boolean; function Listen(Sock,MaxConnect:Longint):Boolean; -function Accept(Sock:Longint;var Addr;var Addrlen:Longint):Longint; +function Accept(Sock:Longint;var Addr;var Addrlen:Longint):Longint; overload; function GetSocketName(Sock:Longint;var Addr;var Addrlen:Longint):Longint; function GetPeerName(Sock:Longint;var Addr;var Addrlen:Longint):Longint; function GetSocketOptions(Sock,Level,OptName:Longint;var OptVal;var optlen:longint):Longint; @@ -523,11 +535,22 @@ function fpgetsockopt(s:cint; level:cint; optname:cint; optval:pointer; optlen : function fpsetsockopt(s:cint; level:cint; optname:cint; optval:pointer; optlen :tsocklen):cint; function fpsocketpair(d:cint; xtype:cint; protocol:cint; sv:pcint):cint; +{==============================================================================} +{RTL File/Text Sockets Functions} +procedure Sock2Text(Sock:Longint;Var SockIn,SockOut:Text); deprecated; +function Accept(Sock:longint;var addr:TInetSockAddr;var SockIn,SockOut:File):Boolean; deprecated; overload; +function Accept(Sock:longint;var addr:TInetSockAddr;var SockIn,SockOut:text):Boolean; deprecated; overload; +function Connect(Sock:longint;const addr:TInetSockAddr;var SockIn,SockOut:text):Boolean; deprecated; overload; +function Connect(Sock:longint;const addr:TInetSockAddr;var SockIn,SockOut:file):Boolean; deprecated; overload; +procedure Sock2File(Sock:Longint;Var SockIn,SockOut:File); deprecated; + {==============================================================================} {Sockets Helper Functions} procedure SocketsProcessConfig(Data:Pointer); procedure SocketsProcessFilter(Data:Pointer); procedure SocketsProcessProtocol(Data:Pointer); +procedure SocketsProcessAuth(Data:Pointer); +procedure SocketsProcessMonitor(Data:Pointer); procedure SocketsProcessTransport(Data:Pointer); procedure SocketsProcessAdapter(Data:Pointer); @@ -537,6 +560,31 @@ function SocketsNetworkDeviceRemove(Network:PNetworkDevice):LongWord; function SocketsNetworkDeviceEnum(Network:PNetworkDevice;Data:Pointer):LongWord; function SocketsNetworkDeviceNotify(Device:PDevice;Data:Pointer;Notification:LongWord):LongWord; +{==============================================================================} +{RTL Sockets Helper Functions} +function htonl(host:cardinal):cardinal; inline; +function ntohl(net:cardinal):cardinal; inline; +function htons(host:word):word; inline; +function ntohs(net:word):word; inline; + +function NetAddrToStr(Entry:in_addr):AnsiString; +function HostAddrToStr(Entry:in_addr):AnsiString; +function StrToHostAddr(IP:AnsiString):in_addr; +function StrToNetAddr(IP:AnsiString):in_addr; + +{Netdb legacy compatibility} +function HostToNet(Host:in_addr):in_addr; overload; deprecated; +function NetToHost(Net:in_addr):in_addr; overload; deprecated; +function HostToNet(Host:Longint):Longint; overload; deprecated; +function NetToHost(Net:Longint):Longint; overload; deprecated; +function ShortHostToNet(Host:Word):Word; deprecated; +function ShortNetToHost(Net:Word):Word; deprecated; + +function HostAddrToStr6(Entry:Tin6_addr):AnsiString; +function StrToHostAddr6(IP:String):Tin6_addr; +function NetAddrToStr6(Entry:Tin6_addr):AnsiString; +function StrToNetAddr6(IP:AnsiString):TIn6_Addr; + {==============================================================================} {==============================================================================} @@ -556,6 +604,8 @@ implementation SocketsConfigTimer:TTimerHandle = INVALID_HANDLE_VALUE; SocketsFilterTimer:TTimerHandle = INVALID_HANDLE_VALUE; SocketsProtocolTimer:TTimerHandle = INVALID_HANDLE_VALUE; + SocketsAuthTimer:TTimerHandle = INVALID_HANDLE_VALUE; + SocketsMonitorTimer:TTimerHandle = INVALID_HANDLE_VALUE; SocketsTransportTimer:TTimerHandle = INVALID_HANDLE_VALUE; SocketsAdapterTimer:TTimerHandle = INVALID_HANDLE_VALUE; @@ -607,8 +657,11 @@ function SocketsStart:LongWord; if TransportManager = nil then Exit; if ProtocolManager = nil then Exit; + {Check Settings} + if NetworkSettings = nil then Exit; + {Check Clients} - if DNSClient = nil then Exit; + if NetworkSettings.GetBoolean('DNS_CLIENT_ENABLED') and (DNSClient = nil) then Exit; {Acquire the Lock} if CriticalSectionLock(SocketsLock) = ERROR_SUCCESS then @@ -652,13 +705,13 @@ function SocketsStart:LongWord; {Start Transports} if TransportStart <> ERROR_SUCCESS then Exit; {$IFDEF SOCKET_DEBUG} - if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Started transports'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Started transports and monitors'); {$ENDIF} {Start Protocols} if ProtocolStart <> ERROR_SUCCESS then Exit; {$IFDEF SOCKET_DEBUG} - if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Started protocols'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Started protocols, filters and configs'); {$ENDIF} {Start Clients} @@ -667,15 +720,11 @@ function SocketsStart:LongWord; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Started clients'); {$ENDIF} - {Bind Transports} //To Do //Move to TransportBind ? - if not TransportManager.BindTransports(nil) then - begin - if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to bind one or more network transports'); - end; - - //To Do //Bind Protocols ? //No ? - - //To Do //Bind Clients ? //No ? + {Bind Transports} + if TransportBind <> ERROR_SUCCESS then Exit; + {$IFDEF SOCKET_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Bound transports and monitors'); + {$ENDIF} {Create Config Timer} SocketsConfigTimer:=TimerCreateEx(SOCKETS_CONFIG_TIMER_INTERVAL,TIMER_STATE_ENABLED,TIMER_FLAG_WORKER,TTimerEvent(SocketsProcessConfig),nil); {Rescheduled by Timer Event} @@ -685,7 +734,13 @@ function SocketsStart:LongWord; {Create Protocol Timer} SocketsProtocolTimer:=TimerCreateEx(SOCKETS_PROTOCOL_TIMER_INTERVAL,TIMER_STATE_ENABLED,TIMER_FLAG_WORKER,TTimerEvent(SocketsProcessProtocol),nil); {Rescheduled by Timer Event} - + + {Create Auth Timer} + SocketsAuthTimer:=TimerCreateEx(SOCKETS_AUTH_TIMER_INTERVAL,TIMER_STATE_ENABLED,TIMER_FLAG_WORKER,TTimerEvent(SocketsProcessAuth),nil); {Rescheduled by Timer Event} + + {Create Monitor Timer} + SocketsMonitorTimer:=TimerCreateEx(SOCKETS_MONITOR_TIMER_INTERVAL,TIMER_STATE_ENABLED,TIMER_FLAG_WORKER,TTimerEvent(SocketsProcessMonitor),nil); {Rescheduled by Timer Event} + {Create Transport Timer} SocketsTransportTimer:=TimerCreateEx(SOCKETS_TRANSPORT_TIMER_INTERVAL,TIMER_STATE_ENABLED,TIMER_FLAG_WORKER,TTimerEvent(SocketsProcessTransport),nil); {Rescheduled by Timer Event} @@ -723,15 +778,18 @@ function SocketsStop:LongWord; begin {} Result:=ERROR_INVALID_PARAMETER; - - {Check Clients} - if DNSClient = nil then Exit; {Check Managers} if ProtocolManager = nil then Exit; if TransportManager = nil then Exit; if AdapterManager = nil then Exit; + {Check Settings} + if NetworkSettings = nil then Exit; + + {Check Clients} + if NetworkSettings.GetBoolean('DNS_CLIENT_ENABLED') and (DNSClient = nil) then Exit; + {Acquire the Lock} if CriticalSectionLock(SocketsLock) = ERROR_SUCCESS then begin @@ -764,6 +822,12 @@ function SocketsStop:LongWord; {Destroy Transport Timer} TimerDestroy(SocketsTransportTimer); + {Destroy Monitor Timer} + TimerDestroy(SocketsMonitorTimer); + + {Destroy Auth Timer} + TimerDestroy(SocketsAuthTimer); + {Destroy Protocol Timer} TimerDestroy(SocketsProtocolTimer); @@ -773,15 +837,11 @@ function SocketsStop:LongWord; {Destroy Config Timer} TimerDestroy(SocketsConfigTimer); - //To Do //Unbind Clients ? //No ? - - //To Do //Unbind Protocols ? //No ? - - {Unbind Transports} //To Do //Move to TransportUnbind ? - if not TransportManager.UnbindTransports(nil) then - begin - if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to unbind one or more network transports'); - end; + {Unbind Transports} + if TransportUnbind <> ERROR_SUCCESS then Exit; + {$IFDEF SOCKET_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Unbound transports and monitors'); + {$ENDIF} {Stop Clients} if DNSStop <> ERROR_SUCCESS then Exit; @@ -792,13 +852,13 @@ function SocketsStop:LongWord; {Stop Protocols} if ProtocolStop <> ERROR_SUCCESS then Exit; {$IFDEF SOCKET_DEBUG} - if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Stopped protocols'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Stopped protocols, filters and configs'); {$ENDIF} {Stop Transports} if TransportStop <> ERROR_SUCCESS then Exit; {$IFDEF SOCKET_DEBUG} - if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Stopped transports'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Stopped transports and monitors'); {$ENDIF} {Stop Adapters} @@ -2048,6 +2108,328 @@ function fpsocketpair(d:cint; xtype:cint; protocol:cint; sv:pcint):cint; SetLastError(WSAEOPNOTSUPP); end; +{==============================================================================} +{==============================================================================} +{RTL File/Text Sockets Functions} +function fpRead(Handle:LongInt;var BufPtr;Size:DWORD):DWORD; +var + Available:DWORD; + Socket:TProtocolSocket; +begin + {} + Result:=0; + try + {Check Started} + SetLastError(WSANOTINITIALISED); + if SocketsStartupError <> ERROR_SUCCESS then Exit; + + {Check Socket} + SetLastError(WSAENOTSOCK); + Socket:=TProtocolSocket(Handle); + if Socket = nil then Exit; + + {Check Manager} + if ProtocolManager = nil then Exit; + + {Check Socket} + if not ProtocolManager.CheckSocket(Handle,True,NETWORK_LOCK_READ) then Exit; + + {IOCTL Socket} + if Socket.Protocol.IoctlSocket(Socket,FIONREAD,Available) = SOCKET_ERROR then Exit; + + if Available > 0 then + begin + if Size > Available then Size:=Available; + + {Receive Socket} + Result:=DWORD(Socket.Protocol.Recv(Socket,BufPtr,Size,0)); + if Result = DWORD(SOCKET_ERROR) then Result:=0; + end; + + {Unlock Socket} + Socket.ReaderUnlock; + except + on E: Exception do + begin + SetLastError(WSAENOTSOCK); + {$IFDEF SOCKET_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Exception: fpRead ' + E.Message); + {$ENDIF} + end; + end; +end; + +{==============================================================================} + +function fpWrite(Handle:LongInt;var BufPtr;Size:DWORD):DWORD; +var + Socket:TProtocolSocket; +begin + {} + Result:=0; + try + {Check Started} + SetLastError(WSANOTINITIALISED); + if SocketsStartupError <> ERROR_SUCCESS then Exit; + + {Check Socket} + SetLastError(WSAENOTSOCK); + Socket:=TProtocolSocket(Handle); + if Socket = nil then Exit; + + {Check Manager} + if ProtocolManager = nil then Exit; + + {Check Socket} + if not ProtocolManager.CheckSocket(Handle,True,NETWORK_LOCK_READ) then Exit; + + {Send Socket} + Result:=DWORD(Socket.Protocol.Send(Socket,BufPtr,Size,0)); + if Result = DWORD(SOCKET_ERROR) then Result:=0; + + {Unlock Socket} + Socket.ReaderUnlock; + except + on E: Exception do + begin + SetLastError(WSAENOTSOCK); + {$IFDEF SOCKET_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Exception: fpWrite ' + E.Message); + {$ENDIF} + end; + end; +end; + +{==============================================================================} + +procedure OpenSock(var F:Text); +begin + {} + if Textrec(F).Handle=UnusedHandle then + begin + Textrec(F).Mode:=fmClosed; + end + else + begin + case Textrec(F).userdata[1] of + S_OUT:Textrec(F).Mode:=fmOutput; + S_IN:Textrec(F).Mode:=fmInput; + else + Textrec(F).Mode:=fmClosed; + end; + end; +end; + +{==============================================================================} + +procedure IOSock(var F:Text); +var + Return:sizeint; + DefaultError:Word; +begin + {} + with Textrec(F) do + begin + case Mode of + fmOutput:begin + repeat + {$ifdef use_readwrite} + Return:=fpWrite(Handle,BufPtr^,BufPos); + {$else} + Return:=fpSend(Handle,BufPtr,BufPos,0); + {$endif} + until (Return <> -1) or (SocketError <> EsockEINTR); + + BufEnd:=Return; + DefaultError:=101; {File write error} + end; + fmInput:begin + repeat + {$ifdef use_readwrite} + Return:=fpRead(Handle,BufPtr^,BufSize); + {$else} + Return:=fpRecv(Handle,BufPtr,BufSize,0); + {$endif} + until (Return <> -1) or (SocketError <> EsockEINTR); + + BufEnd:=Return; + DefaultError:=100; {File read error} + end; + end; + + if Return = -1 then + begin + case SocketError of + EsockEBADF,EsockENOTSOCK:InOutRes:=6; {Invalid file handle} + EsockEFAULT:InOutRes:=217; + EsockEINVAL:InOutRes:=218; + else + InOutRes:=DefaultError; + end; + end; + + BufPos:=0; + end; +end; + +{==============================================================================} + +procedure FlushSock(var F:Text); +begin + {} + if (Textrec(F).Mode = fmOutput) and (Textrec(F).BufPos <> 0) then + begin + IOSock(F); + Textrec(F).BufPos:=0; + end; +end; + +{==============================================================================} + +procedure CloseSock(var F:text); +begin + {Nothing special has to be done here} +end; + +{==============================================================================} + +procedure Sock2Text(Sock:Longint;Var SockIn,SockOut:Text); +{Set up two Pascal Text file descriptors for reading and writing} +begin + {First the reading part.} + Assign(SockIn,'.'); + Textrec(SockIn).Handle:=Sock; + Textrec(Sockin).userdata[1]:=S_IN; + TextRec(SockIn).OpenFunc:=@OpenSock; + TextRec(SockIn).InOutFunc:=@IOSock; + TextRec(SockIn).FlushFunc:=@FlushSock; + TextRec(SockIn).CloseFunc:=@CloseSock; + TextRec(SockIn).Mode:=fmInput; + + case DefaultTextLineBreakStyle of + tlbsLF:TextRec(SockIn).LineEnd:=#10; + tlbsCRLF:TextRec(SockIn).LineEnd:=#13#10; + tlbsCR:TextRec(SockIn).LineEnd:=#13; + end; + + {Now the writing part} + Assign(SockOut,'.'); + Textrec(SockOut).Handle:=Sock; + Textrec(SockOut).userdata[1]:=S_OUT; + TextRec(SockOut).OpenFunc:=@OpenSock; + TextRec(SockOut).InOutFunc:=@IOSock; + TextRec(SockOut).FlushFunc:=@FlushSock; + TextRec(SockOut).CloseFunc:=@CloseSock; + TextRec(SockOut).Mode:=fmOutput; + + case DefaultTextLineBreakStyle of + tlbsLF:TextRec(SockOut).LineEnd:=#10; + tlbsCRLF:TextRec(SockOut).LineEnd:=#13#10; + tlbsCR:TextRec(SockOut).LineEnd:=#13; + end; +end; + +{==============================================================================} + +function DoAccept(Sock:longint;var addr:TInetSockAddr):longint; +var + AddrLen:Longint; +begin + {} + AddrLen:=SizeOf(Addr); + repeat + Result:=fpAccept(Sock,@Addr,@AddrLen); + until (Result <> -1) or (SocketError <> EsockEINTR); +end; + +{==============================================================================} + +function Accept(Sock:longint;var addr:TInetSockAddr;var SockIn,SockOut:File):Boolean; +var + S:longint; +begin + {} + S:=DoAccept(Sock,addr); + if S > 0 then + begin + Sock2File(S,SockIn,SockOut); + Result:=True; + end + else + begin + Result:=False; + end; +end; + +{==============================================================================} + +function Accept(Sock:longint;var addr:TInetSockAddr;var SockIn,SockOut:text):Boolean; +var + S:longint; +begin + {} + S:=DoAccept(Sock,addr); + if S > 0 then + begin + Sock2Text(S,SockIn,SockOut); + Result:=True; + end + else + begin + Result:=False; + end; +end; + +{==============================================================================} + +function DoConnect(Sock:longint;const addr:TInetSockAddr):Boolean; +var + Res:longint; +begin + {} + repeat + Res:=fpConnect(Sock,@Addr,SizeOF(TInetSockAddr)); + until (Res <> -1) or (SocketError <> EsockEINTR); + Result:=(Res = 0); +end; + +{==============================================================================} + +function Connect(Sock:longint;const addr:TInetSockAddr;var SockIn,SockOut:text):Boolean; +begin + {} + Result:=DoConnect(Sock,addr); + if Result then Sock2Text(Sock,SockIn,SockOut); +end; + +{==============================================================================} + +function Connect(Sock:longint;const addr:TInetSockAddr;var SockIn,SockOut:file):Boolean; +begin + {} + Result:=DoConnect(Sock,addr); + if Result then Sock2File(Sock,SockIn,SockOut); +end; + +{==============================================================================} + +procedure Sock2File(Sock:Longint;Var SockIn,SockOut:File); +begin + {Input} + Assign(SockIn,'.'); + FileRec(SockIn).Handle:=Sock; + FileRec(SockIn).RecSize:=1; + FileRec(Sockin).userdata[1]:=S_IN; + FileRec(SockIn).Mode:=fmInput; + + {Output} + Assign(SockOut,'.'); + FileRec(SockOut).Handle:=Sock; + FileRec(SockOut).RecSize:=1; + FileRec(SockOut).userdata[1]:=S_OUT; + FileRec(SockOut).Mode:=fmOutput; +end; + {==============================================================================} {==============================================================================} {Sockets Helper Functions} @@ -2117,6 +2499,50 @@ procedure SocketsProcessProtocol(Data:Pointer); {==============================================================================} +procedure SocketsProcessAuth(Data:Pointer); +begin + {} + try + {$IFDEF SOCKET_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Process authenticators'); + {$ENDIF} + + {Check Manager} + if TransportManager = nil then Exit; + + {Process Authenticators} + TransportManager.ProcessAuthenticators; + + finally + {Enable Timer} + TimerEnable(SocketsAuthTimer); + end; +end; + +{==============================================================================} + +procedure SocketsProcessMonitor(Data:Pointer); +begin + {} + try + {$IFDEF SOCKET_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'Sockets: Process monitors'); + {$ENDIF} + + {Check Manager} + if TransportManager = nil then Exit; + + {Process Monitors} + TransportManager.ProcessMonitors; + + finally + {Enable Timer} + TimerEnable(SocketsMonitorTimer); + end; +end; + +{==============================================================================} + procedure SocketsProcessTransport(Data:Pointer); begin {} @@ -2190,6 +2616,9 @@ procedure SocketsNetworkDeviceAdd(Event:PSocketsDeviceEvent); if TransportManager = nil then Exit; if ProtocolManager = nil then Exit; + {Check Settings} + if NetworkSettings = nil then Exit; + {Acquire the Lock} if CriticalSectionLock(SocketsLock) = ERROR_SUCCESS then begin @@ -2205,15 +2634,25 @@ procedure SocketsNetworkDeviceAdd(Event:PSocketsDeviceEvent); if Adapter = nil then begin {Create Adapter} - if WIRED_NETWORK_ENABLED then + if NetworkSettings.GetBooleanDefault('WIRED_NETWORK_ENABLED',WIRED_NETWORK_ENABLED) then begin Adapter:=TWiredAdapter.Create(AdapterManager,Event.Device,DeviceGetName(@Event.Device.Device)); - - {Start Adapter} - Adapter.StartAdapter; - - {Bind Transports} - TransportManager.BindTransports(Adapter); + + {Check Adapter} + if not NetworkSettings.GetBoolean(Adapter.Name + '_DISABLED') then + begin + {Start Adapter} + Adapter.StartAdapter; + + {Bind Transports} + TransportManager.BindTransports(Adapter); + + {Bind Monitors} + TransportManager.BindMonitors(Adapter); + + {Bind Authenticators} + TransportManager.BindAuthenticators(Adapter); + end; end; end; end; @@ -2268,6 +2707,12 @@ function SocketsNetworkDeviceRemove(Network:PNetworkDevice):LongWord; Adapter:=AdapterManager.GetAdapterByDevice(Network,True,NETWORK_LOCK_READ); if Adapter <> nil then begin + {Unbind Authenticators} + TransportManager.UnbindAuthenticators(Adapter); + + {Unbind Monitors} + TransportManager.UnbindMonitors(Adapter); + {Unbind Transports} TransportManager.UnbindTransports(Adapter); @@ -2316,6 +2761,9 @@ function SocketsNetworkDeviceEnum(Network:PNetworkDevice;Data:Pointer):LongWord; {Check Manager} if AdapterManager = nil then Exit; + {Check Settings} + if NetworkSettings = nil then Exit; + {Acquire the Lock} if CriticalSectionLock(SocketsLock) = ERROR_SUCCESS then begin @@ -2331,7 +2779,7 @@ function SocketsNetworkDeviceEnum(Network:PNetworkDevice;Data:Pointer):LongWord; if Adapter = nil then begin {Create Adapter} - if WIRED_NETWORK_ENABLED then + if NetworkSettings.GetBooleanDefault('WIRED_NETWORK_ENABLED',WIRED_NETWORK_ENABLED) then begin TWiredAdapter.Create(AdapterManager,Network,DeviceGetName(@Network.Device)); end; @@ -2451,6 +2899,346 @@ function SocketsNetworkDeviceNotify(Device:PDevice;Data:Pointer;Notification:Lon end; end; +{==============================================================================} +{==============================================================================} +{RTL Sockets Helper Functions} +function htonl(host:cardinal):cardinal; inline; +begin + {} + {$IFDEF FPC_BIG_ENDIAN} + Result:=host; + {$ELSE} + Result:=SwapEndian(host); + {$ENDIF} +end; + +{==============================================================================} + +function ntohl(net:cardinal):cardinal; inline; +begin + {} + {$IFDEF FPC_BIG_ENDIAN} + Result:=net; + {$ELSE} + Result:=SwapEndian(net); + {$ENDIF} +end; + +{==============================================================================} + +function htons(host:word):word; inline; +begin + {} + {$IFDEF FPC_BIG_ENDIAN} + Result:=host; + {$ELSE} + Result:=SwapEndian(host); + {$ENDIF} +end; + +{==============================================================================} + +function ntohs(net:word):word; inline; +begin + {} + {$IFDEF FPC_BIG_ENDIAN} + Result:=net; + {$ELSE} + Result:=SwapEndian(net); + {$ENDIF} +end; + +{==============================================================================} + +type + Array4Int = array[1..4] of Byte; + +function NetAddrToStr(Entry:in_addr):AnsiString; +var + Count:LongInt; + Value:LongInt; + Dummy:AnsiString; +begin + {} + Result:=''; + + Value:=Entry.S_addr; + for Count:=1 to 4 do + begin + Str(Array4Int(Value)[Count],Dummy); + Result:=Result + Dummy; + if Count < 4 then Result:=Result + '.'; + end; +end; + +{==============================================================================} + +function HostAddrToStr(Entry:in_addr):AnsiString; +var + Value:in_addr; +begin + {} + Value.S_addr:=htonl(Entry.S_addr); + Result:=NetAddrToStr(Value); +end; + +{==============================================================================} + +function StrToHostAddr(IP:AnsiString):in_addr; +var + Temp:in_addr; + Count,Index,Value:LongInt; + Dummy:AnsiString; +begin + {} + Result.S_addr:=0; { :=NoAddress; } + + for Count:=1 to 4 do + begin + if Count < 4 then + begin + Index:=Pos('.',IP); + if Index = 0 then Exit; + + Dummy:=Copy(IP,1,Index - 1); + Delete(IP,1,Index); + end + else + begin + Dummy:=IP; + end; + + Val(Dummy,Value,Index); + Array4Int(Temp.S_addr)[Count]:=Value; + if Index <> 0 then Exit; + end; + + Result.S_addr:=ntohl(Temp.S_addr); +end; + +{==============================================================================} + +function StrToNetAddr(IP:AnsiString):in_addr; +begin + {} + Result.S_addr:=htonl(StrToHostAddr(IP).S_addr); +end; + +{==============================================================================} + +function HostToNet(Host:in_addr):in_addr; +begin + {} + Result.S_addr:=htonl(Host.S_addr); +end; + +{==============================================================================} + +function NetToHost(Net:in_addr):in_addr; +begin + {} + Result.S_addr:=ntohl(Net.S_addr); +end; + +{==============================================================================} + +function HostToNet(Host:Longint):Longint; +begin + {} + Result:=htonl(Host); +end; + +{==============================================================================} + +function NetToHost(Net:Longint):Longint; +begin + {} + Result:=ntohl(Net); +end; + +{==============================================================================} + +function ShortHostToNet(Host:Word):Word; +begin + {} + Result:=htons(Host); +end; + +{==============================================================================} + +function ShortNetToHost(Net:Word):Word; +begin + {} + Result:=ntohs(Net); +end; + +{==============================================================================} + +const + DigitTab:ShortString = ('0123456789ABCDEF'); + +function LocalIntToHex(Value:Integer;Digits:LongInt):AnsiString; +begin + {} + SetLength(Result,4); + Result[4]:=DigitTab[1 +(Value and 15)]; + Result[3]:=DigitTab[1 +((Value shr 4) and 15)]; + Result[2]:=DigitTab[1 +((Value shr 8) and 15)]; + Result[1]:=DigitTab[1 +((Value shr 12) and 15)];; +end; + +{==============================================================================} + +function HostAddrToStr6(Entry:Tin6_addr):AnsiString; +//To Do //This needs testing +var + Count:Byte; + ZC1,ZC2:Byte; + ZR1,ZR2:set of Byte; + Skipped:Boolean; +begin + {} + ZR1:=[]; + ZR2:=[]; + ZC1:=0; + ZC2:=0; + + for Count:=0 to 7 do + begin + if Entry.u6_addr16[Count] = 0 then + begin + Include(ZR2,Count); + Inc(ZC2); + end + else + begin + if ZC1 < ZC2 then + begin + ZC1:=ZC2; + ZR1:=ZR2; + ZC2:=0; + ZR2:=[]; + end; + end; + end; + + if ZC1 < ZC2 then + begin + ZC1:=ZC2; + ZR1:=ZR2; + end; + + SetLength(Result,8 * 5 - 1); + SetLength(Result,0); + Skipped:=False; + + for Count:=0 to 7 do + begin + if not(Count in ZR1) then + begin + if Skipped then + begin + if Result = '' then Result:='::' else Result:=Result + ':'; + + Skipped:=False; + end; + + //FIXME: is that shortnettohost really proper there? I wouldn't be too sure... + Result:=Result + LocalIntToHex(ShortNetToHost(Entry.u6_addr16[Count]),1) + ':'; + end + else + begin + Skipped:=True; + end; + end; + + if Skipped then + begin + if Result = '' then Result:='::' else Result:=Result + ':'; + end; + + if Result = '' then Result:='::'; + + if not(7 in ZR1) then SetLength(Result,Length(Result) - 1); +end; + +{==============================================================================} + +function StrToHostAddr6(IP:String):Tin6_addr; +//To Do //This needs testing +var + Part:String; + Value:Word; + Code:Integer; + Index:Integer; + ZeroAt:Integer; + IPv6:TIn6_addr; + Position:Integer; +Begin + {} + FillChar(IPv6,SizeOf(IPv6),0); + + { Every 16-bit block is converted at its own and stored into Result. When } + { the '::' zero-spacer is found, its location is stored. Afterwards the } + { address is shifted and zero-filled. } + Index:=0; + ZeroAt:=-1; + Code:=0; + Position:=Pos(':',IP); + while (Position > 0) and (Length(IP) > 0) and (Index < 8) do + begin + Part:='$' + Copy(IP,1,Position - 1); + Delete(IP,1,Position); + + if Length(Part) > 1 then Val(Part,Value,Code) else Value:=0; { is there a digit after the '$'? } + + IPv6.u6_addr16[Index]:=htons(Value); + + if Code <> 0 then + begin + FillChar(IPv6,SizeOf(IPv6),0); + Exit; + end; + + if IP[1] = ':' then + begin + ZeroAt:=Index; + Delete(IP,1,1); + end; + + Inc(Index); + Position:=Pos(':',IP); + if Position = 0 then Position:=Length(IP) + 1; + end; + + { Address a:b:c::f:g:h } + { Result now a : b : c : f : g : h : 0 : 0, ZeroAt = 2, Index = 6 } + { Result after a : b : c : 0 : 0 : f : g : h } + if ZeroAt >= 0 then + begin + System.Move(IPv6.u6_addr16[ZeroAt + 1],IPv6.u6_addr16[(8 - Index) + ZeroAt + 1],2 * (Index - ZeroAt - 1)); + FillChar(IPv6.u6_addr16[ZeroAt + 1],2 * (8 - Index),0); + end; + + Result:=IPv6; +End; + +{==============================================================================} + +function NetAddrToStr6(Entry:Tin6_addr):AnsiString; +begin + {} + Result:=HostAddrToStr6(Entry); +end; + +{==============================================================================} + +function StrToNetAddr6(IP:AnsiString):TIn6_Addr; +begin + {} + Result:=StrToHostAddr6(IP); +end; + {==============================================================================} {==============================================================================} diff --git a/source/rtl/ultibo/core/tcp.pas b/source/rtl/ultibo/core/tcp.pas index 2d46f66..88eaca8 100644 --- a/source/rtl/ultibo/core/tcp.pas +++ b/source/rtl/ultibo/core/tcp.pas @@ -244,9 +244,10 @@ TTCPProtocol = class(TNetworkProtocol) private {Internal Variables} FNextPort:Word; - + FReceiveBacklog:Integer; + {Status Variables} - + {Internal Methods} function PacketHandler(AHandle:THandle;ASource,ADest,APacket:Pointer;ASize:Integer;ABroadcast:Boolean):Boolean; function SegmentHandler(ASocket:TTCPSocket;ASource,ADest,APacket:Pointer;ASize:Integer):Boolean; @@ -1018,7 +1019,7 @@ function TTCPProtocol.SegmentHandler(ASocket:TTCPSocket;ASource,ADest,APacket:Po if ASocket.AcceptQueue.Count >= ASocket.BackLog then Exit; {Check Receive Backlog} - if ASocket.ReceiveQueue.Count >= TCP_RECEIVE_BACKLOG then Exit; + if ASocket.ReceiveQueue.Count >= FReceiveBacklog then Exit; {Clone Socket} Socket:=CloneSocket(ASocket,@IP.DestIP,@IP.SourceIP,TCP.DestPort,TCP.SourcePort,True,NETWORK_LOCK_READ); @@ -4573,8 +4574,11 @@ function TTCPProtocol.StartProtocol:Boolean; Transport.ReaderUnlock; end; + {Get Receive Backlog} + FReceiveBacklog:=Manager.Settings.GetIntegerDefault('TCP_RECEIVE_BACKLOG',TCP_RECEIVE_BACKLOG); + {Create Thread} - FThread:=TSocketThread.Create(Self,TCP_MESSAGESLOT_MAXIMUM); + FThread:=TSocketThread.Create(Self,Manager.Settings.GetIntegerDefault('TCP_MESSAGESLOT_MAXIMUM',TCP_MESSAGESLOT_MAXIMUM)); {FThread.FreeOnTerminate:=True;} {Freed by StopProtocol} {Start Thread} @@ -8739,7 +8743,7 @@ procedure TCPInit; if TCPInitialized then Exit; {Create TCP Protocol} - if TCP_PROTOCOL_ENABLED then + if NetworkSettings.GetBooleanDefault('TCP_PROTOCOL_ENABLED',TCP_PROTOCOL_ENABLED) then begin TTCPProtocol.Create(ProtocolManager,TCP_PROTOCOL_NAME); end; diff --git a/source/rtl/ultibo/core/transport.pas b/source/rtl/ultibo/core/transport.pas index fd91bbe..a99c1b1 100644 --- a/source/rtl/ultibo/core/transport.pas +++ b/source/rtl/ultibo/core/transport.pas @@ -59,10 +59,6 @@ interface uses GlobalConfig,GlobalConst,GlobalTypes,GlobalSock,Threads,Devices,SysUtils,Classes,Network,Ultibo,UltiboClasses; -//To Do //Look for: - -//-- - {==============================================================================} {Global definitions} {$INCLUDE GlobalDefines.inc} @@ -70,7 +66,6 @@ interface {==============================================================================} const {Transport specific constants} - {These items must also be included in Winsock.pas/Winsock2.pas} //To Do //No longer true since the addition of GlobalSock ? and other structure changes ? HOST_TYPE_DYNAMIC = 0; HOST_TYPE_STATIC = 1; HOST_TYPE_LOOPBACK = 2; @@ -172,14 +167,14 @@ interface {Transport specific types} {Generic Transport} PTransportStatistics = ^TTransportStatistics; - TTransportStatistics = packed record - PacketsIn:LongInt; //To Do //LongWord/Int64 ? - PacketsOut:LongInt; - BytesIn:LongInt; //To Do //Int64 - BytesOut:LongInt; //To Do //Int64 - ErrorsIn:LongInt; - ErrorsOut:LongInt; - PacketsLost:LongInt; + TTransportStatistics = record + PacketsIn:Int64; + PacketsOut:Int64; + BytesIn:Int64; + BytesOut:Int64; + ErrorsIn:Int64; + ErrorsOut:Int64; + PacketsLost:Int64; end; {IP Transport} @@ -207,17 +202,26 @@ interface TNetworkTransport = class; TTransportCallback = function(ATransport:TNetworkTransport):Boolean of object; + TNetworkMonitor = class; + TMonitorCallback = function(AMonitor:TNetworkMonitor):Boolean of object; + + TNetworkAuthenticator = class; + TAuthenticatorCallback = function(AAuthenticator:TNetworkAuthenticator):Boolean of object; + TTransportManager = class(TObject) - constructor Create(AAdapters:TAdapterManager); + constructor Create(ASettings:TNetworkSettings;AAdapters:TAdapterManager); destructor Destroy; override; private {Internal Variables} FLock:TSynchronizerHandle; + FSettings:TNetworkSettings; FAdapters:TAdapterManager; - + {Status Variables} - FTransports:TNetworkList; {List of TNetworkTransport objects} - + FTransports:TNetworkList; {List of TNetworkTransport objects} + FMonitors:TNetworkList; {List of TNetworkMonitor objects} + FAuthenticators:TNetworkList; {List of TNetworkAuthenticator objects} + {Event Variables} {Internal Methods} @@ -227,8 +231,9 @@ TTransportManager = class(TObject) function WriterUnlock:Boolean; public {Public Properties} + property Settings:TNetworkSettings read FSettings; property Adapters:TAdapterManager read FAdapters; - + {Public Methods} function AddTransport(ATransport:TNetworkTransport):Boolean; function RemoveTransport(ATransport:TNetworkTransport):Boolean; @@ -237,6 +242,19 @@ TTransportManager = class(TObject) function GetTransportByTransport(ATransport:TNetworkTransport;ALock:Boolean;AState:LongWord):TNetworkTransport; function GetTransportByNext(APrevious:TNetworkTransport;ALock,AUnlock:Boolean;AState:LongWord):TNetworkTransport; + function AddMonitor(AMonitor:TNetworkMonitor):Boolean; + function RemoveMonitor(AMonitor:TNetworkMonitor):Boolean; + + function GetMonitorByMonitor(AMonitor:TNetworkMonitor;ALock:Boolean;AState:LongWord):TNetworkMonitor; + function GetMonitorByNext(APrevious:TNetworkMonitor;ALock,AUnlock:Boolean;AState:LongWord):TNetworkMonitor; + + function AddAuthenticator(AAuthenticator:TNetworkAuthenticator):Boolean; + function RemoveAuthenticator(AAuthenticator:TNetworkAuthenticator):Boolean; + + function GetAuthenticatorByType(AAuthType:Word;ALock:Boolean;AState:LongWord):TNetworkAuthenticator; + function GetAuthenticatorByAuthenticator(AAuthenticator:TNetworkAuthenticator;ALock:Boolean;AState:LongWord):TNetworkAuthenticator; + function GetAuthenticatorByNext(APrevious:TNetworkAuthenticator;ALock,AUnlock:Boolean;AState:LongWord):TNetworkAuthenticator; + function StartTransports:Boolean; function StopTransports:Boolean; function ProcessTransports:Boolean; @@ -245,6 +263,24 @@ TTransportManager = class(TObject) function BindTransports(AAdapter:TNetworkAdapter):Boolean; function UnbindTransports(AAdapter:TNetworkAdapter):Boolean; + + function StartMonitors:Boolean; + function StopMonitors:Boolean; + function ProcessMonitors:Boolean; + + function EnumerateMonitors(ACallback:TMonitorCallback):Boolean; + + function BindMonitors(AAdapter:TNetworkAdapter):Boolean; + function UnbindMonitors(AAdapter:TNetworkAdapter):Boolean; + + function StartAuthenticators:Boolean; + function StopAuthenticators:Boolean; + function ProcessAuthenticators:Boolean; + + function EnumerateAuthenticators(ACallback:TAuthenticatorCallback):Boolean; + + function BindAuthenticators(AAdapter:TNetworkAdapter):Boolean; + function UnbindAuthenticators(AAdapter:TNetworkAdapter):Boolean; end; TTransportAdapter = class; @@ -516,6 +552,132 @@ TNetworkTransport = class(TListObject) function UnbindTransport(AAdapter:TNetworkAdapter):Boolean; virtual; end; + TMonitorAdapter = class(TListObject) {Downstream} + constructor Create; + destructor Destroy; override; + private + {Internal Variables} + FLock:TSynchronizerHandle; + public + {Status Variables} + Handle:THandle; //To Do //Do these need lock protection ? + Adapter:TNetworkAdapter; + + {Public Methods} + function ReaderLock:Boolean; + function ReaderUnlock:Boolean; + function WriterLock:Boolean; + function WriterUnlock:Boolean; + end; + + TNetworkMonitor = class(TListObject) {eg Packet Capture} + constructor Create(AManager:TTransportManager); + destructor Destroy; override; + private + {Internal Variables} + FLock:TSynchronizerHandle; + protected + {Internal Variables} + FManager:TTransportManager; + + {Status Variables} + FAdapters:TNetworkList; {List of TMonitorAdapter objects} + + {Event Methods} + + {Internal Methods} + function GetAdapterByHandle(AHandle:THandle;ALock:Boolean;AState:LongWord):TMonitorAdapter; + function GetAdapterByAdapter(AAdapter:TNetworkAdapter;ALock:Boolean;AState:LongWord):TMonitorAdapter; + function GetAdapterByNext(APrevious:TMonitorAdapter;ALock,AUnlock:Boolean;AState:LongWord):TMonitorAdapter; + + {Protected Methods} + function AddAdapter(AAdapter:TNetworkAdapter):Boolean; virtual; + function RemoveAdapter(AAdapter:TNetworkAdapter):Boolean; virtual; + public + {Public Properties} + property Manager:TTransportManager read FManager; + + {Public Methods} + function ReaderLock:Boolean; + function ReaderUnlock:Boolean; + function WriterLock:Boolean; + function WriterUnlock:Boolean; + + function StartMonitor:Boolean; virtual; + function StopMonitor:Boolean; virtual; + function ProcessMonitor:Boolean; virtual; + + function BindMonitor(AAdapter:TNetworkAdapter):Boolean; virtual; + function UnbindMonitor(AAdapter:TNetworkAdapter):Boolean; virtual; + end; + + TAuthenticatorAdapter = class(TListObject) {Downstream} + constructor Create; + destructor Destroy; override; + private + {Internal Variables} + FLock:TSynchronizerHandle; + public + {Status Variables} + Handle:THandle; //To Do //Do these need lock protection ? + Adapter:TNetworkAdapter; + + {Public Methods} + function ReaderLock:Boolean; + function ReaderUnlock:Boolean; + function WriterLock:Boolean; + function WriterUnlock:Boolean; + end; + + TNetworkAuthenticator = class(TListObject) {eg EAP/RSN} + constructor Create(AManager:TTransportManager); + destructor Destroy; override; + private + {Internal Variables} + FLock:TSynchronizerHandle; + protected + {Internal Variables} + FManager:TTransportManager; + + {Status Variables} + FAuthType:Word; + FInitDelay:LongWord; + FRetryCount:LongWord; + FRetryTimeout:LongWord; + FAdapters:TNetworkList; {List of TAuthenticatorAdapter objects} + + {Event Methods} + + {Internal Methods} + function GetAdapterByHandle(AHandle:THandle;ALock:Boolean;AState:LongWord):TAuthenticatorAdapter; + function GetAdapterByAdapter(AAdapter:TNetworkAdapter;ALock:Boolean;AState:LongWord):TAuthenticatorAdapter; + function GetAdapterByNext(APrevious:TAuthenticatorAdapter;ALock,AUnlock:Boolean;AState:LongWord):TAuthenticatorAdapter; + + {Protected Methods} + function AddAdapter(AAdapter:TNetworkAdapter;AAuthType:Word;ACipher,AKey,AEntity,AToken:Pointer):Boolean; virtual; + function RemoveAdapter(AAdapter:TNetworkAdapter):Boolean; virtual; + public + {Public Properties} + property Manager:TTransportManager read FManager; + property AuthType:Word read FAuthType; + property InitDelay:LongWord read FInitDelay; + property RetryCount:LongWord read FRetryCount; + property RetryTimeout:LongWord read FRetryTimeout; + + {Public Methods} + function ReaderLock:Boolean; + function ReaderUnlock:Boolean; + function WriterLock:Boolean; + function WriterUnlock:Boolean; + + function StartAuthenticator:Boolean; virtual; + function StopAuthenticator:Boolean; virtual; + function ProcessAuthenticator:Boolean; virtual; + + function BindAuthenticator(AAdapter:TNetworkAdapter):Boolean; virtual; + function UnbindAuthenticator(AAdapter:TNetworkAdapter):Boolean; virtual; + end; + TSocketList = class; TSocketState = class; TSocketBuffer = class; @@ -1118,6 +1280,9 @@ procedure TransportInit; function TransportStart:LongWord; function TransportStop:LongWord; +function TransportBind:LongWord; +function TransportUnbind:LongWord; + {==============================================================================} {Transport Functions} function InAddrToHost(const AAddress:TInAddr):TInAddr; inline; @@ -1182,13 +1347,17 @@ implementation {==============================================================================} {==============================================================================} {TTransportManager} -constructor TTransportManager.Create(AAdapters:TAdapterManager); +constructor TTransportManager.Create(ASettings:TNetworkSettings;AAdapters:TAdapterManager); begin {} inherited Create; FLock:=SynchronizerCreate; + FSettings:=ASettings; FAdapters:=AAdapters; + FTransports:=TNetworkList.Create; + FMonitors:=TNetworkList.Create; + FAuthenticators:=TNetworkList.Create; end; {==============================================================================} @@ -1198,7 +1367,10 @@ destructor TTransportManager.Destroy; {} WriterLock; try + FAuthenticators.Free; + FMonitors.Free; FTransports.Free; + FSettings:=nil; FAdapters:=nil; inherited Destroy; finally @@ -1405,29 +1577,24 @@ function TTransportManager.GetTransportByNext(APrevious:TNetworkTransport;ALock, {==============================================================================} -function TTransportManager.StartTransports:Boolean; -var - Transport:TNetworkTransport; +function TTransportManager.AddMonitor(AMonitor:TNetworkMonitor):Boolean; begin {} ReaderLock; try - Result:=True; - {$IFDEF TRANSPORT_DEBUG} - if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: StartTransports'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: AddMonitor'); {$ENDIF} - - {Get Transport} - Transport:=TNetworkTransport(GetTransportByNext(nil,True,False,NETWORK_LOCK_READ)); - while Transport <> nil do - begin - {Start Transport} - if not(Transport.StartTransport) then Result:=False; - - {Get Next} - Transport:=TNetworkTransport(GetTransportByNext(Transport,True,True,NETWORK_LOCK_READ)); - end; + + {Acquire Lock} + FMonitors.WriterLock; + try + {Add Monitor} + Result:=FMonitors.Add(AMonitor); + finally + {Release Lock} + FMonitors.WriterUnlock; + end; finally ReaderUnlock; end; @@ -1435,29 +1602,24 @@ function TTransportManager.StartTransports:Boolean; {==============================================================================} -function TTransportManager.StopTransports:Boolean; -var - Transport:TNetworkTransport; +function TTransportManager.RemoveMonitor(AMonitor:TNetworkMonitor):Boolean; begin {} ReaderLock; try - Result:=True; - {$IFDEF TRANSPORT_DEBUG} - if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: StopTransports'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: RemoveMonitor'); {$ENDIF} - - {Get Transport} - Transport:=TNetworkTransport(GetTransportByNext(nil,True,False,NETWORK_LOCK_READ)); - while Transport <> nil do - begin - {Stop Transport} - if not(Transport.StopTransport) then Result:=False; - - {Get Next} - Transport:=TNetworkTransport(GetTransportByNext(Transport,True,True,NETWORK_LOCK_READ)); - end; + + {Acquire Lock} + FMonitors.WriterLock; + try + {Remove Monitor} + Result:=FMonitors.Remove(AMonitor); + finally + {Release Lock} + FMonitors.WriterUnlock; + end; finally ReaderUnlock; end; @@ -1465,64 +1627,104 @@ function TTransportManager.StopTransports:Boolean; {==============================================================================} -function TTransportManager.ProcessTransports:Boolean; +function TTransportManager.GetMonitorByMonitor(AMonitor:TNetworkMonitor;ALock:Boolean;AState:LongWord):TNetworkMonitor; var - Transport:TNetworkTransport; + Monitor:TNetworkMonitor; begin {} - ReaderLock; + FMonitors.ReaderLock; try - Result:=True; - - {$IFDEF TRANSPORT_DEBUG} - //--if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: ProcessTransports'); - {$ENDIF} + Result:=nil; - {Get Transport} - Transport:=TNetworkTransport(GetTransportByNext(nil,True,False,NETWORK_LOCK_READ)); - while Transport <> nil do + {Get Monitor} + Monitor:=TNetworkMonitor(FMonitors.First); + while Monitor <> nil do begin - {Process Transport} - if not(Transport.ProcessTransport) then Result:=False; - - {Get Next} - Transport:=TNetworkTransport(GetTransportByNext(Transport,True,True,NETWORK_LOCK_READ)); + {Check Monitor} + if Monitor = AMonitor then + begin + {Lock Monitor} + if ALock then if AState = NETWORK_LOCK_READ then Monitor.ReaderLock else Monitor.WriterLock; + + {Return Result} + Result:=Monitor; + Exit; + end; + + {Get Next} + Monitor:=TNetworkMonitor(Monitor.Next); end; finally - ReaderUnlock; + FMonitors.ReaderUnlock; end; end; {==============================================================================} -function TTransportManager.EnumerateTransports(ACallback:TTransportCallback):Boolean; +function TTransportManager.GetMonitorByNext(APrevious:TNetworkMonitor;ALock,AUnlock:Boolean;AState:LongWord):TNetworkMonitor; var - Transport:TNetworkTransport; + Monitor:TNetworkMonitor; begin {} - ReaderLock; + FMonitors.ReaderLock; try - Result:=False; + Result:=nil; - {Check Callback} - if not Assigned(ACallback) then Exit; + {Check Previous} + if APrevious = nil then + begin + {Get First} + Monitor:=TNetworkMonitor(FMonitors.First); + if Monitor <> nil then + begin + {Lock Monitor} + if ALock then if AState = NETWORK_LOCK_READ then Monitor.ReaderLock else Monitor.WriterLock; + + {Return Result} + Result:=Monitor; + end; + end + else + begin + {Get Next} + Monitor:=TNetworkMonitor(APrevious.Next); + if Monitor <> nil then + begin + {Lock Monitor} + if ALock then if AState = NETWORK_LOCK_READ then Monitor.ReaderLock else Monitor.WriterLock; + + {Return Result} + Result:=Monitor; + end; - Result:=True; - + {Unlock Previous} + if AUnlock then if AState = NETWORK_LOCK_READ then APrevious.ReaderUnlock else APrevious.WriterUnlock; + end; + finally + FMonitors.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TTransportManager.AddAuthenticator(AAuthenticator:TNetworkAuthenticator):Boolean; +begin + {} + ReaderLock; + try {$IFDEF TRANSPORT_DEBUG} - if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: EnumerateTransports'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: AddAuthenticator'); {$ENDIF} - - {Get Transport} - Transport:=TNetworkTransport(GetTransportByNext(nil,True,False,NETWORK_LOCK_READ)); - while Transport <> nil do - begin - {Enumerate Transport} - if not(ACallback(Transport)) then Result:=False; - - {Get Next} - Transport:=TNetworkTransport(GetTransportByNext(Transport,True,True,NETWORK_LOCK_READ)); - end; + + {Acquire Lock} + FAuthenticators.WriterLock; + try + {Add Authenticator} + Result:=FAuthenticators.Add(AAuthenticator); + finally + {Release Lock} + FAuthenticators.WriterUnlock; + end; finally ReaderUnlock; end; @@ -1530,30 +1732,294 @@ function TTransportManager.EnumerateTransports(ACallback:TTransportCallback):Boo {==============================================================================} -function TTransportManager.BindTransports(AAdapter:TNetworkAdapter):Boolean; -var - Transport:TNetworkTransport; +function TTransportManager.RemoveAuthenticator(AAuthenticator:TNetworkAuthenticator):Boolean; begin {} ReaderLock; try - Result:=False; - {$IFDEF TRANSPORT_DEBUG} - if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: BindTransports'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: RemoveAuthenticator'); {$ENDIF} - - {Check Adapter} - if AAdapter = nil then - begin - {Check Adapters} - if FAdapters = nil then Exit; - - {Enumerate Adapters} - Result:=FAdapters.EnumerateAdapters(BindTransports); - end - else - begin + + {Acquire Lock} + FAuthenticators.WriterLock; + try + {Remove Authenticator} + Result:=FAuthenticators.Remove(AAuthenticator); + finally + {Release Lock} + FAuthenticators.WriterUnlock; + end; + finally + ReaderUnlock; + end; +end; + +{==============================================================================} + +function TTransportManager.GetAuthenticatorByType(AAuthType:Word;ALock:Boolean;AState:LongWord):TNetworkAuthenticator; +var + Authenticator:TNetworkAuthenticator; +begin + {} + FAuthenticators.ReaderLock; + try + Result:=nil; + + {Get Authenticator} + Authenticator:=TNetworkAuthenticator(FAuthenticators.First); + while Authenticator <> nil do + begin + {Check Authenticator} + if Authenticator.AuthType = AAuthType then + begin + {Lock Authenticator} + if ALock then if AState = NETWORK_LOCK_READ then Authenticator.ReaderLock else Authenticator.WriterLock; + + {Return Result} + Result:=Authenticator; + Exit; + end; + + {Get Next} + Authenticator:=TNetworkAuthenticator(Authenticator.Next); + end; + finally + FAuthenticators.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TTransportManager.GetAuthenticatorByAuthenticator(AAuthenticator:TNetworkAuthenticator;ALock:Boolean;AState:LongWord):TNetworkAuthenticator; +var + Authenticator:TNetworkAuthenticator; +begin + {} + FAuthenticators.ReaderLock; + try + Result:=nil; + + {Get Authenticator} + Authenticator:=TNetworkAuthenticator(FAuthenticators.First); + while Authenticator <> nil do + begin + {Check Authenticator} + if Authenticator = AAuthenticator then + begin + {Lock Authenticator} + if ALock then if AState = NETWORK_LOCK_READ then Authenticator.ReaderLock else Authenticator.WriterLock; + + {Return Result} + Result:=Authenticator; + Exit; + end; + + {Get Next} + Authenticator:=TNetworkAuthenticator(Authenticator.Next); + end; + finally + FAuthenticators.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TTransportManager.GetAuthenticatorByNext(APrevious:TNetworkAuthenticator;ALock,AUnlock:Boolean;AState:LongWord):TNetworkAuthenticator; +var + Authenticator:TNetworkAuthenticator; +begin + {} + FAuthenticators.ReaderLock; + try + Result:=nil; + + {Check Previous} + if APrevious = nil then + begin + {Get First} + Authenticator:=TNetworkAuthenticator(FAuthenticators.First); + if Authenticator <> nil then + begin + {Lock Authenticator} + if ALock then if AState = NETWORK_LOCK_READ then Authenticator.ReaderLock else Authenticator.WriterLock; + + {Return Result} + Result:=Authenticator; + end; + end + else + begin + {Get Next} + Authenticator:=TNetworkAuthenticator(APrevious.Next); + if Authenticator <> nil then + begin + {Lock Authenticator} + if ALock then if AState = NETWORK_LOCK_READ then Authenticator.ReaderLock else Authenticator.WriterLock; + + {Return Result} + Result:=Authenticator; + end; + + {Unlock Previous} + if AUnlock then if AState = NETWORK_LOCK_READ then APrevious.ReaderUnlock else APrevious.WriterUnlock; + end; + finally + FAuthenticators.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TTransportManager.StartTransports:Boolean; +var + Transport:TNetworkTransport; +begin + {} + ReaderLock; + try + Result:=True; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: StartTransports'); + {$ENDIF} + + {Get Transport} + Transport:=TNetworkTransport(GetTransportByNext(nil,True,False,NETWORK_LOCK_READ)); + while Transport <> nil do + begin + {Start Transport} + if not(Transport.StartTransport) then Result:=False; + + {Get Next} + Transport:=TNetworkTransport(GetTransportByNext(Transport,True,True,NETWORK_LOCK_READ)); + end; + finally + ReaderUnlock; + end; +end; + +{==============================================================================} + +function TTransportManager.StopTransports:Boolean; +var + Transport:TNetworkTransport; +begin + {} + ReaderLock; + try + Result:=True; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: StopTransports'); + {$ENDIF} + + {Get Transport} + Transport:=TNetworkTransport(GetTransportByNext(nil,True,False,NETWORK_LOCK_READ)); + while Transport <> nil do + begin + {Stop Transport} + if not(Transport.StopTransport) then Result:=False; + + {Get Next} + Transport:=TNetworkTransport(GetTransportByNext(Transport,True,True,NETWORK_LOCK_READ)); + end; + finally + ReaderUnlock; + end; +end; + +{==============================================================================} + +function TTransportManager.ProcessTransports:Boolean; +var + Transport:TNetworkTransport; +begin + {} + ReaderLock; + try + Result:=True; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: ProcessTransports'); + {$ENDIF} + + {Get Transport} + Transport:=TNetworkTransport(GetTransportByNext(nil,True,False,NETWORK_LOCK_READ)); + while Transport <> nil do + begin + {Process Transport} + if not(Transport.ProcessTransport) then Result:=False; + + {Get Next} + Transport:=TNetworkTransport(GetTransportByNext(Transport,True,True,NETWORK_LOCK_READ)); + end; + finally + ReaderUnlock; + end; +end; + +{==============================================================================} + +function TTransportManager.EnumerateTransports(ACallback:TTransportCallback):Boolean; +var + Transport:TNetworkTransport; +begin + {} + ReaderLock; + try + Result:=False; + + {Check Callback} + if not Assigned(ACallback) then Exit; + + Result:=True; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: EnumerateTransports'); + {$ENDIF} + + {Get Transport} + Transport:=TNetworkTransport(GetTransportByNext(nil,True,False,NETWORK_LOCK_READ)); + while Transport <> nil do + begin + {Enumerate Transport} + if not(ACallback(Transport)) then Result:=False; + + {Get Next} + Transport:=TNetworkTransport(GetTransportByNext(Transport,True,True,NETWORK_LOCK_READ)); + end; + finally + ReaderUnlock; + end; +end; + +{==============================================================================} + +function TTransportManager.BindTransports(AAdapter:TNetworkAdapter):Boolean; +var + Transport:TNetworkTransport; +begin + {} + ReaderLock; + try + Result:=False; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: BindTransports'); + {$ENDIF} + + {Check Adapter} + if AAdapter = nil then + begin + {Check Adapters} + if FAdapters = nil then Exit; + + {Enumerate Adapters} + Result:=FAdapters.EnumerateAdapters(BindTransports); + end + else + begin Result:=True; {Get Transport} @@ -1616,140 +2082,566 @@ function TTransportManager.UnbindTransports(AAdapter:TNetworkAdapter):Boolean; end; end; -{==============================================================================} -{==============================================================================} -{TTransportBuffer} -constructor TTransportBuffer.Create(ATransport:TNetworkTransport); -begin - {} - inherited Create; - FLock:=CriticalSectionCreate; - - FTransport:=ATransport; -end; - {==============================================================================} -destructor TTransportBuffer.Destroy; +function TTransportManager.StartMonitors:Boolean; +var + Monitor:TNetworkMonitor; begin {} - AcquireLock; + ReaderLock; try - FTransport:=nil; - inherited Destroy; - finally - {ReleaseLock;} {Can destroy Critical Section while holding lock} - CriticalSectionDestroy(FLock); - end; + Result:=True; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: StartMonitors'); + {$ENDIF} + + {Get Monitor} + Monitor:=TNetworkMonitor(GetMonitorByNext(nil,True,False,NETWORK_LOCK_READ)); + while Monitor <> nil do + begin + {Start Monitor} + if not(Monitor.StartMonitor) then Result:=False; + + {Get Next} + Monitor:=TNetworkMonitor(GetMonitorByNext(Monitor,True,True,NETWORK_LOCK_READ)); + end; + finally + ReaderUnlock; + end; end; {==============================================================================} -function TTransportBuffer.AcquireLock:Boolean; +function TTransportManager.StopMonitors:Boolean; +var + Monitor:TNetworkMonitor; begin {} - Result:=(CriticalSectionLock(FLock) = ERROR_SUCCESS); + ReaderLock; + try + Result:=True; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: StopMonitors'); + {$ENDIF} + + {Get Monitor} + Monitor:=TNetworkMonitor(GetMonitorByNext(nil,True,False,NETWORK_LOCK_READ)); + while Monitor <> nil do + begin + {Stop Monitor} + if not(Monitor.StopMonitor) then Result:=False; + + {Get Next} + Monitor:=TNetworkMonitor(GetMonitorByNext(Monitor,True,True,NETWORK_LOCK_READ)); + end; + finally + ReaderUnlock; + end; end; {==============================================================================} -function TTransportBuffer.ReleaseLock:Boolean; +function TTransportManager.ProcessMonitors:Boolean; +var + Monitor:TNetworkMonitor; begin {} - Result:=(CriticalSectionUnlock(FLock) = ERROR_SUCCESS); + ReaderLock; + try + Result:=True; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: ProcessMonitors'); + {$ENDIF} + + {Get Monitor} + Monitor:=TNetworkMonitor(GetMonitorByNext(nil,True,False,NETWORK_LOCK_READ)); + while Monitor <> nil do + begin + {Process Monitor} + if not(Monitor.ProcessMonitor) then Result:=False; + + {Get Next} + Monitor:=TNetworkMonitor(GetMonitorByNext(Monitor,True,True,NETWORK_LOCK_READ)); + end; + finally + ReaderUnlock; + end; end; {==============================================================================} -{==============================================================================} -{TTransportBufferEx} -constructor TTransportBufferEx.Create(ATransport:TNetworkTransport); + +function TTransportManager.EnumerateMonitors(ACallback:TMonitorCallback):Boolean; +var + Monitor:TNetworkMonitor; begin {} - inherited Create; - FLock:=SynchronizerCreate; - - FTransport:=ATransport; + ReaderLock; + try + Result:=False; + + {Check Callback} + if not Assigned(ACallback) then Exit; + + Result:=True; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: EnumerateMonitors'); + {$ENDIF} + + {Get Monitor} + Monitor:=TNetworkMonitor(GetMonitorByNext(nil,True,False,NETWORK_LOCK_READ)); + while Monitor <> nil do + begin + {Enumerate Monitor} + if not(ACallback(Monitor)) then Result:=False; + + {Get Next} + Monitor:=TNetworkMonitor(GetMonitorByNext(Monitor,True,True,NETWORK_LOCK_READ)); + end; + finally + ReaderUnlock; + end; end; {==============================================================================} -destructor TTransportBufferEx.Destroy; +function TTransportManager.BindMonitors(AAdapter:TNetworkAdapter):Boolean; +var + Monitor:TNetworkMonitor; begin {} - WriterLock; + ReaderLock; try - FTransport:=nil; - inherited Destroy; + Result:=False; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: BindMonitors'); + {$ENDIF} + + {Check Adapter} + if AAdapter = nil then + begin + {Check Adapters} + if FAdapters = nil then Exit; + + {Enumerate Adapters} + Result:=FAdapters.EnumerateAdapters(BindMonitors); + end + else + begin + Result:=True; + + {Get Monitor} + Monitor:=TNetworkMonitor(GetMonitorByNext(nil,True,False,NETWORK_LOCK_READ)); + while Monitor <> nil do + begin + {Bind Monitor} + if not(Monitor.BindMonitor(AAdapter)) then Result:=False; + + {Get Next} + Monitor:=TNetworkMonitor(GetMonitorByNext(Monitor,True,True,NETWORK_LOCK_READ)); + end; + end; finally - {WriterUnlock;} {Can destroy Synchronizer while holding lock} - SynchronizerDestroy(FLock); - end; + ReaderUnlock; + end; end; {==============================================================================} -function TTransportBufferEx.ReaderLock:Boolean; +function TTransportManager.UnbindMonitors(AAdapter:TNetworkAdapter):Boolean; +var + Monitor:TNetworkMonitor; begin {} - Result:=(SynchronizerReaderLock(FLock) = ERROR_SUCCESS); + ReaderLock; + try + Result:=False; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: UnbindMonitors'); + {$ENDIF} + + {Check Adapter} + if AAdapter = nil then + begin + {Check Adapters} + if FAdapters = nil then Exit; + + {Enumerate Adapters} + Result:=FAdapters.EnumerateAdapters(UnbindMonitors); + end + else + begin + Result:=True; + + {Get Monitor} + Monitor:=TNetworkMonitor(GetMonitorByNext(nil,True,False,NETWORK_LOCK_READ)); + while Monitor <> nil do + begin + {Unbind Monitor} + if not(Monitor.UnbindMonitor(AAdapter)) then Result:=False; + + {Get Next} + Monitor:=TNetworkMonitor(GetMonitorByNext(Monitor,True,True,NETWORK_LOCK_READ)); + end; + end; + finally + ReaderUnlock; + end; end; {==============================================================================} -function TTransportBufferEx.ReaderUnlock:Boolean; +function TTransportManager.StartAuthenticators:Boolean; +var + Authenticator:TNetworkAuthenticator; begin {} - Result:=(SynchronizerReaderUnlock(FLock) = ERROR_SUCCESS); + ReaderLock; + try + Result:=True; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: StartAuthenticators'); + {$ENDIF} + + {Get Authenticator} + Authenticator:=TNetworkAuthenticator(GetAuthenticatorByNext(nil,True,False,NETWORK_LOCK_READ)); + while Authenticator <> nil do + begin + {Start Authenticator} + if not(Authenticator.StartAuthenticator) then Result:=False; + + {Get Next} + Authenticator:=TNetworkAuthenticator(GetAuthenticatorByNext(Authenticator,True,True,NETWORK_LOCK_READ)); + end; + finally + ReaderUnlock; + end; end; {==============================================================================} -function TTransportBufferEx.ReaderConvert:Boolean; -{Convert a Reader lock to a Writer lock} +function TTransportManager.StopAuthenticators:Boolean; +var + Authenticator:TNetworkAuthenticator; begin {} - Result:=(SynchronizerReaderConvert(FLock) = ERROR_SUCCESS); + ReaderLock; + try + Result:=True; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: StopAuthenticators'); + {$ENDIF} + + {Get Authenticator} + Authenticator:=TNetworkAuthenticator(GetAuthenticatorByNext(nil,True,False,NETWORK_LOCK_READ)); + while Authenticator <> nil do + begin + {Stop Authenticator} + if not(Authenticator.StopAuthenticator) then Result:=False; + + {Get Next} + Authenticator:=TNetworkAuthenticator(GetAuthenticatorByNext(Authenticator,True,True,NETWORK_LOCK_READ)); + end; + finally + ReaderUnlock; + end; end; {==============================================================================} -function TTransportBufferEx.WriterLock:Boolean; +function TTransportManager.ProcessAuthenticators:Boolean; +var + Authenticator:TNetworkAuthenticator; begin {} - Result:=(SynchronizerWriterLock(FLock) = ERROR_SUCCESS); + ReaderLock; + try + Result:=True; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: ProcessAuthenticators'); + {$ENDIF} + + {Get Authenticator} + Authenticator:=TNetworkAuthenticator(GetAuthenticatorByNext(nil,True,False,NETWORK_LOCK_READ)); + while Authenticator <> nil do + begin + {Process Authenticator} + if not(Authenticator.ProcessAuthenticator) then Result:=False; + + {Get Next} + Authenticator:=TNetworkAuthenticator(GetAuthenticatorByNext(Authenticator,True,True,NETWORK_LOCK_READ)); + end; + finally + ReaderUnlock; + end; end; {==============================================================================} -function TTransportBufferEx.WriterUnlock:Boolean; +function TTransportManager.EnumerateAuthenticators(ACallback:TAuthenticatorCallback):Boolean; +var + Authenticator:TNetworkAuthenticator; begin {} - Result:=(SynchronizerWriterUnlock(FLock) = ERROR_SUCCESS); + ReaderLock; + try + Result:=False; + + {Check Callback} + if not Assigned(ACallback) then Exit; + + Result:=True; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: EnumerateAuthenticators'); + {$ENDIF} + + {Get Authenticator} + Authenticator:=TNetworkAuthenticator(GetAuthenticatorByNext(nil,True,False,NETWORK_LOCK_READ)); + while Authenticator <> nil do + begin + {Enumerate Authenticator} + if not(ACallback(Authenticator)) then Result:=False; + + {Get Next} + Authenticator:=TNetworkAuthenticator(GetAuthenticatorByNext(Authenticator,True,True,NETWORK_LOCK_READ)); + end; + finally + ReaderUnlock; + end; end; {==============================================================================} -function TTransportBufferEx.WriterConvert:Boolean; -{Convert a Writer lock to a Reader lock} +function TTransportManager.BindAuthenticators(AAdapter:TNetworkAdapter):Boolean; +var + Authenticator:TNetworkAuthenticator; begin {} - Result:=(SynchronizerWriterConvert(FLock) = ERROR_SUCCESS); + ReaderLock; + try + Result:=False; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: BindAuthenticators'); + {$ENDIF} + + {Check Adapter} + if AAdapter = nil then + begin + {Check Adapters} + if FAdapters = nil then Exit; + + {Enumerate Adapters} + Result:=FAdapters.EnumerateAdapters(BindAuthenticators); + end + else + begin + Result:=True; + + {Get Authenticator} + Authenticator:=TNetworkAuthenticator(GetAuthenticatorByNext(nil,True,False,NETWORK_LOCK_READ)); + while Authenticator <> nil do + begin + {Bind Authenticator} + if not(Authenticator.BindAuthenticator(AAdapter)) then Result:=False; + + {Get Next} + Authenticator:=TNetworkAuthenticator(GetAuthenticatorByNext(Authenticator,True,True,NETWORK_LOCK_READ)); + end; + end; + finally + ReaderUnlock; + end; end; {==============================================================================} -{==============================================================================} -{TTransportAdapter} -constructor TTransportAdapter.Create; + +function TTransportManager.UnbindAuthenticators(AAdapter:TNetworkAdapter):Boolean; +var + Authenticator:TNetworkAuthenticator; begin {} - inherited Create; - FLock:=SynchronizerCreate; - - Name:=''; - Index:=LongWord(Self); - Handle:=INVALID_HANDLE_VALUE; - PacketType:=PACKET_TYPE_RAW; - Adapter:=nil; + ReaderLock; + try + Result:=False; + + {$IFDEF TRANSPORT_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'TransportManager: UnbindAuthenticators'); + {$ENDIF} + + {Check Adapter} + if AAdapter = nil then + begin + {Check Adapters} + if FAdapters = nil then Exit; + + {Enumerate Adapters} + Result:=FAdapters.EnumerateAdapters(UnbindAuthenticators); + end + else + begin + Result:=True; + + {Get Authenticator} + Authenticator:=TNetworkAuthenticator(GetAuthenticatorByNext(nil,True,False,NETWORK_LOCK_READ)); + while Authenticator <> nil do + begin + {Unbind Authenticator} + if not(Authenticator.UnbindAuthenticator(AAdapter)) then Result:=False; + + {Get Next} + Authenticator:=TNetworkAuthenticator(GetAuthenticatorByNext(Authenticator,True,True,NETWORK_LOCK_READ)); + end; + end; + finally + ReaderUnlock; + end; +end; + +{==============================================================================} +{==============================================================================} +{TTransportBuffer} +constructor TTransportBuffer.Create(ATransport:TNetworkTransport); +begin + {} + inherited Create; + FLock:=CriticalSectionCreate; + + FTransport:=ATransport; +end; + +{==============================================================================} + +destructor TTransportBuffer.Destroy; +begin + {} + AcquireLock; + try + FTransport:=nil; + inherited Destroy; + finally + {ReleaseLock;} {Can destroy Critical Section while holding lock} + CriticalSectionDestroy(FLock); + end; +end; + +{==============================================================================} + +function TTransportBuffer.AcquireLock:Boolean; +begin + {} + Result:=(CriticalSectionLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TTransportBuffer.ReleaseLock:Boolean; +begin + {} + Result:=(CriticalSectionUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} +{==============================================================================} +{TTransportBufferEx} +constructor TTransportBufferEx.Create(ATransport:TNetworkTransport); +begin + {} + inherited Create; + FLock:=SynchronizerCreate; + + FTransport:=ATransport; +end; + +{==============================================================================} + +destructor TTransportBufferEx.Destroy; +begin + {} + WriterLock; + try + FTransport:=nil; + inherited Destroy; + finally + {WriterUnlock;} {Can destroy Synchronizer while holding lock} + SynchronizerDestroy(FLock); + end; +end; + +{==============================================================================} + +function TTransportBufferEx.ReaderLock:Boolean; +begin + {} + Result:=(SynchronizerReaderLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TTransportBufferEx.ReaderUnlock:Boolean; +begin + {} + Result:=(SynchronizerReaderUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TTransportBufferEx.ReaderConvert:Boolean; +{Convert a Reader lock to a Writer lock} +begin + {} + Result:=(SynchronizerReaderConvert(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TTransportBufferEx.WriterLock:Boolean; +begin + {} + Result:=(SynchronizerWriterLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TTransportBufferEx.WriterUnlock:Boolean; +begin + {} + Result:=(SynchronizerWriterUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TTransportBufferEx.WriterConvert:Boolean; +{Convert a Writer lock to a Reader lock} +begin + {} + Result:=(SynchronizerWriterConvert(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} +{==============================================================================} +{TTransportAdapter} +constructor TTransportAdapter.Create; +begin + {} + inherited Create; + FLock:=SynchronizerCreate; + + Name:=''; + Index:=LongWord(Self); + Handle:=INVALID_HANDLE_VALUE; + PacketType:=PACKET_TYPE_RAW; + Adapter:=nil; Hardware:=HARDWARE_DEFAULT; Broadcast:=HARDWARE_BROADCAST; @@ -2394,86 +3286,632 @@ function TNetworkTransport.GetFilterByHandle(AHandle:THandle;ALock:Boolean;AStat Filter:=TTransportFilter(Filter.Next); end; finally - FFilters.ReaderUnlock; - end; + FFilters.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkTransport.GetFilterByProtocol(AProtocol:Word;ALock:Boolean;AState:LongWord):TTransportFilter; +var + Filter:TTransportFilter; +begin + {} + FFilters.ReaderLock; + try + Result:=nil; + + {Get Filter} + Filter:=TTransportFilter(FFilters.First); + while Filter <> nil do + begin + {Check Filter} + if Filter.Protocol = AProtocol then + begin + {Lock Filter} + if ALock then if AState = NETWORK_LOCK_READ then Filter.ReaderLock else Filter.WriterLock; + + {Return Result} + Result:=Filter; + Exit; + end; + + {Get Next} + Filter:=TTransportFilter(Filter.Next); + end; + finally + FFilters.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkTransport.GetFilterByFilter(AFilter:TTransportFilter;ALock:Boolean;AState:LongWord):TTransportFilter; +var + Filter:TTransportFilter; +begin + {} + FFilters.ReaderLock; + try + Result:=nil; + + {Get Filter} + Filter:=TTransportFilter(FFilters.First); + while Filter <> nil do + begin + {Check Filter} + if Filter = AFilter then + begin + {Lock Filter} + if ALock then if AState = NETWORK_LOCK_READ then Filter.ReaderLock else Filter.WriterLock; + + {Return Result} + Result:=Filter; + Exit; + end; + + {Get Next} + Filter:=TTransportFilter(Filter.Next); + end; + finally + FFilters.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkTransport.GetFilterByNext(APrevious:TTransportFilter;ALock,AUnlock:Boolean;AState:LongWord):TTransportFilter; +var + Filter:TTransportFilter; +begin + {} + FFilters.ReaderLock; + try + Result:=nil; + + {Check Previous} + if APrevious = nil then + begin + {Get First} + Filter:=TTransportFilter(FFilters.First); + if Filter <> nil then + begin + {Lock Filter} + if ALock then if AState = NETWORK_LOCK_READ then Filter.ReaderLock else Filter.WriterLock; + + {Return Result} + Result:=Filter; + end; + end + else + begin + {Get Next} + Filter:=TTransportFilter(APrevious.Next); + if Filter <> nil then + begin + {Lock Filter} + if ALock then if AState = NETWORK_LOCK_READ then Filter.ReaderLock else Filter.WriterLock; + + {Return Result} + Result:=Filter; + end; + + {Unlock Previous} + if AUnlock then if AState = NETWORK_LOCK_READ then APrevious.ReaderUnlock else APrevious.WriterUnlock; + end; + finally + FFilters.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkTransport.GetConfigByHandle(AHandle:THandle;ALock:Boolean;AState:LongWord):TTransportConfig; +var + Config:TTransportConfig; +begin + {} + FConfigs.ReaderLock; + try + Result:=nil; + + {Get Config} + Config:=TTransportConfig(FConfigs.First); + while Config <> nil do + begin + {Check Config} + if THandle(Config) = AHandle then + begin + {Lock Config} + if ALock then if AState = NETWORK_LOCK_READ then Config.ReaderLock else Config.WriterLock; + + {Return Result} + Result:=Config; + Exit; + end; + + {Get Next} + Config:=TTransportConfig(Config.Next); + end; + finally + FConfigs.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkTransport.GetConfigByType(AConfigType:Word;ALock:Boolean;AState:LongWord):TTransportConfig; +var + Config:TTransportConfig; +begin + {} + FConfigs.ReaderLock; + try + Result:=nil; + + {Get Config} + Config:=TTransportConfig(FConfigs.First); + while Config <> nil do + begin + {Check Config} + if Config.ConfigType = AConfigType then + begin + {Lock Config} + if ALock then if AState = NETWORK_LOCK_READ then Config.ReaderLock else Config.WriterLock; + + {Return Result} + Result:=Config; + Exit; + end; + + {Get Next} + Config:=TTransportConfig(Config.Next); + end; + finally + FConfigs.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkTransport.GetConfigByConfig(AConfig:TTransportConfig;ALock:Boolean;AState:LongWord):TTransportConfig; +var + Config:TTransportConfig; +begin + {} + FConfigs.ReaderLock; + try + Result:=nil; + + {Get Config} + Config:=TTransportConfig(FConfigs.First); + while Config <> nil do + begin + {Check Config} + if Config = AConfig then + begin + {Lock Config} + if ALock then if AState = NETWORK_LOCK_READ then Config.ReaderLock else Config.WriterLock; + + {Return Result} + Result:=Config; + Exit; + end; + + {Get Next} + Config:=TTransportConfig(Config.Next); + end; + finally + FConfigs.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkTransport.GetConfigByNext(APrevious:TTransportConfig;ALock,AUnlock:Boolean;AState:LongWord):TTransportConfig; +var + Config:TTransportConfig; +begin + {} + FConfigs.ReaderLock; + try + Result:=nil; + + {Check Previous} + if APrevious = nil then + begin + {Get First} + Config:=TTransportConfig(FConfigs.First); + if Config <> nil then + begin + {Lock Config} + if ALock then if AState = NETWORK_LOCK_READ then Config.ReaderLock else Config.WriterLock; + + {Return Result} + Result:=Config; + end; + end + else + begin + {Get Next} + Config:=TTransportConfig(APrevious.Next); + if Config <> nil then + begin + {Lock Config} + if ALock then if AState = NETWORK_LOCK_READ then Config.ReaderLock else Config.WriterLock; + + {Return Result} + Result:=Config; + end; + + {Unlock Previous} + if AUnlock then if AState = NETWORK_LOCK_READ then APrevious.ReaderUnlock else APrevious.WriterUnlock; + end; + finally + FConfigs.ReaderUnlock; + end; +end; + +{==============================================================================} + +function TNetworkTransport.AddAdapter(AAdapter:TNetworkAdapter;AConfigType:Word;AAddress,ANetmask,AGateway,AServer:Pointer):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkTransport.RemoveAdapter(AAdapter:TNetworkAdapter):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkTransport.AddProtocol(AProtocol:Word;APacketHandler:TTransportPacketHandler;AControlHandler:TTransportControlHandler):THandle; +begin + {Virtual Base Method} + Result:=INVALID_HANDLE_VALUE; +end; + +{==============================================================================} + +function TNetworkTransport.RemoveProtocol(AHandle:THandle;AProtocol:Word):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkTransport.AddFilter(AProtocol:Word;AFilterHandler:TTransportFilterHandler):THandle; +begin + {Virtual Base Method} + Result:=INVALID_HANDLE_VALUE; +end; + +{==============================================================================} + +function TNetworkTransport.RemoveFilter(AHandle:THandle;AProtocol:Word):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkTransport.AddConfig(AConfigType:Word;AConfigAuto:Boolean;AConfigHandler:TTransportConfigHandler):THandle; +begin + {Virtual Base Method} + Result:=INVALID_HANDLE_VALUE; +end; + +{==============================================================================} + +function TNetworkTransport.RemoveConfig(AHandle:THandle;AConfigType:Word):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkTransport.SendPacket(ASocket:TTransportSocket;ASource,ADest:Pointer;APacket:PPacketFragment;ASize,AFlags:Integer):Integer; +begin + {Virtual Base Method} + Result:=SOCKET_ERROR; +end; + +{==============================================================================} + +function TNetworkTransport.SendControl(ASource,ADest:Pointer;AProtocol,ACommand,ACode:Word;AAddress,AData:Pointer;ASize:Integer):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkTransport.FilterPacket(ASource,ADest,APacket:Pointer;ASize:Integer;ABroadcast:Boolean):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkTransport.ForwardPacket(AAdapter:TTransportAdapter;ASource,ADest,APacket:Pointer;ASize:Integer;ABroadcast:Boolean):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkTransport.GetSockOpt(ASocket:TTransportSocket;ALevel,AOptName:Integer;AOptValue:PChar;var AOptLength:Integer):Integer; +begin + {Virtual Base Method} + Result:=SOCKET_ERROR; +end; + +{==============================================================================} + +function TNetworkTransport.SetSockOpt(ASocket:TTransportSocket;ALevel,AOptName:Integer;AOptValue:PChar;AOptLength:Integer):Integer; +begin + {Virtual Base Method} + Result:=SOCKET_ERROR; +end; + +{==============================================================================} + +function TNetworkTransport.GetStatistics:TTransportStatistics; +begin + {Virtual Base Method} + FillChar(Result,SizeOf(TTransportStatistics),0); +end; + +{==============================================================================} + +function TNetworkTransport.ReaderLock:Boolean; +begin + {} + Result:=(SynchronizerReaderLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkTransport.ReaderUnlock:Boolean; +begin + {} + Result:=(SynchronizerReaderUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkTransport.WriterLock:Boolean; +begin + {} + Result:=(SynchronizerWriterLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkTransport.WriterUnlock:Boolean; +begin + {} + Result:=(SynchronizerWriterUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkTransport.StartTransport:Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkTransport.StopTransport:Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkTransport.ProcessTransport:Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkTransport.BindTransport(AAdapter:TNetworkAdapter):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkTransport.UnbindTransport(AAdapter:TNetworkAdapter):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} +{==============================================================================} +{TMonitorAdapter} +constructor TMonitorAdapter.Create; +begin + {} + inherited Create; + FLock:=SynchronizerCreate; + + Handle:=INVALID_HANDLE_VALUE; + Adapter:=nil; +end; + +{==============================================================================} + +destructor TMonitorAdapter.Destroy; +begin + {} + WriterLock; + try + Adapter:=nil; + inherited Destroy; + finally + {WriterUnlock;} {Can destroy Synchronizer while holding lock} + SynchronizerDestroy(FLock); + end; +end; + +{==============================================================================} + +function TMonitorAdapter.ReaderLock:Boolean; +begin + {} + Result:=(SynchronizerReaderLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TMonitorAdapter.ReaderUnlock:Boolean; +begin + {} + Result:=(SynchronizerReaderUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TMonitorAdapter.WriterLock:Boolean; +begin + {} + Result:=(SynchronizerWriterLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TMonitorAdapter.WriterUnlock:Boolean; +begin + {} + Result:=(SynchronizerWriterUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} +{==============================================================================} +{TNetworkMonitor} +constructor TNetworkMonitor.Create(AManager:TTransportManager); +begin + {} + inherited Create; + FLock:=SynchronizerCreate; + + FManager:=AManager; + + FAdapters:=TNetworkList.Create; + if FManager <> nil then FManager.AddMonitor(Self); +end; + +{==============================================================================} + +destructor TNetworkMonitor.Destroy; +begin + {} + WriterLock; + try + if FManager <> nil then FManager.RemoveMonitor(Self); + FAdapters.Free; + FManager:=nil; + inherited Destroy; + finally + {WriterUnlock;} {Can destroy Synchronizer while holding lock} + SynchronizerDestroy(FLock); + end; end; {==============================================================================} -function TNetworkTransport.GetFilterByProtocol(AProtocol:Word;ALock:Boolean;AState:LongWord):TTransportFilter; +function TNetworkMonitor.GetAdapterByHandle(AHandle:THandle;ALock:Boolean;AState:LongWord):TMonitorAdapter; var - Filter:TTransportFilter; + Adapter:TMonitorAdapter; begin {} - FFilters.ReaderLock; + FAdapters.ReaderLock; try Result:=nil; - {Get Filter} - Filter:=TTransportFilter(FFilters.First); - while Filter <> nil do + {Get Adapter} + Adapter:=TMonitorAdapter(FAdapters.First); + while Adapter <> nil do begin - {Check Filter} - if Filter.Protocol = AProtocol then + {Check Adapter} + if Adapter.Handle = AHandle then begin - {Lock Filter} - if ALock then if AState = NETWORK_LOCK_READ then Filter.ReaderLock else Filter.WriterLock; + {Lock Adapter} + if ALock then if AState = NETWORK_LOCK_READ then Adapter.ReaderLock else Adapter.WriterLock; {Return Result} - Result:=Filter; + Result:=Adapter; Exit; end; {Get Next} - Filter:=TTransportFilter(Filter.Next); + Adapter:=TMonitorAdapter(Adapter.Next); end; finally - FFilters.ReaderUnlock; + FAdapters.ReaderUnlock; end; end; {==============================================================================} -function TNetworkTransport.GetFilterByFilter(AFilter:TTransportFilter;ALock:Boolean;AState:LongWord):TTransportFilter; +function TNetworkMonitor.GetAdapterByAdapter(AAdapter:TNetworkAdapter;ALock:Boolean;AState:LongWord):TMonitorAdapter; var - Filter:TTransportFilter; + Adapter:TMonitorAdapter; begin {} - FFilters.ReaderLock; + FAdapters.ReaderLock; try Result:=nil; - {Get Filter} - Filter:=TTransportFilter(FFilters.First); - while Filter <> nil do + {Get Adapter} + Adapter:=TMonitorAdapter(FAdapters.First); + while Adapter <> nil do begin - {Check Filter} - if Filter = AFilter then + {Check Adapter} + if Adapter.Adapter = AAdapter then begin - {Lock Filter} - if ALock then if AState = NETWORK_LOCK_READ then Filter.ReaderLock else Filter.WriterLock; + {Lock Adapter} + if ALock then if AState = NETWORK_LOCK_READ then Adapter.ReaderLock else Adapter.WriterLock; {Return Result} - Result:=Filter; + Result:=Adapter; Exit; end; {Get Next} - Filter:=TTransportFilter(Filter.Next); + Adapter:=TMonitorAdapter(Adapter.Next); end; finally - FFilters.ReaderUnlock; + FAdapters.ReaderUnlock; end; end; {==============================================================================} -function TNetworkTransport.GetFilterByNext(APrevious:TTransportFilter;ALock,AUnlock:Boolean;AState:LongWord):TTransportFilter; +function TNetworkMonitor.GetAdapterByNext(APrevious:TMonitorAdapter;ALock,AUnlock:Boolean;AState:LongWord):TMonitorAdapter; var - Filter:TTransportFilter; + Adapter:TMonitorAdapter; begin {} - FFilters.ReaderLock; + FAdapters.ReaderLock; try Result:=nil; @@ -2481,147 +3919,296 @@ function TNetworkTransport.GetFilterByNext(APrevious:TTransportFilter;ALock,AUnl if APrevious = nil then begin {Get First} - Filter:=TTransportFilter(FFilters.First); - if Filter <> nil then + Adapter:=TMonitorAdapter(FAdapters.First); + if Adapter <> nil then begin - {Lock Filter} - if ALock then if AState = NETWORK_LOCK_READ then Filter.ReaderLock else Filter.WriterLock; + {Lock Adapter} + if ALock then if AState = NETWORK_LOCK_READ then Adapter.ReaderLock else Adapter.WriterLock; {Return Result} - Result:=Filter; + Result:=Adapter; end; end else begin {Get Next} - Filter:=TTransportFilter(APrevious.Next); - if Filter <> nil then + Adapter:=TMonitorAdapter(APrevious.Next); + if Adapter <> nil then begin - {Lock Filter} - if ALock then if AState = NETWORK_LOCK_READ then Filter.ReaderLock else Filter.WriterLock; + {Lock Adapter} + if ALock then if AState = NETWORK_LOCK_READ then Adapter.ReaderLock else Adapter.WriterLock; {Return Result} - Result:=Filter; + Result:=Adapter; end; {Unlock Previous} if AUnlock then if AState = NETWORK_LOCK_READ then APrevious.ReaderUnlock else APrevious.WriterUnlock; end; finally - FFilters.ReaderUnlock; + FAdapters.ReaderUnlock; end; end; {==============================================================================} -function TNetworkTransport.GetConfigByHandle(AHandle:THandle;ALock:Boolean;AState:LongWord):TTransportConfig; -var - Config:TTransportConfig; +function TNetworkMonitor.AddAdapter(AAdapter:TNetworkAdapter):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkMonitor.RemoveAdapter(AAdapter:TNetworkAdapter):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkMonitor.ReaderLock:Boolean; begin {} - FConfigs.ReaderLock; + Result:=(SynchronizerReaderLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkMonitor.ReaderUnlock:Boolean; +begin + {} + Result:=(SynchronizerReaderUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkMonitor.WriterLock:Boolean; +begin + {} + Result:=(SynchronizerWriterLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkMonitor.WriterUnlock:Boolean; +begin + {} + Result:=(SynchronizerWriterUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TNetworkMonitor.StartMonitor:Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkMonitor.StopMonitor:Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkMonitor.ProcessMonitor:Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkMonitor.BindMonitor(AAdapter:TNetworkAdapter):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} + +function TNetworkMonitor.UnbindMonitor(AAdapter:TNetworkAdapter):Boolean; +begin + {Virtual Base Method} + Result:=False; +end; + +{==============================================================================} +{==============================================================================} +{TAuthenticatorAdapter} +constructor TAuthenticatorAdapter.Create; +begin + {} + inherited Create; + FLock:=SynchronizerCreate; + + Handle:=INVALID_HANDLE_VALUE; + Adapter:=nil; +end; + +{==============================================================================} + +destructor TAuthenticatorAdapter.Destroy; +begin + {} + WriterLock; try - Result:=nil; - - {Get Config} - Config:=TTransportConfig(FConfigs.First); - while Config <> nil do - begin - {Check Config} - if THandle(Config) = AHandle then - begin - {Lock Config} - if ALock then if AState = NETWORK_LOCK_READ then Config.ReaderLock else Config.WriterLock; - - {Return Result} - Result:=Config; - Exit; - end; - - {Get Next} - Config:=TTransportConfig(Config.Next); - end; + Adapter:=nil; + inherited Destroy; + finally + {WriterUnlock;} {Can destroy Synchronizer while holding lock} + SynchronizerDestroy(FLock); + end; +end; + +{==============================================================================} + +function TAuthenticatorAdapter.ReaderLock:Boolean; +begin + {} + Result:=(SynchronizerReaderLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TAuthenticatorAdapter.ReaderUnlock:Boolean; +begin + {} + Result:=(SynchronizerReaderUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TAuthenticatorAdapter.WriterLock:Boolean; +begin + {} + Result:=(SynchronizerWriterLock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} + +function TAuthenticatorAdapter.WriterUnlock:Boolean; +begin + {} + Result:=(SynchronizerWriterUnlock(FLock) = ERROR_SUCCESS); +end; + +{==============================================================================} +{==============================================================================} +{TNetworkAuthenticator} +constructor TNetworkAuthenticator.Create(AManager:TTransportManager); +begin + {} + inherited Create; + FLock:=SynchronizerCreate; + + FManager:=AManager; + FAuthType:=AUTH_TYPE_UNKNOWN; + FInitDelay:=0; + FRetryCount:=1; + FRetryTimeout:=5000; + FAdapters:=TNetworkList.Create; + if FManager <> nil then FManager.AddAuthenticator(Self); +end; + +{==============================================================================} + +destructor TNetworkAuthenticator.Destroy; +begin + {} + WriterLock; + try + if FManager <> nil then FManager.RemoveAuthenticator(Self); + FAdapters.Free; + FManager:=nil; + inherited Destroy; finally - FConfigs.ReaderUnlock; - end; + {WriterUnlock;} {Can destroy Synchronizer while holding lock} + SynchronizerDestroy(FLock); + end; end; {==============================================================================} -function TNetworkTransport.GetConfigByType(AConfigType:Word;ALock:Boolean;AState:LongWord):TTransportConfig; +function TNetworkAuthenticator.GetAdapterByHandle(AHandle:THandle;ALock:Boolean;AState:LongWord):TAuthenticatorAdapter; var - Config:TTransportConfig; + Adapter:TAuthenticatorAdapter; begin {} - FConfigs.ReaderLock; + FAdapters.ReaderLock; try Result:=nil; - {Get Config} - Config:=TTransportConfig(FConfigs.First); - while Config <> nil do + {Get Adapter} + Adapter:=TAuthenticatorAdapter(FAdapters.First); + while Adapter <> nil do begin - {Check Config} - if Config.ConfigType = AConfigType then + {Check Adapter} + if Adapter.Handle = AHandle then begin - {Lock Config} - if ALock then if AState = NETWORK_LOCK_READ then Config.ReaderLock else Config.WriterLock; + {Lock Adapter} + if ALock then if AState = NETWORK_LOCK_READ then Adapter.ReaderLock else Adapter.WriterLock; {Return Result} - Result:=Config; + Result:=Adapter; Exit; end; {Get Next} - Config:=TTransportConfig(Config.Next); + Adapter:=TAuthenticatorAdapter(Adapter.Next); end; finally - FConfigs.ReaderUnlock; + FAdapters.ReaderUnlock; end; end; {==============================================================================} -function TNetworkTransport.GetConfigByConfig(AConfig:TTransportConfig;ALock:Boolean;AState:LongWord):TTransportConfig; +function TNetworkAuthenticator.GetAdapterByAdapter(AAdapter:TNetworkAdapter;ALock:Boolean;AState:LongWord):TAuthenticatorAdapter; var - Config:TTransportConfig; + Adapter:TAuthenticatorAdapter; begin {} - FConfigs.ReaderLock; + FAdapters.ReaderLock; try Result:=nil; - {Get Config} - Config:=TTransportConfig(FConfigs.First); - while Config <> nil do + {Get Adapter} + Adapter:=TAuthenticatorAdapter(FAdapters.First); + while Adapter <> nil do begin - {Check Config} - if Config = AConfig then + {Check Adapter} + if Adapter.Adapter = AAdapter then begin - {Lock Config} - if ALock then if AState = NETWORK_LOCK_READ then Config.ReaderLock else Config.WriterLock; + {Lock Adapter} + if ALock then if AState = NETWORK_LOCK_READ then Adapter.ReaderLock else Adapter.WriterLock; {Return Result} - Result:=Config; + Result:=Adapter; Exit; end; {Get Next} - Config:=TTransportConfig(Config.Next); + Adapter:=TAuthenticatorAdapter(Adapter.Next); end; finally - FConfigs.ReaderUnlock; + FAdapters.ReaderUnlock; end; end; {==============================================================================} -function TNetworkTransport.GetConfigByNext(APrevious:TTransportConfig;ALock,AUnlock:Boolean;AState:LongWord):TTransportConfig; +function TNetworkAuthenticator.GetAdapterByNext(APrevious:TAuthenticatorAdapter;ALock,AUnlock:Boolean;AState:LongWord):TAuthenticatorAdapter; var - Config:TTransportConfig; + Adapter:TAuthenticatorAdapter; begin {} - FConfigs.ReaderLock; + FAdapters.ReaderLock; try Result:=nil; @@ -2629,120 +4216,40 @@ function TNetworkTransport.GetConfigByNext(APrevious:TTransportConfig;ALock,AUnl if APrevious = nil then begin {Get First} - Config:=TTransportConfig(FConfigs.First); - if Config <> nil then + Adapter:=TAuthenticatorAdapter(FAdapters.First); + if Adapter <> nil then begin - {Lock Config} - if ALock then if AState = NETWORK_LOCK_READ then Config.ReaderLock else Config.WriterLock; + {Lock Adapter} + if ALock then if AState = NETWORK_LOCK_READ then Adapter.ReaderLock else Adapter.WriterLock; {Return Result} - Result:=Config; + Result:=Adapter; end; end else begin {Get Next} - Config:=TTransportConfig(APrevious.Next); - if Config <> nil then + Adapter:=TAuthenticatorAdapter(APrevious.Next); + if Adapter <> nil then begin - {Lock Config} - if ALock then if AState = NETWORK_LOCK_READ then Config.ReaderLock else Config.WriterLock; + {Lock Adapter} + if ALock then if AState = NETWORK_LOCK_READ then Adapter.ReaderLock else Adapter.WriterLock; {Return Result} - Result:=Config; + Result:=Adapter; end; {Unlock Previous} if AUnlock then if AState = NETWORK_LOCK_READ then APrevious.ReaderUnlock else APrevious.WriterUnlock; end; finally - FConfigs.ReaderUnlock; + FAdapters.ReaderUnlock; end; end; {==============================================================================} -function TNetworkTransport.AddAdapter(AAdapter:TNetworkAdapter;AConfigType:Word;AAddress,ANetmask,AGateway,AServer:Pointer):Boolean; -begin - {Virtual Base Method} - Result:=False; -end; - -{==============================================================================} - -function TNetworkTransport.RemoveAdapter(AAdapter:TNetworkAdapter):Boolean; -begin - {Virtual Base Method} - Result:=False; -end; - -{==============================================================================} - -function TNetworkTransport.AddProtocol(AProtocol:Word;APacketHandler:TTransportPacketHandler;AControlHandler:TTransportControlHandler):THandle; -begin - {Virtual Base Method} - Result:=INVALID_HANDLE_VALUE; -end; - -{==============================================================================} - -function TNetworkTransport.RemoveProtocol(AHandle:THandle;AProtocol:Word):Boolean; -begin - {Virtual Base Method} - Result:=False; -end; - -{==============================================================================} - -function TNetworkTransport.AddFilter(AProtocol:Word;AFilterHandler:TTransportFilterHandler):THandle; -begin - {Virtual Base Method} - Result:=INVALID_HANDLE_VALUE; -end; - -{==============================================================================} - -function TNetworkTransport.RemoveFilter(AHandle:THandle;AProtocol:Word):Boolean; -begin - {Virtual Base Method} - Result:=False; -end; - -{==============================================================================} - -function TNetworkTransport.AddConfig(AConfigType:Word;AConfigAuto:Boolean;AConfigHandler:TTransportConfigHandler):THandle; -begin - {Virtual Base Method} - Result:=INVALID_HANDLE_VALUE; -end; - -{==============================================================================} - -function TNetworkTransport.RemoveConfig(AHandle:THandle;AConfigType:Word):Boolean; -begin - {Virtual Base Method} - Result:=False; -end; - -{==============================================================================} - -function TNetworkTransport.SendPacket(ASocket:TTransportSocket;ASource,ADest:Pointer;APacket:PPacketFragment;ASize,AFlags:Integer):Integer; -begin - {Virtual Base Method} - Result:=SOCKET_ERROR; -end; - -{==============================================================================} - -function TNetworkTransport.SendControl(ASource,ADest:Pointer;AProtocol,ACommand,ACode:Word;AAddress,AData:Pointer;ASize:Integer):Boolean; -begin - {Virtual Base Method} - Result:=False; -end; - -{==============================================================================} - -function TNetworkTransport.FilterPacket(ASource,ADest,APacket:Pointer;ASize:Integer;ABroadcast:Boolean):Boolean; +function TNetworkAuthenticator.AddAdapter(AAdapter:TNetworkAdapter;AAuthType:Word;ACipher,AKey,AEntity,AToken:Pointer):Boolean; begin {Virtual Base Method} Result:=False; @@ -2750,7 +4257,7 @@ function TNetworkTransport.FilterPacket(ASource,ADest,APacket:Pointer;ASize:Inte {==============================================================================} -function TNetworkTransport.ForwardPacket(AAdapter:TTransportAdapter;ASource,ADest,APacket:Pointer;ASize:Integer;ABroadcast:Boolean):Boolean; +function TNetworkAuthenticator.RemoveAdapter(AAdapter:TNetworkAdapter):Boolean; begin {Virtual Base Method} Result:=False; @@ -2758,31 +4265,7 @@ function TNetworkTransport.ForwardPacket(AAdapter:TTransportAdapter;ASource,ADes {==============================================================================} -function TNetworkTransport.GetSockOpt(ASocket:TTransportSocket;ALevel,AOptName:Integer;AOptValue:PChar;var AOptLength:Integer):Integer; -begin - {Virtual Base Method} - Result:=SOCKET_ERROR; -end; - -{==============================================================================} - -function TNetworkTransport.SetSockOpt(ASocket:TTransportSocket;ALevel,AOptName:Integer;AOptValue:PChar;AOptLength:Integer):Integer; -begin - {Virtual Base Method} - Result:=SOCKET_ERROR; -end; - -{==============================================================================} - -function TNetworkTransport.GetStatistics:TTransportStatistics; -begin - {Virtual Base Method} - FillChar(Result,SizeOf(TTransportStatistics),0); -end; - -{==============================================================================} - -function TNetworkTransport.ReaderLock:Boolean; +function TNetworkAuthenticator.ReaderLock:Boolean; begin {} Result:=(SynchronizerReaderLock(FLock) = ERROR_SUCCESS); @@ -2790,7 +4273,7 @@ function TNetworkTransport.ReaderLock:Boolean; {==============================================================================} -function TNetworkTransport.ReaderUnlock:Boolean; +function TNetworkAuthenticator.ReaderUnlock:Boolean; begin {} Result:=(SynchronizerReaderUnlock(FLock) = ERROR_SUCCESS); @@ -2798,7 +4281,7 @@ function TNetworkTransport.ReaderUnlock:Boolean; {==============================================================================} -function TNetworkTransport.WriterLock:Boolean; +function TNetworkAuthenticator.WriterLock:Boolean; begin {} Result:=(SynchronizerWriterLock(FLock) = ERROR_SUCCESS); @@ -2806,7 +4289,7 @@ function TNetworkTransport.WriterLock:Boolean; {==============================================================================} -function TNetworkTransport.WriterUnlock:Boolean; +function TNetworkAuthenticator.WriterUnlock:Boolean; begin {} Result:=(SynchronizerWriterUnlock(FLock) = ERROR_SUCCESS); @@ -2814,7 +4297,7 @@ function TNetworkTransport.WriterUnlock:Boolean; {==============================================================================} -function TNetworkTransport.StartTransport:Boolean; +function TNetworkAuthenticator.StartAuthenticator:Boolean; begin {Virtual Base Method} Result:=False; @@ -2822,7 +4305,7 @@ function TNetworkTransport.StartTransport:Boolean; {==============================================================================} -function TNetworkTransport.StopTransport:Boolean; +function TNetworkAuthenticator.StopAuthenticator:Boolean; begin {Virtual Base Method} Result:=False; @@ -2830,7 +4313,7 @@ function TNetworkTransport.StopTransport:Boolean; {==============================================================================} -function TNetworkTransport.ProcessTransport:Boolean; +function TNetworkAuthenticator.ProcessAuthenticator:Boolean; begin {Virtual Base Method} Result:=False; @@ -2838,7 +4321,7 @@ function TNetworkTransport.ProcessTransport:Boolean; {==============================================================================} -function TNetworkTransport.BindTransport(AAdapter:TNetworkAdapter):Boolean; +function TNetworkAuthenticator.BindAuthenticator(AAdapter:TNetworkAdapter):Boolean; begin {Virtual Base Method} Result:=False; @@ -2846,7 +4329,7 @@ function TNetworkTransport.BindTransport(AAdapter:TNetworkAdapter):Boolean; {==============================================================================} -function TNetworkTransport.UnbindTransport(AAdapter:TNetworkAdapter):Boolean; +function TNetworkAuthenticator.UnbindAuthenticator(AAdapter:TNetworkAdapter):Boolean; begin {Virtual Base Method} Result:=False; @@ -5433,7 +6916,7 @@ procedure TransportInit; if TransportInitialized then Exit; {Create Transport Manager} - TransportManager:=TTransportManager.Create(AdapterManager); + TransportManager:=TTransportManager.Create(NetworkSettings,AdapterManager); TransportInitialized:=True; end; @@ -5459,8 +6942,18 @@ function TransportStart:LongWord; if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to start one or more network transports'); end; - //To Do - + {Start Monitors} + if not TransportManager.StartMonitors then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to start one or more network monitors'); + end; + + {Start Authenticators} + if not TransportManager.StartAuthenticators then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to start one or more network authenticators'); + end; + {Set Started} TransportStarted:=True; @@ -5483,14 +6976,24 @@ function TransportStop:LongWord; {Check Manager} if TransportManager = nil then Exit; + {Stop Authenticators} + if not TransportManager.StopAuthenticators then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to stop one or more network authenticators'); + end; + + {Stop Monitors} + if not TransportManager.StopMonitors then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to stop one or more network monitors'); + end; + {Stop Transports} if not TransportManager.StopTransports then begin if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to stop one or more network transports'); end; - //To Do - {Set Started} TransportStarted:=False; @@ -5498,6 +7001,80 @@ function TransportStop:LongWord; Result:=ERROR_SUCCESS; end; +{==============================================================================} + +function TransportBind:LongWord; +begin + {} + Result:=ERROR_NOT_READY; + + {Check Started} + if not(TransportStarted) then Exit; + + Result:=ERROR_INVALID_PARAMETER; + + {Check Manager} + if TransportManager = nil then Exit; + + {Bind Transports} + if not TransportManager.BindTransports(nil) then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to bind one or more network transports'); + end; + + {Bind Monitors} + if not TransportManager.BindMonitors(nil) then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to bind one or more network monitors'); + end; + + {Bind Authenticators} + if not TransportManager.BindAuthenticators(nil) then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to bind one or more network authenticators'); + end; + + {Return Result} + Result:=ERROR_SUCCESS; +end; + +{==============================================================================} + +function TransportUnbind:LongWord; +begin + {} + Result:=ERROR_NOT_READY; + + {Check Started} + if not(TransportStarted) then Exit; + + Result:=ERROR_INVALID_PARAMETER; + + {Check Manager} + if TransportManager = nil then Exit; + + {Unbind Authenticators} + if not TransportManager.UnbindAuthenticators(nil) then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to unbind one or more network authenticators'); + end; + + {Unbind Monitors} + if not TransportManager.UnbindMonitors(nil) then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to unbind one or more network monitors'); + end; + + {Unbind Transports} + if not TransportManager.UnbindTransports(nil) then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(nil,'Failed to unbind one or more network transports'); + end; + + {Return Result} + Result:=ERROR_SUCCESS; +end; + {==============================================================================} {==============================================================================} {Transport Functions} diff --git a/source/rtl/ultibo/core/udp.pas b/source/rtl/ultibo/core/udp.pas index d695d88..0a54f96 100644 --- a/source/rtl/ultibo/core/udp.pas +++ b/source/rtl/ultibo/core/udp.pas @@ -4005,11 +4005,12 @@ procedure UDPInit; if UDPInitialized then Exit; {Setup UDP Protocol} - if DHCP_CONFIG_ENABLED then UDP_PROTOCOL_ENABLED:=True; - if BOOTP_CONFIG_ENABLED then UDP_PROTOCOL_ENABLED:=True; + if NetworkSettings.GetBoolean('DNS_CLIENT_ENABLED') then NetworkSettings.AddBoolean('UDP_PROTOCOL_ENABLED',True); + if NetworkSettings.GetBoolean('DHCP_CONFIG_ENABLED') then NetworkSettings.AddBoolean('UDP_PROTOCOL_ENABLED',True); + if NetworkSettings.GetBoolean('BOOTP_CONFIG_ENABLED') then NetworkSettings.AddBoolean('UDP_PROTOCOL_ENABLED',True); {Create UDP Protocol} - if UDP_PROTOCOL_ENABLED then + if NetworkSettings.GetBooleanDefault('UDP_PROTOCOL_ENABLED',UDP_PROTOCOL_ENABLED) then begin TUDPProtocol.Create(ProtocolManager,UDP_PROTOCOL_NAME); end; diff --git a/source/rtl/ultibo/core/ultibo.pas b/source/rtl/ultibo/core/ultibo.pas index 449b19d..06839bc 100644 --- a/source/rtl/ultibo/core/ultibo.pas +++ b/source/rtl/ultibo/core/ultibo.pas @@ -745,6 +745,191 @@ _MEMORY_BASIC_INFORMATION = record TMemoryBasicInformation = MEMORY_BASIC_INFORMATION; PMemoryBasicInformation = PMEMORY_BASIC_INFORMATION; +type + {RGB Color Types} + FXPT16DOT16 = Longint; + LPFXPT16DOT16 = ^FXPT16DOT16; + + FXPT2DOT30 = Longint; + LPFXPT2DOT30 = ^FXPT2DOT30; + + PCieXyz = ^TCieXyz; + tagCIEXYZ = record + ciexyzX: FXPT2DOT30; + ciexyzY: FXPT2DOT30; + ciexyzZ: FXPT2DOT30; + end; + CIEXYZ = tagCIEXYZ; + LPCIEXYZ = ^CIEXYZ; + TCieXyz = CIEXYZ; + + PCieXyzTriple = ^TCieXyzTriple; + tagCIEXYZTRIPLE = record + ciexyzRed: CIEXYZ; + ciexyzGreen: CIEXYZ; + ciexyzBlue: CIEXYZ; + end; + CIEXYZTRIPLE = tagCIEXYZTRIPLE; + LPCIEXYZTRIPLE = ^CIEXYZTRIPLE; + TCieXyzTriple = CIEXYZTRIPLE; + +type + {Bitmap Types} + PBitmap = ^TBitmap; + tagBITMAP = record + bmType: LONG; + bmWidth: LONG; + bmHeight: LONG; + bmWidthBytes: LONG; + bmPlanes: WORD; + bmBitsPixel: WORD; + bmBits: LPVOID; + end; + BITMAP = tagBITMAP; + LPBITMAP = ^BITMAP; + NPBITMAP = ^BITMAP; + TBitmap = BITMAP; + + PRgbTriple = ^TRgbTriple; + tagRGBTRIPLE = packed record + rgbtBlue: BYTE; + rgbtGreen: BYTE; + rgbtRed: BYTE; + end; + RGBTRIPLE = tagRGBTRIPLE; + TRgbTriple = RGBTRIPLE; + + PRgbQuad = ^TRgbQuad; + tagRGBQUAD = record + rgbBlue: BYTE; + rgbGreen: BYTE; + rgbRed: BYTE; + rgbReserved: BYTE; + end; + RGBQUAD = tagRGBQUAD; + LPRGBQUAD = ^RGBQUAD; + TRgbQuad = RGBQUAD; + +type + {Bitmap Header Types} + PBitmapCoreHeader = ^TBitmapCoreHeader; + tagBITMAPCOREHEADER = record + bcSize: DWORD; + bcWidth: WORD; + bcHeight: WORD; + bcPlanes: WORD; + bcBitCount: WORD; + end; + BITMAPCOREHEADER = tagBITMAPCOREHEADER; + LPBITMAPCOREHEADER = ^BITMAPCOREHEADER; + TBitmapCoreHeader = BITMAPCOREHEADER; + + PBitmapInfoHeader = ^TBitmapInfoHeader; + tagBITMAPINFOHEADER = record + biSize: DWORD; + biWidth: LONG; + biHeight: LONG; + biPlanes: WORD; + biBitCount: WORD; + biCompression: DWORD; + biSizeImage: DWORD; + biXPelsPerMeter: LONG; + biYPelsPerMeter: LONG; + biClrUsed: DWORD; + biClrImportant: DWORD; + end; + BITMAPINFOHEADER = tagBITMAPINFOHEADER; + LPBITMAPINFOHEADER = ^BITMAPINFOHEADER; + TBitmapInfoHeader = BITMAPINFOHEADER; + + PBitmapV4Header = ^TBitmapV4Header; + BITMAPV4HEADER = record + bV4Size: DWORD; + bV4Width: LONG; + bV4Height: LONG; + bV4Planes: WORD; + bV4BitCount: WORD; + bV4V4Compression: DWORD; + bV4SizeImage: DWORD; + bV4XPelsPerMeter: LONG; + bV4YPelsPerMeter: LONG; + bV4ClrUsed: DWORD; + bV4ClrImportant: DWORD; + bV4RedMask: DWORD; + bV4GreenMask: DWORD; + bV4BlueMask: DWORD; + bV4AlphaMask: DWORD; + bV4CSType: DWORD; + bV4Endpoints: CIEXYZTRIPLE; + bV4GammaRed: DWORD; + bV4GammaGreen: DWORD; + bV4GammaBlue: DWORD; + end; + LPBITMAPV4HEADER = ^BITMAPV4HEADER; + TBitmapV4Header = BITMAPV4HEADER; + + PBitmapV5Header = ^TBitmapV5Header; + BITMAPV5HEADER = record + bV5Size: DWORD; + bV5Width: LONG; + bV5Height: LONG; + bV5Planes: WORD; + bV5BitCount: WORD; + bV5Compression: DWORD; + bV5SizeImage: DWORD; + bV5XPelsPerMeter: LONG; + bV5YPelsPerMeter: LONG; + bV5ClrUsed: DWORD; + bV5ClrImportant: DWORD; + bV5RedMask: DWORD; + bV5GreenMask: DWORD; + bV5BlueMask: DWORD; + bV5AlphaMask: DWORD; + bV5CSType: DWORD; + bV5Endpoints: CIEXYZTRIPLE; + bV5GammaRed: DWORD; + bV5GammaGreen: DWORD; + bV5GammaBlue: DWORD; + bV5Intent: DWORD; + bV5ProfileData: DWORD; + bV5ProfileSize: DWORD; + bV5Reserved: DWORD; + end; + LPBITMAPV5HEADER = ^BITMAPV5HEADER; + TBitmapV5Header = BITMAPV5HEADER; + +type + {Bitmap Info Types} + PBitmapInfo = ^TBitmapInfo; + tagBITMAPINFO = record + bmiHeader: BITMAPINFOHEADER; + bmiColors: array [0..0] of RGBQUAD; + end; + BITMAPINFO = tagBITMAPINFO; + LPBITMAPINFO = ^BITMAPINFO; + TBitmapInfo = BITMAPINFO; + + PBitmapCoreInfo = ^TBitmapCoreInfo; + tagBITMAPCOREINFO = record + bmciHeader: BITMAPCOREHEADER; + bmciColors: array [0..0] of RGBTRIPLE; + end; + BITMAPCOREINFO = tagBITMAPCOREINFO; + LPBITMAPCOREINFO = ^BITMAPCOREINFO; + TBitmapCoreInfo = BITMAPCOREINFO; + + PBitmapFileHeader = ^TBitmapFileHeader; + tagBITMAPFILEHEADER = packed record + bfType: WORD; + bfSize: DWORD; + bfReserved1: WORD; + bfReserved2: WORD; + bfOffBits: DWORD; + end; + BITMAPFILEHEADER = tagBITMAPFILEHEADER; + LPBITMAPFILEHEADER = ^BITMAPFILEHEADER; + TBitmapFileHeader = BITMAPFILEHEADER; + {==============================================================================} {Compatibility variables} {var} diff --git a/source/rtl/ultibo/core/usb.pas b/source/rtl/ultibo/core/usb.pas index 26269c8..64e16ca 100644 --- a/source/rtl/ultibo/core/usb.pas +++ b/source/rtl/ultibo/core/usb.pas @@ -499,7 +499,7 @@ interface USB_PACKETID_STALL = $1e; USB_PACKETID_UNDEF_F = $0f; - {USB Class Codes (Note that only the hub class is defined in the USB 2.0 specification itself the other standard class codes are defined in additional specifications)} + {USB Class Codes (bDeviceClass / bInterfaceClass) (Note that only the hub class is defined in the USB 2.0 specification itself the other standard class codes are defined in additional specifications)} USB_CLASS_CODE_INTERFACE_SPECIFIC = $00; {Use class code info from Interface Descriptors } USB_CLASS_CODE_AUDIO = $01; {Audio device} USB_CLASS_CODE_COMMUNICATIONS_AND_CDC_CONTROL = $02; {Communication device class} @@ -523,6 +523,20 @@ interface USB_CLASS_CODE_VENDOR_SPECIFIC = $ff; {Vendor Specific} {USB SubClass Codes (bInterfaceSubClass) (See: http://www.usb.org/developers/defined_class/)} + {Communications Devices} + USB_SUBCLASS_CDC_DLCM = $01; {Direct Line Control Model (USBPSTN1.2)} + USB_SUBCLASS_CDC_ACM = $02; {Abstract Control Model (USBPSTN1.2)} + USB_SUBCLASS_CDC_TCM = $03; {Telephone Control Model (USBPSTN1.2)} + USB_SUBCLASS_CDC_MCCM = $04; {Multi-Channel Control Model (USBISDN1.2)} + USB_SUBCLASS_CDC_CCM = $05; {CAPI Control Model (USBISDN1.2)} + USB_SUBCLASS_CDC_ETHERNET = $06; {Ethernet Networking Control Model (USBECM1.2)} + USB_SUBCLASS_CDC_WHCM = $08; {Wireless Handset Control Model (USBWMC1.1)} + USB_SUBCLASS_CDC_DMM = $09; {Device Management Model (USBWMC1.1)} + USB_SUBCLASS_CDC_MDLM = $0a; {Mobile Direct Line Model (USBWMC1.1)} + USB_SUBCLASS_CDC_OBEX = $0b; {OBEX (USBWMC1.1)} + USB_SUBCLASS_CDC_EEM = $0c; {Ethernet Emulation Model (USBEEM1.0)} + USB_SUBCLASS_CDC_NCM = $0d; {Network Control Model (USBNCM1.0)} + USB_SUBCLASS_CDC_MBIM = $0e; {Still Image Devices} USB_SUBCLASS_IMAGE_DEFAULT = $01; {Mass Storage Devices} @@ -561,6 +575,18 @@ interface USB_SUBCLASS_APPLICATION_SPECIFIC_TMC = $02; {USB Protocol Codes (bInterfaceProtocol) (See: http://www.usb.org/developers/defined_class/)} + {Communications Devices} + USB_PROTOCOL_CDC_ACM_NONE = 0; {Abstract Control Model - No class specific protocol required} + USB_PROTOCOL_CDC_ACM_AT_V25TER = 1; {Abstract Control Model - AT Commands: V.250 etc} + USB_PROTOCOL_CDC_ACM_AT_PCCA101 = 2; {Abstract Control Model - AT Commands defined by PCCA-101} + USB_PROTOCOL_CDC_ACM_AT_PCCA101_WAKE = 3; {Abstract Control Model - AT Commands defined by PCCA-101 & Annex O} + USB_PROTOCOL_CDC_ACM_AT_GSM = 4; {Abstract Control Model - AT Commands defined by GSM 07.07} + USB_PROTOCOL_CDC_ACM_AT_3G = 5; {Abstract Control Model - AT Commands defined by 3GPP 27.007} + USB_PROTOCOL_CDC_ACM_AT_CDMA = 6; {Abstract Control Model - AT Commands defined by TIA for CDMA} + USB_PROTOCOL_CDC_ACM_VENDOR = $ff; {Abstract Control Model - Vendor-specific} + USB_PROTOCOL_CDC_EEM = 7; {Ethernet Emulation Model} + USB_PROTOCOL_CDC_NCM_NTB = 1; {Network Control Model - Network Transfer Block} + USB_PROTOCOL_CDC_MBIM_NTB = 2; {Network Transfer Block} {Still Image Devices} USB_PROTOCOL_IMAGE_DEFAULT = $01; {Mass Storage Devices} @@ -1407,7 +1433,8 @@ function USBBufferRelease(Buffer:Pointer):LongWord; function USBRequestAllocate(Device:PUSBDevice;Endpoint:PUSBEndpointDescriptor;Callback:TUSBRequestCompleted;Size:LongWord;DriverData:Pointer):PUSBRequest; inline; function USBRequestAllocateEx(Device:PUSBDevice;Endpoint:PUSBEndpointDescriptor;Callback:TUSBRequestCompleted;var Data:Pointer;Size:LongWord;DriverData:Pointer):PUSBRequest; function USBRequestRelease(Request:PUSBRequest):LongWord; -function USBRequestInitialize(Request:PUSBRequest):LongWord; //To Do //Remove (Modify SMSC95XX first) +function USBRequestInitialize(Request:PUSBRequest;Callback:TUSBRequestCompleted;Data:Pointer;Size:LongWord;DriverData:Pointer):LongWord; +function USBRequestInitializeOld(Request:PUSBRequest):LongWord; //To Do //Remove (Modify SMSC95XX first) function USBRequestSubmit(Request:PUSBRequest):LongWord; function USBRequestCancel(Request:PUSBRequest):LongWord; @@ -5238,6 +5265,7 @@ function USBBufferValidate(Device:PUSBDevice;Buffer:Pointer;Size:LongWord;var Fl {Flags: The returned flags for the validated buffer (eg USB_REQUEST_FLAG_SHARED)} {Return: USB_STATUS_SUCCESS on success or another error code on failure} var + HeapSize:LongWord; HeapFlags:LongWord; begin {} @@ -5285,13 +5313,27 @@ function USBBufferValidate(Device:PUSBDevice;Buffer:Pointer;Size:LongWord;var Fl begin {Set Flags} Flags:=Flags or USB_REQUEST_FLAG_SIZED; - end; + end + else + begin + {Get Heap Size} + HeapSize:=MemSize(Buffer); + if HeapSize <> 0 then + begin + {Check Host Multiplier} + if RoundUp(HeapSize,Device.Host.Multiplier) = HeapSize then + begin + {Set Flags} + Flags:=Flags or USB_REQUEST_FLAG_SIZED; + end; + end; + end; {Check Host Flags} if (Device.Host.Device.DeviceFlags and USBHOST_FLAG_SHARED) = USBHOST_FLAG_SHARED then begin {Check Flags} - if (Flags and (USB_REQUEST_FLAG_SHARED or USB_REQUEST_FLAG_ALIGNED)) = (USB_REQUEST_FLAG_SHARED or USB_REQUEST_FLAG_ALIGNED) then + if (Flags and (USB_REQUEST_FLAG_SHARED or USB_REQUEST_FLAG_ALIGNED or USB_REQUEST_FLAG_SIZED)) = (USB_REQUEST_FLAG_SHARED or USB_REQUEST_FLAG_ALIGNED or USB_REQUEST_FLAG_SIZED) then begin {Set Flags} Flags:=Flags or USB_REQUEST_FLAG_COMPATIBLE; @@ -5300,7 +5342,7 @@ function USBBufferValidate(Device:PUSBDevice;Buffer:Pointer;Size:LongWord;var Fl else if (Device.Host.Device.DeviceFlags and USBHOST_FLAG_NOCACHE) = USBHOST_FLAG_NOCACHE then begin {Check Flags} - if (Flags and (USB_REQUEST_FLAG_NOCACHE or USB_REQUEST_FLAG_ALIGNED)) = (USB_REQUEST_FLAG_NOCACHE or USB_REQUEST_FLAG_ALIGNED) then + if (Flags and (USB_REQUEST_FLAG_NOCACHE or USB_REQUEST_FLAG_ALIGNED or USB_REQUEST_FLAG_SIZED)) = (USB_REQUEST_FLAG_NOCACHE or USB_REQUEST_FLAG_ALIGNED or USB_REQUEST_FLAG_SIZED) then begin {Set Flags} Flags:=Flags or USB_REQUEST_FLAG_COMPATIBLE; @@ -5309,10 +5351,10 @@ function USBBufferValidate(Device:PUSBDevice;Buffer:Pointer;Size:LongWord;var Fl else begin {Check Flags} - if (Flags and USB_REQUEST_FLAG_ALIGNED) = USB_REQUEST_FLAG_ALIGNED then + if (Flags and (USB_REQUEST_FLAG_ALIGNED or USB_REQUEST_FLAG_SIZED)) = (USB_REQUEST_FLAG_ALIGNED or USB_REQUEST_FLAG_SIZED) then begin {Set Flags} - //Flags:=Flags or USB_REQUEST_FLAG_COMPATIBLE; //To Do //This was missing ? //If we add it USB fails to bind devices, why ? + //Flags:=Flags or USB_REQUEST_FLAG_COMPATIBLE; //Testing end; end; end; @@ -5486,9 +5528,65 @@ function USBRequestRelease(Request:PUSBRequest):LongWord; Result:=USB_STATUS_SUCCESS; end; +{==============================================================================} + +function USBRequestInitialize(Request:PUSBRequest;Callback:TUSBRequestCompleted;Data:Pointer;Size:LongWord;DriverData:Pointer):LongWord; +{Initialize or Reinitialize an existing USB request} +{Request: The request to be initialized} +{Callback: The callback function to be called on completion of the request} +{Data: The returned data buffer allocated for the request (Or nil if size is zero)} +{Size: The size of the data buffer for the request} +{DriverData: Device driver private data for the callback (Optional)} + +{Return: USB_STATUS_SUCCESS on success or another error code on failure} +begin + {} + Result:=USB_STATUS_INVALID_PARAMETER; + + {Check Request} + if Request = nil then Exit; + + {Check Device} + if Request.Device = nil then Exit; + if Request.Device.Host = nil then Exit; + if Request.Device.Device.Signature <> DEVICE_SIGNATURE then Exit; + + {Check Callback} + if not Assigned(Callback) then Exit; + + {Check Size} + {if Size = 0 then Exit;} {Size may be zero} + + {Check Driver Data} + {if DriverData = nil then Exit;} {DriverData may be nil} + + {Initialize Request} + Request.Data:=Data; + Request.Size:=Size; + Request.Callback:=Callback; + Request.DriverData:=DriverData; + Request.Status:=USB_STATUS_NOT_VALID; + Request.ResubmitThread:=INVALID_HANDLE_VALUE; + Request.ResubmitSemaphore:=INVALID_HANDLE_VALUE; + + {Check Size and Data} + if (Size > 0) and (Data <> nil) then + begin + {Validate Buffer} + if USBBufferValidate(Request.Device,Data,Size,Request.Flags) <> USB_STATUS_SUCCESS then Exit; + end + else + begin + Request.Flags:=USB_REQUEST_FLAG_NONE; + end; + + {Return Result} + Result:=USB_STATUS_SUCCESS; +end; + {==============================================================================} //To Do //Remove (Modify SMSC95XX first) -function USBRequestInitialize(Request:PUSBRequest):LongWord; +function USBRequestInitializeOld(Request:PUSBRequest):LongWord; {Initialize a USB request} {Request: The request to be initialized} {Return: USB_STATUS_SUCCESS on success or another error code on failure} diff --git a/source/rtl/ultibo/core/wifi.pas b/source/rtl/ultibo/core/wifi.pas index 1d88885..d715310 100644 --- a/source/rtl/ultibo/core/wifi.pas +++ b/source/rtl/ultibo/core/wifi.pas @@ -1,5 +1,5 @@ { -Ultibo WiFi (WPA) interface unit. +Ultibo WiFi (IEEE 802.11 / WPA) interface unit. Copyright (C) 2016 - SoftOz Pty Ltd. @@ -26,12 +26,20 @@ Linux - \include\net\cfg80211.h \include\net\mac80211.h \include\linux\ieee80211.h + + \net\mac80211\rx.c + \net\wireless\chan.c + \net\wireless\util.c + References ========== Based on information from sources of WPA supplicant, the Linux kernel and others + Linux Wireless - https://wireless.wiki.kernel.org/en/developers/Documentation/ieee80211 + https://wireless.wiki.kernel.org/en/developers/documentation/mac80211 + WiFi ==== @@ -115,7 +123,12 @@ interface //To Do //In general terms WPA appears to the network stack as a Transport layer //sending and receiving 2 specific packet types: //EAP-over-LAN (EAPOL) $888E and RSN pre-authentication $88C7 - + +//To Do //radiotap support + //See: http://www.radiotap.org/ + //See: /include/net/ieee80211_radiotap.h + //See: \net\mac80211\rx.c + {==============================================================================} {Global definitions} {$INCLUDE GlobalDefines.inc} @@ -241,6 +254,8 @@ interface IEEE80211_FIRST_TSPEC_TSID = 8; IEEE80211_NUM_TIDS = 16; + IEEE80211_MAX_CHAINS = 4; + {Number of user priorities 802.11 uses} IEEE80211_NUM_UPS = 8; @@ -1394,11 +1409,46 @@ interface WIFI_TX_POWER_LIMITED = 1; {limit TX power by the mBm parameter} WIFI_TX_POWER_FIXED = 2; {fix TX power to the mBm parameter} + {WiFi RX Flags} {As per Linux mac80211.h RX_FLAG_*} + WIFI_RX_FLAG_MMIC_ERROR = (1 shl 0); {Michael MIC error was reported on this frame} + WIFI_RX_FLAG_DECRYPTED = (1 shl 1); {This frame was decrypted in hardware} + WIFI_RX_FLAG_MMIC_STRIPPED = (1 shl 3); {The Michael MIC is stripped off this frame,verification has been done by the hardware} + WIFI_RX_FLAG_IV_STRIPPED = (1 shl 4); {The IV/ICV are stripped from this frame} + WIFI_RX_FLAG_FAILED_FCS_CRC = (1 shl 5); {Set this flag if the FCS check failed on the frame} + WIFI_RX_FLAG_FAILED_PLCP_CRC = (1 shl 6); {Set this flag if the PCLP check failed on the frame} + WIFI_RX_FLAG_MACTIME_START = (1 shl 7); {The timestamp passed in the RX status MACTime field is valid and contains the time the first symbol of the MPDU was received} + WIFI_RX_FLAG_SHORTPRE = (1 shl 8); {Short preamble was used for this frame} + WIFI_RX_FLAG_HT = (1 shl 9); {HT MCS was used and RateIndex is MCS index} + WIFI_RX_FLAG_40MHZ = (1 shl 10); {HT40 (40 MHz) was used} + WIFI_RX_FLAG_SHORT_GI = (1 shl 11); {Short guard interval was used} + WIFI_RX_FLAG_NO_SIGNAL_VAL = (1 shl 12); {The signal strength value is not present. Valid only for data frames (mainly A-MPDU)} + WIFI_RX_FLAG_HT_GF = (1 shl 13); {This frame was received in a HT-greenfield transmission} + WIFI_RX_FLAG_AMPDU_DETAILS = (1 shl 14); {A-MPDU details are known} + WIFI_RX_FLAG_AMPDU_REPORT_ZEROLEN = (1 shl 15); {Driver reports 0-length subframes} + WIFI_RX_FLAG_AMPDU_IS_ZEROLEN = (1 shl 16); {This is a zero-length subframe} + WIFI_RX_FLAG_AMPDU_LAST_KNOWN = (1 shl 17); {Last subframe is known} + WIFI_RX_FLAG_AMPDU_IS_LAST = (1 shl 18); {This subframe is the last subframe of the A-MPDU} + WIFI_RX_FLAG_AMPDU_DELIM_CRC_ERROR = (1 shl 19); {A delimiter CRC error has been detected on this subframe} + WIFI_RX_FLAG_AMPDU_DELIM_CRC_KNOWN = (1 shl 20); {The delimiter CRC field is known} + WIFI_RX_FLAG_MACTIME_END = (1 shl 21); {The timestamp passed in the RX status MACTime field is valid and contains the time the last symbol of the MPDU (including FCS) was received} + WIFI_RX_FLAG_VHT = (1 shl 22); {HT MCS was used and RateIndex is MCS index} + WIFI_RX_FLAG_LDPC = (1 shl 23); {LDPC was used} + WIFI_RX_FLAG_STBC_MASK = (1 shl 26) or (1 shl 27); {STBC 2 bit bitmask. 1 - Nss=1, 2 - Nss=2, 3 - Nss=3} + WIFI_RX_FLAG_10MHZ = (1 shl 28); {10 MHz (half channel) was used} + WIFI_RX_FLAG_5MHZ = (1 shl 29); {5 MHz (quarter channel) was used} + WIFI_RX_FLAG_AMSDU_MORE = (1 shl 30); {Some drivers may prefer to report separate A-MSDU subframes instead of a one huge frame for performance reasons} + WIFI_RX_FLAG_RADIOTAP_VENDOR_DATA = (1 shl 31); {This frame contains vendor-specific radiotap data in the data (before the frame)} + + {WiFi RX VHT Flags} {As per Linux mac80211.h RX_VHT_FLAG_*} + WIFI_RX_VHT_FLAG_80MHZ = (1 shl 0); {80 MHz was used} + WIFI_RX_VHT_FLAG_160MHZ = (1 shl 1); {160 MHz was used} + WIFI_RX_VHT_FLAG_BF = (1 shl 2); {packet was beamformed} + {==============================================================================} type {IEEE80211 specific types} {As per Linux ieee80211.h} {$PACKRECORDS 2} - PIEEE80211Header = ^TIEEE80211Header; + PIEEE80211Header = ^TIEEE80211Header; {From Linux ieee80211.h ieee80211_hdr} TIEEE80211Header = record {Not Packed} FrameControl:Word; {LE16} DurationId:Word; {LE16} @@ -1411,7 +1461,7 @@ TIEEE80211Header = record {Not Packed} {$PACKRECORDS DEFAULT} {$PACKRECORDS 2} - PIEEE80211Header3Address = ^TIEEE80211Header3Address; + PIEEE80211Header3Address = ^TIEEE80211Header3Address; {From Linux ieee80211.h ieee80211_hdr_3addr} TIEEE80211Header3Address = record {Not Packed} FrameControl:Word; {LE16} DurationId:Word; {LE16} @@ -1423,7 +1473,7 @@ TIEEE80211Header3Address = record {Not Packed} {$PACKRECORDS DEFAULT} {$PACKRECORDS 2} - PIEEE80211QOSHeader = ^TIEEE80211QOSHeader; + PIEEE80211QOSHeader = ^TIEEE80211QOSHeader; {From Linux ieee80211.h ieee80211_qos_hdr} TIEEE80211QOSHeader = record {Not Packed} FrameControl:Word; {LE16} DurationId:Word; {LE16} @@ -1434,11 +1484,9 @@ TIEEE80211QOSHeader = record {Not Packed} QoSControl:Word; {LE16} end; {$PACKRECORDS DEFAULT} - - //To Do //ieee80211_has_tods/ieee80211_has_fromds etc from ieee80211.h {$PACKRECORDS 2} - PIEEE80211SHeader = ^TIEEE80211SHeader; + PIEEE80211SHeader = ^TIEEE80211SHeader; {From Linux ieee80211.h ieee80211s_hdr} TIEEE80211SHeader = record {Not Packed} Flags:Byte; TTL:Byte; @@ -1499,7 +1547,7 @@ TIEEE80211SHeader = record {Not Packed} NewCenterFreqSeg1:Byte; end; - PIEEE80211TrafficIndicationMapIE = ^TIEEE80211TrafficIndicationMapIE; {Traffic Indication Map information element} {From Linux ieee80211.h ieee80211_tim} + PIEEE80211TrafficIndicationMapIE = ^TIEEE80211TrafficIndicationMapIE; {Traffic Indication Map information element} {From Linux ieee80211.h ieee80211_tim_ie} TIEEE80211TrafficIndicationMapIE = packed record DTIMCount:Byte; DTIMPeriod:Byte; @@ -1535,7 +1583,7 @@ TIEEE80211SHeader = record {Not Packed} LinkMargin:Byte; end; - TIEEE80211ManagementAuth = packed record + TIEEE80211ManagementAuth = packed record {From Linux ieee80211.h ieee80211_mgmt} AuthAlgorithm:Word; {LE16} AuthTransaction:Word; {LE16} StatusCode:Word; {LE16} @@ -1543,18 +1591,18 @@ TIEEE80211SHeader = record {Not Packed} Variable:array[0..0] of Byte; end; - TIEEE80211ManagementDeauth = packed record + TIEEE80211ManagementDeauth = packed record {From Linux ieee80211.h ieee80211_mgmt} ReasonCode:Word; {LE16} end; - TIEEE80211ManagementAssocRequest = packed record + TIEEE80211ManagementAssocRequest = packed record {From Linux ieee80211.h ieee80211_mgmt} CapabilitiesInfo:Word; {LE16} ListenInterval:Word; {LE16} {followed by SSID and Supported rates} Variable:array[0..0] of Byte; end; - TIEEE80211ManagementAssocResponse = packed record + TIEEE80211ManagementAssocResponse = packed record {From Linux ieee80211.h ieee80211_mgmt} CapabilitiesInfo:Word; {LE16} StatusCode:Word; {LE16} AID:Word; {LE16} @@ -1562,7 +1610,7 @@ TIEEE80211SHeader = record {Not Packed} Variable:array[0..0] of Byte; end; - TIEEE80211ManagementReassocRequest = packed record + TIEEE80211ManagementReassocRequest = packed record {From Linux ieee80211.h ieee80211_mgmt} CapabilitiesInfo:Word; {LE16} ListenInterval:Word; {LE16} CurrentAP:THardwareAddress; @@ -1570,11 +1618,11 @@ TIEEE80211SHeader = record {Not Packed} Variable:array[0..0] of Byte; end; - TIEEE80211ManagementDisassoc = packed record + TIEEE80211ManagementDisassoc = packed record {From Linux ieee80211.h ieee80211_mgmt} ReasonCode:Word; {LE16} end; - TIEEE80211ManagementBeacon = packed record + TIEEE80211ManagementBeacon = packed record {From Linux ieee80211.h ieee80211_mgmt} Timestamp:Int64; {LE64} BeaconInterval:Word; {LE16} CapabilitiesInfo:Word; {LE16} @@ -1582,12 +1630,12 @@ TIEEE80211SHeader = record {Not Packed} Variable:array[0..0] of Byte; end; - TIEEE80211ManagementProbeRequest = packed record + TIEEE80211ManagementProbeRequest = packed record {From Linux ieee80211.h ieee80211_mgmt} {only variable items: SSID, Supported rates} Variable:array[0..0] of Byte; end; - TIEEE80211ManagementProbeResponse = packed record + TIEEE80211ManagementProbeResponse = packed record {From Linux ieee80211.h ieee80211_mgmt} Timestamp:Int64; {LE64} BeaconInterval:Word; {LE16} CapabilitiesInfo:Word; {LE16} @@ -1595,25 +1643,25 @@ TIEEE80211SHeader = record {Not Packed} Variable:array[0..0] of Byte; end; - TIEEE80211ManagementActionWMEAction = packed record + TIEEE80211ManagementActionWMEAction = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; DialogToken:Byte; StatusCode:Byte; Variable:array[0..0] of Byte; end; - TIEEE80211ManagementActionChannelSwitch = packed record + TIEEE80211ManagementActionChannelSwitch = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; Variable:array[0..0] of Byte; end; - TIEEE80211ManagementActionExtChannelSwitch = packed record + TIEEE80211ManagementActionExtChannelSwitch = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; Data:TIEEE80211ExtChannelSwitchIE; Variable:array[0..0] of Byte; end; - TIEEE80211ManagementActionMeasurement = packed record + TIEEE80211ManagementActionMeasurement = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; DialogToken:Byte; ElementID:Byte; @@ -1621,7 +1669,7 @@ TIEEE80211SHeader = record {Not Packed} Element:TIEEE80211MeasurementIE; end; - TIEEE80211ManagementActionAddBARequest = packed record + TIEEE80211ManagementActionAddBARequest = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; DialogToken:Byte; Capability:Word; {LE16} @@ -1629,7 +1677,7 @@ TIEEE80211SHeader = record {Not Packed} StartSequenceNumber:Word; {LE16} end; - TIEEE80211ManagementActionAddBAResponse = packed record + TIEEE80211ManagementActionAddBAResponse = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; DialogToken:Byte; Status:Word; {LE16} @@ -1637,50 +1685,50 @@ TIEEE80211SHeader = record {Not Packed} Timeout:Word; {LE16} end; - TIEEE80211ManagementActionDelBA = packed record + TIEEE80211ManagementActionDelBA = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; Params:Word; {LE16} ReasonCode:Word; {LE16} end; - TIEEE80211ManagementActionSelfProt = packed record + TIEEE80211ManagementActionSelfProt = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; Variable:array[0..0] of Byte; end; - TIEEE80211ManagementActionMeshAction = packed record + TIEEE80211ManagementActionMeshAction = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; Variable:array[0..0] of Byte; end; - TIEEE80211ManagementActionSAQuery = packed record + TIEEE80211ManagementActionSAQuery = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; TransID:array[0..WLAN_SA_QUERY_TR_ID_LEN - 1] of Byte; end; - TIEEE80211ManagementActionHTSMPS = packed record + TIEEE80211ManagementActionHTSMPS = packed record {From Linux ieee80211.h ieee80211_mgmt} Action:Byte; SMPSControl:Byte; end; - TIEEE80211ManagementActionHTNotifyChannelWidth = packed record + TIEEE80211ManagementActionHTNotifyChannelWidth = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; ChannelWidth:Byte; end; - TIEEE80211ManagementActionTDLSDiscoverResponse = packed record + TIEEE80211ManagementActionTDLSDiscoverResponse = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; DialogToken:Byte; Capability:Word; {LE16} Variable:array[0..0] of Byte; end; - TIEEE80211ManagementActionVHTOpmodeNotify = packed record + TIEEE80211ManagementActionVHTOpmodeNotify = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; OperatingMode:Byte; end; - TIEEE80211ManagementActionTPCReport = packed record + TIEEE80211ManagementActionTPCReport = packed record {From Linux ieee80211.h ieee80211_mgmt} ActionCode:Byte; DialogToken:Byte; TPCElementID:Byte; @@ -1688,7 +1736,7 @@ TIEEE80211SHeader = record {Not Packed} TPC:TIEEE80211TPCReportIE; end; - TIEEE80211ManagementAction = packed record + TIEEE80211ManagementAction = packed record {From Linux ieee80211.h ieee80211_mgmt} case Integer of 0:(WMEAction:TIEEE80211ManagementAuth); 1:(ChannelSwitch:TIEEE80211ManagementActionChannelSwitch); @@ -1708,7 +1756,7 @@ TIEEE80211SHeader = record {Not Packed} end; {$PACKRECORDS 2} - PIEEE80211Management = ^TIEEE80211Management; + PIEEE80211Management = ^TIEEE80211Management; {From Linux ieee80211.h ieee80211_mgmt} TIEEE80211Management = record {Not Packed} FrameControl:Word; {LE16} Duration:Word; {LE16} @@ -2095,7 +2143,7 @@ TIEEE80211BSSConfiguration = record {From Linux mac80211.h ieee80211_bss_conf} SyncTSF:Int64; {Last beacon's/probe response's TSF timestamp (could be old as it may have been received during scanning long ago)} SyncDeviceTS:LongWord; {The device timestamp corresponding to the SyncTSF} SyncDTIMCount:Byte; {Only valid when IEEE80211_HW_TIMING_BEACON_ONLY is requested} - BasicRates:LongWord; {Bitmap of basic rates, each bit stands for an index into the rate table configured by the driver in the current band} + BasicRates:LongWord; {Bitmap of basic rates, each bit stands for an index into the rate table configured by the driver in the current band} BeaconRate:PIEEE80211Rate; {Associated AP's beacon TX rate} MulticastRate:array[0..IEEE80211_NUM_BANDS - 1] of Integer; {Per-band multicast rate index + 1 (0: disabled)} HTOperationMode:Word; {HT operation mode like in TIEEE80211HTOperation} @@ -2115,6 +2163,90 @@ TIEEE80211BSSConfiguration = record {From Linux mac80211.h ieee80211_bss_conf} P2PNOAAttribute:TIEEE80211P2PNOAAttribute; {P2P NoA attribute for P2P powersave} end; + PIEEE80211RXStatus = ^TIEEE80211RXStatus; + TIEEE80211RXStatus = record {From Linux mac80211.h ieee80211_rx_status} + MACTime:Int64; {Value in microseconds of the 64-bit Time Synchronization Function (TSF) timer when the first data symbol (MPDU) arrived at the hardware} + DeviceTimestamp:LongWord; {Arbitrary timestamp for the device} //To Do //Remove ? + AMPDUReference:LongWord; {A-MPDU reference number, must be a different value for each A-MPDU but the same for each subframe within one A-MPDU} + Flags:LongWord; {WIFI_RX_FLAG_*} + Frequency:Word; {Frequency the radio was tuned to when receiving this frame, in MHz} + VHTFlags:Byte; {WIFI_RX_VHT_FLAG_*} + RateIndex:Byte; {Index of data rate into band's supported rates or MCS index if HT or VHT is used (WIFI_RX_FLAG_HT/WIFI_RX_FLAG_VHT)} + VHTNSS:Byte; {Number of streams (VHT only)} + RXFlags:Byte; {Internal RX flags (IEEE80211_RX_*)} + Band:Byte; {The active band when this frame was received} + Antenna:Byte; {Antenna used} + Signal:Byte; {Signal strength when receiving this frame, either in dBm, in dB or unspecified depending on the hardware capabilities flags IEEE80211_HW_SIGNAL_*} + Chains:Byte; {Bitmask of receive chains for which separate signal strength values were filled} + ChainSignal:array[0..IEEE80211_MAX_CHAINS - 1] of Byte; {Per-chain signal strength, in dBm (unlike Signal, doesn't support dB or unspecified units)} + AMPDUDelimiterCRC:Byte; {A-MPDU delimiter CRC} + end; + + PIEEE80211TXInfo = ^TIEEE80211TXInfo; + TIEEE80211TXInfo = record {From Linux mac80211.h ieee80211_tx_info} + //To Do //From ieee80211_tx_info + end; + + PIEEE80211InformationElements = ^TIEEE80211InformationElements; {From Linux ieee80211_i.h ieee802_11_elems} + TIEEE80211InformationElements = record + Address:Pointer; + Size:LongWord; + + {Information Elements} + LinkIdentifier:PIEEE80211TDLSLinkIdentifierIE; + ChannelSwitchTiming:PIEEE80211ChannelSwitchTiming; + ExtendedCapabilities:Pointer; + SSID:Pointer; + SupportedRates:Pointer; + DSParameters:Pointer; + TrafficIndicationMap:PIEEE80211TrafficIndicationMapIE; + ChallengeText:Pointer; + RSN:Pointer; + ERPInfo:Pointer; + ExtendedSupportedRates:Pointer; + WMMInfo:Pointer; + WMMParam:Pointer; + HTCapabilities:PIEEE80211HTCapabilities; + HTOperation:PIEEE80211HTOperation; + VHTCapabilities:PIEEE80211VHTCapabilities; + VHTOperation:PIEEE80211VHTOperation; + MeshConfiguration:PIEEE80211MeshConfigurationIE; + MeshID:Pointer; + PeerManagement:Pointer; + MeshAwakeWindow:Word; {LE16} + PREQ:Pointer; + PREP:Pointer; + PERR:Pointer; + RootAnnouncement:PIEEE80211RootAnnouncementIE; + ChannelSwitch:PIEEE80211ChannelSwitchIE; + ExtChannelSwitch:PIEEE80211ExtChannelSwitchIE; + WidebandChannelSwitch:PIEEE80211WidebandChannelSwitchIE; + Country:Pointer; + PowerConstraint:Pointer; + CiscoDTPC:Pointer; + TimeoutInterval:PIEEE80211TimeoutIntervalIE; + OpmodeNotification:Pointer; + SecondaryChannelOffset:PIEEE80211SecondaryChannelOffsetIE; + MeshChannelSwitchParams:PIEEE80211MeshChannelSwitchParamsIE; + + {Lengths of Elements} + ExtendedCapabilitiesLength:Byte; + SSIDLength:Byte; + SupportedRatesLength:Byte; + TrafficIndicationMapLength:Byte; + ChallengeTextLength:Byte; + RSNLength:Byte; + ExtendedSupportedRatesLength:Byte; + WMMInfoLength:Byte; + WMMParamLength:Byte; + MeshIDLength:Byte; + PeerManagementLength:Byte; + PREQLength:Byte; + PREPLength:Byte; + PERRLength:Byte; + CountryLength:Byte; + end; + {==============================================================================} type {WiFi specific types} @@ -2225,10 +2357,11 @@ TWiFiDevice = record {Driver Properties} //To Do end; - + {==============================================================================} type {WiFi specific classes} + //TWiFiServiceSet = class; TWiFiAdapter = class(TNetworkAdapter) constructor Create(AManager:TAdapterManager;ADevice:PNetworkDevice;const AName:String); private @@ -2239,6 +2372,14 @@ TWiFiAdapter = class(TNetworkAdapter) FHardwareAddress:THardwareAddress; FBroadcastAddress:THardwareAddress; FMulticastAddresses:TMulticastAddresses; + + {Internal Methods} + function CheckReceiveFrame(APacket:PNetworkPacket;AStatus:PIEEE80211RXStatus):Boolean; + + function ReceiveHandler(APacket:PNetworkPacket;AStatus:PIEEE80211RXStatus):Boolean; + + function ScanReceiver(APacket:PNetworkPacket;AStatus:PIEEE80211RXStatus):Boolean; + function DataReceiver(APacket:PNetworkPacket;AStatus:PIEEE80211RXStatus):Boolean; protected {Inherited Methods} @@ -2395,6 +2536,57 @@ function WiFiNetworkDeviceNotify(Device:PDevice;Data:Pointer;Notification:LongWo {==============================================================================} {IEEE80211 Helper Functions} +function IEEE80211HasToDS(FrameControl:Word):Boolean; inline; +function IEEE80211HasFromDS(FrameControl:Word):Boolean; inline; +function IEEE80211HasA4(FrameControl:Word):Boolean; inline; + +function IEEE80211HasMoreFrags(FrameControl:Word):Boolean; inline; +function IEEE80211HasRetry(FrameControl:Word):Boolean; inline; +function IEEE80211HasPM(FrameControl:Word):Boolean; inline; +function IEEE80211HasMoreData(FrameControl:Word):Boolean; inline; +function IEEE80211HasProtected(FrameControl:Word):Boolean; inline; +function IEEE80211HasOrder(FrameControl:Word):Boolean; inline; + +function IEEE80211IsMgmt(FrameControl:Word):Boolean; inline; +function IEEE80211IsCtl(FrameControl:Word):Boolean; inline; +function IEEE80211IsData(FrameControl:Word):Boolean; inline; +function IEEE80211IsDataQoS(FrameControl:Word):Boolean; inline; +function IEEE80211IsDataPresent(FrameControl:Word):Boolean; inline; + +function IEEE80211IsAssocReq(FrameControl:Word):Boolean; inline; +function IEEE80211IsAssocResp(FrameControl:Word):Boolean; inline; + +function IEEE80211IsReassocReq(FrameControl:Word):Boolean; inline; +function IEEE80211IsReassocResp(FrameControl:Word):Boolean; inline; + +function IEEE80211IsProbeReq(FrameControl:Word):Boolean; inline; +function IEEE80211IsProbeResp(FrameControl:Word):Boolean; inline; +function IEEE80211IsBeacon(FrameControl:Word):Boolean; inline; +function IEEE80211IsATIM(FrameControl:Word):Boolean; inline; + +function IEEE80211IsDisassoc(FrameControl:Word):Boolean; inline; +function IEEE80211IsAuth(FrameControl:Word):Boolean; inline; +function IEEE80211IsDeauth(FrameControl:Word):Boolean; inline; + +function IEEE80211IsAction(FrameControl:Word):Boolean; inline; +function IEEE80211IsBackReq(FrameControl:Word):Boolean; inline; +function IEEE80211IsBack(FrameControl:Word):Boolean; inline; +function IEEE80211IsPSPoll(FrameControl:Word):Boolean; inline; +function IEEE80211IsRTS(FrameControl:Word):Boolean; inline; +function IEEE80211IsCTS(FrameControl:Word):Boolean; inline; +function IEEE80211IsACK(FrameControl:Word):Boolean; inline; + +function IEEE80211IsCFEnd(FrameControl:Word):Boolean; inline; +function IEEE80211IsCFEndAck(FrameControl:Word):Boolean; inline; +function IEEE80211IsNullFunc(FrameControl:Word):Boolean; inline; +function IEEE80211IsQoSNullFunc(FrameControl:Word):Boolean; inline; +function IEEE80211IsBufferableMMPDU(FrameControl:Word):Boolean; inline; + +function IEEE80211IsFirstFrag(SequenceControl:Word):Boolean; inline; + +function IEEE80211HeaderLength(FrameControl:Word):LongWord; +function IEEE80211HeaderLengthFromBuffer(Data:Pointer;Size:LongWord):LongWord; + function IEEE80211MCSToChains(MCS:PIEEE80211MCSInfo):Byte; function IEEE80211ChannelToFrequency(Channel:Integer;Band:LongWord):Integer; @@ -2402,6 +2594,10 @@ function IEEE80211FrequencyToChannel(Frequency:Integer):Integer; procedure IEEE80211InitializeChannelDefinition(Definition:PIEEE80211ChannelDefinition;Channel:PIEEE80211Channel;ChannelType:LongWord); +function IEEE80211FindInformationElement(Identifier:Byte;InformationElement:PByte;ElementLength:LongWord):PByte; + +function IEEE80211ParseInformationElements(Buffer:Pointer;Size:LongWord;Action:Boolean;Elements:PIEEE80211InformationElements):Boolean; + {==============================================================================} {==============================================================================} @@ -2428,6 +2624,196 @@ constructor TWiFiAdapter.Create(AManager:TAdapterManager;ADevice:PNetworkDevice; FillChar(FBroadcastAddress,SizeOf(THardwareAddress),0); FillChar(FMulticastAddresses,SizeOf(TMulticastAddresses),0); end; + +{==============================================================================} + +function TWiFiAdapter.CheckReceiveFrame(APacket:PNetworkPacket;AStatus:PIEEE80211RXStatus):Boolean; +{Check if a received frame is valid to continue processing or should be dropped} + +{should_drop_frame} +begin + {} + Result:=False; + + {Check Packet} + if APacket = nil then Exit; + + {Check Status} + if AStatus = nil then Exit; + + {Check Frame Errors} + if (AStatus.Flags and (WIFI_RX_FLAG_FAILED_FCS_CRC or WIFI_RX_FLAG_FAILED_PLCP_CRC or WIFI_RX_FLAG_AMPDU_IS_ZEROLEN)) <> 0 then Exit; + + {Check Frame Size} + if APacket.Length < 16 then Exit; + + {Check Control Frames} + if IEEE80211IsCtl(PIEEE80211Header(APacket.Data).FrameControl) and not(IEEE80211IsPSPoll(PIEEE80211Header(APacket.Data).FrameControl)) and not(IEEE80211IsBackReq(PIEEE80211Header(APacket.Data).FrameControl)) then Exit; + + Result:=True; +end; + +{==============================================================================} + +function TWiFiAdapter.ReceiveHandler(APacket:PNetworkPacket;AStatus:PIEEE80211RXStatus):Boolean; +{__ieee80211_rx_handle_packet / ieee80211_prepare_and_rx_handle} +var + FrameType:Word; + PacketType:Word; + FrameControl:Word; + Transport:TAdapterTransport; +begin + {} + Result:=False; + + {Check Packet} + if APacket = nil then Exit; + + {Check Status} + if AStatus = nil then Exit; + + {Get Frame Control} + FrameControl:=PIEEE80211Header(APacket.Data).FrameControl; + + {$IFDEF WIFI_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: Receiving Frame (FrameControl=' + IntToHex(FrameControl,4) + ')'); + {$ENDIF} + + {Check Management} + if IEEE80211IsMgmt(FrameControl) then + begin + {Check Length (Drop if too short)} + if APacket.Length < IEEE80211HeaderLength(FrameControl) then Exit; + end; + + {Check Beacon / Probe Response} + if IEEE80211IsProbeResp(FrameControl) or IEEE80211IsBeacon(FrameControl) then + begin + Result:=ScanReceiver(APacket,AStatus); + end; + + {Check Data} + if IEEE80211IsData(FrameControl) then + begin + Result:=DataReceiver(APacket,AStatus); + end + else + begin + + //To Do //Continuing //ieee80211_prepare_and_rx_handle + + end; +end; + +{==============================================================================} + +function TWiFiAdapter.ScanReceiver(APacket:PNetworkPacket;AStatus:PIEEE80211RXStatus):Boolean; +{ieee80211_scan_rx} +var + Buffer:Pointer; + Offset:LongWord; + Management:PIEEE80211Management; + Elements:TIEEE80211InformationElements; +begin + {} + Result:=False; + + {Check Packet} + if APacket = nil then Exit; + + {Check Status} + if AStatus = nil then Exit; + + {$IFDEF WIFI_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: Scan Receive'); + {$ENDIF} + + {Get Management} + Management:=PIEEE80211Management(APacket.Data); + + {Check Length (Drop if too short)} + if APacket.Length < 24 then Exit; + + {$IFDEF WIFI_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: FrameControl=' + IntToHex(Management.FrameControl,4)); + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: Duration=' + IntToHex(Management.Duration,4)); + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: DestinationAddress=' + HardwareAddressToString(Management.DestinationAddress)); + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: SourceAddress=' + HardwareAddressToString(Management.SourceAddress)); + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: BSSID=' + HardwareAddressToString(Management.BSSID)); + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: SequenceControl=' + IntToHex(Management.SequenceControl,4)); + {$ENDIF} + + {Check Type} + if IEEE80211IsProbeResp(Management.FrameControl) then + begin + {Elements Buffer} + Buffer:=@Management.ProbeResponse.Variable; + + {Elements Offset} + Offset:=PtrUInt(Buffer) - PtrUInt(Management); + + {$IFDEF WIFI_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: ProbeResponse.Timestamp=' + IntToHex(Management.ProbeResponse.Timestamp,16)); + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: ProbeResponse.BeaconInterval=' + IntToHex(Management.ProbeResponse.BeaconInterval,4)); + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: ProbeResponse.CapabilitiesInfo=' + IntToHex(Management.ProbeResponse.CapabilitiesInfo,4)); + {$ENDIF} + end + else if IEEE80211IsBeacon(Management.FrameControl) then + begin + {Elements Buffer} + Buffer:=@Management.Beacon.Variable; + + {Elements Offset} + Offset:=PtrUInt(Buffer) - PtrUInt(Management); + + {$IFDEF WIFI_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: Beacon.Timestamp=' + IntToHex(Management.Beacon.Timestamp,16)); + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: Beacon.BeaconInterval=' + IntToHex(Management.Beacon.BeaconInterval,4)); + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: Beacon.CapabilitiesInfo=' + IntToHex(Management.Beacon.CapabilitiesInfo,4)); + {$ENDIF} + end + else + begin + {Invalid} + Exit; + end; + + {Check Offset} + if Offset > APacket.Length then Exit; + + {Parse Elements} + if not IEEE80211ParseInformationElements(Buffer + Offset,APacket.Length - Offset,False,@Elements) then Exit; + + //check Offset ? - Done + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: Offset=' + IntToStr(Offset)); + + //To Do //Continuing //ieee802_11_parse_elems + + //To Do //Continuing + + Result:=True; +end; + +{==============================================================================} + +function TWiFiAdapter.DataReceiver(APacket:PNetworkPacket;AStatus:PIEEE80211RXStatus):Boolean; +{ieee80211_prepare_and_rx_handle} +begin + {} + Result:=False; + + {Check Packet} + if APacket = nil then Exit; + + {Check Status} + if AStatus = nil then Exit; + + {$IFDEF WIFI_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: Data Receive'); + {$ENDIF} + + //To Do //Continuing +end; {==============================================================================} @@ -2447,8 +2833,8 @@ function TWiFiAdapter.AddTransport(APacketType,AFrameType:Word;const APacketName if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Name = ' + APacketName); {$ENDIF} - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2459,7 +2845,7 @@ function TWiFiAdapter.AddTransport(APacketType,AFrameType:Word;const APacketName {Check Frame Type} case AFrameType of - FRAME_TYPE_ETHERNET_II:begin + FRAME_TYPE_ETHERNET_II:begin //To Do //Continuing //FRAME_TYPE_ETHERNET_8022 {Check Media Type} if FMediaType <> MEDIA_TYPE_ETHERNET then Exit; end; @@ -2510,9 +2896,9 @@ function TWiFiAdapter.RemoveTransport(AHandle:THandle;APacketType:Word):Boolean; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Handle = ' + IntToHex(AHandle,8)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Packet = ' + PacketTypeToString(APacketType)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Get Transport} Transport:=TAdapterTransport(GetTransportByHandle(AHandle,True,NETWORK_LOCK_WRITE)); {Writer due to remove} @@ -2564,9 +2950,9 @@ function TWiFiAdapter.GetMTU(AHandle:THandle):Word; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: GetMTU (' + Name + ')'); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Handle = ' + IntToHex(AHandle,8)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2588,7 +2974,9 @@ function TWiFiAdapter.SendPacket(AHandle:THandle;ADest:Pointer;APacket:PPacketFr Size:Integer; Length:LongWord; Buffer:Pointer; - Packet:PPacketFragment; + Entry:PNetworkEntry; + Packet:PNetworkPacket; + Fragment:PPacketFragment; Ethernet:PEthernetHeader; Transport:TAdapterTransport; begin @@ -2606,18 +2994,21 @@ function TWiFiAdapter.SendPacket(AHandle:THandle;ADest:Pointer;APacket:PPacketFr {Check Packet} if APacket = nil then Exit; - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; + {Check Flags} + if (FDevice.Device.DeviceFlags and NETWORK_FLAG_TX_BUFFER) = 0 then Exit; + {Get Transport} Transport:=TAdapterTransport(GetTransportByHandle(AHandle,True,NETWORK_LOCK_READ)); if Transport = nil then Exit; try - //To Do + //To Do //Continuing finally Transport.ReaderUnlock; end; @@ -2637,8 +3028,8 @@ function TWiFiAdapter.GetDefaultAddress(AHandle:THandle):THardwareAddress; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Handle = ' + IntToHex(AHandle,8)); {$ENDIF} - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2665,9 +3056,9 @@ function TWiFiAdapter.GetHardwareAddress(AHandle:THandle):THardwareAddress; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: GetHardwareAddress (' + Name + ')'); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Handle = ' + IntToHex(AHandle,8)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2695,9 +3086,9 @@ function TWiFiAdapter.SetHardwareAddress(AHandle:THandle;const AAddress:THardwar if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Handle = ' + IntToHex(AHandle,8)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Address = ' + HardwareAddressToString(AAddress)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2730,9 +3121,9 @@ function TWiFiAdapter.GetBroadcastAddress(AHandle:THandle):THardwareAddress; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: GetBroadcastAddress (' + Name + ')'); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Handle = ' + IntToHex(AHandle,8)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2757,9 +3148,9 @@ function TWiFiAdapter.GetMulticastAddresses(AHandle:THandle):TMulticastAddresses if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: GetMulticastAddresses (' + Name + ')'); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Handle = ' + IntToHex(AHandle,8)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2784,9 +3175,9 @@ function TWiFiAdapter.AddMulticastAddress(AHandle:THandle;const AAddress:THardwa if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Handle = ' + IntToHex(AHandle,8)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Address = ' + HardwareAddressToString(AAddress)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2811,9 +3202,9 @@ function TWiFiAdapter.RemoveMulticastAddress(AHandle:THandle;const AAddress:THar if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Handle = ' + IntToHex(AHandle,8)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: Address = ' + HardwareAddressToString(AAddress)); {$ENDIF} - - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2839,8 +3230,8 @@ function TWiFiAdapter.StartAdapter:Boolean; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: StartAdapter (' + Name + ')'); {$ENDIF} - {Check Status} - if FStatus <> ADAPTER_STATUS_UNKNOWN then Exit; + {Check State} + if FState <> ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2851,6 +3242,10 @@ function TWiFiAdapter.StartAdapter:Boolean; end; if FMediaType = MEDIA_TYPE_UNKNOWN then Exit; + {Check Flags} + if (FDevice.Device.DeviceFlags and NETWORK_FLAG_RX_BUFFER) = 0 then Exit; + if (FDevice.Device.DeviceFlags and NETWORK_FLAG_TX_BUFFER) = 0 then Exit; + //To Do //See ieee80211_do_open for other stuff (IFTYPES etc) {Open Device} @@ -2878,8 +3273,11 @@ function TWiFiAdapter.StartAdapter:Boolean; //To Do - {Set Status} - FStatus:=ADAPTER_STATUS_READY; + {Set State} + FState:=ADAPTER_STATE_ENABLED; + + {Set Status (Down until Associated)} + FStatus:=ADAPTER_STATUS_DOWN; {Get Properties} FDefaultAddress:=GetDefaultAddress(INVALID_HANDLE_VALUE); @@ -2919,8 +3317,8 @@ function TWiFiAdapter.StopAdapter:Boolean; if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'WiFiAdapter: StopAdapter (' + Name + ')'); {$ENDIF} - {Check Status} - if FStatus <> ADAPTER_STATUS_READY then Exit; + {Check State} + if FState <> ADAPTER_STATE_ENABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2953,11 +3351,14 @@ function TWiFiAdapter.StopAdapter:Boolean; Transport:=TAdapterTransport(GetTransportByNext(Current,True,True,NETWORK_LOCK_READ)); {Remove Transport} - RemoveTransport(THandle(Transport),Transport.PacketType); + RemoveTransport(THandle(Current),Current.PacketType); end; + {Reset State} + FState:=ADAPTER_STATE_DISABLED; + {Reset Status} - FStatus:=ADAPTER_STATUS_UNKNOWN; + FStatus:=ADAPTER_STATUS_DOWN; {Reset Properties} FillChar(FDefaultAddress,SizeOf(THardwareAddress),0); @@ -2976,12 +3377,19 @@ function TWiFiAdapter.StopAdapter:Boolean; {==============================================================================} function TWiFiAdapter.ProcessAdapter:Boolean; +{ieee80211_rx} +var + Rate:PIEEE80211Rate; + Entry:PNetworkEntry; + Packet:PNetworkPacket; + Status:PIEEE80211RXStatus; + SupportedBand:PIEEE80211SupportedBand; begin {} Result:=False; - {Check Status} - if FStatus = ADAPTER_STATUS_UNKNOWN then Exit; + {Check State} + if FState = ADAPTER_STATE_DISABLED then Exit; {Check Device} if FDevice = nil then Exit; @@ -2989,8 +3397,102 @@ function TWiFiAdapter.ProcessAdapter:Boolean; {Check Thread} if FThread = nil then Exit; - Sleep(1000); //To Do - //To Do + {Check Flags} + if (FDevice.Device.DeviceFlags and NETWORK_FLAG_RX_BUFFER) = 0 then Exit; + + {Receive Buffer} + if NetworkBufferReceive(FDevice,Entry) = ERROR_SUCCESS then + begin + try + {$IFDEF WIFI_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: ProcessAdapter (' + Name + ')'); + {$ENDIF} + + {Get Packet} + Packet:=@Entry.Packets[0]; //To Do //Multiple packets per entry + + {$IFDEF WIFI_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: Packet Length = ' + IntToStr(Packet.Length)); + {$ENDIF} + + {Get Status} + Status:=PIEEE80211RXStatus(Entry.DriverData); + + {$IFDEF WIFI_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: Status.Band = ' + IntToStr(Status.Band)); + {$ENDIF} + + {Check Band} + if Status.Band >= IEEE80211_NUM_BANDS then Exit; + + {Get Band} + SupportedBand:=PWiFiDevice(FDevice).Bands[Status.Band]; + if SupportedBand = nil then Exit; + + //To Do //Continuing //Check Reconfig/Quiescing/Suspended ? //ieee80211_rx + + {Check Status} + Rate:=nil; + if (Status.Flags and WIFI_RX_FLAG_FAILED_PLCP_CRC) = 0 then + begin + {Validate the rate, unless a PLCP error means that we probably can't have a valid rate here anyway} + if (Status.Flags and WIFI_RX_FLAG_HT) <> 0 then + begin + {RateIndex is MCS index, which can be [0-76] as documented on: + + http://wireless.kernel.org/en/developers/Documentation/ieee80211/802.11n + + Anything else would be some sort of driver or hardware error} + if Status.RateIndex > 76 then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(FDevice,'WiFiAdapter: HT rate not in MCS index range [0-76] (RateIndex= ' + IntToStr(Status.RateIndex) + ')'); + Exit; + end; + end + else if (Status.Flags and WIFI_RX_FLAG_VHT) <> 0 then + begin + if (Status.RateIndex > 9) or (Status.VHTNSS = 0) or (Status.VHTNSS > 8) then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(FDevice,'WiFiAdapter: VHT rate with invalid data (RateIndex= ' + IntToStr(Status.RateIndex) + ' VHTNSS=' + IntToStr(Status.VHTNSS) + ')'); + Exit; + end; + end + else + begin + if Status.RateIndex >= SupportedBand.RateCount then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(FDevice,'WiFiAdapter: Rate index exceeds supported rate count (RateIndex= ' + IntToStr(Status.RateIndex) + ')'); + Exit; + end; + + {Get Rate} + Rate:=@SupportedBand.Rates[Status.RateIndex]; + end; + end; + + //To Do //Continuing //ieee80211_rx_monitor //radiotap not supported yet //Add TAdapterMonitor class + + if CheckReceiveFrame(Packet,Status) then + begin + //To Do //Continuing //ieee80211_tpt_led_trig_rx + + {Call Receive Handler} + ReceiveHandler(Packet,Status); + end + else + begin + {$IFDEF WIFI_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(FDevice,'WiFiAdapter: Dropping received frame (FrameControl=' + IntToHex(PIEEE80211Header(Packet.Data).FrameControl,4) + ' Length=' + IntToStr(Packet.Length) +')'); + {$ENDIF} + end; + + {Return Result} + Result:=True; + finally + {Release Buffer} + NetworkBufferRelease(FDevice,Entry); + end; + end; end; {==============================================================================} @@ -3097,9 +3599,9 @@ function TEAPOLTransport.AddAdapter(AAdapter:TNetworkAdapter;AConfigType:Word;AA {Check Adapter} if AAdapter = nil then Exit; - - {Check Status} - if AAdapter.Status <> ADAPTER_STATUS_READY then Exit; + + {Check State} + if AAdapter.State <> ADAPTER_STATE_ENABLED then Exit; {Get Adapter} Adapter:=TEAPOLTransportAdapter(GetAdapterByAdapter(AAdapter,True,NETWORK_LOCK_READ)); @@ -3253,7 +3755,7 @@ function TEAPOLTransport.StopTransport:Boolean; Adapter:=TEAPOLTransportAdapter(GetAdapterByNext(Current,True,True,NETWORK_LOCK_READ)); {Remove Adapter} - RemoveAdapter(Adapter.Adapter); + RemoveAdapter(Current.Adapter); end; {Return Result} @@ -3297,13 +3799,14 @@ function TEAPOLTransport.BindTransport(AAdapter:TNetworkAdapter):Boolean; {$IFDEF WIFI_DEBUG} if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'EAPOL: Adapter = ' + AAdapter.Name); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'EAPOL: State = ' + AdapterStateToString(AAdapter.State)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'EAPOL: Status = ' + AdapterStatusToString(AAdapter.Status)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'EAPOL: Type = ' + AdapterTypeToString(AAdapter.AdapterType)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'EAPOL: Media = ' + MediaTypeToString(AAdapter.MediaType)); {$ENDIF} - - {Check Status} - if AAdapter.Status <> ADAPTER_STATUS_READY then Exit; + + {Check State} + if AAdapter.State <> ADAPTER_STATE_ENABLED then Exit; Result:=True; @@ -3488,9 +3991,9 @@ function TRSNTransport.AddAdapter(AAdapter:TNetworkAdapter;AConfigType:Word;AAdd {Check Adapter} if AAdapter = nil then Exit; - - {Check Status} - if AAdapter.Status <> ADAPTER_STATUS_READY then Exit; + + {Check State} + if AAdapter.State <> ADAPTER_STATE_ENABLED then Exit; {Get Adapter} Adapter:=TRSNTransportAdapter(GetAdapterByAdapter(AAdapter,True,NETWORK_LOCK_READ)); @@ -3644,7 +4147,7 @@ function TRSNTransport.StopTransport:Boolean; Adapter:=TRSNTransportAdapter(GetAdapterByNext(Current,True,True,NETWORK_LOCK_READ)); {Remove Adapter} - RemoveAdapter(Adapter.Adapter); + RemoveAdapter(Current.Adapter); end; {Return Result} @@ -3688,13 +4191,14 @@ function TRSNTransport.BindTransport(AAdapter:TNetworkAdapter):Boolean; {$IFDEF WIFI_DEBUG} if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'RSN: Adapter = ' + AAdapter.Name); + if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'RSN: State = ' + AdapterStateToString(AAdapter.State)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'RSN: Status = ' + AdapterStatusToString(AAdapter.Status)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'RSN: Type = ' + AdapterTypeToString(AAdapter.AdapterType)); if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'RSN: Media = ' + MediaTypeToString(AAdapter.MediaType)); {$ENDIF} - - {Check Status} - if AAdapter.Status <> ADAPTER_STATUS_READY then Exit; + + {Check State} + if AAdapter.State <> ADAPTER_STATE_ENABLED then Exit; Result:=True; @@ -3785,13 +4289,13 @@ procedure WiFiInit; if WiFiInitialized then Exit; {Create EAPOL Transport} - if EAPOL_TRANSPORT_ENABLED then + if NetworkSettings.GetBooleanDefault('EAPOL_TRANSPORT_ENABLED',EAPOL_TRANSPORT_ENABLED) then begin TEAPOLTransport.Create(TransportManager,EAPOL_TRANSPORT_NAME); end; {Create RSN Transport} - if RSN_TRANSPORT_ENABLED then + if NetworkSettings.GetBooleanDefault('RSN_TRANSPORT_ENABLED',RSN_TRANSPORT_ENABLED) then begin TRSNTransport.Create(TransportManager,RSN_TRANSPORT_NAME); end; @@ -4019,9 +4523,18 @@ function WiFiDeviceRegister(WiFi:PWiFiDevice):LongWord; if not Assigned(WiFi.DeviceConfigureInterface) then Exit; {Check Network Functions} - //To Do //if not Assigned(WiFi.Network.BufferTransmit) then Exit; if not Assigned(WiFi.Network.DeviceOpen) then Exit; if not Assigned(WiFi.Network.DeviceClose) then Exit; + if not Assigned(WiFi.Network.DeviceRead) then + begin + if not Assigned(WiFi.Network.BufferReceive) then Exit; + if not Assigned(WiFi.Network.BufferRelease) then Exit; + end; + if not Assigned(WiFi.Network.DeviceWrite) then + begin + if not Assigned(WiFi.Network.BufferAllocate) then Exit; + if not Assigned(WiFi.Network.BufferTransmit) then Exit; + end; {Check Optional Flags} //if Assigned(WiFi.DeviceRemainOnChannel) then //To Do @@ -4321,6 +4834,9 @@ procedure WiFiNetworkDeviceAdd(Event:PWiFiDeviceEvent); if AdapterManager = nil then Exit; if TransportManager = nil then Exit; + {Check Settings} + if NetworkSettings = nil then Exit; + {Check Started} if WiFiStarted then begin @@ -4332,15 +4848,25 @@ procedure WiFiNetworkDeviceAdd(Event:PWiFiDeviceEvent); if Adapter = nil then begin {Create Adapter} - if WIRELESS_NETWORK_ENABLED then + if NetworkSettings.GetBooleanDefault('WIRELESS_NETWORK_ENABLED',WIRELESS_NETWORK_ENABLED) then begin Adapter:=TWiFiAdapter.Create(AdapterManager,Event.Device,DeviceGetName(@Event.Device.Device)); - {Start Adapter} - Adapter.StartAdapter; - - {Bind Transports} - TransportManager.BindTransports(Adapter); + {Check Adapter} + if not NetworkSettings.GetBoolean(Adapter.Name + '_DISABLED') then + begin + {Start Adapter} + Adapter.StartAdapter; + + {Bind Transports} + TransportManager.BindTransports(Adapter); + + {Bind Monitors} + TransportManager.BindMonitors(Adapter); + + {Bind Authenticators} + TransportManager.BindAuthenticators(Adapter); + end; end; end; end; @@ -4382,6 +4908,12 @@ function WiFiNetworkDeviceRemove(Network:PNetworkDevice):LongWord; Adapter:=AdapterManager.GetAdapterByDevice(Network,True,NETWORK_LOCK_READ); if Adapter <> nil then begin + {Unbind Authenticators} + TransportManager.UnbindAuthenticators(Adapter); + + {Unbind Monitors} + TransportManager.UnbindMonitors(Adapter); + {Unbind Transports} TransportManager.UnbindTransports(Adapter); @@ -4425,6 +4957,9 @@ function WiFiNetworkDeviceEnum(Network:PNetworkDevice;Data:Pointer):LongWord; {Check Manager} if AdapterManager = nil then Exit; + {Check Settings} + if NetworkSettings = nil then Exit; + {Check Started} if not WiFiStarted then begin @@ -4436,7 +4971,7 @@ function WiFiNetworkDeviceEnum(Network:PNetworkDevice;Data:Pointer):LongWord; if Adapter = nil then begin {Create Adapter} - if WIRELESS_NETWORK_ENABLED then + if NetworkSettings.GetBooleanDefault('WIRELESS_NETWORK_ENABLED',WIRELESS_NETWORK_ENABLED) then begin TWiFiAdapter.Create(AdapterManager,Network,DeviceGetName(@Network.Device)); end; @@ -4527,75 +5062,538 @@ function WiFiNetworkDeviceNotify(Device:PDevice;Data:Pointer;Notification:LongWo {==============================================================================} {==============================================================================} {IEEE80211 Helper Functions} -function IEEE80211MCSToChains(MCS:PIEEE80211MCSInfo):Byte; +function IEEE80211HasToDS(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FCTL_TODS is set} +{ieee80211_has_tods} begin {} - Result:=1; - - if MCS = nil then exit; - - {TODO: consider RXHighest} - if MCS.RXMask[3] <> 0 then - begin - Result:=4; - end - else if MCS.RXMask[2] <> 0 then - begin - Result:=3; - end - else if MCS.RXMask[1] <> 0 then - begin - Result:=2; - end; - - //From ieee80211_mcs_to_chains in \net\mac80211\util.c + Result:=(FrameControl and IEEE80211_FCTL_TODS) <> 0; end; {==============================================================================} -function IEEE80211ChannelToFrequency(Channel:Integer;Band:LongWord):Integer; +function IEEE80211HasFromDS(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FCTL_FROMDS is set} +{ieee80211_has_fromds} begin {} - Result:=0; - - {See 802.11 17.3.8.3.2 and Annex J there are overlapping channel numbers in 5GHz and 2GHz bands} - if Channel <= 0 then Exit; {Not Supported} - - case Band of - IEEE80211_BAND_2GHZ:begin - if Channel = 14 then - begin - Result:=2484; - end - else if Channel < 14 then - begin - Result:=2407 + Channel * 5; - end; - end; - IEEE80211_BAND_5GHZ:begin - if (Channel >= 182) and (Channel <= 196) then - begin - Result:=4000 + Channel * 5; - end - else - begin - Result:=5000 + Channel * 5; - end; - end; - IEEE80211_BAND_60GHZ:begin - if Channel < 5 then - begin - Result:=56160 + Channel * 2160; - end; + Result:=(FrameControl and IEEE80211_FCTL_FROMDS) <> 0; +end; + +{==============================================================================} + +function IEEE80211HasA4(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set} +{ieee80211_has_a4} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_TODS or IEEE80211_FCTL_FROMDS)) = (IEEE80211_FCTL_TODS or IEEE80211_FCTL_FROMDS); +end; + +{==============================================================================} + +function IEEE80211HasMoreFrags(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FCTL_MOREFRAGS is set} +{ieee80211_has_morefrags} +begin + {} + Result:=(FrameControl and IEEE80211_FCTL_MOREFRAGS) <> 0; +end; + +{==============================================================================} + +function IEEE80211HasRetry(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FCTL_RETRY is set} +{ieee80211_has_retry} +begin + {} + Result:=(FrameControl and IEEE80211_FCTL_RETRY) <> 0; +end; + +{==============================================================================} + +function IEEE80211HasPM(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FCTL_PM is set} +{ieee80211_has_pm} +begin + {} + Result:=(FrameControl and IEEE80211_FCTL_PM) <> 0; +end; + +{==============================================================================} + +function IEEE80211HasMoreData(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FCTL_MOREDATA is set} +{ieee80211_has_moredata} +begin + {} + Result:=(FrameControl and IEEE80211_FCTL_MOREDATA) <> 0; +end; + +{==============================================================================} + +function IEEE80211HasProtected(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FCTL_PROTECTED is set} +{ieee80211_has_protected} +begin + {} + Result:=(FrameControl and IEEE80211_FCTL_PROTECTED) <> 0; +end; + +{==============================================================================} + +function IEEE80211HasOrder(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FCTL_ORDER is set} +{ieee80211_has_order} +begin + {} + Result:=(FrameControl and IEEE80211_FCTL_ORDER) <> 0; +end; + +{==============================================================================} + +function IEEE80211IsMgmt(FrameControl:Word):Boolean; inline; +{Check if type is IEEE80211_FTYPE_MGMT} +{ieee80211_is_mgmt} +begin + {} + Result:=(FrameControl and IEEE80211_FCTL_FTYPE) = IEEE80211_FTYPE_MGMT; +end; + +{==============================================================================} + +function IEEE80211IsCtl(FrameControl:Word):Boolean; inline; +{Check if type is IEEE80211_FTYPE_CTL} +{ieee80211_is_ctl} +begin + {} + Result:=(FrameControl and IEEE80211_FCTL_FTYPE) = IEEE80211_FTYPE_CTL; +end; + +{==============================================================================} + +function IEEE80211IsData(FrameControl:Word):Boolean; inline; +{Check if type is IEEE80211_FTYPE_DATA} +{ieee80211_is_data} +begin + {} + Result:=(FrameControl and IEEE80211_FCTL_FTYPE) = IEEE80211_FTYPE_DATA; +end; + +{==============================================================================} + +function IEEE80211IsDataQoS(FrameControl:Word):Boolean; inline; +{Check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set} +{ieee80211_is_data_qos} +begin + {} + {Mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need to check the one bit} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_STYPE_QOS_DATA)) = (IEEE80211_FTYPE_DATA or IEEE80211_STYPE_QOS_DATA); +end; + +{==============================================================================} + +function IEEE80211IsDataPresent(FrameControl:Word):Boolean; inline; +{Check if type is IEEE80211_FTYPE_DATA and has data} +{ieee80211_is_data_present} +begin + {} + {Mask with 0x40 and test that that bit is clear to only return true for the data-containing substypes} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or $40)) = IEEE80211_FTYPE_DATA; +end; + +{==============================================================================} + +function IEEE80211IsAssocReq(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ} +{ieee80211_is_assoc_req} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_MGMT or IEEE80211_STYPE_ASSOC_REQ); +end; + +{==============================================================================} + +function IEEE80211IsAssocResp(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP} +{ieee80211_is_assoc_resp} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_MGMT or IEEE80211_STYPE_ASSOC_RESP); +end; + +{==============================================================================} + +function IEEE80211IsReassocReq(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ} +{ieee80211_is_reassoc_req} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_MGMT or IEEE80211_STYPE_REASSOC_REQ); +end; + +{==============================================================================} + +function IEEE80211IsReassocResp(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP} +{ieee80211_is_reassoc_resp} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_MGMT or IEEE80211_STYPE_REASSOC_RESP); +end; + +{==============================================================================} + +function IEEE80211IsProbeReq(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ} +{ieee80211_is_probe_req} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_MGMT or IEEE80211_STYPE_PROBE_REQ); +end; + +{==============================================================================} + +function IEEE80211IsProbeResp(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP} +{ieee80211_is_probe_resp} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_MGMT or IEEE80211_STYPE_PROBE_RESP); +end; + +{==============================================================================} + +function IEEE80211IsBeacon(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON} +{ieee80211_is_beacon} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_MGMT or IEEE80211_STYPE_BEACON); +end; + +{==============================================================================} + +function IEEE80211IsATIM(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM} +{ieee80211_is_atim} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_MGMT or IEEE80211_STYPE_ATIM); +end; + +{==============================================================================} + +function IEEE80211IsDisassoc(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC} +{ieee80211_is_disassoc} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_MGMT or IEEE80211_STYPE_DISASSOC); +end; + +{==============================================================================} + +function IEEE80211IsAuth(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH} +{ieee80211_is_auth} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_MGMT or IEEE80211_STYPE_AUTH); +end; + +{==============================================================================} + +function IEEE80211IsDeauth(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH} +{ieee80211_is_deauth} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_MGMT or IEEE80211_STYPE_DEAUTH); +end; + +{==============================================================================} + +function IEEE80211IsAction(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION} +{ieee80211_is_action} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_MGMT or IEEE80211_STYPE_ACTION); +end; + +{==============================================================================} + +function IEEE80211IsBackReq(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ} +{ieee80211_is_back_req} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_CTL or IEEE80211_STYPE_BACK_REQ); +end; + +{==============================================================================} + +function IEEE80211IsBack(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK} +{ieee80211_is_back} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_CTL or IEEE80211_STYPE_BACK); +end; + +{==============================================================================} + +function IEEE80211IsPSPoll(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL} +{ieee80211_is_pspoll} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_CTL or IEEE80211_STYPE_PSPOLL); +end; + +{==============================================================================} + +function IEEE80211IsRTS(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS} +{ieee80211_is_rts} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_CTL or IEEE80211_STYPE_RTS); +end; + +{==============================================================================} + +function IEEE80211IsCTS(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS} +{ieee80211_is_cts} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_CTL or IEEE80211_STYPE_CTS); +end; + +{==============================================================================} + +function IEEE80211IsACK(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK} +{ieee80211_is_ack} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_CTL or IEEE80211_STYPE_ACK); +end; + +{==============================================================================} + +function IEEE80211IsCFEnd(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND} +{ieee80211_is_cfend} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_CTL or IEEE80211_STYPE_CFEND); +end; + +{==============================================================================} + +function IEEE80211IsCFEndAck(FrameControl:Word):Boolean; inline; +{Check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK} +{ieee80211_is_cfendack} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_CTL or IEEE80211_STYPE_CFENDACK); +end; + +{==============================================================================} + +function IEEE80211IsNullFunc(FrameControl:Word):Boolean; inline; +{Check if frame is a regular (non-QoS) nullfunc frame} +{ieee80211_is_nullfunc} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_DATA or IEEE80211_STYPE_NULLFUNC); +end; + +{==============================================================================} + +function IEEE80211IsQoSNullFunc(FrameControl:Word):Boolean; inline; +{Check if frame is a QoS nullfunc frame} +{ieee80211_is_qos_nullfunc} +begin + {} + Result:=(FrameControl and (IEEE80211_FCTL_FTYPE or IEEE80211_FCTL_STYPE)) = (IEEE80211_FTYPE_DATA or IEEE80211_STYPE_QOS_NULLFUNC); +end; + +{==============================================================================} + +function IEEE80211IsBufferableMMPDU(FrameControl:Word):Boolean; inline; +{Check if frame is bufferable MMPDU} +{ieee80211_is_bufferable_mmpdu} +begin + {} + {IEEE 802.11-2012, definition of "bufferable management frame" note that this ignores the IBSS special case} + Result:=IEEE80211IsMgmt(FrameControl) and (IEEE80211IsAction(FrameControl) or IEEE80211IsDisassoc(FrameControl) or IEEE80211IsDeauth(FrameControl)); +end; + +{==============================================================================} + +function IEEE80211IsFirstFrag(SequenceControl:Word):Boolean; inline; +{Check if IEEE80211_SCTL_FRAG is not set} +{ieee80211_is_first_frag} +begin + {} + Result:=(SequenceControl and IEEE80211_SCTL_FRAG) = 0; +end; + +{==============================================================================} + +function IEEE80211HeaderLength(FrameControl:Word):LongWord; +{ieee80211_hdrlen} +var + HeaderLength:LongWord; +begin + {} + HeaderLength:=24; + + if IEEE80211IsData(FrameControl) then + begin + if IEEE80211HasA4(FrameControl) then + begin + HeaderLength:=30; + end; + if IEEE80211IsDataQoS(FrameControl) then + begin + HeaderLength:=HeaderLength + IEEE80211_QOS_CTL_LEN; + if IEEE80211HasOrder(FrameControl) then + begin + HeaderLength:=HeaderLength + IEEE80211_HT_CTL_LEN; + end; + end; + + Result:=HeaderLength; + Exit; + end; + + if IEEE80211IsMgmt(FrameControl) then + begin + if IEEE80211HasOrder(FrameControl) then + begin + HeaderLength:=HeaderLength + IEEE80211_HT_CTL_LEN; + end; + + Result:=HeaderLength; + Exit; + end; + + if IEEE80211IsCtl(FrameControl) then + begin + {ACK and CTS are 10 bytes, all others 16. To see how + to get this condition consider + subtype mask: 0b0000000011110000 (0x00F0) + ACK subtype: 0b0000000011010000 (0x00D0) + CTS subtype: 0b0000000011000000 (0x00C0) + bits that matter: ^^^ (0x00E0) + value of those: 0b0000000011000000 (0x00C0)} + if FrameControl and $00E0 = $00C0 then + begin + HeaderLength:=10; + end + else + begin + HeaderLength:=16; + end; + end; + + Result:=HeaderLength; +end; + +{==============================================================================} + +function IEEE80211HeaderLengthFromBuffer(Data:Pointer;Size:LongWord):LongWord; +{ieee80211_get_hdrlen_from_skb} +var + HeaderLength:LongWord; +begin + {} + Result:=0; + + if Data = nil then Exit; + if Size < 10 then Exit; + + HeaderLength:=IEEE80211HeaderLength(PIEEE80211Header(Data).FrameControl); + if HeaderLength > Size then Exit; + + Result:=HeaderLength; +end; + +{==============================================================================} + +function IEEE80211MCSToChains(MCS:PIEEE80211MCSInfo):Byte; +{ieee80211_mcs_to_chains} +begin + {} + Result:=1; + + if MCS = nil then exit; + + {TODO: consider RXHighest} + if MCS.RXMask[3] <> 0 then + begin + Result:=4; + end + else if MCS.RXMask[2] <> 0 then + begin + Result:=3; + end + else if MCS.RXMask[1] <> 0 then + begin + Result:=2; + end; +end; + +{==============================================================================} + +function IEEE80211ChannelToFrequency(Channel:Integer;Band:LongWord):Integer; +{ieee80211_channel_to_frequency} +begin + {} + Result:=0; + + {See 802.11 17.3.8.3.2 and Annex J there are overlapping channel numbers in 5GHz and 2GHz bands} + if Channel <= 0 then Exit; {Not Supported} + + case Band of + IEEE80211_BAND_2GHZ:begin + if Channel = 14 then + begin + Result:=2484; + end + else if Channel < 14 then + begin + Result:=2407 + Channel * 5; + end; + end; + IEEE80211_BAND_5GHZ:begin + if (Channel >= 182) and (Channel <= 196) then + begin + Result:=4000 + Channel * 5; + end + else + begin + Result:=5000 + Channel * 5; + end; + end; + IEEE80211_BAND_60GHZ:begin + if Channel < 5 then + begin + Result:=56160 + Channel * 2160; + end; end; end; - - //From ieee80211_channel_to_frequency in \net\wireless\util.c end; {==============================================================================} function IEEE80211FrequencyToChannel(Frequency:Integer):Integer; +{ieee80211_frequency_to_channel} begin {} {See 802.11 17.3.8.3.2 and Annex J} @@ -4623,13 +5621,12 @@ function IEEE80211FrequencyToChannel(Frequency:Integer):Integer; begin Result:=0; end; - - //From ieee80211_frequency_to_channel in \net\wireless\util.c end; {==============================================================================} procedure IEEE80211InitializeChannelDefinition(Definition:PIEEE80211ChannelDefinition;Channel:PIEEE80211Channel;ChannelType:LongWord); +{cfg80211_chandef_create} begin {} if Definition = nil then exit; @@ -4660,8 +5657,412 @@ procedure IEEE80211InitializeChannelDefinition(Definition:PIEEE80211ChannelDefin if NETWORK_LOG_ENABLED then NetworkLogError(nil,'WiFi: Invalid ChannelType=' + IntToStr(ChannelType)); end; end; +end; - //From cfg80211_chandef_create in \net\wireless\chan.c +{==============================================================================} + +function IEEE80211FindInformationElement(Identifier:Byte;InformationElement:PByte;ElementLength:LongWord):PByte; +{cfg80211_find_ie} +begin + {} + Result:=nil; + + {Check Element} + if InformationElement = nil then Exit; + + while (ElementLength > 2) and (InformationElement[0] <> Identifier) do + begin + Dec(ElementLength,InformationElement[1] + 2); + Inc(InformationElement,InformationElement[1] + 2); + end; + + if ElementLength < 2 then Exit; + if ElementLength < (2 + InformationElement[1]) then Exit; + + Result:=InformationElement; +end; + +{==============================================================================} + +function IEEE80211ParseInformationElements(Buffer:Pointer;Size:LongWord;Action:Boolean;Elements:PIEEE80211InformationElements):Boolean; +{ieee802_11_parse_elems_crc} +var + Current:PByte; + Remain:LongWord; + Identifier:Byte; + ElementLength:Byte; + ParseError:Boolean; + ParseFailed:Boolean; + InformationElement:PByte; +begin + {} + Result:=False; + + {Check Buffer} + if Buffer = nil then Exit; + + {Check Elements} + if Elements = nil then Exit; + + {Setup Elements} + FillChar(Elements^,SizeOf(TIEEE80211InformationElements),0); + Elements.Address:=Buffer; + Elements.Size:=Size; + + {Parse Elements} + Remain:=Size; + Current:=Buffer; + ParseError:=False; + while Remain >= 2 do + begin + {Get Identifier} + Identifier:=Current^; + Inc(Current); + + {Get Length} + ElementLength:=Current^; + Inc(Current); + + {Check Remain} + Dec(Remain,2); + if ElementLength > Remain then + begin + ParseError:=True; + Break; + end; + + ParseFailed:=False; + + case Identifier of + WLAN_EID_LINK_ID:begin + if (ElementLength + 2) <> SizeOf(TIEEE80211TDLSLinkIdentifierIE) then + begin + ParseFailed:=True; + end + else + begin + Elements.LinkIdentifier:=PIEEE80211TDLSLinkIdentifierIE(Current - 2); + end; + end; + WLAN_EID_CHAN_SWITCH_TIMING:begin + if ElementLength <> SizeOf(TIEEE80211ChannelSwitchTiming) then + begin + ParseFailed:=True; + end + else + begin + Elements.ChannelSwitchTiming:=PIEEE80211ChannelSwitchTiming(Current); + end; + end; + WLAN_EID_EXT_CAPABILITY:begin + Elements.ExtendedCapabilities:=Current; + Elements.ExtendedCapabilitiesLength:=ElementLength; + end; + WLAN_EID_SSID:begin + Elements.SSID:=Current; + Elements.SSIDLength:=ElementLength; + end; + WLAN_EID_SUPP_RATES:begin + Elements.SupportedRates:=Current; + Elements.SupportedRatesLength:=ElementLength; + end; + WLAN_EID_DS_PARAMS:begin + if ElementLength >= 1 then + begin + Elements.DSParameters:=Current; + end + else + begin + ParseFailed:=True; + end; + end; + WLAN_EID_TIM:begin + if ElementLength >= SizeOf(TIEEE80211TrafficIndicationMapIE) then + begin + Elements.TrafficIndicationMap:=PIEEE80211TrafficIndicationMapIE(Current); + Elements.TrafficIndicationMapLength:=ElementLength; + end + else + begin + ParseFailed:=True; + end; + end; + WLAN_EID_CHALLENGE:begin + Elements.ChallengeText:=Current; + Elements.ChallengeTextLength:=ElementLength; + end; + WLAN_EID_VENDOR_SPECIFIC:begin + {Microsoft OUI (00:50:F2)} + if (ElementLength >= 4) and (Current[0] = $00) and (Current[1] = $50) and (Current[2] = $f2) then + begin + {OUI Type 2 - WMM IE} + if (ElementLength >= 5) and (Current[3] = 2) then + begin + if Current[4] = 0 then + begin + Elements.WMMInfo:=Current; + Elements.WMMInfoLength:=ElementLength; + end + else if Current[4] = 1 then + begin + Elements.WMMParam:=Current; + Elements.WMMParamLength:=ElementLength; + end; + end + + end; + end; + WLAN_EID_RSN:begin + Elements.RSN:=Current; + Elements.RSNLength:=ElementLength; + end; + WLAN_EID_ERP_INFO: + if ElementLength >= 1 then + begin + Elements.ERPInfo:=Current; + end + else + begin + ParseFailed:=True; + end; + WLAN_EID_EXT_SUPP_RATES:begin + Elements.ExtendedSupportedRates:=Current; + Elements.ExtendedSupportedRatesLength:=ElementLength; + end; + WLAN_EID_HT_CAPABILITY:begin + if ElementLength >= SizeOf(TIEEE80211HTCapabilities) then + begin + Elements.HTCapabilities:=PIEEE80211HTCapabilities(Current); + end + else + begin + ParseFailed:=True; + end; + end; + WLAN_EID_HT_OPERATION:begin + if ElementLength >= SizeOf(TIEEE80211HTOperation) then + begin + Elements.HTOperation:=PIEEE80211HTOperation(Current); + end + else + begin + ParseFailed:=True; + end; + end; + WLAN_EID_VHT_CAPABILITY:begin + if ElementLength >= SizeOf(TIEEE80211VHTCapabilities) then + begin + Elements.VHTCapabilities:=PIEEE80211VHTCapabilities(Current); + end + else + begin + ParseFailed:=True; + end; + end; + WLAN_EID_VHT_OPERATION:begin + if ElementLength >= SizeOf(TIEEE80211VHTOperation) then + begin + Elements.VHTOperation:=PIEEE80211VHTOperation(Current); + end + else + begin + ParseFailed:=True; + end; + end; + WLAN_EID_OPMODE_NOTIF:begin + if ElementLength > 0 then + begin + Elements.OpmodeNotification:=Current; + end + else + begin + ParseFailed:=True; + end; + end; + WLAN_EID_MESH_ID:begin + Elements.MeshID:=Current; + Elements.MeshIDLength:=ElementLength; + end; + WLAN_EID_MESH_CONFIG:begin + if ElementLength >= SizeOf(TIEEE80211MeshConfigurationIE) then + begin + Elements.MeshConfiguration:=PIEEE80211MeshConfigurationIE(Current); + end + else + begin + ParseFailed:=True; + end; + end; + WLAN_EID_PEER_MGMT:begin + Elements.PeerManagement:=Current; + Elements.PeerManagementLength:=ElementLength; + end; + WLAN_EID_MESH_AWAKE_WINDOW:begin + if ElementLength >= 2 then + begin + Elements.MeshAwakeWindow:=PWord(Current)^; + end; + end; + WLAN_EID_PREQ:begin + Elements.PREQ:=Current; + Elements.PREQLength:=ElementLength; + end; + WLAN_EID_PREP:begin + Elements.PREP:=Current; + Elements.PREPLength:=ElementLength; + end; + WLAN_EID_PERR:begin + Elements.PERR:=Current; + Elements.PERRLength:=ElementLength; + end; + WLAN_EID_RANN:begin + if ElementLength >= SizeOf(TIEEE80211RootAnnouncementIE) then + begin + Elements.RootAnnouncement:=PIEEE80211RootAnnouncementIE(Current); + end + else + begin + ParseFailed:=True; + end; + end; + WLAN_EID_CHANNEL_SWITCH:begin + if ElementLength <> SizeOf(TIEEE80211ChannelSwitchIE) then + begin + ParseFailed:=True; + end + else + begin + Elements.ChannelSwitch:=PIEEE80211ChannelSwitchIE(Current); + end; + end; + WLAN_EID_EXT_CHANSWITCH_ANN:begin + if ElementLength <> SizeOf(TIEEE80211ExtChannelSwitchIE) then + begin + ParseFailed:=True; + end + else + begin + Elements.ExtChannelSwitch:=PIEEE80211ExtChannelSwitchIE(Current); + end; + end; + WLAN_EID_SECONDARY_CHANNEL_OFFSET:begin + if ElementLength <> SizeOf(TIEEE80211SecondaryChannelOffsetIE) then + begin + ParseFailed:=True; + end + else + begin + Elements.SecondaryChannelOffset:=PIEEE80211SecondaryChannelOffsetIE(Current); + end; + end; + WLAN_EID_CHAN_SWITCH_PARAM:begin + if ElementLength <> SizeOf(TIEEE80211MeshChannelSwitchParamsIE) then + begin + ParseFailed:=True; + end + else + begin + Elements.MeshChannelSwitchParams:=PIEEE80211MeshChannelSwitchParamsIE(Current); + end; + end; + WLAN_EID_WIDE_BW_CHANNEL_SWITCH:begin + if not(Action) or (ElementLength <> SizeOf(TIEEE80211WidebandChannelSwitchIE)) then + begin + ParseFailed:=True; + end + else + begin + Elements.WidebandChannelSwitch:=PIEEE80211WidebandChannelSwitchIE(Current); + end; + end; + WLAN_EID_CHANNEL_SWITCH_WRAPPER:begin + if Action then + begin + ParseFailed:=True; + end + else + begin + {We only care about the wide bandwidth channel switch element, so parse it out manually} + InformationElement:=IEEE80211FindInformationElement(WLAN_EID_WIDE_BW_CHANNEL_SWITCH,Current,ElementLength); + if InformationElement <> nil then + begin + if InformationElement[1] = SizeOf(TIEEE80211WidebandChannelSwitchIE) then + begin + Elements.WidebandChannelSwitch:=PIEEE80211WidebandChannelSwitchIE(InformationElement + 2); + end + else + begin + ParseFailed:=True; + end; + end; + end; + end; + WLAN_EID_COUNTRY:begin + Elements.Country:=Current; + Elements.CountryLength:=ElementLength; + end; + WLAN_EID_PWR_CONSTRAINT:begin + if ElementLength <> 1 then + begin + ParseFailed:=True; + end + else + begin + Elements.PowerConstraint:=Current; + end; + end; + WLAN_EID_CISCO_VENDOR_SPECIFIC:begin + {Lots of different options exist, get the Dynamic Transmit Power Control element} + if ElementLength < 4 then + begin + ParseFailed:=True; + end + else + begin + {Cisco OUI and DTPC tag (0x00)} + if (Current[0] = $00) and (Current[1] = $40) and (Current[2] = $96) and (Current[3] = $00) then + begin + if ElementLength <> 6 then + begin + ParseFailed:=True; + end + else + begin + Elements.CiscoDTPC:=Current; + end; + end; + end; + end; + WLAN_EID_TIMEOUT_INTERVAL:begin + if ElementLength >= SizeOf(TIEEE80211TimeoutIntervalIE) then + begin + Elements.TimeoutInterval:=PIEEE80211TimeoutIntervalIE(Current); + end + else + begin + ParseFailed:=True; + end; + end; + end; + + + {Check Error} + if ParseFailed then + begin + ParseError:=True; + end; + + {Update Position} + Dec(Remain,ElementLength); + Inc(Current,ElementLength); + end; + + if Remain <> 0 then + begin + ParseError:=True; + end; + + Result:=not(ParseError); end; {==============================================================================} diff --git a/source/rtl/ultibo/core/winsock.pas b/source/rtl/ultibo/core/winsock.pas index d092ce1..6ecd12a 100644 --- a/source/rtl/ultibo/core/winsock.pas +++ b/source/rtl/ultibo/core/winsock.pas @@ -2879,8 +2879,8 @@ function WsControlEx(Proto:DWORD;Action:DWORD;pRequestInfo:Pointer;var pcbReques if pcbRequestInfoLen < SizeOf(TWSAFixedInfo) then Exit; WSAFixedInfo:=PWSAFixedInfo(pRequestInfo); if WSAFixedInfo = nil then Exit; - StrLCopy(WSAFixedInfo.HostName,PChar(TIPTransport(Transport).HostName),WSA_MAX_HOSTNAME_LEN); - StrLCopy(WSAFixedInfo.DomainName,PChar(TIPTransport(Transport).DomainName),WSA_MAX_DOMAIN_NAME_LEN); + StrLCopy(WSAFixedInfo.HostName,PChar(Transport.Manager.Settings.HostName),WSA_MAX_HOSTNAME_LEN); + StrLCopy(WSAFixedInfo.DomainName,PChar(Transport.Manager.Settings.DomainName),WSA_MAX_DOMAIN_NAME_LEN); WSAFixedInfo.DnsServerList.Next:=nil; StrLCopy(WSAFixedInfo.DnsServerList.IpAddress.S,PChar(InAddrToString(InAddrToNetwork(TIPTransport(Transport).Nameservers[0]))),15); diff --git a/source/rtl/ultibo/core/winsock2.pas b/source/rtl/ultibo/core/winsock2.pas index afe333d..fa7bc5d 100644 --- a/source/rtl/ultibo/core/winsock2.pas +++ b/source/rtl/ultibo/core/winsock2.pas @@ -9953,12 +9953,12 @@ function getaddrinfo(pNodeName, pServiceName: PChar; pHints: PAddrInfo; var ppRe Result:=WSAEAFNOSUPPORT; SetLastError(WSAEAFNOSUPPORT); if (Family <> AF_UNSPEC) and (Family <> AF_INET) and (Family <> AF_INET6) then Exit; - if not(IP_TRANSPORT_ENABLED) and (Family = AF_INET) then Exit; - if not(IP6_TRANSPORT_ENABLED) and (Family = AF_INET6) then Exit; + if not(IP_TRANSPORT_ENABLED) and (Family = AF_INET) then Exit; //To Do //Need to use NetworkSettings, restructure when moved to DNSClient + if not(IP6_TRANSPORT_ENABLED) and (Family = AF_INET6) then Exit; //To Do //Need to use NetworkSettings, restructure when moved to DNSClient if Family = AF_UNSPEC then begin - if IP_TRANSPORT_ENABLED and not(IP6_TRANSPORT_ENABLED) then Family:=AF_INET; - if not(IP_TRANSPORT_ENABLED) and IP6_TRANSPORT_ENABLED then Family:=AF_INET6; + if IP_TRANSPORT_ENABLED and not(IP6_TRANSPORT_ENABLED) then Family:=AF_INET; //To Do //Need to use NetworkSettings, restructure when moved to DNSClient + if not(IP_TRANSPORT_ENABLED) and IP6_TRANSPORT_ENABLED then Family:=AF_INET6; //To Do //Need to use NetworkSettings, restructure when moved to DNSClient end; {Check Socket Type} @@ -12108,8 +12108,8 @@ function WsControlEx(Proto:DWORD;Action:DWORD;pRequestInfo:Pointer; var pcbReque if pcbRequestInfoLen < SizeOf(TWSAFixedInfo) then Exit; WSAFixedInfo:=PWSAFixedInfo(pRequestInfo); if WSAFixedInfo = nil then Exit; - StrLCopy(WSAFixedInfo.HostName,PChar(TIPTransport(Transport).HostName),WSA_MAX_HOSTNAME_LEN); - StrLCopy(WSAFixedInfo.DomainName,PChar(TIPTransport(Transport).DomainName),WSA_MAX_DOMAIN_NAME_LEN); + StrLCopy(WSAFixedInfo.HostName,PChar(Transport.Manager.Settings.HostName),WSA_MAX_HOSTNAME_LEN); + StrLCopy(WSAFixedInfo.DomainName,PChar(Transport.Manager.Settings.DomainName),WSA_MAX_DOMAIN_NAME_LEN); WSAFixedInfo.DnsServerList.Next:=nil; StrLCopy(WSAFixedInfo.DnsServerList.IpAddress.S,PChar(InAddrToString(InAddrToNetwork(TIPTransport(Transport).Nameservers[0]))),15); diff --git a/source/rtl/ultibo/drivers/rt2800lib.pas b/source/rtl/ultibo/drivers/rt2800lib.pas index 2628826..d656ba3 100644 --- a/source/rtl/ultibo/drivers/rt2800lib.pas +++ b/source/rtl/ultibo/drivers/rt2800lib.pas @@ -646,41 +646,41 @@ interface {RF_CSR_CFG1 (RF control register)} RT2800_RF_CSR_CFG1 = $1024; - RT2800_RF_CSR_CFG1_REGID_AND_VALUE = $00ffffff; {REGID_AND_VALUE: Register value to program into RF} - RT2800_RF_CSR_CFG1_RFGAP = $1f000000; {RFGAP: Gap between BB_CONTROL_RF and RF_LE} + RT2800_RF_CSR_CFG1_REGID_AND_VALUE = $00ffffff; {REGID_AND_VALUE: Register value to program into RF} + RT2800_RF_CSR_CFG1_RFGAP = $1f000000; {RFGAP: Gap between BB_CONTROL_RF and RF_LE} { 0: 3 system clock cycle (37.5usec)} { 1: 5 system clock cycle (62.5usec)} {RF_CSR_CFG2 (RF control register)} RT2800_RF_CSR_CFG2 = $1028; - RT2800_RF_CSR_CFG2_VALUE = $00ffffff; {VALUE: Register value to program into RF} + RT2800_RF_CSR_CFG2_VALUE = $00ffffff; {VALUE: Register value to program into RF} {LED_CFG (LED control)} RT2800_LED_CFG = $102c; - RT2800_LED_CFG_ON_PERIOD = $000000ff; {ON_PERIOD: LED active time (ms) during TX (only used for LED mode 1)} - RT2800_LED_CFG_OFF_PERIOD = $0000ff00; {OFF_PERIOD: LED inactive time (ms) during TX (only used for LED mode 1)} - RT2800_LED_CFG_SLOW_BLINK_PERIOD = $003f0000; {SLOW_BLINK_PERIOD: LED blink interval in seconds (only used for LED mode 2)} - RT2800_LED_CFG_R_LED_MODE = $03000000; {color LED's:} - RT2800_LED_CFG_G_LED_MODE = $0c000000; { 0: off / 1: blinking upon TX2 / 2: periodic slow blinking / 3: always on} - RT2800_LED_CFG_Y_LED_MODE = $30000000; - RT2800_LED_CFG_LED_POLAR = $40000000; {LED polarity: 0: active low / 1: active high} + RT2800_LED_CFG_ON_PERIOD = $000000ff; {ON_PERIOD: LED active time (ms) during TX (only used for LED mode 1)} + RT2800_LED_CFG_OFF_PERIOD = $0000ff00; {OFF_PERIOD: LED inactive time (ms) during TX (only used for LED mode 1)} + RT2800_LED_CFG_SLOW_BLINK_PERIOD = $003f0000; {SLOW_BLINK_PERIOD: LED blink interval in seconds (only used for LED mode 2)} + RT2800_LED_CFG_R_LED_MODE = $03000000; {color LED's:} + RT2800_LED_CFG_G_LED_MODE = $0c000000; { 0: off / 1: blinking upon TX2 / 2: periodic slow blinking / 3: always on} + RT2800_LED_CFG_Y_LED_MODE = $30000000; + RT2800_LED_CFG_LED_POLAR = $40000000; {LED polarity: 0: active low / 1: active high} {AMPDU_BA_WINSIZE (Force BlockAck window size)} RT2800_AMPDU_BA_WINSIZE = $1040; - RT2800_AMPDU_BA_WINSIZE_FORCE_WINSIZE_ENABLE = $00000020; {FORCE_WINSIZE_ENABLE: 0: Disable forcing of BlockAck window size / 1: Enable forcing of BlockAck window size, overwrites values BlockAck window size values in the TXWI} - RT2800_AMPDU_BA_WINSIZE_FORCE_WINSIZE = $0000001f; {FORCE_WINSIZE: BlockAck window size} + RT2800_AMPDU_BA_WINSIZE_FORCE_WINSIZE_ENABLE = $00000020; {FORCE_WINSIZE_ENABLE: 0: Disable forcing of BlockAck window size / 1: Enable forcing of BlockAck window size, overwrites values BlockAck window size values in the TXWI} + RT2800_AMPDU_BA_WINSIZE_FORCE_WINSIZE = $0000001f; {FORCE_WINSIZE: BlockAck window size} {XIFS_TIME_CFG (MAC timing)} RT2800_XIFS_TIME_CFG = $1100; - RT2800_XIFS_TIME_CFG_CCKM_SIFS_TIME = $000000ff; {CCKM_SIFS_TIME: unit 1us. Applied after CCK RX/TX} - RT2800_XIFS_TIME_CFG_OFDM_SIFS_TIME = $0000ff00; {OFDM_SIFS_TIME: unit 1us. Applied after OFDM RX/TX} - RT2800_XIFS_TIME_CFG_OFDM_XIFS_TIME = $000f0000; {OFDM_XIFS_TIME: unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND} - RT2800_XIFS_TIME_CFG_EIFS = $1ff00000; {EIFS: unit 1us} - RT2800_XIFS_TIME_CFG_BB_RXEND_ENABLE = $20000000; {BB_RXEND_ENABLE: reference RXEND signal to begin XIFS defer} + RT2800_XIFS_TIME_CFG_CCKM_SIFS_TIME = $000000ff; {CCKM_SIFS_TIME: unit 1us. Applied after CCK RX/TX} + RT2800_XIFS_TIME_CFG_OFDM_SIFS_TIME = $0000ff00; {OFDM_SIFS_TIME: unit 1us. Applied after OFDM RX/TX} + RT2800_XIFS_TIME_CFG_OFDM_XIFS_TIME = $000f0000; {OFDM_XIFS_TIME: unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND} + RT2800_XIFS_TIME_CFG_EIFS = $1ff00000; {EIFS: unit 1us} + RT2800_XIFS_TIME_CFG_BB_RXEND_ENABLE = $20000000; {BB_RXEND_ENABLE: reference RXEND signal to begin XIFS defer} {BKOFF_SLOT_CFG} RT2800_BKOFF_SLOT_CFG = $1104; @@ -1361,17 +1361,17 @@ interface triggered, the hw seems to simply drop further tx results} RT2800_TX_STA_FIFO = $1718; - RT2800_TX_STA_FIFO_VALID = $00000001; {VALID: 1: this tx result is valid 0: no valid tx result -> driver should stop reading} - RT2800_TX_STA_FIFO_PID_TYPE = $0000001e; {PID_TYPE: The PID latched from the PID field in the TXWI, can be used to match a frame with its tx result (even though the PID isonly 4 bits wide)} - RT2800_TX_STA_FIFO_PID_QUEUE = $00000006; {PID_QUEUE: Part of PID_TYPE, this is the queue index number (0-3)} - RT2800_TX_STA_FIFO_PID_ENTRY = $00000018; {PID_ENTRY: Part of PID_TYPE, this is the queue entry index number (1-3; This identification number is calculated by ((idx % 3; + 1)} + RT2800_TX_STA_FIFO_VALID = $00000001; {VALID: 1: this tx result is valid 0: no valid tx result -> driver should stop reading} + RT2800_TX_STA_FIFO_PID_TYPE = $0000001e; {PID_TYPE: The PID latched from the PID field in the TXWI, can be used to match a frame with its tx result (even though the PID isonly 4 bits wide)} + RT2800_TX_STA_FIFO_PID_QUEUE = $00000006; {PID_QUEUE: Part of PID_TYPE, this is the queue index number (0-3)} + RT2800_TX_STA_FIFO_PID_ENTRY = $00000018; {PID_ENTRY: Part of PID_TYPE, this is the queue entry index number (1-3; This identification number is calculated by ((idx % 3; + 1)} RT2800_TX_STA_FIFO_TX_SUCCESS = $00000020; {TX_SUCCESS: Indicates tx success (1; or failure (0)} - RT2800_TX_STA_FIFO_TX_AGGRE = $00000040; {TX_AGGRE: Indicates if the frame was part of an aggregate (1; or not (0)} - RT2800_TX_STA_FIFO_TX_ACK_REQUIRED = $00000080; {TX_ACK_REQUIRED: Indicates if the frame needed to get ack'ed (1; or not (0)} - RT2800_TX_STA_FIFO_WCID = $0000ff00; {WCID: The wireless client ID.} - RT2800_TX_STA_FIFO_SUCCESS_RATE = $ffff0000; - RT2800_TX_STA_FIFO_MCS = $007f0000; {MCS: The tx rate used during the last transmission of this frame, be it successful or not.} - RT2800_TX_STA_FIFO_PHYMODE = $c0000000; {PHYMODE: The phymode used for the transmission.} + RT2800_TX_STA_FIFO_TX_AGGRE = $00000040; {TX_AGGRE: Indicates if the frame was part of an aggregate (1; or not (0)} + RT2800_TX_STA_FIFO_TX_ACK_REQUIRED = $00000080; {TX_ACK_REQUIRED: Indicates if the frame needed to get ack'ed (1; or not (0)} + RT2800_TX_STA_FIFO_WCID = $0000ff00; {WCID: The wireless client ID.} + RT2800_TX_STA_FIFO_SUCCESS_RATE = $ffff0000; + RT2800_TX_STA_FIFO_MCS = $007f0000; {MCS: The tx rate used during the last transmission of this frame, be it successful or not.} + RT2800_TX_STA_FIFO_PHYMODE = $c0000000; {PHYMODE: The phymode used for the transmission.} {TX_AGG_CNT (Debug counter)} RT2800_TX_AGG_CNT = $171c; @@ -2725,6 +2725,10 @@ function RT2800GetGainCalibrationDelta(RT2X00:PRT2X00WiFiDevice):LongInt; function RT2800CompensateTXPower(RT2X00:PRT2X00WiFiDevice;IsRateB,Band:LongWord;PowerLevel:LongInt;TXPower:Byte;Delta:LongInt):Byte; +function RT2800AGCtoRSSI(RT2X00:PRT2X00WiFiDevice;RXWI2:LongWord):LongInt; + +function RT2800ReceiveProcessRXWI(RT2X00:PRT2X00WiFiDevice;Descriptor:PRT2X00RXDescriptor;var Data:Pointer;var Size:LongWord):Boolean; + function RT2800_MAC_WCID_ENTRY(Index:LongWord):LongWord; inline; function RT2800_PAIRWISE_KEY_ENTRY(Index:LongWord):LongWord; inline; function RT2800_MAC_IVEIV_ENTRY(Index:LongWord):LongWord; inline; @@ -2837,6 +2841,10 @@ function RT2800DriverInit(RT2X00:PRT2X00WiFiDevice):LongWord; {Set RSSI offset} RT2X00.RSSIOffset:=RT2800_DEFAULT_RSSI_OFFSET; + {Set TXWI/RXWI size} + RT2X00.TXWISize:=RT2800GetTXWISize(RT2X00); + RT2X00.RXWISize:=RT2800GetRXWISize(RT2X00); + Result:=ERROR_SUCCESS; end; @@ -7748,6 +7756,7 @@ function RT2800WaitForMCU(RT2X00:PRT2X00WiFiDevice;Reg:PLongWord):Boolean; inlin {==============================================================================} function RT2800GetEeprom16(RT2X00:PRT2X00WiFiDevice;ID:Word):Word; +{rt2800_eeprom_read} var Offset:Word; begin @@ -8197,7 +8206,147 @@ function RT2800CompensateTXPower(RT2X00:PRT2X00WiFiDevice;IsRateB,Band:LongWord; //if NETWORK_LOG_ENABLED then NetworkLogDebug(PNetworkDevice(@RT2X00.WiFi.Network),'RT2800: (Result=' + IntToStr(Result) + ')'); //To Do {$ENDIF} end; + +{==============================================================================} + +function RT2800AGCtoRSSI(RT2X00:PRT2X00WiFiDevice;RXWI2:LongWord):LongInt; +var + Value:Word; + RSSI0:ShortInt; + RSSI1:ShortInt; + RSSI2:ShortInt; + Offset0:Byte; + Offset1:Byte; + Offset2:Byte; +begin + {} + Result:=0; + + {$IFDEF RT2800USB_DEBUG} + //if NETWORK_LOG_ENABLED then NetworkLogDebug(PNetworkDevice(@RT2X00.WiFi.Network),'RT2800: RT2800AGCtoRSSI'); //To Do + //if NETWORK_LOG_ENABLED then NetworkLogDebug(PNetworkDevice(@RT2X00.WiFi.Network),'RT2800: (RXWI2=' + IntToHex(RXWI2,8) + ')'); //To Do + {$ENDIF} + + {Check Device} + if RT2X00 = nil then Exit; + + RSSI0:=RT2X00GetRegister32(RXWI2,RT2800_RXWI_W2_RSSI0,0); + RSSI1:=RT2X00GetRegister32(RXWI2,RT2800_RXWI_W2_RSSI1,8); + RSSI2:=RT2X00GetRegister32(RXWI2,RT2800_RXWI_W2_RSSI2,16); + + if RT2X00.CurrentBand = IEEE80211_BAND_2GHZ then + begin + Value:=RT2800GetEeprom16(RT2X00,RT2800_EEPROM_RSSI_BG); + Offset0:=RT2X00GetRegister16(Value,RT2800_EEPROM_RSSI_BG_OFFSET0,0); + Offset1:=RT2X00GetRegister16(Value,RT2800_EEPROM_RSSI_BG_OFFSET1,8); + Value:=RT2800GetEeprom16(RT2X00,RT2800_EEPROM_RSSI_BG2); + Offset2:=RT2X00GetRegister16(Value,RT2800_EEPROM_RSSI_BG2_OFFSET2,0); + end + else + begin + Value:=RT2800GetEeprom16(RT2X00,RT2800_EEPROM_RSSI_A); + Offset0:=RT2X00GetRegister16(Value,RT2800_EEPROM_RSSI_A_OFFSET0,0); + Offset1:=RT2X00GetRegister16(Value,RT2800_EEPROM_RSSI_A_OFFSET1,8); + Value:=RT2800GetEeprom16(RT2X00,RT2800_EEPROM_RSSI_A2); + Offset2:=RT2X00GetRegister16(Value,RT2800_EEPROM_RSSI_A2_OFFSET2,0); + end; + + {Convert the value from the descriptor into the RSSI value If the value in the descriptor is 0, it is considered invalid and the default (extremely low) rssi value is assumed} + if RSSI0 <> 0 then RSSI0:=(-12 - Offset0 - RT2X00.LNAGain - RSSI0) else RSSI0:=-128; + if RSSI1 <> 0 then RSSI1:=(-12 - Offset1 - RT2X00.LNAGain - RSSI1) else RSSI1:=-128; + if RSSI2 <> 0 then RSSI2:=(-12 - Offset2 - RT2X00.LNAGain - RSSI2) else RSSI2:=-128; + + {RX Status only accepts a single RSSI value. Calculating the average doesn't deliver a fair answer either since + -60:-60 would be considered equally good as -50:-70 while the second is the one which gives less energy...} + RSSI0:=Max(RSSI0,RSSI1); + Result:=Max(RSSI0,RSSI2); + + {$IFDEF RT2800USB_DEBUG} + //if NETWORK_LOG_ENABLED then NetworkLogDebug(PNetworkDevice(@RT2X00.WiFi.Network),'RT2800: (Result=' + IntToStr(Result) + ')'); //To Do + {$ENDIF} +end; +{==============================================================================} + +function RT2800ReceiveProcessRXWI(RT2X00:PRT2X00WiFiDevice;Descriptor:PRT2X00RXDescriptor;var Data:Pointer;var Size:LongWord):Boolean; +{rt2800_process_rxwi} +var + RXWI:Pointer; + Value:LongWord; +begin + {} + Result:=False; + + {Check Device} + if RT2X00 = nil then Exit; + + {Check Descriptor} + if Descriptor = nil then Exit; + + {Check Data and Size} + if Data = nil then Exit; + if Size = 0 then Exit; + + {Get RXWI} + RXWI:=Data; + + {Get Word0} + Value:=RT2X00ReadDescriptor(RXWI,0); + {$IFDEF RT2800USB_DEBUG} + //if NETWORK_LOG_ENABLED then NetworkLogDebug(@RT2X00.WiFi.Network,'RT2800: (RXWI Word0 Value=' + IntToHex(Value,8) + ')'); //To Do + {$ENDIF} + + {Cipher} + Descriptor.Cipher:=RT2X00GetRegister32(Value,RT2800_RXWI_W0_UDF,13); + + {Size} + Descriptor.Size:=RT2X00GetRegister32(Value,RT2800_RXWI_W0_MPDU_TOTAL_BYTE_COUNT,16); + + {Get Word1} + Value:=RT2X00ReadDescriptor(RXWI,1); + {$IFDEF RT2800USB_DEBUG} + //if NETWORK_LOG_ENABLED then NetworkLogDebug(@RT2X00.WiFi.Network,'RT2800: (RXWI Word1 Value=' + IntToHex(Value,8) + ')'); //To Do + {$ENDIF} + + {Short GI} + if RT2X00GetRegister32(Value,RT2800_RXWI_W1_SHORT_GI,24) <> 0 then + begin + Descriptor.Flags:=Descriptor.Flags or WIFI_RX_FLAG_SHORT_GI; + end; + + {Bandwidth} + if RT2X00GetRegister32(Value,RT2800_RXWI_W1_BW,23) <> 0 then + begin + Descriptor.Flags:=Descriptor.Flags or WIFI_RX_FLAG_40MHZ; + end; + + {RX rate (always use MCS as signal type)} + Descriptor.RXFlags:=Descriptor.RXFlags or RT2X00_RXDONE_SIGNAL_MCS; + Descriptor.Signal:=RT2X00GetRegister32(Value,RT2800_RXWI_W1_MCS,16); + Descriptor.RateMode:=RT2X00GetRegister32(Value,RT2800_RXWI_W1_PHYMODE,30); + + {Mask off 0x8 bit to remove the short preamble flag} + if Descriptor.RateMode = RT2X00_RATE_MODE_CCK then + begin + Descriptor.Signal:=Descriptor.Signal and not($8); + end; + + {Get Word2} + Value:=RT2X00ReadDescriptor(RXWI,2); + {$IFDEF RT2800USB_DEBUG} + //if NETWORK_LOG_ENABLED then NetworkLogDebug(@RT2X00.WiFi.Network,'RT2800: (RXWI Word2 Value=' + IntToHex(Value,8) + ')'); //To Do + {$ENDIF} + + {Convert descriptor AGC value to RSSI value} + Descriptor.RSSI:=RT2800AGCtoRSSI(RT2X00,Value); + + {Update Data and Size (Remove RXWI from start of buffer)} + Inc(Data,RT2X00.RXWISize); + Dec(Size,RT2X00.RXWISize); + + Result:=True; +end; + {==============================================================================} function RT2800_MAC_WCID_ENTRY(Index:LongWord):LongWord; inline; diff --git a/source/rtl/ultibo/drivers/rt2800usb.pas b/source/rtl/ultibo/drivers/rt2800usb.pas index b64b465..a6e75b3 100644 --- a/source/rtl/ultibo/drivers/rt2800usb.pas +++ b/source/rtl/ultibo/drivers/rt2800usb.pas @@ -457,6 +457,7 @@ interface PRT2800USBRequest = ^TRT2800USBRequest; TRT2800USBRequest = record Index:LongWord; {The index of this request in the receive or transmit requests array} + Entry:PNetworkEntry; {The network queue entry currently allocated to this endpoint} Request:PUSBRequest; {The USB request allocated for this endpoint} Endpoint:PUSBEndpointDescriptor; {The USB endpoint descriptor found during bind for this endpoint} end; @@ -467,17 +468,14 @@ TRT2800USBWiFiDevice = record {RT2X00 Properties} RT2X00:TRT2X00WiFiDevice; {USB Properties} - ReceiveMask:LongWord; {Bit mask of Receive requests} - ReceiveFree:LongWord; {Map of free Receive requests} - ReceiveRequests:array of PRT2800USBRequest; {Receive requests, 1 per Bulk IN Endpoint} - TransmitMask:LongWord; {Bit mask of Transmit requests} - TransmitFree:LongWord; {Map of free Transmit requests} - TransmitRequests:array of PRT2800USBRequest; {Transmit requests, 1 per Bulk OUT Endpoint} - //To Do - ReceiveEndpoint:PUSBEndpointDescriptor; {Bulk IN Endpoint} //To Do //Remove //Now ReceiveRequests - TransmitEndpoint:PUSBEndpointDescriptor; {Bulk OUT Endpoint} //To Do //Remove //Now TransmitRequests - PendingCount:LongWord; {Number of USB requests pending for this network} - WaiterThread:TThreadId; {Thread waiting for pending requests to complete (for network close)} + ReceiveMask:LongWord; {Bit mask of Receive requests} + ReceiveFree:LongWord; {Map of free Receive requests} + ReceiveRequests:array of PRT2800USBRequest; {Receive requests, 1 per Bulk IN Endpoint} + TransmitMask:LongWord; {Bit mask of Transmit requests} + TransmitFree:LongWord; {Map of free Transmit requests} + TransmitRequests:array of PRT2800USBRequest; {Transmit requests, 1 per Bulk OUT Endpoint} + PendingCount:LongWord; {Number of USB requests pending for this network} + WaiterThread:TThreadId; {Thread waiting for pending requests to complete (for network close)} end; {==============================================================================} @@ -496,8 +494,6 @@ procedure RT2800USBInit; {RT2800USB Network Functions} function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; function RT2800USBDeviceClose(Network:PNetworkDevice):LongWord; -function RT2800USBDeviceRead(Network:PNetworkDevice;Buffer:Pointer;Size:LongWord;var Length:LongWord):LongWord; -function RT2800USBDeviceWrite(Network:PNetworkDevice;Buffer:Pointer;Size:LongWord;var Length:LongWord):LongWord; function RT2800USBDeviceControl(Network:PNetworkDevice;Request:Integer;Argument1:LongWord;var Argument2:LongWord):LongWord; function RT2800USBBufferAllocate(Network:PNetworkDevice;var Entry:PNetworkEntry):LongWord; @@ -550,6 +546,8 @@ function RT2800USBDetectAutorun(RT2X00:PRT2X00WiFiDevice):LongWord; function RT2800USBEnableRadio(RT2X00:PRT2X00WiFiDevice):LongWord; function RT2800USBDisableRadio(RT2X00:PRT2X00WiFiDevice):LongWord; +function RT2800USBReceiveProcessRXD(RT2X00:PRT2X00WiFiDevice;Descriptor:PRT2X00RXDescriptor;var Data:Pointer;var Size:LongWord;PacketLength:LongWord):Boolean; + {==============================================================================} {==============================================================================} @@ -1655,7 +1653,6 @@ function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; Count:LongWord; Status:LongWord; Device:PUSBDevice; - Request:PUSBRequest; Entry:PNetworkEntry; begin {} @@ -1670,7 +1667,7 @@ function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; if Device = nil then Exit; {$IFDEF RT2800USB_DEBUG} - if USB_LOG_ENABLED then USBLogDebug(Device,'RT2800USB: Device Open'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(Network,'RT2800USB: Device Open'); {$ENDIF} {Acquire the Lock} @@ -1684,6 +1681,8 @@ function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; {Set Result} Result:=ERROR_OPERATION_FAILED; + //To Do //Set State to OPENING ? //Need to return to closed on fail as well + {Load Firmware} Status:=RT2X00LoadFirmware(PRT2X00WiFiDevice(Network)); if Status <> ERROR_SUCCESS then @@ -1707,7 +1706,7 @@ function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; try {Allocate Receive Queue Buffer} - Network.ReceiveQueue.Buffer:=BufferCreate(SizeOf(TNetworkEntry),RT2800USB_MAX_RX_ENTRIES); + Network.ReceiveQueue.Buffer:=BufferCreate(SizeOf(TNetworkEntry) + SizeOf(TIEEE80211RXStatus),RT2800USB_MAX_RX_ENTRIES); if Network.ReceiveQueue.Buffer = INVALID_HANDLE_VALUE then begin if NETWORK_LOG_ENABLED then NetworkLogError(Network,'RT2800USB: Failed to create receive queue buffer'); @@ -1726,12 +1725,12 @@ function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; Exit; end; - {Initialize Receive Queue Buffers} + {Allocate Receive Queue Buffers} Entry:=BufferIterate(Network.ReceiveQueue.Buffer,nil); while Entry <> nil do begin {Initialize Entry} - Entry.Size:=SIZE_4K; //To Do //Size per buffer //See drivers + Entry.Size:=RT2X00GetRXBufferSize(PRT2X00WiFiDevice(Network)); Entry.Offset:=0; //To Do //Offset //See drivers Entry.Count:=1; @@ -1747,7 +1746,12 @@ function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; {Initialize Packets} SetLength(Entry.Packets,Entry.Count); - + + {Initialize Packet} + Entry.Packets[0].Buffer:=Entry.Buffer; + Entry.Packets[0].Data:=Entry.Buffer + Entry.Offset; + Entry.Packets[0].Length:=Entry.Size - Entry.Offset; + Entry:=BufferIterate(Network.ReceiveQueue.Buffer,Entry); end; @@ -1755,7 +1759,7 @@ function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; SetLength(Network.ReceiveQueue.Entries,RT2800USB_MAX_RX_ENTRIES); {Allocate Transmit Queue Buffer} - Network.TransmitQueue.Buffer:=BufferCreate(SizeOf(TNetworkEntry),RT2800USB_MAX_TX_ENTRIES); + Network.TransmitQueue.Buffer:=BufferCreate(SizeOf(TNetworkEntry) + SizeOf(TIEEE80211TXInfo),RT2800USB_MAX_TX_ENTRIES); if Network.TransmitQueue.Buffer = INVALID_HANDLE_VALUE then begin if NETWORK_LOG_ENABLED then NetworkLogError(Network,'RT2800USB: Failed to create transmit queue buffer'); @@ -1786,13 +1790,18 @@ function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; {Initialize Packets} SetLength(Entry.Packets,Entry.Count); + {Initialize Packet} + Entry.Packets[0].Buffer:=Entry.Buffer; + Entry.Packets[0].Data:=Entry.Buffer + Entry.Offset; + Entry.Packets[0].Length:=Entry.Size - Entry.Offset; + Entry:=BufferIterate(Network.TransmitQueue.Buffer,Entry); end; {Allocate Receive Requests} for Count:=0 to Length(PRT2800USBWiFiDevice(Network).ReceiveRequests) - 1 do begin - PRT2800USBWiFiDevice(Network).ReceiveRequests[Count].Request:=USBRequestAllocate(Device,PRT2800USBWiFiDevice(Network).ReceiveRequests[Count].Endpoint,RT2800USBReceiveComplete,0,Network); + PRT2800USBWiFiDevice(Network).ReceiveRequests[Count].Request:=USBRequestAllocate(Device,PRT2800USBWiFiDevice(Network).ReceiveRequests[Count].Endpoint,RT2800USBReceiveComplete,0,PRT2800USBWiFiDevice(Network).ReceiveRequests[Count]); if PRT2800USBWiFiDevice(Network).ReceiveRequests[Count].Request = nil then begin if NETWORK_LOG_ENABLED then NetworkLogError(Network,'RT2800USB: Failed to allocate USB receive request'); @@ -1805,7 +1814,7 @@ function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; {Allocate Transmit Requests} for Count:=0 to Length(PRT2800USBWiFiDevice(Network).TransmitRequests) - 1 do begin - PRT2800USBWiFiDevice(Network).TransmitRequests[Count].Request:=USBRequestAllocate(Device,PRT2800USBWiFiDevice(Network).TransmitRequests[Count].Endpoint,RT2800USBTransmitComplete,0,Network); + PRT2800USBWiFiDevice(Network).TransmitRequests[Count].Request:=USBRequestAllocate(Device,PRT2800USBWiFiDevice(Network).TransmitRequests[Count].Endpoint,RT2800USBTransmitComplete,0,PRT2800USBWiFiDevice(Network).TransmitRequests[Count]); if PRT2800USBWiFiDevice(Network).TransmitRequests[Count].Request = nil then begin if NETWORK_LOG_ENABLED then NetworkLogError(Network,'RT2800USB: Failed to allocate USB transmit request'); @@ -1818,61 +1827,60 @@ function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; {Submit Receive Requests} for Count:=0 to Length(PRT2800USBWiFiDevice(Network).ReceiveRequests) - 1 do begin - {Update Pending} - Inc(PRT2800USBWiFiDevice(Network).PendingCount); - - //TO Do //BufferGet(Network.ReceiveQueue.Buffer) - - //To Do //USBRequestFill //Or redo USBRequestInitialize for this, same params as USBRequestAllocateEx ? - - {Submit Request} - Status:=USBRequestSubmit(Request); - if Status <> USB_STATUS_SUCCESS then + {Get Entry} + Entry:=BufferGet(Network.ReceiveQueue.Buffer); + if Entry <> nil then begin - if USB_LOG_ENABLED then USBLogError(Device,'RT2800USB: Failed to submit USB receive request: ' + USBStatusToString(Status)); - {Update Pending} - Dec(PRT2800USBWiFiDevice(Network).PendingCount); + Inc(PRT2800USBWiFiDevice(Network).PendingCount); - //To Do //What to do here, can we cancel the other requests ? //Can't wait on the waiter thread notification, device is not detaching ? - //Possibly just don't exit, allow the process to proceed unless Count = 0 ? //Yes + {Update Free} + PRT2800USBWiFiDevice(Network).ReceiveFree:=PRT2800USBWiFiDevice(Network).ReceiveFree xor (1 shl Count); - Result:=ERROR_OPERATION_FAILED; - Exit; + {Update Entry} + Entry.DriverData:=Network; + + {Update Request} + PRT2800USBWiFiDevice(Network).ReceiveRequests[Count].Entry:=Entry; + + {Reinitialize Request} + USBRequestInitialize(PRT2800USBWiFiDevice(Network).ReceiveRequests[Count].Request,RT2800USBReceiveComplete,Entry.Buffer,Entry.Size,PRT2800USBWiFiDevice(Network).ReceiveRequests[Count]); + + {Submit Request} + Status:=USBRequestSubmit(PRT2800USBWiFiDevice(Network).ReceiveRequests[Count].Request); + if Status <> USB_STATUS_SUCCESS then + begin + if NETWORK_LOG_ENABLED then NetworkLogError(Network,'RT2800USB: Failed to submit USB receive request: ' + USBStatusToString(Status)); + + {Update Pending} + Dec(PRT2800USBWiFiDevice(Network).PendingCount); + + {Update Free} + PRT2800USBWiFiDevice(Network).ReceiveFree:=PRT2800USBWiFiDevice(Network).ReceiveFree or (1 shl Count); + + {Update Entry} + Entry.DriverData:=nil; + + {Update Request} + PRT2800USBWiFiDevice(Network).ReceiveRequests[Count].Entry:=nil; + + {Free Entry} + BufferFree(Entry); + end; end; - if USB_LOG_ENABLED then USBLogDebug(Device,'RT2800USB: Submitted receive request'); //To Do //Testing only end; - - - ///////////////////////////////////////////////////////////////////////////////////////////////// - - {Allocate Receive Request} //To Do //Testing only - Request:=USBRequestAllocate(Device,PRT2800USBWiFiDevice(Network).ReceiveEndpoint,RT2800USBReceiveComplete,SIZE_8K,Network); //SIZE_2K * 12 //To Do - if Request = nil then + {Check Pending Count} + if PRT2800USBWiFiDevice(Network).PendingCount = 0 then begin - if USB_LOG_ENABLED then USBLogError(Device,'RT2800USB: Failed to allocate receive request'); + Result:=ERROR_OPERATION_FAILED; Exit; end; - - {Update Pending} - Inc(PRT2800USBWiFiDevice(Network).PendingCount); - {Submit Request} //To Do //Testing only - Status:=USBRequestSubmit(Request); - if Status <> USB_STATUS_SUCCESS then - begin - if USB_LOG_ENABLED then USBLogError(Device,'RT2800USB: Failed to submit receive request: ' + USBStatusToString(Status)); - - {Update Pending} - Dec(PRT2800USBWiFiDevice(Network).PendingCount); - - Exit; - end; - if USB_LOG_ENABLED then USBLogDebug(Device,'RT2800USB: Submitted receive request'); //To Do //Testing only + ///////////////////////////////////////////////////////////////////////////////////////////////// - //TO Do //Continuing + //To Do //Continuing //DoBulkIn //F:\Download\Ralink\DPO_RT5572_LinuxSTA_2.6.1.3_20121022\common\rtusb_bulk.c //RTUSBInitRxDesc //RTUSBBulkReceive @@ -1885,8 +1893,6 @@ function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; ///////////////////////////////////////////////////////////////////////////////////////////////// - - {Set State to Open} Network.NetworkState:=NETWORK_STATE_OPEN; @@ -1908,6 +1914,7 @@ function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; {Release Receive Requests} for Count:=0 to Length(PRT2800USBWiFiDevice(Network).ReceiveRequests) - 1 do begin + //To Do //Cancel the request first ? USBRequestRelease(PRT2800USBWiFiDevice(Network).ReceiveRequests[Count].Request); end; @@ -1949,10 +1956,8 @@ function RT2800USBDeviceOpen(Network:PNetworkDevice):LongWord; {Destroy Receive Queue Buffer} BufferDestroy(Network.ReceiveQueue.Buffer); - - + {Disable Radio} //To Do - end; end; finally @@ -1985,7 +1990,7 @@ function RT2800USBDeviceClose(Network:PNetworkDevice):LongWord; if Device = nil then Exit; {$IFDEF RT2800USB_DEBUG} - if USB_LOG_ENABLED then USBLogDebug(Device,'RT2800USB: Device Close'); + if NETWORK_LOG_ENABLED then NetworkLogDebug(Network,'RT2800USB: Device Close'); {$ENDIF} {Check State} @@ -1996,56 +2001,24 @@ function RT2800USBDeviceClose(Network:PNetworkDevice):LongWord; Result:=ERROR_OPERATION_FAILED; if NetworkDeviceSetState(Network,NETWORK_STATE_CLOSING) <> ERROR_SUCCESS then Exit; - //To Do //rt2x00lib_stop -end; - -{==============================================================================} - -function RT2800USBDeviceRead(Network:PNetworkDevice;Buffer:Pointer;Size:LongWord;var Length:LongWord):LongWord; -{Implementation of NetworkDeviceRead for the RT2800USB device} -begin - {} - Result:=ERROR_INVALID_PARAMETER; - - {Setup Length} - Length:=0; - - {Check Network} - if Network = nil then Exit; - if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; - - {Check Buffer} - if Buffer = nil then Exit; - - {Check Size} - if Size = 0 then Exit; - - {Check State} - Result:=ERROR_NOT_READY; - if Network.NetworkState <> NETWORK_STATE_OPEN then Exit; - - //To Do -end; - -{==============================================================================} - -function RT2800USBDeviceWrite(Network:PNetworkDevice;Buffer:Pointer;Size:LongWord;var Length:LongWord):LongWord; -{Implementation of NetworkDeviceWrite for the RT2800USB device} -begin - {} - Result:=ERROR_INVALID_PARAMETER; - - {Setup Length} - Length:=0; - - {Check Network} - if Network = nil then Exit; - if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; + {Acquire the Lock} + if MutexLock(Network.Lock) = ERROR_SUCCESS then + begin + try - {Check Buffer} - if Buffer = nil then Exit; - - //To Do + //To Do //rt2x00lib_stop + + {Return Result} + Result:=ERROR_SUCCESS; + finally + {Release the Lock} + MutexUnlock(Network.Lock); + end; + end + else + begin + Result:=ERROR_CAN_NOT_COMPLETE; + end; end; {==============================================================================} @@ -2066,7 +2039,28 @@ function RT2800USBDeviceControl(Network:PNetworkDevice;Request:Integer;Argument1 Device:=PUSBDevice(Network.Device.DeviceData); if Device = nil then Exit; - //To Do + {$IFDEF RT2800USB_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(Network,'RT2800USB: Device Control'); + {$ENDIF} + + {Acquire the Lock} + if MutexLock(Network.Lock) = ERROR_SUCCESS then + begin + try + + //To Do + + {Return Result} + Result:=ERROR_SUCCESS; + finally + {Release the Lock} + MutexUnlock(Network.Lock); + end; + end + else + begin + Result:=ERROR_CAN_NOT_COMPLETE; + end; end; {==============================================================================} @@ -2077,11 +2071,32 @@ function RT2800USBBufferAllocate(Network:PNetworkDevice;var Entry:PNetworkEntry) {} Result:=ERROR_INVALID_PARAMETER; + {Setup Entry} + Entry:=nil; + {Check Network} if Network = nil then Exit; if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; - //To Do + {$IFDEF RT2800USB_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(Network,'RT2800USB: Buffer Allocate'); + {$ENDIF} + + {Check State} + Result:=ERROR_NOT_READY; + if Network.NetworkState <> NETWORK_STATE_OPEN then Exit; + + {Set Result} + Result:=ERROR_OPERATION_FAILED; + + {Wait for Entry} + Entry:=BufferGet(Network.TransmitQueue.Buffer); + if Entry <> nil then + begin + //To Do //Continuing //Update Packet ? + {Return Result} + Result:=ERROR_SUCCESS; + end; end; {==============================================================================} @@ -2092,11 +2107,36 @@ function RT2800USBBufferRelease(Network:PNetworkDevice;Entry:PNetworkEntry):Long {} Result:=ERROR_INVALID_PARAMETER; + {Check Entry} + if Entry = nil then Exit; + {Check Network} if Network = nil then Exit; if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; - //To Do + {$IFDEF RT2800USB_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(Network,'RT2800USB: Buffer Release'); + {$ENDIF} + + {Check State} + Result:=ERROR_NOT_READY; + if Network.NetworkState <> NETWORK_STATE_OPEN then Exit; + + {Acquire the Lock} + if MutexLock(Network.Lock) = ERROR_SUCCESS then + begin + try + {Free Entry} + Result:=BufferFree(Entry); + finally + {Release the Lock} + MutexUnlock(Network.Lock); + end; + end + else + begin + Result:=ERROR_CAN_NOT_COMPLETE; + end; end; {==============================================================================} @@ -2107,26 +2147,97 @@ function RT2800USBBufferReceive(Network:PNetworkDevice;var Entry:PNetworkEntry): {} Result:=ERROR_INVALID_PARAMETER; + {Setup Entry} + Entry:=nil; + {Check Network} if Network = nil then Exit; if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; - //To Do + {$IFDEF RT2800USB_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(Network,'RT2800USB: Buffer Receive'); + {$ENDIF} + + {Check State} + Result:=ERROR_NOT_READY; + if Network.NetworkState <> NETWORK_STATE_OPEN then Exit; + + {Wait for Entry} + if SemaphoreWait(Network.ReceiveQueue.Wait) = ERROR_SUCCESS then + begin + {Acquire the Lock} + if MutexLock(Network.Lock) = ERROR_SUCCESS then + begin + try + {Remove Entry} + Entry:=Network.ReceiveQueue.Entries[Network.ReceiveQueue.Start]; + + {Update Start} + Network.ReceiveQueue.Start:=(Network.ReceiveQueue.Start + 1) mod RT2800USB_MAX_RX_ENTRIES; + + {Update Count} + Dec(Network.ReceiveQueue.Count); + + {Return Result} + Result:=ERROR_SUCCESS; + finally + {Release the Lock} + MutexUnlock(Network.Lock); + end; + end + else + begin + Result:=ERROR_CAN_NOT_COMPLETE; + end; + end + else + begin + Result:=ERROR_CAN_NOT_COMPLETE; + end; end; {==============================================================================} function RT2800USBBufferTransmit(Network:PNetworkDevice;Entry:PNetworkEntry):LongWord; - {Implementation of NetworkBufferTransmit for the RT2800USB device} +{Implementation of NetworkBufferTransmit for the RT2800USB device} begin {} Result:=ERROR_INVALID_PARAMETER; + {Check Entry} + if Entry = nil then Exit; + {Check Network} if Network = nil then Exit; if Network.Device.Signature <> DEVICE_SIGNATURE then Exit; - //To Do + {$IFDEF RT2800USB_DEBUG} + if NETWORK_LOG_ENABLED then NetworkLogDebug(Network,'RT2800USB: Buffer Transmit'); + {$ENDIF} + + {Check State} + Result:=ERROR_NOT_READY; + if Network.NetworkState <> NETWORK_STATE_OPEN then Exit; + + {Acquire the Lock} + if MutexLock(Network.Lock) = ERROR_SUCCESS then + begin + try + + //To Do //Continuing //Use the TransmitQueue ? and Wait for completion ? + //Need to check empty and do Submit ? + + {Return Result} + Result:=ERROR_SUCCESS; + finally + {Release the Lock} + MutexUnlock(Network.Lock); + end; + end + else + begin + Result:=ERROR_CAN_NOT_COMPLETE; + end; end; {==============================================================================} @@ -2452,21 +2563,20 @@ function RT2800USBDriverBind(Device:PUSBDevice;Interrface:PUSBInterface):LongWor {Device} RT2800USB.RT2X00.WiFi.Network.Device.DeviceBus:=DEVICE_BUS_USB; RT2800USB.RT2X00.WiFi.Network.Device.DeviceType:=NETWORK_TYPE_80211; - RT2800USB.RT2X00.WiFi.Network.Device.DeviceFlags:=NETWORK_FLAG_NONE; + RT2800USB.RT2X00.WiFi.Network.Device.DeviceFlags:=NETWORK_FLAG_RX_BUFFER or NETWORK_FLAG_TX_BUFFER; RT2800USB.RT2X00.WiFi.Network.Device.DeviceData:=Device; {Network} RT2800USB.RT2X00.WiFi.Network.NetworkState:=NETWORK_STATE_CLOSED; RT2800USB.RT2X00.WiFi.Network.NetworkStatus:=NETWORK_STATUS_DOWN; RT2800USB.RT2X00.WiFi.Network.DeviceOpen:=RT2800USBDeviceOpen; RT2800USB.RT2X00.WiFi.Network.DeviceClose:=RT2800USBDeviceClose; - RT2800USB.RT2X00.WiFi.Network.DeviceRead:=RT2800USBDeviceRead; - RT2800USB.RT2X00.WiFi.Network.DeviceWrite:=RT2800USBDeviceWrite; RT2800USB.RT2X00.WiFi.Network.DeviceControl:=RT2800USBDeviceControl; RT2800USB.RT2X00.WiFi.Network.BufferAllocate:=RT2800USBBufferAllocate; RT2800USB.RT2X00.WiFi.Network.BufferRelease:=RT2800USBBufferRelease; RT2800USB.RT2X00.WiFi.Network.BufferReceive:=RT2800USBBufferReceive; RT2800USB.RT2X00.WiFi.Network.BufferTransmit:=RT2800USBBufferTransmit; {WiFi} + //To Do //State/Status/Flags etc RT2800USB.RT2X00.WiFi.DeviceConfigure:=RT2800USBDeviceConfigure; RT2800USB.RT2X00.WiFi.DeviceConfigureFilter:=RT2800USBDeviceConfigureFilter; RT2800USB.RT2X00.WiFi.DeviceConfigureInterface:=RT2800USBDeviceConfigureInterface; @@ -2505,10 +2615,7 @@ function RT2800USBDriverBind(Device:PUSBDevice;Interrface:PUSBInterface):LongWor {USB} SetLength(RT2800USB.ReceiveRequests,USBDeviceCountEndpointsByType(Device,NetworkInterface,USB_DIRECTION_IN,USB_TRANSFER_TYPE_BULK)); SetLength(RT2800USB.TransmitRequests,USBDeviceCountEndpointsByType(Device,NetworkInterface,USB_DIRECTION_OUT,USB_TRANSFER_TYPE_BULK)); - RT2800USB.ReceiveEndpoint:=ReceiveEndpoint; - RT2800USB.TransmitEndpoint:=TransmitEndpoint; RT2800USB.WaiterThread:=INVALID_HANDLE_VALUE; - //To Do try {Create Data} @@ -2581,7 +2688,10 @@ function RT2800USBDriverBind(Device:PUSBDevice;Interrface:PUSBInterface):LongWor RT2800USB.ReceiveRequests[Count].Index:=Count; RT2800USB.ReceiveRequests[Count].Endpoint:=USBDeviceFindEndpointByTypeEx(Device,NetworkInterface,USB_DIRECTION_IN,USB_TRANSFER_TYPE_BULK,Index); {Note: USB Request allocated by DeviceOpen} + { Network Entry set by Receive (Submit)} + RT2800USB.ReceiveMask:=RT2800USB.ReceiveMask or (1 shl Count); end; + RT2800USB.ReceiveFree:=RT2800USB.ReceiveMask; {Create Transmit Requests / Assign OUT Endpoints} Index:=0; @@ -2600,7 +2710,10 @@ function RT2800USBDriverBind(Device:PUSBDevice;Interrface:PUSBInterface):LongWor RT2800USB.TransmitRequests[Count].Index:=Count; RT2800USB.TransmitRequests[Count].Endpoint:=USBDeviceFindEndpointByTypeEx(Device,NetworkInterface,USB_DIRECTION_OUT,USB_TRANSFER_TYPE_BULK,Index); {Note: USB Request allocated by DeviceOpen} + { Network Entry set by Transmit (Submit)} + RT2800USB.TransmitMask:=RT2800USB.TransmitMask or (1 shl Count); end; + RT2800USB.TransmitFree:=RT2800USB.TransmitMask; {Initialize Driver} if RT2X00DriverInit(@RT2800USB.RT2X00) <> ERROR_SUCCESS then @@ -2744,156 +2857,356 @@ procedure RT2800USBReceiveWorker(Request:PUSBRequest); {Called (by a Worker thread) to process a completed USB request from the RT2800USB bulk IN endpoint} {Request: The USB request which has completed} var - RXD:Pointer; Data:Pointer; Size:LongWord; RXINFO:Pointer; Value:LongWord; Status:LongWord; Message:TMessage; + RateIndex:LongWord; PacketLength:LongWord; + HeaderLength:LongWord; + Next:PNetworkEntry; + Entry:PNetworkEntry; + RXStatus:PIEEE80211RXStatus; + Descriptor:TRT2X00RXDescriptor; RT2800USB:PRT2800USBWiFiDevice; + RT2800USBRequest:PRT2800USBRequest; begin {} {Check Request} if Request = nil then Exit; - {Get WiFi} - RT2800USB:=PRT2800USBWiFiDevice(Request.DriverData); - if RT2800USB <> nil then + {Get Request} + RT2800USBRequest:=PRT2800USBRequest(Request.DriverData); + if (RT2800USBRequest <> nil) and (RT2800USBRequest.Request = Request) then begin - {Acquire the Lock} - if MutexLock(RT2800USB.RT2X00.WiFi.Network.Lock) = ERROR_SUCCESS then + {Get Entry} + Entry:=RT2800USBRequest.Entry; + if Entry <> nil then begin - try - {Update Statistics} - Inc(RT2800USB.RT2X00.WiFi.Network.ReceiveCount); - - {Check State} - if RT2800USB.RT2X00.WiFi.Network.NetworkState = NETWORK_STATE_CLOSING then - begin - {$IFDEF RT2800USB_DEBUG} - if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: Close pending, setting receive request status to USB_STATUS_DEVICE_DETACHED'); - {$ENDIF} - - {Update Request} - Request.Status:=USB_STATUS_DEVICE_DETACHED; - end; - - {Check Result} - if Request.Status = USB_STATUS_SUCCESS then - begin - {$IFDEF RT2800USB_DEBUG} - if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: Receive complete (Actual Size=' + IntToStr(Request.ActualSize) + ')'); - {$ENDIF} - {RX frame format is : | RXINFO | RXWI | header | L2 pad | payload | pad | RXD | USB pad | - |<----------- PacketLength ------------->| } - {Get Data and Size} - Data:=Request.Data; - Size:=Request.Size; - - {Get RXINFO} - RXINFO:=Data; - Value:=RT2X00ReadDescriptor(RXINFO,0); - {$IFDEF RT2800USB_DEBUG} - if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: (RXINFO Value=' + IntToHex(Value,8) + ')'); - {$ENDIF} - - {Get Packet Length} - PacketLength:=RT2X00GetRegister32(Value,RT2800USB_RXINFO_W0_USB_DMA_RX_PKT_LEN,0); - {$IFDEF RT2800USB_DEBUG} - if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: (PacketLength=' + IntToStr(PacketLength) + ')'); - {$ENDIF} - - {Check Packet Length} - if (PacketLength > 0) and (PacketLength < Size) then - begin - {Update Data and Size} - Inc(Data,RT2800USB_RXINFO_DESC_SIZE); - Dec(Size,RT2800USB_RXINFO_DESC_SIZE); - - {Get RXD} - RXD:=Data + PacketLength; - Value:=RT2X00ReadDescriptor(RXD,0); - {$IFDEF RT2800USB_DEBUG} - if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: (RXD Value=' + IntToHex(Value,8) + ')'); - {$ENDIF} - - {Update Data and Size} - - //To Do // - end - else - begin - if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Receive error (PacketLength=' + IntToStr(PacketLength) + ')'); - + {Get WiFi} + RT2800USB:=PRT2800USBWiFiDevice(Entry.DriverData); + if RT2800USB <> nil then + begin + {Acquire the Lock} + if MutexLock(RT2800USB.RT2X00.WiFi.Network.Lock) = ERROR_SUCCESS then + begin + try {Update Statistics} - Inc(RT2800USB.RT2X00.WiFi.Network.ReceiveErrors); - end; - end - else - begin - if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Failed receive request (Status=' + USBStatusToString(Request.Status) + ')'); - - {Update Statistics} - Inc(RT2800USB.RT2X00.WiFi.Network.ReceiveErrors); - end; - - {Update Pending} - Dec(RT2800USB.PendingCount); - - {Check State} - if RT2800USB.RT2X00.WiFi.Network.NetworkState = NETWORK_STATE_CLOSING then - begin - {Check Pending} - if RT2800USB.PendingCount = 0 then - begin - {Check Waiter} - if RT2800USB.WaiterThread <> INVALID_HANDLE_VALUE then + Inc(RT2800USB.RT2X00.WiFi.Network.ReceiveCount); + + {Check State} + if RT2800USB.RT2X00.WiFi.Network.NetworkState = NETWORK_STATE_CLOSING then begin {$IFDEF RT2800USB_DEBUG} - if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: Close pending, sending message to waiter thread (Thread=' + IntToHex(RT2800USB.WaiterThread,8) + ')'); + if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: Close pending, setting receive request status to USB_STATUS_DEVICE_DETACHED'); {$ENDIF} + + {Update Request} + Request.Status:=USB_STATUS_DEVICE_DETACHED; + end; + + {Check Result} + if Request.Status = USB_STATUS_SUCCESS then + begin + {$IFDEF RT2800USB_DEBUG} + if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: Receive complete (Size=' + IntToStr(Request.Size) + ' Actual Size=' + IntToStr(Request.ActualSize) + ')'); + {$ENDIF} + {RX frame format is : | RXINFO | RXWI | header | L2 pad | payload | pad | RXD | USB pad | + |<----------- PacketLength ------------->| } + {Get Data and Size} + Data:=Request.Data; + Size:=Request.ActualSize; - {Send Message} - FillChar(Message,SizeOf(TMessage),0); - ThreadSendMessage(RT2800USB.WaiterThread,Message); - RT2800USB.WaiterThread:=INVALID_HANDLE_VALUE; - end; - end; - end - else - begin - {Update Pending} - Inc(RT2800USB.PendingCount); - - {$IFDEF RT2800USB_DEBUG} - if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: Resubmitting receive request'); - {$ENDIF} - - {Resubmit Request} - Status:=USBRequestSubmit(Request); - if Status <> USB_STATUS_SUCCESS then - begin - if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Failed to resubmit receive request: ' + USBStatusToString(Status)); - + {Get RXINFO} + RXINFO:=Data; + Value:=RT2X00ReadDescriptor(RXINFO,0); + + {$IFDEF RT2800USB_DEBUG} + //if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: (RXINFO Value=' + IntToHex(Value,8) + ')'); //To Do + {$ENDIF} + + {Get Packet Length} + PacketLength:=RT2X00GetRegister32(Value,RT2800USB_RXINFO_W0_USB_DMA_RX_PKT_LEN,0); + + {$IFDEF RT2800USB_DEBUG} + if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: (PacketLength=' + IntToStr(PacketLength) + ')'); + {$ENDIF} + + {Check Packet Length} + if (PacketLength > 0) and (PacketLength <= RT2X00_AGGREGATION_SIZE) then + begin + {Update Data and Size (Remove the RXINFO from start of buffer)} + Inc(Data,RT2800USB_RXINFO_DESC_SIZE); + Dec(Size,RT2800USB_RXINFO_DESC_SIZE); + + {Get Next} + Next:=nil; + if BufferAvailable(RT2800USB.RT2X00.WiFi.Network.ReceiveQueue.Buffer) > 0 then + begin + Next:=BufferGet(RT2800USB.RT2X00.WiFi.Network.ReceiveQueue.Buffer); + end; + + {Check Next} + if Next <> nil then + begin + if RT2800USB.RT2X00.WiFi.Network.ReceiveQueue.Count < RT2800USB_MAX_RX_ENTRIES then + begin + {Setup Descriptor} + FillChar(Descriptor,SizeOf(TRT2X00RXDescriptor),0); + + {Process RXD} + RT2800USBReceiveProcessRXD(@RT2800USB.RT2X00,@Descriptor,Data,Size,PacketLength); + + {Process RXWI} + RT2800ReceiveProcessRXWI(@RT2800USB.RT2X00,@Descriptor,Data,Size); + + {$IFDEF RT2800USB_DEBUG} + if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: (Descriptor.Size=' + IntToStr(Descriptor.Size) + ')'); + {$ENDIF} + + {Check Descriptor Size} + if (Descriptor.Size > 0) and (Descriptor.Size <= RT2X00_AGGREGATION_SIZE) then + begin + {The data behind the IEEE80211 header must be aligned on a 4 byte boundary} + HeaderLength:=IEEE80211HeaderLengthFromBuffer(Data,Size); + + {$IFDEF RT2800USB_DEBUG} + if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: (HeaderLength=' + IntToStr(HeaderLength) + ')'); + {$ENDIF} + + {Hardware might have stripped the IV/EIV/ICV data, it is possible that the data was provided + separately (through hardware descriptor) in which case we should reinsert the data into the frame} + if ((Descriptor.RXFlags and RT2X00_RXDONE_CRYPTO_IV) <> 0) and ((Descriptor.Flags and WIFI_RX_FLAG_IV_STRIPPED) <> 0) then + begin + RT2X00ReceiveInsertIV(@Descriptor,Data,Size,HeaderLength); + end + else if (HeaderLength <> 0) and (Descriptor.Size > HeaderLength) and ((Descriptor.RXFlags and RT2X00_RXDONE_L2PAD) <> 0) then + begin + RT2X00RemoveL2PAD(Data,Size,HeaderLength); + end; + + {Update Size (Actual size from descriptor)} + Size:=Descriptor.Size; + + {Translate the signal to the correct bitrate index} + RateIndex:=RT2X00ReceiveReadSignal(@RT2800USB.RT2X00,@Descriptor); + if (Descriptor.RateMode = RT2X00_RATE_MODE_HT_MIX) or (Descriptor.RateMode = RT2X00_RATE_MODE_HT_GREENFIELD) then + begin + Descriptor.Flags:=Descriptor.Flags or WIFI_RX_FLAG_HT; + end; + + //To Do //Continuing //rt2x00lib_rxdone_check_ps + + //To Do //Continuing //rt2x00lib_rxdone_check_ba + + {Update extra components} + //To Do //Continuing //rt2x00link_update_stats + //To Do //Continuing //rt2x00debug_update_crypto + //To Do //Continuing //rt2x00debug_dump_frame + + {Setup RX Status} + RXStatus:=PIEEE80211RXStatus(PtrUInt(Entry) + SizeOf(TNetworkEntry)); + FillChar(RXStatus^,SizeOf(TIEEE80211RXStatus),0); + + {Update RX Status} + RXStatus.MACTime:=Descriptor.Timestamp; + RXStatus.Band:=RT2800USB.RT2X00.CurrentBand; + RXStatus.Frequency:=RT2800USB.RT2X00.CurrentFrequency; + RXStatus.RateIndex:=RateIndex; + RXStatus.Signal:=Descriptor.RSSI; + RXStatus.Flags:=Descriptor.Flags; + RXStatus.Antenna:=RT2800USB.RT2X00.Link.Antenna.ActiveAntenna.RX; + + {Update Packet} + Entry.Packets[0].Buffer:=Entry.Buffer; + Entry.Packets[0].Data:=Data; + Entry.Packets[0].Length:=Size; + + {Update Entry} + Entry.DriverData:=RXStatus; + + {Add Entry} + RT2800USB.RT2X00.WiFi.Network.ReceiveQueue.Entries[(RT2800USB.RT2X00.WiFi.Network.ReceiveQueue.Start + RT2800USB.RT2X00.WiFi.Network.ReceiveQueue.Count) mod RT2800USB_MAX_RX_ENTRIES]:=Entry; + + {Update Count} + Inc(RT2800USB.RT2X00.WiFi.Network.ReceiveQueue.Count); + + {Signal Packet Received} + SemaphoreSignal(RT2800USB.RT2X00.WiFi.Network.ReceiveQueue.Wait); + + {$IFDEF RT2800USB_DEBUG} + //if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: (Queue Count=' + IntToStr(RT2800USB.RT2X00.WiFi.Network.ReceiveQueue.Count) + ')'); //To Do + {$ENDIF} + end + else + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Receive error (Descriptor.Size=' + IntToStr(Descriptor.Size) + ')'); + + {Free Entry} + BufferFree(Entry); + + {Update Statistics} + Inc(RT2800USB.RT2X00.WiFi.Network.ReceiveErrors); + end; + end + else + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Receive queue overrun, packet discarded'); + + {Free Entry} + BufferFree(Entry); + + {Update Statistics} + Inc(RT2800USB.RT2X00.WiFi.Network.BufferOverruns); + end; + end + else + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: No receive buffer available, packet discarded'); + + {Get Next} + Next:=Entry; + + {Update Statistics} + Inc(RT2800USB.RT2X00.WiFi.Network.BufferUnavailable); + end; + end + else + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Receive error (PacketLength=' + IntToStr(PacketLength) + ')'); + + {Get Next} + Next:=Entry; + + {Update Statistics} + Inc(RT2800USB.RT2X00.WiFi.Network.ReceiveErrors); + end; + end + else + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Failed receive request (Status=' + USBStatusToString(Request.Status) + ')'); + + {Get Next} + Next:=Entry; + + {Update Statistics} + Inc(RT2800USB.RT2X00.WiFi.Network.ReceiveErrors); + end; + {Update Pending} - Dec(RT2800USB.PendingCount); + Dec(RT2800USB.PendingCount); + + {Update Free} + RT2800USB.ReceiveFree:=RT2800USB.ReceiveFree or (1 shl RT2800USBRequest.Index); + + {Update Next} + Next.DriverData:=nil; + + {Update Request} + RT2800USBRequest.Entry:=nil; + + {Check State} + if RT2800USB.RT2X00.WiFi.Network.NetworkState = NETWORK_STATE_CLOSING then + begin + {Free Next} + BufferFree(Next); + + {Check Pending} + if RT2800USB.PendingCount = 0 then + begin + {Check Waiter} + if RT2800USB.WaiterThread <> INVALID_HANDLE_VALUE then + begin + {$IFDEF RT2800USB_DEBUG} + if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: Close pending, sending message to waiter thread (Thread=' + IntToHex(RT2800USB.WaiterThread,8) + ')'); + {$ENDIF} + + {Send Message} + FillChar(Message,SizeOf(TMessage),0); + ThreadSendMessage(RT2800USB.WaiterThread,Message); + RT2800USB.WaiterThread:=INVALID_HANDLE_VALUE; + end; + end; + end + else + begin + {Check Next} + if Next <> nil then + begin + {Update Pending} + Inc(RT2800USB.PendingCount); + + {Update Free} + RT2800USB.ReceiveFree:=RT2800USB.ReceiveFree xor (1 shl RT2800USBRequest.Index); + + {Update Next} + Next.DriverData:=RT2800USB; + + {Update Request} + RT2800USBRequest.Entry:=Next; + + {Reinitialize Request} + USBRequestInitialize(RT2800USBRequest.Request,RT2800USBReceiveComplete,Next.Buffer,Next.Size,RT2800USBRequest); + + {$IFDEF RT2800USB_DEBUG} + if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: Resubmitting receive request'); + {$ENDIF} + + {Resubmit Request} + Status:=USBRequestSubmit(RT2800USBRequest.Request); + if Status <> USB_STATUS_SUCCESS then + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Failed to resubmit receive request: ' + USBStatusToString(Status)); + + {Update Pending} + Dec(RT2800USB.PendingCount); + + {Update Free} + RT2800USB.ReceiveFree:=RT2800USB.ReceiveFree or (1 shl RT2800USBRequest.Index); + + {Update Next} + Next.DriverData:=nil; + + {Update Request} + RT2800USBRequest.Entry:=nil; + + {Free Next} + BufferFree(Next); + end; + end + else + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: No receive buffer available, cannot resubmit receive request'); + + {Update Statistics} + Inc(RT2800USB.RT2X00.WiFi.Network.BufferUnavailable); + end; + end; + finally + {Release the Lock} + MutexUnlock(RT2800USB.RT2X00.WiFi.Network.Lock); end; - end; - finally - {Release the Lock} - MutexUnlock(RT2800USB.RT2X00.WiFi.Network.Lock); - end; + end + else + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Failed to acquire lock'); + end; + end + else + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Receive request invalid (WiFi)'); + end; end else begin - if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Failed to acquire lock'); - end; + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Receive request invalid (Entry)'); + end; end else begin - if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Receive request invalid'); + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Receive request invalid (Request)'); end; end; @@ -2916,9 +3229,121 @@ procedure RT2800USBReceiveComplete(Request:PUSBRequest); procedure RT2800USBTransmitWorker(Request:PUSBRequest); {Called (by a Worker thread) to process a completed USB request to the RT2800USB bulk OUT endpoint} {Request: The USB request which has completed} +var + Message:TMessage; + Next:PNetworkEntry; + Entry:PNetworkEntry; + RT2800USB:PRT2800USBWiFiDevice; + RT2800USBRequest:PRT2800USBRequest; begin {} - //To Do // + {Check Request} + if Request = nil then Exit; + + {Get Request} + RT2800USBRequest:=PRT2800USBRequest(Request.DriverData); + if (RT2800USBRequest <> nil) and (RT2800USBRequest.Request = Request) then + begin + {Get Entry} + Entry:=RT2800USBRequest.Entry; + if Entry <> nil then + begin + {Get WiFi} + RT2800USB:=PRT2800USBWiFiDevice(Entry.DriverData); + if RT2800USB <> nil then + begin + {Acquire the Lock} + if MutexLock(RT2800USB.RT2X00.WiFi.Network.Lock) = ERROR_SUCCESS then + begin + try + {Update Statistics} + Inc(RT2800USB.RT2X00.WiFi.Network.TransmitCount); + + {Check State} + if RT2800USB.RT2X00.WiFi.Network.NetworkState = NETWORK_STATE_CLOSING then + begin + {$IFDEF RT2800USB_DEBUG} + if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: Close pending, setting transmit request status to USB_STATUS_DEVICE_DETACHED'); + {$ENDIF} + + {Update Request} + Request.Status:=USB_STATUS_DEVICE_DETACHED; + end; + + {Check Result} + if Request.Status = USB_STATUS_SUCCESS then + begin + {$IFDEF RT2800USB_DEBUG} + if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: Transmit complete (Size=' + IntToStr(Request.Size) + ' Actual Size=' + IntToStr(Request.ActualSize) + ')'); + {$ENDIF} + + //To Do //Continuing + + //Signal waiting thread (Semaphore) + //Get Next from Queue + //What about status of result ? + + end + else + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Failed transmit request (Status=' + USBStatusToString(Request.Status) + ')'); + + {Update Statistics} + Inc(RT2800USB.RT2X00.WiFi.Network.TransmitErrors); + end; + + //To Do //Continuing + + {Update Pending} + Dec(RT2800USB.PendingCount); + + {Update Free} + RT2800USB.TransmitFree:=RT2800USB.TransmitFree or (1 shl RT2800USBRequest.Index); + + {Check State} + if RT2800USB.RT2X00.WiFi.Network.NetworkState = NETWORK_STATE_CLOSING then + begin + {Check Pending} + if RT2800USB.PendingCount = 0 then + begin + {Check Waiter} + if RT2800USB.WaiterThread <> INVALID_HANDLE_VALUE then + begin + {$IFDEF RT2800USB_DEBUG} + if USB_LOG_ENABLED then USBLogDebug(Request.Device,'RT2800USB: Close pending, sending message to waiter thread (Thread=' + IntToHex(RT2800USB.WaiterThread,8) + ')'); + {$ENDIF} + + {Send Message} + FillChar(Message,SizeOf(TMessage),0); + ThreadSendMessage(RT2800USB.WaiterThread,Message); + RT2800USB.WaiterThread:=INVALID_HANDLE_VALUE; + end; + end; + end; + finally + {Release the Lock} + MutexUnlock(RT2800USB.RT2X00.WiFi.Network.Lock); + end; + end + else + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Failed to acquire lock'); + end; + end + else + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Transmit request invalid (WiFi)'); + end; + end + else + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Transmit request invalid (Entry)'); + end; + end + else + begin + if USB_LOG_ENABLED then USBLogError(Request.Device,'RT2800USB: Transmit request invalid (Request)'); + end; end; {==============================================================================} @@ -2978,7 +3403,9 @@ function RT2800USBDriverInit(RT2X00:PRT2X00WiFiDevice):LongWord; if USB_LOG_ENABLED then USBLogDebug(PUSBDevice(RT2X00.WiFi.Network.Device.DeviceData),'RT2800USB: Driver init'); {$ENDIF} - {Nothing RT2800USB specific} + {Set TXINFO/RXINFO size} + RT2X00.TXINFOSize:=RT2800USB_TXINFO_DESC_SIZE; + RT2X00.RXINFOSize:=RT2800USB_RXINFO_DESC_SIZE; {Call RT2800 initialization} Result:=RT2800DriverInit(RT2X00); @@ -3512,6 +3939,81 @@ function RT2800USBDisableRadio(RT2X00:PRT2X00WiFiDevice):LongWord; Result:=RT2800DisableRadio(RT2X00); end; +{==============================================================================} + +function RT2800USBReceiveProcessRXD(RT2X00:PRT2X00WiFiDevice;Descriptor:PRT2X00RXDescriptor;var Data:Pointer;var Size:LongWord;PacketLength:LongWord):Boolean; +{rt2800usb_fill_rxdone} +var + RXD:Pointer; + Value:LongWord; +begin + {} + Result:=False; + + {Check Device} + if RT2X00 = nil then Exit; + + {Check Descriptor} + if Descriptor = nil then Exit; + + {Check Data and Size} + if Data = nil then Exit; + if Size = 0 then Exit; + + {Get RXD} + RXD:=Data + PacketLength; + Value:=RT2X00ReadDescriptor(RXD,0); + {$IFDEF RT2800USB_DEBUG} + //if NETWORK_LOG_ENABLED then NetworkLogDebug(@RT2X00.WiFi.Network,'RT2800USB: (RXD Value=' + IntToHex(Value,8) + ')'); //To Do + {$ENDIF} + + {CRC Error} + if RT2X00GetRegister32(Value,RT2800USB_RXD_W0_CRC_ERROR,8) <> 0 then + begin + Descriptor.Flags:=Descriptor.Flags or WIFI_RX_FLAG_FAILED_FCS_CRC; + end; + + {Cipher Status} + Descriptor.CipherStatus:=RT2X00GetRegister32(Value,RT2800USB_RXD_W0_CIPHER_ERROR,9); + + {Decrypted} + if RT2X00GetRegister32(Value,RT2800USB_RXD_W0_DECRYPTED,16) <> 0 then + begin + {Hardware has stripped IV/EIV data from 802.11 frame during decryption. Unfortunately the + descriptor doesn't contain any fields with the EIV/IV data either, so they can't be restored} + Descriptor.Flags:=Descriptor.Flags or WIFI_RX_FLAG_IV_STRIPPED; + + {The hardware has already checked the Michael Mic and has stripped it from the frame} + Descriptor.Flags:=Descriptor.Flags or WIFI_RX_FLAG_MMIC_STRIPPED; + + if Descriptor.CipherStatus = RT2X00_RX_CRYPTO_SUCCESS then + begin + Descriptor.Flags:=Descriptor.Flags or WIFI_RX_FLAG_DECRYPTED; + end + else if Descriptor.CipherStatus = RT2X00_RX_CRYPTO_FAIL_MIC then + begin + Descriptor.Flags:=Descriptor.Flags or WIFI_RX_FLAG_MMIC_ERROR; + end; + end; + + {My BSS} + if RT2X00GetRegister32(Value,RT2800USB_RXD_W0_MY_BSS,7) <> 0 then + begin + Descriptor.RXFlags:=Descriptor.RXFlags or RT2X00_RXDONE_MY_BSS; + end; + + {L2 Pad} + if RT2X00GetRegister32(Value,RT2800USB_RXD_W0_L2PAD,14) <> 0 then + begin + Descriptor.RXFlags:=Descriptor.RXFlags or RT2X00_RXDONE_L2PAD; + end; + + {Update Size (Remove RXD from end of buffer)} + Size:=PacketLength; + + Result:=True; +end; + {==============================================================================} {==============================================================================} diff --git a/source/rtl/ultibo/drivers/rt2x00lib.pas b/source/rtl/ultibo/drivers/rt2x00lib.pas index 2a86377..5396617 100644 --- a/source/rtl/ultibo/drivers/rt2x00lib.pas +++ b/source/rtl/ultibo/drivers/rt2x00lib.pas @@ -89,8 +89,8 @@ interface //RT2X00_SHORT_EIFS = RT2X00_SIFS + RT2X00_SHORT_DIFS + RT2X00_GET_DURATION(RT2X00_IEEE80211_HEADER + RT2X00_ACK_SIZE,10); //To Do //rt2x00.h {Extra TX headroom for alignment purposes} - RT2X00_ALIGN_SIZE = 4; {Only whole frame needs alignment} - RT2X00_L2PAD_SIZE = 8; {Both header & payload need alignment} + RT2X00_ALIGN_EXTRA = 4; {RT2X00_ALIGN_SIZE}{Only whole frame needs alignment} + RT2X00_L2PAD_EXTRA = 8; {RT2X00_L2PAD_SIZE}{Both header & payload need alignment} {RT chip constants (The chipset on the device is composed of an RT and RF chip)} RT2X00_RT2460 = $2460; @@ -121,7 +121,7 @@ interface RT2X00_REQUIRE_DMA = 1 shl 3; RT2X00_REQUIRE_COPY_IV = 1 shl 4; RT2X00_REQUIRE_L2PAD = 1 shl 5; - RT2X00_REQUIRE_TXSTATUS_FIFO = 1 shl 6; //To Do //Remove ? + RT2X00_REQUIRE_TXSTATUS_FIFO = 1 shl 6; RT2X00_REQUIRE_SW_SEQNO = 1 shl 7; RT2X00_REQUIRE_HT_TX_DESC = 1 shl 8; RT2X00_REQUIRE_PS_AUTOWAKE = 1 shl 9; @@ -152,6 +152,44 @@ interface RT2X00_RX_CRYPTO_FAIL_ICV = 1; RT2X00_RX_CRYPTO_FAIL_MIC = 2; RT2X00_RX_CRYPTO_FAIL_KEY = 3; + + {RX descriptor flags} + RT2X00_RXDONE_SIGNAL_PLCP = (1 shl 0); {Signal field contains the plcp value} + RT2X00_RXDONE_SIGNAL_BITRATE = (1 shl 1); {Signal field contains the bitrate value} + RT2X00_RXDONE_SIGNAL_MCS = (1 shl 2); {Signal field contains the mcs value} + RT2X00_RXDONE_MY_BSS = (1 shl 3); {Does this frame originate from device's BSS} + RT2X00_RXDONE_CRYPTO_IV = (1 shl 4); {Driver provided IV/EIV data} + RT2X00_RXDONE_CRYPTO_ICV = (1 shl 5); {Driver provided ICV data} + RT2X00_RXDONE_L2PAD = (1 shl 6); {802.11 payload has been padded to 4-byte boundary} + + RT2X00_RXDONE_SIGNAL_MASK = (RT2X00_RXDONE_SIGNAL_PLCP or RT2X00_RXDONE_SIGNAL_BITRATE or RT2X00_RXDONE_SIGNAL_MCS); + + {TX descriptor flags} + RT2X00_ENTRY_TXD_RTS_FRAME = (1 shl 0); {This frame is a RTS frame} + RT2X00_ENTRY_TXD_CTS_FRAME = (1 shl 1); {This frame is a CTS-to-self frame} + RT2X00_ENTRY_TXD_GENERATE_SEQ = (1 shl 2); {This frame requires sequence counter} + RT2X00_ENTRY_TXD_FIRST_FRAGMENT = (1 shl 3); {This is the first frame} + RT2X00_ENTRY_TXD_MORE_FRAG = (1 shl 4); {This frame is followed by another fragment} + RT2X00_ENTRY_TXD_REQ_TIMESTAMP = (1 shl 5); {Require timestamp to be inserted} + RT2X00_ENTRY_TXD_BURST = (1 shl 6); {This frame belongs to the same burst event} + RT2X00_ENTRY_TXD_ACK = (1 shl 7); {An ACK is required for this frame} + RT2X00_ENTRY_TXD_RETRY_MODE = (1 shl 8); {When set, the long retry count is used} + RT2X00_ENTRY_TXD_ENCRYPT = (1 shl 9); {This frame should be encrypted} + RT2X00_ENTRY_TXD_ENCRYPT_PAIRWISE = (1 shl 10); {Use pairwise key table (instead of shared)} + RT2X00_ENTRY_TXD_ENCRYPT_IV = (1 shl 11); {Generate IV/EIV in hardware} + RT2X00_ENTRY_TXD_ENCRYPT_MMIC = (1 shl 12); {Generate MIC in hardware} + RT2X00_ENTRY_TXD_HT_AMPDU = (1 shl 13); {This frame is part of an AMPDU} + RT2X00_ENTRY_TXD_HT_BW_40 = (1 shl 14); {Use 40MHz Bandwidth} + RT2X00_ENTRY_TXD_HT_SHORT_GI = (1 shl 15); {Use short GI} + RT2X00_ENTRY_TXD_HT_MIMO_PS = (1 shl 16); {The receiving STA is in dynamic SM PS mode} + + {TX complete flags} + RT2X00_TXDONE_UNKNOWN = (1 shl 0); {Hardware could not determine success of transmission} + RT2X00_TXDONE_SUCCESS = (1 shl 1); {Frame was successfully sent} + RT2X00_TXDONE_FALLBACK = (1 shl 2); {Hardware used fallback rates for retries} + RT2X00_TXDONE_FAILURE = (1 shl 3); {Frame was not successfully sent} + RT2X00_TXDONE_EXCESSIVE_RETRY = (1 shl 4); {In addition to TXDONE_FAILURE, the frame transmission failed due to excessive retries} + RT2X00_TXDONE_AMPDU = (1 shl 5); {Antenna constants} RT2X00_ANTENNA_SW_DIVERSITY = 0; @@ -383,6 +421,35 @@ TRT2X00InterfaceConfiguration = record //To Do //rt2x00intf_conf end; + PRT2X00RXDescriptor = ^TRT2X00RXDescriptor; {rxdone_entry_desc} + TRT2X00RXDescriptor = record + Timestamp:Int64; {RX Timestamp} + Signal:LongInt; {Signal of the received frame} + RSSI:LongInt; {RSSI of the received frame} + Size:LongWord; {Data size of the received frame} + Flags:LongWord; {Receive flags (WIFI_RX_FLAG_*)} + RXFlags:LongWord; {Receive flags (RT2X00_RXDONE_*)} + RateMode:Word; {Rate mode (RT2X00_RATE_MODE_*)} + Cipher:Byte; {Cipher type used during decryption} + CipherStatus:Byte; {Decryption status} + IV:array[0..1] of LongWord; {IV/EIV data used during decryption} + ICV:LongWord; {ICV data used during decryption} + end; + + PRT2X00TXDescriptor = ^TRT2X00TXDescriptor; {txentry_desc} + TRT2X00TXDescriptor = record + Flags:LongWord; + Length:Word; + HeaderLength:Word; + //To Do //txentry_desc + end; + + PRT2X00TXComplete = ^TRT2X00TXComplete; {txdone_entry_desc} + TRT2X00TXComplete = record + Flags:LongWord; {Transmit flags (RT2X00_TXDONE_*)} + Retry:LongWord; {Retry count} + end; + {RT2X00 Device} PRT2X00WiFiDevice = ^TRT2X00WiFiDevice; @@ -493,6 +560,13 @@ TRT2X00WiFiDevice = record EepromSize:LongWord; {EEPROM size} CSRLock:TMutexHandle; {Protect against concurrent indirect register access (BBP, RF, MCU)} //To Do + + TXWISize:LongWord; {Size of the TXWI field in the TX frame} + RXWISize:LongWord; {Size of the RXWI field in the RX frame} + TXINFOSize:LongWord; {Size of the TXINFO field in the TX frame} + RXINFOSize:LongWord; {Size of the RXINFO field in the RX frame} + + ExtraTXHeadroom:LongWord; {Extra headroom required for TX frames} end; @@ -604,9 +678,23 @@ procedure RT2X00SetRegister32(var Reg:LongWord;Mask,Shift,Value:LongWord); inlin function RT2X00ReadDescriptor(Descriptor:PLongWord;Index:Byte):LongWord; inline; procedure RT2X00WriteDescriptor(Descriptor:PLongWord;Index:Byte;Value:LongWord); inline; -function RT2X00GetRate(Value:Word):PRT2X00Rate; +function RT2X00GetRate(Value:Word):PRT2X00Rate; inline; +function RT2X00GetRateMCS(Value:Word):LongInt; inline; + +function RT2X00GetTXBufferSize(RT2X00:PRT2X00WiFiDevice):LongWord; +function RT2X00GetTXBufferOffset(RT2X00:PRT2X00WiFiDevice):LongWord; + +function RT2X00GetRXBufferSize(RT2X00:PRT2X00WiFiDevice):LongWord; +function RT2X00GetRXBufferOffset(RT2X00:PRT2X00WiFiDevice):LongWord; + +function RT2X00InsertL2PAD(var Data:Pointer;var Size:LongWord;HeaderLength:LongWord):Boolean; +function RT2X00RemoveL2PAD(var Data:Pointer;var Size:LongWord;HeaderLength:LongWord):Boolean; + +function RT2X00ReceiveReadSignal(RT2X00:PRT2X00WiFiDevice;Descriptor:PRT2X00RXDescriptor):LongWord; +function RT2X00ReceiveInsertIV(Descriptor:PRT2X00RXDescriptor;var Data:Pointer;var Size:LongWord;HeaderLength:LongWord):Boolean; function RT2X00_RATE_MCS(Mode,MCS:Word):Word; inline; +function RT2X00_L2PAD_SIZE(HeaderLength:LongWord):LongWord; inline; {==============================================================================} {==============================================================================} @@ -621,8 +709,6 @@ implementation {==============================================================================} {RT2X00LIB Functions} function RT2X00DriverInit(RT2X00:PRT2X00WiFiDevice):LongWord; -var - ExtraTXHeadroom:LongWord; begin {} Result:=ERROR_INVALID_PARAMETER; @@ -653,11 +739,11 @@ function RT2X00DriverInit(RT2X00:PRT2X00WiFiDevice):LongWord; {Get TX Headroom value} if RT2X00IsUSB(RT2X00) then begin - ExtraTXHeadroom:=0; //To Do //tx[0].winfo_size + tx[0].desc_size; //rt2x00dev_extra_tx_headroom + RT2X00.ExtraTXHeadroom:=RT2X00.TXWISize + RT2X00.TXINFOSize; end else begin - ExtraTXHeadroom:=0; //To Do //tx[0].winfo_size //rt2x00dev_extra_tx_headroom + RT2X00.ExtraTXHeadroom:=RT2X00.TXWISize; end; {Determine which operating modes are supported} @@ -676,16 +762,16 @@ function RT2X00DriverInit(RT2X00:PRT2X00WiFiDevice):LongWord; //To Do //rt2x00lib_probe_hw {Initialize extra TX headroom required} - RT2X00.WiFi.Hardware.ExtraTXHeadroom:=Max(IEEE80211_TX_STATUS_HEADROOM,ExtraTXHeadroom); + RT2X00.WiFi.Hardware.ExtraTXHeadroom:=Max(IEEE80211_TX_STATUS_HEADROOM,RT2X00.ExtraTXHeadroom); {Take TX headroom required for alignment into account} if RT2X00GetRequirement(RT2X00,RT2X00_REQUIRE_L2PAD) then begin - Inc(RT2X00.WiFi.Hardware.ExtraTXHeadroom,RT2X00_L2PAD_SIZE); + Inc(RT2X00.WiFi.Hardware.ExtraTXHeadroom,RT2X00_L2PAD_EXTRA); end else if RT2X00GetRequirement(RT2X00,RT2X00_REQUIRE_DMA) then begin - Inc(RT2X00.WiFi.Hardware.ExtraTXHeadroom,RT2X00_ALIGN_SIZE); + Inc(RT2X00.WiFi.Hardware.ExtraTXHeadroom,RT2X00_ALIGN_EXTRA); end; {Allocate tx status FIFO} @@ -2090,7 +2176,8 @@ procedure RT2X00WriteDescriptor(Descriptor:PLongWord;Index:Byte;Value:LongWord); {==============================================================================} -function RT2X00GetRate(Value:Word):PRT2X00Rate; +function RT2X00GetRate(Value:Word):PRT2X00Rate; inline; +{rt2x00_get_rate} begin {} Result:=@RT2X00SupportedRates[Value and $ff]; @@ -2098,12 +2185,234 @@ function RT2X00GetRate(Value:Word):PRT2X00Rate; {==============================================================================} +function RT2X00GetRateMCS(Value:Word):LongInt; inline; +{rt2x00_get_rate_mcs} +begin + {} + Result:=Value and $00ff; +end; + +{==============================================================================} + +function RT2X00GetTXBufferSize(RT2X00:PRT2X00WiFiDevice):LongWord; +{} +begin + {} + Result:=0; + + {Check Device} + if RT2X00 = nil then Exit; + + //To Do //Continuing +end; + +{==============================================================================} + +function RT2X00GetTXBufferOffset(RT2X00:PRT2X00WiFiDevice):LongWord; +{} +begin + {} + Result:=0; + + {Check Device} + if RT2X00 = nil then Exit; + + //To Do //Continuing + //See RT2X00DriverInit / ExtraTXHeadroom +end; + +{==============================================================================} + +function RT2X00GetRXBufferSize(RT2X00:PRT2X00WiFiDevice):LongWord; +{rt2x00queue_alloc_rxskb} +var + HeadSize:LongWord; + TailSize:LongWord; + FrameSize:LongWord; +begin + {} + Result:=0; + + {Check Device} + if RT2X00 = nil then Exit; + + {The frame size includes descriptor size, because the hardware directly receives the frame into the buffer} + FrameSize:=RT2X00_AGGREGATION_SIZE + RT2X00.RXINFOSize + RT2X00.RXWISize; + + {The payload should be aligned to a 4-byte boundary, this means we need at least 3 bytes for moving the frame into the correct offset} + HeadSize:=4; + + {For IV/EIV/ICV assembly we must make sure there is at least 8 bytes bytes available in headroom for IV/EIV and 8 bytes for ICV data as tailroom} + TailSize:=0; + if RT2X00GetCapability(RT2X00,RT2X00_CAPABILITY_HW_CRYPTO) then + begin + HeadSize:=HeadSize + 8; + TailSize:=TailSize + 8; + end; + + {Return Result} + Result:=FrameSize + HeadSize + TailSize; +end; + +{==============================================================================} + +function RT2X00GetRXBufferOffset(RT2X00:PRT2X00WiFiDevice):LongWord; +{} +begin + {} + Result:=0; + + {Check Device} + if RT2X00 = nil then Exit; + + //To Do //Continuing + //See above HeadSize +end; + +{==============================================================================} + +function RT2X00InsertL2PAD(var Data:Pointer;var Size:LongWord;HeaderLength:LongWord):Boolean; +{rt2x00queue_insert_l2pad} +var + L2PAD:LongWord; +begin + {} + Result:=False; + + if Data = nil then Exit; + if Size = 0 then Exit; + + if Size > HeaderLength then L2PAD:=RT2X00_L2PAD_SIZE(HeaderLength) else L2PAD:=0; + + if L2PAD > 0 then + begin + {Update Data and Size (Add bytes to start of buffer)} + Dec(Data,L2PAD); + Inc(Size,L2PAD); + + {Move Header Back} + System.Move(Pointer(Data + L2PAD)^,Data^,HeaderLength); + end; + + Result:=True; +end; + +{==============================================================================} + +function RT2X00RemoveL2PAD(var Data:Pointer;var Size:LongWord;HeaderLength:LongWord):Boolean; +{rt2x00queue_remove_l2pad} +var + L2PAD:LongWord; +begin + {} + Result:=False; + + if Data = nil then Exit; + if Size = 0 then Exit; + + if Size > HeaderLength then L2PAD:=RT2X00_L2PAD_SIZE(HeaderLength) else L2PAD:=0; + + if L2PAD > 0 then + begin + {Move Header Forward} + System.Move(Data^,Pointer(Data + L2PAD)^,HeaderLength); + + {Update Data and Size (Remove bytes from start of buffer)} + Inc(Data,L2PAD); + Dec(Size,L2PAD); + end; + + Result:=True; +end; + +{==============================================================================} + +function RT2X00ReceiveReadSignal(RT2X00:PRT2X00WiFiDevice;Descriptor:PRT2X00RXDescriptor):LongWord; +{rt2x00lib_rxdone_read_signal} +var + Count:LongWord; + Signal:LongInt; + Rate:PRT2X00Rate; + SignalType:LongWord; + SupportedBand:PIEEE80211SupportedBand; +begin + {} + Result:=0; + + {Check Device} + if RT2X00 = nil then Exit; + + {Check Descriptor} + if Descriptor = nil then Exit; + + {Get Signal} + Signal:=Descriptor.Signal; + SignalType:=(Descriptor.RXFlags and RT2X00_RXDONE_SIGNAL_MASK); + + {Check Rate Mode} + case Descriptor.RateMode of + RT2X00_RATE_MODE_CCK,RT2X00_RATE_MODE_OFDM:begin + {For non-HT rates the MCS value needs to contain the actually used rate modulation (CCK or OFDM)} + if (Descriptor.RXFlags and RT2X00_RXDONE_SIGNAL_MCS) <> 0 then + begin + Signal:=RT2X00_RATE_MCS(Descriptor.RateMode,Signal); + end; + + SupportedBand:=RT2X00.WiFi.Bands[RT2X00.CurrentBand]; + for Count:=0 to SupportedBand.RateCount - 1 do + begin + Rate:=RT2X00GetRate(SupportedBand.Rates[Count].HardwareRate); + + if ((SignalType = RT2X00_RXDONE_SIGNAL_PLCP) and (Rate.PLCP = Signal)) or ((SignalType = RT2X00_RXDONE_SIGNAL_BITRATE) and (Rate.BitRate = Signal)) or ((SignalType = RT2X00_RXDONE_SIGNAL_MCS) and (Rate.MCS = Signal)) then + begin + Result:=Count; + end; + end; + end; + RT2X00_RATE_MODE_HT_MIX,RT2X00_RATE_MODE_HT_GREENFIELD:begin + if (Signal >= 0) and (Signal <= 76) then + begin + Result:=Signal; + end; + end; + end; +end; + +{==============================================================================} + +function RT2X00ReceiveInsertIV(Descriptor:PRT2X00RXDescriptor;var Data:Pointer;var Size:LongWord;HeaderLength:LongWord):Boolean; +{rt2x00crypto_rx_insert_iv} +begin + {} + Result:=False; + + if Descriptor = nil then Exit; + if Data = nil then Exit; + if Size = 0 then Exit; + + //To Do //Continuing //See rt2x00crypto_rx_insert_iv not used by RT2800USB + + Result:=True; +end; + +{==============================================================================} + function RT2X00_RATE_MCS(Mode,MCS:Word):Word; inline; +{RATE_MCS} begin {} Result:=((Mode and $00ff) shl 8) or (MCS and $00ff); end; +{==============================================================================} + +function RT2X00_L2PAD_SIZE(HeaderLength:LongWord):LongWord; inline; +{L2PAD_SIZE} +begin + {} + Result:=(-HeaderLength and 3); +end; + {==============================================================================} {==============================================================================} diff --git a/source/rtl/ultibo/rpi3.cfg.template b/source/rtl/ultibo/rpi3.cfg.template new file mode 100644 index 0000000..2ffc2e3 --- /dev/null +++ b/source/rtl/ultibo/rpi3.cfg.template @@ -0,0 +1,8 @@ +# +# Raspberry Pi 3B specific config file +# +-CfVFPV3 +-CIARM +-OoFASTMATH +-Fu%INSTALLDIRECTORY%/units/armv7-ultibo/rtl +-Fu%INSTALLDIRECTORY%/units/armv7-ultibo/packages \ No newline at end of file