Squashed 'Sources/OpenVPN3/' content from commit 0a6e0b6e54

git-subtree-dir: Sources/OpenVPN3
git-subtree-split: 0a6e0b6e542c2d19de1f416c4caccd899d72831a
This commit is contained in:
Sergey Abramchuk
2020-02-24 14:43:11 +03:00
commit 86cc97e55f
655 changed files with 146468 additions and 0 deletions

3
test/ovpncli/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
cli
cli.dSYM
build.tmp

View File

@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.5)
project(ovpncli)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake;${CMAKE_MODULE_PATH}")
include(findcoredeps)
add_executable(ovpncli
cli.cpp)
add_core_dependencies(ovpncli)

24
test/ovpncli/README.txt Normal file
View File

@@ -0,0 +1,24 @@
Build on Mac:
With MbedTLS:
GCC_EXTRA="-ferror-limit=4" STRIP=1 MTLS=1 SNAP=1 LZ4=1 build cli
With MbedTLS and Minicrypto:
GCC_EXTRA="-ferror-limit=4" STRIP=1 MTLS=1 MINI=1 SNAP=1 LZ4=1 build cli
With MbedTLS, Minicrypto, and C++11 for optimized move constructors:
GCC_EXTRA="-ferror-limit=4 -std=c++11" STRIP=1 MTLS=1 MINI=1 SNAP=1 LZ4=1 build cli
With OpenSSL:
GCC_EXTRA="-ferror-limit=4" STRIP=1 OSSL=1 OPENSSL_SYS=1 SNAP=1 LZ4=1 build cli
With MbedTLS/AppleCrypto hybrid:
GCC_EXTRA="-ferror-limit=4" STRIP=1 HYBRID=1 SNAP=1 LZ4=1 build cli
Build on Linux:
With MbedTLS:
STRIP=1 SNAP=1 LZ4=1 MTLS=1 NOSSL=1 build cli
With OpenSSL:
STRIP=1 SNAP=1 LZ4=1 build cli

1202
test/ovpncli/cli.cpp Normal file

File diff suppressed because it is too large Load Diff

45
test/ovpncli/go Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
# Options:
# OSSL=1 -- build using OpenSSL
# MTLS=1 -- build using mbedTLS
# PTPROXY=1 -- build using Private Tunnel proxy
# Other options
GCC_EXTRA="$GCC_EXTRA -DOPENVPN_SHOW_SESSION_TOKEN"
[ "$EER" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DTEST_EER"
[ "$NULL" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DOPENVPN_FORCE_TUN_NULL"
[ "$EXIT" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DTUN_NULL_EXIT"
[ "$GREMLIN" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DOPENVPN_GREMLIN"
[ "$DEX" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DOPENVPN_DISABLE_EXPLICIT_EXIT"
[ "$BS64" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DOPENVPN_BS64_DATA_LIMIT=2500000"
[ "$ROVER" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DOPENVPN_REMOTE_OVERRIDE"
[ "$TLS" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DOPENVPN_TLS_LINK"
[ "$SITNL" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DOPENVPN_USE_SITNL"
[ "$MDNC" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DMBEDTLS_DISABLE_NAME_CONSTRAINTS"
if [ "$AGENT" = "1" ]; then
GCC_EXTRA="$GCC_EXTRA -DOPENVPN_COMMAND_AGENT"
fi
GCC_EXTRA="$GCC_EXTRA -DOPENVPN_VERSION=\"$($(dirname $0)/../../scripts/version)\""
export GCC_EXTRA
# determine platform
if [ "$(uname)" == "Darwin" ]; then
export PROF=${PROF:-osx64}
elif [ "$(uname)" == "Linux" ]; then
export PROF=${PROF:-linux}
else
echo this script only knows how to build on Mac OS or Linux
fi
# use mbedTLS by default
[[ -z "$OSSL" && -z "$MTLS" ]] && export MTLS=1
# don't link with OpenSSL if mbedTLS is specified
if [ "$MTLS" = "1" ]; then
export OSSL=0
export NOSSL=1
fi
# build
ASIO=1 LZ4=1 ../../scripts/build cli

5
test/ssl/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
proto
proto.gcda
proto.dSYM
proto.exe
proto.obj

80
test/ssl/README.txt Normal file
View File

@@ -0,0 +1,80 @@
Building proto.cpp sample:
On Mac
Build with MbedTLS client and server (no minicrypto ASM algs for MbedTLS):
MTLS=1 build proto
Build with MbedTLS client and server using 4 concurrent threads (no minicrypto ASM algs for MbedTLS):
-DN_THREADS=4" MTLS=1 build proto
Build with MbedTLS client and OpenSSL server (no minicrypto ASM algs for MbedTLS):
MTLS=1 OSSL=1 OPENSSL_SYS=1 build proto
Build with OpenSSL client and server:
OSSL=1 OPENSSL_SYS=1 build proto
Build with AppleSSL client and OpenSSL server:
SSL_BOTH=1 OPENSSL_SYS=1 build proto
Build with MbedTLS client and server + minicrypto lib:
MTLS=1 MINI=1 build proto
Build with MbedTLS client and server (no minicrypto ASM algs for MbedTLS),
except substitute AppleSSL crypto algs for the client side:
HYBRID=1 build proto
On Linux:
Build with MbedTLS client and server (no ASM crypto algs):
MTLS=1 NOSSL=1 build proto
Build with OpenSSL client and server:
OSSL=1 build proto
Build with MbedTLS client and OpenSSL server:
MTLS=1 OSSL=1 build proto
Build with MbedTLS client and server (no ASM crypto algs)
using Profile-Guided Optimization:
PGEN=1 MTLS=1 NOSSL=1 build proto && ./proto && PUSE=1 MTLS=1 NOSSL=1 build proto
Variations:
To simulate less data-channel activity and more SSL renegotiations
(RENEG default is 900):
GCC_EXTRA="-DRENEG=90" build proto
For verbose output, lower the number of xmit/recv iterations by defining
ITER to be 10000 or less, e.g.
GCC_EXTRA="-DITER=1000" build proto
Crypto self-test (MbedTLS must be built with DEBUG_BUILD=1 or SELF_TEST=1):
./proto test
Caveats:
When using MbedTLS as both client and server, make sure to build
MbedTLS on Mac OS X with OSX_SERVER=1.
Typical output:
$ time ./proto
*** app bytes=73301015 net_bytes=146383320 data_bytes=36327640 prog=0000218807/0000218806 D=12600/600/12600/800 N=1982/1982 SH=17800/17800 HE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eVxOMRXNqSWZOFIF1bu/PxuDA+Sa
hEi44aHbPXt9opdssz/hdGfd8Wo7vEJrbg7c6zR6C/Akav1Rzy9oohIdgOw=
-----END CERTIFICATE-----

103
test/ssl/client.crt Normal file
View File

@@ -0,0 +1,103 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 2 (0x2)
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=KG, ST=NA, L=BISHKEK, O=OpenVPN-TEST/emailAddress=me@myhost.mydomain
Validity
Not Before: Oct 22 21:59:53 2014 GMT
Not After : Oct 19 21:59:53 2024 GMT
Subject: C=KG, ST=NA, O=OpenVPN-TEST, CN=Test-Client/emailAddress=me@myhost.mydomain
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
00:ec:65:8f:e9:12:c2:1a:5b:e6:56:2a:08:a9:82:
3a:2d:44:78:a3:00:3b:b0:9f:e7:27:10:40:93:ef:
f1:cc:3e:a0:aa:04:a2:80:1b:13:a9:e6:fe:81:d6:
70:90:a8:d8:d4:de:30:d8:35:00:d2:be:62:f0:48:
da:fc:15:8d:c4:c6:6d:0b:99:f1:2b:83:00:0a:d3:
2a:23:0b:e5:cd:f9:35:df:43:61:15:72:ad:95:98:
f6:73:21:41:5e:a0:dd:47:27:a0:d5:9a:d4:41:a8:
1c:1d:57:20:71:17:8f:f7:28:9e:3e:07:ce:ec:d5:
0e:42:4f:1e:74:47:8e:47:9d:d2:14:28:27:2c:14:
10:f5:d1:96:b5:93:74:84:ef:f9:04:de:8d:4a:6f:
df:77:ab:ea:d1:58:d3:44:fe:5a:04:01:ff:06:7a:
97:f7:fd:e3:57:48:e1:f0:df:40:13:9f:66:23:5a:
e3:55:54:3d:54:39:ee:00:f9:12:f1:d2:df:74:2e:
ba:d7:f0:8d:c6:dd:18:58:1c:93:22:0b:75:fa:a8:
d6:e0:b5:2f:2d:b9:d4:fe:b9:4f:86:e2:75:48:16:
60:fb:3f:c9:b4:30:42:29:fb:3b:b3:2b:b9:59:81:
6a:46:f3:45:83:bf:fd:d5:1a:ff:37:0c:6f:5b:fd:
61:f1
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
X509v3 Subject Key Identifier:
D2:B4:36:0F:B1:FC:DD:A5:EA:2A:F7:C7:23:89:FA:E3:FA:7A:44:1D
X509v3 Authority Key Identifier:
keyid:2B:40:E5:C9:7D:F5:F4:96:38:E9:2F:E3:2F:D9:40:64:C9:8E:05:9B
DirName:/C=KG/ST=NA/L=BISHKEK/O=OpenVPN-TEST/emailAddress=me@myhost.mydomain
serial:A1:4E:DE:FA:90:F2:AE:81
Signature Algorithm: sha256WithRSAEncryption
7f:e0:fe:84:a7:ec:df:62:a5:cd:3c:c1:e6:42:b1:31:12:f0:
b9:da:a7:9e:3f:bd:96:52:b6:fc:55:74:64:3e:e4:ff:7e:aa:
f7:3e:06:18:5f:73:85:f8:c8:e0:67:1b:4d:97:ca:05:d0:37:
07:33:64:9b:e6:78:77:14:9a:55:bb:2a:ac:c3:7f:c9:15:08:
83:5c:c8:c2:61:d3:71:4c:05:0b:2b:cb:a3:87:6d:a0:32:ed:
b0:b3:27:97:4a:55:8d:01:2a:30:56:68:ab:f2:da:5c:10:73:
c9:aa:0a:9c:4b:4c:a0:5b:51:6e:0a:7e:6c:53:80:b0:00:e1:
1e:9a:4c:0a:37:9e:20:89:bc:c5:e5:79:58:b7:45:ff:d3:c4:
a1:fd:d9:78:3d:45:16:74:df:82:44:1d:1d:81:50:5a:b9:32:
4c:e2:4f:3f:0e:3a:65:5a:64:83:3b:29:31:c4:99:88:bc:c5:
84:39:f2:19:12:e1:66:d0:ea:fb:75:b1:d2:27:be:91:59:a3:
2b:09:d5:5c:bf:46:8e:d6:67:d6:0b:ec:da:ab:f0:80:19:87:
64:07:a9:77:b1:5e:0c:e2:c5:1d:6a:ac:5d:23:f3:30:75:36:
4e:ca:c3:4e:b0:4d:8c:2c:ce:52:61:63:de:d5:f5:ef:ef:0a:
6b:23:25:26:3c:3a:f2:c3:c2:16:19:3f:a9:32:ba:68:f9:c9:
12:3c:3e:c6:1f:ff:9b:4e:f4:90:b0:63:f5:d1:33:00:30:5a:
e8:24:fa:35:44:9b:6a:80:f3:a6:cc:7b:3c:73:5f:50:c4:30:
71:d8:74:90:27:0a:01:4e:a5:5e:b1:f8:da:c2:61:81:11:ae:
29:a3:8f:fa:7e:4c:4e:62:b1:00:de:92:e3:8f:6a:2e:da:d9:
38:5d:6b:7c:0d:e4:01:aa:c8:c6:6d:8b:cd:c0:c8:6e:e4:57:
21:8a:f6:46:30:d9:ad:51:a1:87:96:a6:53:c9:1e:c6:bb:c3:
eb:55:fe:8c:d6:5c:d5:c6:f3:ca:b0:60:d2:d4:2a:1f:88:94:
d3:4c:1a:da:0c:94:fe:c1:5d:0d:2a:db:99:29:5d:f6:dd:16:
c4:c8:4d:74:9e:80:d9:d0:aa:ed:7b:e3:30:e4:47:d8:f5:15:
c1:71:b8:c6:fd:ee:fc:9e:b2:5f:b5:b7:92:ed:ff:ca:37:f6:
c7:82:b4:54:13:9b:83:cd:87:8b:7e:64:f6:2e:54:3a:22:b1:
c5:c1:f4:a5:25:53:9a:4d:a8:0f:e7:35:4b:89:df:19:83:66:
64:d9:db:d1:61:2b:24:1b:1d:44:44:fb:49:30:87:b7:49:23:
08:02:8a:e0:25:f3:f4:43
-----BEGIN CERTIFICATE-----
MIIFFDCCAvygAwIBAgIBAjANBgkqhkiG9w0BAQsFADBmMQswCQYDVQQGEwJLRzEL
MAkGA1UECBMCTkExEDAOBgNVBAcTB0JJU0hLRUsxFTATBgNVBAoTDE9wZW5WUE4t
VEVTVDEhMB8GCSqGSIb3DQEJARYSbWVAbXlob3N0Lm15ZG9tYWluMB4XDTE0MTAy
MjIxNTk1M1oXDTI0MTAxOTIxNTk1M1owajELMAkGA1UEBhMCS0cxCzAJBgNVBAgT
Ak5BMRUwEwYDVQQKEwxPcGVuVlBOLVRFU1QxFDASBgNVBAMTC1Rlc3Q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BEGIN DH PARAMETERS-----
MIIBCAKCAQEArdnA32xujHPlPI+jPffHSoMUZ+b5gRz1H1Lw9//Gugm5TAsRiYrB
t2BDSsMKvAjyqN+i5SJv4TOk98kRRKB27iPvyXmiL945VaDQl/UehCySjYlGFUjW
9nuo+JwQxeSbw0TLiSYoYJZQ8X1CxPl9mgJl277O4cW1Gc8I/bWa+ipU/4K5wv3h
GI8nt+6A0jN3M/KebotMP101G4k0l0qsY4oRMTmP+z3oAP0qU9NZ1jiuMFVzRlNp
5FdYF7ctrH+tBF+QmyT4SRKSED4wE4oX6gp420NaBhIEQifIj75wlMDtxQlpkN+x
QkjsEbPlaPKHGQ4uupssChVUi8IM2yq5EwIBAg==
-----END DH PARAMETERS-----

23
test/ssl/go Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
if [ "$(uname)" == "Darwin" ]; then
cd $O3/core
. vars/vars-osx64
. vars/setpath
cd test/ssl
ASIO=1 MTLS=1 build proto
else
cd $O3/core
. vars/vars-linux
. vars/setpath
cd test/ssl
if [ "$MO_HYBRID" = "1" ]; then
# mbedTLS client, OpenSSL server
ASIO=1 OPENSSL_SYS=1 MTLS=1 build proto
elif [ "$OSSL" = "1" ]; then
# OpenSSL client/server
ASIO=1 OPENSSL_SYS=1 build proto
else
# mbedTLS client/server
ASIO=1 MTLS=1 NOSSL=1 build proto
fi
fi

1148
test/ssl/proto.cpp Normal file

File diff suppressed because it is too large Load Diff

2
test/ssl/protowin.h Normal file
View File

@@ -0,0 +1,2 @@
//#define RENEG 900
//#define ITER 1000

113
test/ssl/server.crt Normal file
View File

@@ -0,0 +1,113 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 1 (0x1)
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=KG, ST=NA, L=BISHKEK, O=OpenVPN-TEST/emailAddress=me@myhost.mydomain
Validity
Not Before: Oct 22 21:59:52 2014 GMT
Not After : Oct 19 21:59:52 2024 GMT
Subject: C=KG, ST=NA, O=OpenVPN-TEST, CN=Test-Server/emailAddress=me@myhost.mydomain
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
00:a5:b8:a2:ee:ce:b1:a6:0f:6a:b2:9f:d3:22:17:
79:de:09:98:71:78:fa:a7:ce:36:51:54:57:c7:31:
99:56:d1:8a:d6:c5:fd:52:e6:88:0e:7b:f9:ea:27:
7a:bf:3f:14:ec:aa:d2:ff:8b:56:58:ac:ca:51:77:
c5:3c:b6:e4:83:6f:22:06:2d:5b:eb:e7:59:d4:ab:
42:c8:d5:a9:87:73:b3:73:36:51:2f:a5:d0:90:a2:
87:64:54:6c:12:d3:b8:76:47:69:af:ae:8f:00:b3:
70:b9:e7:67:3f:8c:6a:3d:79:5f:81:27:a3:0e:aa:
a7:3d:81:48:10:b1:18:6c:38:2e:8f:7a:7b:c5:3d:
21:c8:f9:a0:7f:17:2b:88:4f:ba:f2:ec:6d:24:8e:
6c:f1:0a:5c:d9:5b:b1:b0:fc:49:cb:4a:d2:58:c6:
2a:25:b0:97:84:c3:9e:ff:34:8c:10:46:7f:0f:fb:
3c:59:7a:a6:29:0c:ae:8e:50:3a:f2:53:84:40:2d:
d5:91:7b:0a:37:8e:82:77:ce:66:2f:34:77:5c:a5:
45:3b:00:19:a7:07:d1:92:e6:66:b9:3b:4e:e9:63:
fc:33:98:1a:ae:7b:08:7d:0a:df:7a:ba:aa:59:6d:
86:82:0a:64:2b:da:59:a7:4c:4e:ef:3d:bd:04:a2:
4b:31
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Cert Type:
SSL Server
Netscape Comment:
OpenSSL Generated Server Certificate
X509v3 Subject Key Identifier:
B3:9D:81:E6:16:92:64:C4:86:87:F5:29:10:1B:5E:2F:74:F7:ED:B1
X509v3 Authority Key Identifier:
keyid:2B:40:E5:C9:7D:F5:F4:96:38:E9:2F:E3:2F:D9:40:64:C9:8E:05:9B
DirName:/C=KG/ST=NA/L=BISHKEK/O=OpenVPN-TEST/emailAddress=me@myhost.mydomain
serial:A1:4E:DE:FA:90:F2:AE:81
X509v3 Extended Key Usage:
TLS Web Server Authentication
X509v3 Key Usage:
Digital Signature, Key Encipherment
Signature Algorithm: sha256WithRSAEncryption
4e:25:80:1b:cb:b0:42:ff:bb:3f:e8:0d:58:c1:80:db:cf:d0:
90:df:ca:c1:e6:41:e1:48:7f:a7:1e:c7:35:9f:9c:6d:7c:3e:
82:e8:de:7e:ae:82:16:00:33:0f:02:23:f1:9d:fe:2b:06:16:
05:55:16:89:dc:63:ac:5f:1a:31:13:79:21:a3:6e:60:28:e8:
e7:6b:54:00:22:a1:b7:69:5a:17:31:ce:0f:c2:a6:dd:a3:6f:
de:ea:19:6c:d2:d2:cb:35:9d:dd:87:51:33:68:cd:c3:9b:90:
55:f1:80:3d:5c:b8:09:b6:e1:3c:13:a4:5d:4a:ce:a5:11:9e:
f9:08:ee:be:e3:54:1d:06:4c:bb:1b:72:13:ee:7d:a0:45:cc:
fe:d1:3b:02:03:c1:d4:ea:45:2d:a8:c9:97:e7:f3:8a:7a:a0:
2f:dd:48:3a:75:c9:42:28:94:fc:af:44:52:16:68:98:d6:ad:
a8:65:b1:cd:ac:60:41:70:e5:44:e8:5a:f2:e7:fc:3b:fe:45:
89:17:1d:6d:85:c6:f0:fc:69:87:d1:1d:07:f3:cb:7b:54:8d:
aa:a3:cc:e3:c6:fc:d6:05:76:35:d0:26:63:8e:d1:a8:b7:ff:
61:42:8a:2c:63:1f:d4:ec:14:47:6b:1e:e3:81:61:12:3b:8c:
16:b5:cf:87:6a:2d:42:21:83:9c:0e:3a:90:3a:1e:c1:36:61:
41:f9:fb:4e:5d:ea:f4:df:23:92:33:2b:9b:14:9f:a0:f5:d3:
c4:f8:1f:2f:9c:11:36:af:2a:22:61:95:32:0b:c4:1c:2d:b1:
c1:0a:2a:97:c0:43:4a:6c:3e:db:00:cd:29:15:9e:7e:41:75:
36:a8:56:86:8c:82:9e:46:20:e5:06:1e:60:d2:03:5f:9f:9e:
69:bb:bf:c2:b4:43:e2:7d:85:17:83:18:41:b0:cb:a9:04:1b:
18:52:9f:89:8b:76:9f:94:59:81:4f:60:5b:33:18:fc:c7:52:
d0:d2:69:fc:0b:a2:63:32:75:43:99:e9:d7:f8:6d:c7:55:31:
0c:f3:ef:1a:71:e1:0a:57:e1:9d:13:b2:1e:fe:1d:ef:e4:f1:
51:d9:95:b3:fd:28:28:93:91:4a:29:c5:37:0e:ab:d8:85:6a:
fe:a8:83:1f:7b:80:5d:1f:04:79:b7:a9:08:6e:0d:d6:2e:aa:
7c:f6:63:7d:41:de:70:13:32:ce:dd:58:cc:a6:73:d4:72:7e:
d7:ac:74:a8:35:ba:c3:1b:2a:64:d7:5a:37:97:56:94:34:2b:
2a:71:60:bc:69:ab:00:85:b9:4f:67:32:17:51:c3:da:57:3a:
37:89:66:c4:7a:51:da:5f
-----BEGIN CERTIFICATE-----
MIIFgDCCA2igAwIBAgIBATANBgkqhkiG9w0BAQsFADBmMQswCQYDVQQGEwJLRzEL
MAkGA1UECBMCTkExEDAOBgNVBAcTB0JJU0hLRUsxFTATBgNVBAoTDE9wZW5WUE4t
VEVTVDEhMB8GCSqGSIb3DQEJARYSbWVAbXlob3N0Lm15ZG9tYWluMB4XDTE0MTAy
MjIxNTk1MloXDTI0MTAxOTIxNTk1MlowajELMAkGA1UEBhMCS0cxCzAJBgNVBAgT
Ak5BMRUwEwYDVQQKEwxPcGVuVlBOLVRFU1QxFDASBgNVBAMTC1Rlc3QtU2VydmVy
MSEwHwYJKoZIhvcNAQkBFhJtZUBteWhvc3QubXlkb21haW4wggEiMA0GCSqGSIb3
DQEBAQUAA4IBDwAwggEKAoIBAQCluKLuzrGmD2qyn9MiF3neCZhxePqnzjZRVFfH
MZlW0YrWxf1S5ogOe/nqJ3q/PxTsqtL/i1ZYrMpRd8U8tuSDbyIGLVvr51nUq0LI
1amHc7NzNlEvpdCQoodkVGwS07h2R2mvro8As3C552c/jGo9eV+BJ6MOqq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mxJep+FfQJYgK6rnLAlQqauQKBgQDammSAprnvDvNhSEp8
W+xt7jQnFqaENbGgP0/D/OZMXc4khgexqlKFmSnBCRDmQ6JvLTWqDXC4+aqAbFQz
zAIjiKaT+so8xvFRob+rBMJY5JLYKNa+zUUanfORUNYLFJPvFqnrWGaJ9uufdaM7
0a5bu95PN74NXee3DBbpBv8HLwKBgQDCEk+IjNbjMT+Neq0ywUeM5rFrUKi92abe
AgsVpjbighRV+6jA2lZFJcize+xYJ9wiOR1/TEI9PZ2OtBkqpwVdvTEHTagRLcvd
NfGcptREDnNLoNWA22buQpztiEduutACWQsrd+JQmqbUicUdW4zw86/oCMbYCW3V
QmYOLns7nwKBgHHUX20WZE91S4pmqFKlUzHTDdkk1ESX6Qx2q0R01j8BwawHFs6O
0DW9EZ7w55nfsh+OPRl1sjK/3ubMgfQO0TZLm+IGf3Sya0qEnVeiPMkpDMX+TgRA
wzEe+ou6uho+9uFSvdxMxeglaYA5M2ycvNwLsbEyZ4ZyVYxdgTiKahYFAoGAcIfP
iD0qKQiYcj/tB94cz+3AeJqHjbYT1O1YYhBECOkmQ4kuG80+cs/q5W/45lEOiuWV
Xgfo7Lu6jVGOujWoneci87oqtvNYH4e09oGh2WiLoBG9Wv9dWtBTUERSLzmxfXsG
SAk2uEhEbj8IhfJc8iZLHH9iVUh6YEslBBodqL8CgYEAlAhvcqAvw5SzsfBR5Mcu
4Nql6mXEVhHCvS4hdFCGaNF0z9A6eBORKJpdLWnqhpquDQDsghWE+Ga4QKSNFIi1
fnAaykmZuY3ToqNOIaVlYM6HpMEz0wHQbTWfDLGcTFcElLZgMAk7VlDyiYVOco+E
QX9lXOO1PGpLzXhlDxSe63Y=
-----END PRIVATE KEY-----

21
test/ssl/tls-auth.key Normal file
View File

@@ -0,0 +1,21 @@
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
02a83428cd0e690e4afe8e9f10b439cb
8405bdea3f0cada559df5d8398018258
9727346c21655d956611b40ebbbc5280
56bb220ac635a3432817110b8ff074af
bd3124c39fef2551c3dde7eeb6469c3a
a29b38c499e200ebed75c0381684676e
890e86da25be6473fb0e484aeed91896
ffbc9e78457943a67803924cb6a32074
0d314e5114c979ab3849c176d7738278
d6d7db6c9a8d70cf1445f9aab193a701
38f7af565a8fa368a656e0cec69d4a7b
6515ae50d30b269e1750ba59e9e12629
cfbfcceefabda3a793f5cb5bbdf18ab3
8d69293d8923d427136dd9fcd2660e12
dfaa32c0f865f72fffea123b3c12425b
86f22ba328f5837ccfab21fc068925f3
-----END OpenVPN Static key V1-----

View File

@@ -0,0 +1,14 @@
-----BEGIN OpenVPN tls-crypt-v2 client key-----
fxgWlYpYT1H8ZCW3/139Ip6WSAa2QQZUu64N/x3g7RzhYuaInPRpP9GLpeDpj/PP
MOa0LuvbIr9Wm6V4+WUO+R8hOdfIMwtBlRleMDedFNRD5h1DCpoDdpgr5CxaPyqO
H6eCvNP7POmqdGJyo9L6H9ndyetQp4r/8wXeYWSkcJKsIJsmyBqRzuODTENGYCqG
FN3+XcUrEMYUyvb/c8NqDVQ6xpwc9+6N7840encSMZPYCq6o8J1QXZJ8sMoBEPa1
gVtLCsPXp2oTs1h82NBpxO8BNPNFz1xIG+2Zy1NpU8PONnr0rtCRPNU7ejsG+p2I
vRDt3VOf+3aD2eVFesR4NAWYTZlxg3eLG4zD/xSiGblBltbB/7qGPxgK6WOP2XD/
V0Yh+TruX2vo4xjEXqV1umTx9K8u6nvaC8uv/72NsvPWkuAOEpY6qpDrqiya+zod
zjrlKdLmftaTEMGURDIjooNygFOAania7UhLWOjhnzZFntLHoYmskF0C7om4CqPR
dhf1OuyaD436yQVdt3t/8sjBGuY4hQZ3PuMKDEsHEzmq8bYwfmDf3U8IsK39NbXO
Bh7Q3Gxxy0vTP2TRsGUbePh5ZveVtCJGe79tjtveLdEVdh+TsMB2xo/ZLFfjDPOx
6xvj5xKQtyou5YawuniHn5nrDWbyARQDTmVl7a5w5HvK3SbuVDrJsuLiRohfKyah
M17SAY5reFev6+piR+zT64zwTYdU20i28gEr
-----END OpenVPN tls-crypt-v2 client key-----

View File

@@ -0,0 +1,5 @@
-----BEGIN OpenVPN tls-crypt-v2 server key-----
hn6VWraZG0o64iPI7faGYkwTMajjqhXqG2kC1X19jCl+aXhWPSgmDbRCT/pSfjLZ
a2pKXP6DGdi3nuINKuPw4655AcuMaBe4b45+zJz5xk92NnNosLaTsanXtjfBNOK5
S/M1f4cLZViVsJTDSMcINK/RCclWVK+IFi//CThZQM8=
-----END OpenVPN tls-crypt-v2 server key-----

View File

@@ -0,0 +1,51 @@
cmake_minimum_required(VERSION 3.5)
project(tests)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake;${CMAKE_MODULE_PATH}")
include(findcoredeps)
include(dlgoogletest)
# Extra includes/libraries that are currently only use by the core unit test
FIND_PATH(LZO_INCLUDE_DIR NAMES lzo/lzo1x.h)
FIND_LIBRARY(LZO_LIBRARIES NAMES lzo2)
if (LZO_INCLUDE_DIR AND LZO_LIBRARIES)
list(APPEND CORE_TEST_DEFINES -DHAVE_LZO)
list(APPEND EXTRA_LIBS ${LZO_LIBRARIES})
list(APPEND EXTRA_INCLUDES ${LZO_INCLUDE_DIR})
message("lzo found, running lzo compression tests")
else ()
message("lzo not found, skipping lzo compression tests")
endif ()
set(SOURCES
core_tests.cpp
test_route_emulation.cpp
test_log.cpp
test_comp.cpp
test_b64.cpp
)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
list(APPEND SOURCES test_sitnl.cpp test_cpu_time.cpp)
endif ()
set(CORE_TEST_DEFINES
-DOPENVPN_FORCE_TUN_NULL
-DUNIT_TEST
-DUNITTEST_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\"
)
add_executable(coreUnitTests ${SOURCES})
add_core_dependencies(coreUnitTests)
target_link_libraries(coreUnitTests gtest_main ${EXTRA_LIBS})
target_compile_definitions(coreUnitTests PRIVATE ${CORE_TEST_DEFINES})
target_include_directories(coreUnitTests PRIVATE ${EXTRA_INCLUDES})
add_test(NAME CoreTests COMMAND coreUnitTests)

View File

@@ -0,0 +1,3 @@
To test and compare speed of the decomrpession algorithms define N_EXPAND to be more than 1 by either edition
the test-comp.c or by add a -DN_EXPAND=1000 or -DN_COMPRESS=1000 for the compression speed in the CmakeLists
and looks at the time the unit test take for the different combinations.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,645 @@
<head>
<title>Compression Pointers</title>
<META HTTP-EQUIV="Keywords" CONTENT="compression, compression, compression">
</head>
<body>
<BODY BGCOLOR=#FFFFFF>
<center>
<H1> Compression Pointers </h1>
</center>
<p>
<a href="#Resources">Compression resources</a>, <a href="#Conferences">conferences</a>, and some <a href="#Research">research
groups and companies</a>, are listed towards the end of this page. <p>
Use this <a href="form.html">handy form</a> to add something to this page, or to simply say you liked this page<i> <img src="new.gif">
<p>
</i>
<p>
<h2>What's New?</h2><p>
<a href="http://www.teaser.fr/~jlgailly/">Jean-loup Gailly</a> -- <i>Mr. gzip,
PNG, CCR (1996-06-10)</i>
<img src="new.gif">
<br>
<a href="http://www.creative.net/~tristan/MPEG">MPEG Pointers and Resources</a>
<img src="new.gif">
<br>
<a href="http://www-isl.stanford.edu/~gray/">Robert M. Gray</a> -- <i>Signal
compression, VQ, image quality evaluation (1996-04-22)</i><img src="new.gif">
<br>
<a href="http://www-isl.stanford.edu/~gray/compression.html">Compression and
Classification Group</a> -- <i>ISL,EE,Stanford (1996-04-22)</i><img src="new.gif">
<br>
<a href="http://www-isl.stanford.edu/~gray/iii.html">Signal Processing
and the International Information Infrastructure</a> -- <i>Web sites (1996-04-22)</i> <img src="new.gif">
<br>
<a href="http://www.cs.sc.edu:80/~valenta/">Valenta, Vladimir</a> -- <i>(1996-04-22)</i>
<br>
<a href="http://patpwww.epfl.ch:80/~jordan/Subjects/Parallel/parallel.html">Jordan, Frederic</a> -- <i>Parallel Image Compression (1996-04-12)</i> <img src="new.gif">
<br>
<a href="http://www.garlic.com/biz/eotek">Electro-Optical Technologies, Inc.</a> -- <i>Consultant (1996-04-12)</i> <img src="new.gif">
<br>
<a href="http://quicktime.apple.com">quicktime.apple.com</a> -- <i>Quicktime site (1996-03-11)</i> <img src="new.gif">
<br>
<a href="http://www.chips.ibm.com/products/aldc/index.html">IBM Hardware</a> -- <i>Compression chips (1996-03-11)</i> <img src="new.gif">
<br>
<!---
<img src="new.gif"><i>Do you have, or know of, a research position where an image compression guru with a Ph.D. would feel at
home? Let me know if you do...<a
href="mailto:singlis@cs.waikato.ac.nz"><b>send me some email!</b></a>, or <a
href="http://www.cs.waikato.ac.nz/~singlis/cv.html"><b>check out my
c.v.</b>
</a>
</i>
-->
<p>
<p>
<h2><i>People</i></h2>
<h2>A</h2>
<a href="http://quest.jpl.nasa.gov/Mark.Adler/">Adler, Mark</a> -- <i>Info-ZIP; Zip, UnZip, gzip and zlib co-author; PNG group</i>
<p>
<h2>B</h2>
<a href="http://www.eese.qut.edu.au/~mbaker/">Baker, Matthew</a> -- <i>Region based video compression</i>
<p>
<a href="http://www.eecs.wsu.edu/~bamberg/">Bamberger, Roberto H.</a>
<p>
<a href="http://sutherland.eese.qut.edu.au/~dbell">Bell, Daniel</a> -- <i>Region based image compression</i>
<p>
<a href="http://www.cosc.canterbury.ac.nz/~tim">Bell, Tim</a> -- <i>compression, computer science for children, and computers and music.</i>
<p>
<a href="http://www.polytechnique.fr/poly/~bellard/">Bellard, Fabrice</a> -- <i>Author of LZEXE</I>
<p>
<a href="http://www.cevis.uni-bremen.de/~willy/">Berghorn, Willy </a>
<p>
<a href="http://www.best.com/~bhaskara">Bhaskaran, Vasudev</a> -- <i>Image and Video compression</i>
<p>
<a href="http://wwwvms.utexas.edu/~cbloom/index.html">Bloom, Charles</a> -- <i>text compression, LZ methods, PPM methods...</i>
<p>
<a href="http://www.ime.usp.br/~rbrito">Brito, Roger</a> -- <i>Arithmetic Coding, LZW, Text Compression</i>
<p>
<a href="http://www.engineering.usu.edu/ece/faculty/scottb.html">Budge, Scott E.</a> -- <i>medical/lossy image compression</i>
<p>
<a href="http://www.elec.uow.edu.au/people/staff/burnett/biography.html">Burnett, Ian</a> -- <i>Speech coding, prototype waveform techniques</I> <img src="new.gif">
<p>
<h2>C</h2>
<a href="http://gabor.eecs.berkeley.edu/~wychan/">Chan, Christopher</a> -- <i>universal lossy source coding, adaptive VQ</i>
<p>
<a href="http://www.compsci.com/~chao">Chao, Hong-yang</a> -- <I>Lightning strike image compressor </i>
<p>
<a href="http://monet.uwaterloo.ca:80/schao/">Chao, Stewart</a>
<p>
<a href="http://diana.ecs.soton.ac.uk/~pjc94r/">Cherriman, Peter</a>
<p>
<a href="http://www-video.eecs.berkeley.edu/erl/sccheung.html">Cheung, S.C.</a> -- <i>Scalable video compression algorithms (18th Feb 1996)</i> <img src="new.gif">
<p>
<a href="http://etro.vub.ac.be/chchrist.html">Christopoulos, Charilaos</a> -- <i> Image and Video compression </i>
<p>
<a href="http://sipi.usc.edu/~chrysafi/">Chrysafis, Christos</a>
<p>
<a href="http://www.ee.gatech.edu/research/DSP/students/wchung/index.html">Chung, Wilson C.</a> -- <i>R-D image and video coding, subband/wavelet, filter banks</i>
<p>
<a href="mailto:aclark@hayes.com">Clark, Alan</a> -- <i>primary contact for V.42bis. Developed BTLZ variant of LZW</i>
<p>
<a href="http://www.cs.waikato.ac.nz/cs/Staff/jgc.html">Cleary, John</a> -- <i>PPM, PPM*, K*</i>
<p>
<a href="http://www.cs.brandeis.edu/dept/faculty/cohn/">Cohn, Martin</a>
<p>
<a href="http://plg.uwaterloo.ca/~gvcormac">Cormack, Gordon V.</a> -- <I>DMC</i>
<p>
<a href="http://www.ee.duke.edu/~cec/index.html">Cramer, Chris</a> -- <i>neural network image compression</i>
<p>
<h2>D</h2>
<a href="http://www.cs.dartmouth.edu/~jmd/">Danskin, John</a> -- <i>Protocol compression, document compression (9th Feb 1996)</i>
<p>
<a href="http://www.cs.dartmouth.edu/~gdavis">Davis, Geoff</a> -- <i>wavelets, image compression, medical</i>
<p>
<a href="http://www-mddsp.enel.ucalgary.ca/People/adilger/">Dilger, Andreas</a> -- <i>fractal block coding of video sequences</i>
<p>
<h2>E</h2>
<a href="http://info.cipic.ucdavis.edu/~estes/index.html">Estes, Robert</a>
<p>
<h2>F</h2>
<a href="http://inls.ucsd.edu/y/Fractals/">Fisher, Yuval</a> -- <i>Fractal Image Compression</i>
<p>
<a href="http://www.wmin.ac.uk/~ajoec1/homepage.html">Ford, Adrian</a> -- <i>Subjective and Objective Compression quality (5th Mar 1996)</i> <img src="new.gif">
<p>
<h2>G</h2>
<a href="http://www.teaser.fr/~jlgailly/">Jean-loup Gailly</a> --
<i>Mr. gzip, PNG, CCR (1996-06-10)</i>
<p>
<a href="http://www.ece.ucsb.edu/faculty/gersho/default.html">Gersho, Allen</a> -- <i>Vector Quantisation, Image Compression</i>
<p>
<a href="http://life.anu.edu.au/ci/vol1/goertzel.html">Goertzel, Ben</a>
<p>
<a href="http://info.lut.ac.uk/departments/el/research/sys/compression.html">Gooch, Mark</a> -- <i>High Performance Hardware Compression (7th Feb 1996)</i>
<p>
<a href="http://robotics.eecs.berkeley.edu/~vkgoyal/">Goyal, Vivek</a> -- <i>overcomplete representations, adaptive transform coding, VQ</i>
<p>
<a href="http://www-isl.stanford.edu/~gray/">Robert M. Gray</a> -- <i>Signal
compression, VQ, image quality evaluation</i><img src="new.gif">
<p>
<h2>H</h2>
<a href="http://cork.informatik.uni-wuerzburg.de/mitarbeiter/ulli">Hafner, Ullrich</a> -- <i>WFA image compression</i>
<p>
<a href="http://www.ics.uci.edu/~dan/">Hirschberg, Dan</a> -- <i>algorithm theory, compression</i>
<p>
<a href="http://wolfpack.larc.nasa.gov/holland.html">Holland, Scott</a>
<p>
<a href="http://www.csc.uvic.ca/home/nigelh/nigelh.html">Horspool, R. Nigel</a> -- <i>text compression, ECG compression</i>
<h2>I</h2>
<a href="http://www.cs.waikato.ac.nz/~singlis">Inglis, Stuart</a> -- <i>image compression, OCR, lossy/lossless document compression</I>
<p>
<h2>J</h2>
<a href="http://www.cs.uiowa.edu/~jones/compress/index.html">Jones, Douglas</a> -- <i>splay-tree based compression and encryption</i>
<p>
<a href="http://info.lut.ac.uk/departments/el/research/sys/compression.html">Jones, Simon</a> -- <i>Lossless compression, High Performance Hardware (7th Feb 1996) </i>
<p>
<a href="http://patpwww.epfl.ch:80/~jordan/Subjects/Parallel/parallel.html">Jordan, Frederic</a> -- <i>Parallel Image Compression (12th April 1996)</i> <img src="new.gif">
<p>
<a href="mailto:robjung@world.std.com">Jung, Robert K.</a> -- <i><a href="http://www.info.fundp.ac.be/~fta/arj.html">ARJ</a> </i>
<p>
<a href="http://www.cs.tu-berlin.de/~jutta/toast.html">jutta</a>
<p>
<h2>K</h2>
<a href="http://links.uwaterloo.ca">Kominek, John</a> -- <I>Fractal and spline based compression</i>
<p>
<a href="http://info.lut.ac.uk/departments/el/research/sys/elmk3.html">Kjelso, Morten</a> -- <i>Main memory compression, High performance hardware</i>
<p>
<a href="http://wwwcip.informatik.uni-erlangen.de/user/mskuhn">Kuhn, Markus</a> -- <i>JBIG implementation</i> <img src="new.gif">
<p>
<a href="http://sipi.usc.edu/faculty/Kuo.html">Kuo, C.-C. Jay</a>
<p>
<a href="http://kaarna.cc.jyu.fi:80/~kuru/">Kuru, Esa</a>
<p>
<a href="http://www.prz.tu-berlin.de:80/~teo/">Kyfonidis, Theodoros</a>
<p>
<h2>L</h2>
<a href="http://www.icsi.berkeley.edu/~lampart/">Lamparter, Bernd</a>
<p>
<a href="http://www.cse.ucsc.edu/cgi-bin/faculty?langdon">Langdon, Glen</a>
<p>
<a href="http://www.dna.lth.se/~jesper/">Larsson, Jesper</a> -- <i>algorithms and data structures, text compression</i> <img src="new.gif">
<p>
<h2>M</h2>
<a href="http://glimpse.cs.arizona.edu:1994/udi.html">Manber, Udi</a>
<p>
<a href="http://www.elec.rma.ac.be/~jma/compression.html">Mangen, Jean-Michel</a> -- <i>image compression, wavelets, satellite</I>
<p>
<a href="http://www.cs.mu.oz.au/~alistair">Moffat, Alistair</a> -- <i>text and index compression, coding methods, information retrieval, document databases</i>
<p>
<a href="http://deskfish.cs.titech.ac.jp/squish/squish_index.html">Montgomery, Christopher</a> -- <i>OggSquish, audio compression</i>
<p>
<a href="mailto:umueller@amiga.physik.unizh.ch">Mueller, Urban Dominik</a> -- <i>XPK system</I>
<p>
<h2>N</h2>
<a href="ftp://ai.toronto.edu/pub/radford/www/index.html">Neal, Radford</a>
<p>
<a href="http://www.cs.waikato.ac.nz/~cgn">Nevill-Manning, Craig</a>
<p>
<a href="http://phoenix.bath.ac.uk/jez/jez.html">Nicholls, Jeremy</a>
<p>
<a href="http://www.acti.com/matt/">Noah, Matt</a> -- <i>speech, ATC, ACELP and IMBE</i>
<p>
<a href="http://www.eecs.wsu.edu/~vnuri/">Nuri, Veyis</a> -- <i>wavelets, data compression, DSP (speech & image)</I>
<h2>O</h2>
<a href="ftp://replicant.csci.unt.edu/pub/oleg/README.html">Oleg</a> -- <i>Lots of code</i>
<p>
<a href="http://sipi.usc.edu/faculty/Ortega/Ortega.html">Ortega, Antonio</a> -- <i>Video compression, Packet video, Adaptive quantization</i>
<p>
<a href="http://www.cs.dartmouth.edu:80/~cowen/">Owen, Charles</a>
<p>
<h2>P</h2>
<a
href="http://www-mddsp.enel.ucalgary.ca/People/provine/compression.html">Provine,
Joseph</a> -- <i>Model based coding</i>
<p>
<h2>R</h2>
<a href="http://monet.uwaterloo.ca/~john/btpc.html">Robinson, John</a> -- <i>Binary Tree Predictive Coding</i>
<p>
<a href="http://quest.jpl.nasa.gov/Info-ZIP/people/greg/">Roelofs, Greg</a> -- <i>Info-ZIP; primary UnZip author; PNG group</i>
<p>
<a href="http://www.ece.ucsb.edu/faculty/rose/default.html">Rose, Kenneth</a>
<p>
<a href="http://www.nettuno.it/fiera/telvox/telvox.htm">Russo, Roberto Maria</a> -- <I>Multiplatform Data Compression</i>
<p>
<h2>S</h2>
<a href="http://harc.edu:80/~schmidt/">Schmidt, Bill</a>
<p>
<a href="http://koa.ifa.hawaii.edu/~shaw/shaw.html">Shaw, Sandy C.</a>
<p>
<a href="http://www.comm.toronto.edu/~kamran/kamran.html">Sharifi, Kamran</a> -- <i>Video over ATM networks</i>
<p>
<a href="http://calypso.unl.edu/~sunil/">Shende, Sunil M.</a>
<p>
<a href="http://viewprint2.berkeley.edu/KleinLab/Amnon/Amnon.html">Silverstein, D. Amnon</a>
<p>
<a href="http://www-plateau.cs.berkeley.edu/people/smoot">Smoot, Steve</a> -- <i>MPEG</i>
<p>
<a href="http://www.cs.brandeis.edu/dept/faculty/storer/">Storer, James A.</a>
<p>
<a href="http://rice.ecs.soton.ac.uk/index.html">Streit, Jurgen</a> -- <i>Low bitrate coding</i>
<p>
<a href="http://www_nt.e-technik.uni-rostock.de/~ts/index.html">Strutz, Tilo</a> -- <i>Wavelet image compressor, demonstration execs</i> <img src="new.gif">
<p>
<h2>T</h2>
<a href="http://zaphod.csci.unt.edu:80/~srt/">Tate, Steve</a>
<p>
<a href="http://www.cs.waikato.ac.nz/~wjt">Teahan, Bill</a> -- <i>PPM, PPM*, master of the Calgary Corpus</i>
<p>
<a href="http://lightning.eee.strath.ac.uk/~duncan/">Thomson, Duncan</a> -- <i>ECG compression with ANNs</i>
<p>
<a href="http://outside.gsfc.nasa.gov/GRSS/">Tilton, James C.</a>
<p>
<a href="http://www.uni-karlsruhe.de/~un55/">Tomczyk, Marek</a>
<p>
<a href="http://munkora.cs.mu.oz.au/~aht">Turpin, Andrew</a> -- <i>Prefix Codes</i>
<p>
<h2>V</h2>
<a href="http://gabor.eecs.berkeley.edu/~martin/">Vetterli, Martin</a> -- <i>wavelets, subband coding, video compression, computational complexity</i>
<p>
<a href="http://www.cs.duke.edu/~jsv/HomePage.html">Vitter, Jeff</a>
<p>
<a href="http://www.eee.strath.ac.uk/~stathis/home.html">Voukelatos, Stathis</a>
<p>
<a href="http://www.xs4all.nl/~aipnl">de Vries, Nico</a> -- <i>AIP-NL, UltraCompressor II development</i> <img src="new.gif">
<p>
<h2>W</h2>
<a href="http://ipcl.ee.queensu.ca/wareham/wareham.html">Wareham, Paul</a> -- <i>Region-oriented video coding</I>
<p>
<a href="mailto://Wegs59@aol.com">Wegener, Al</a> -- <i>DSP, lossless audio compression and AC-2</i>
<p>
<a href="http://www-dsp.rice.edu:80/~weid/">Wei, Dong</a> -- <i>Wavelet compression</i>
<p>
<a href="http://www.rocksoft.com/~ross">Williams, Ross</a>
<p>
<a href="http://www.cs.waikato.ac.nz/~ihw">Witten, Ian</a> -- <i>PPM, mg, arithmetic coding</i>
<p>
<a href="http://www.sees.bangor.ac.uk/~gerry/sp_summary.html">Wolff, Gerry</a>
<p>
<a href="http://sipi.usc.edu/~wwoo/">Woo, Woon-Tack</a> -- <i>stereo image and video compression (12th Feb 1996)</i>
<p>
<a href="http://www.csd.uwo.ca/faculty/wu/">Wu, Xiaolin</a> -- <i>CALIC</i>
<P>
<h2>Z</h2>
<a href="http://www.cs.rmit.edu.au/~jz">Zobel, Justin</a> -- <i>index compression, database compression</i>
<p>
<br>
<br>
<a name="Conferences">
<h2><i>Conferences</i></h2>
<a href="http://www.cs.brandeis.edu:80/~dcc/index.html"><b>Data Compression Conference (DCC), Snowbird, Utah, USA.</b></a><br>
<p>
<a name="Resources">
<h2><i>Resources</i></h2>
<dt>
<i><b>Where to get answers...</b></i>
<dd>
<dd><a href="http://info.itu.ch/">International Telecommunication Union (ITU)</a> -- <i>standards documents (CCITT)</i>
<br>
<dd><a href="http://www.cis.ohio-state.edu/hypertext/faq/usenet/compression-faq/top.html">comp.compression -- Frequently Asked Questions</a> -- <i>Come here 1st!</i>
<dd>
<a href="http://www.cis.ohio-state.edu/hypertext/faq/usenet/jpeg-faq/faq.html">JPEG - Frequently Asked Questions</a>
<dd>
<a href="http://www.crs4.it/HTML/LUIGI/MPEG/mpegfaq.html">MPEG - Frequently Asked Questions</a>
<dd>
<a href="ftp://rtfm.mit.edu:/pub/usenet/news.answers/standards-faq">Standards - Frequenty Asked Questions</a>
<dd>
<a href="news:comp.compression.research">usenet newsgroup: comp.compression.research</a>
<br>
<dd>
<a href="http://www.mi.net/act/act.html">Archive Compression Test</a> -- <i>Summary of all archivers</i>
<br>
<dd>
<a href="http://dip1.ee.uct.ac.za/fractal.bib.html">Fractal compression bibliography</a> -- <i>bibtex file</i>
<br>
<dd>
<a href="http://goethe.ira.uka.de/edu/proseminar.html">LZ/Complexity Seminars</a> -- <i>(in German)</i>
<br>
<dd>
<a href="http://www.cs.waikato.ac.nz/~singlis/ratios.html">Comparitive Compression Ratios</a> -- <i>Sofar...B&W, Gray Scale, Text Compression</i>
<br>
<dd>
<a href="http://www.cs.ucl.ac.uk/mice/mpeggloss.html">VCN (Video, Compression, Networking)
Glossary</a>
<br>
<dd>
<a href="http://www.cs.waikato.ac.nz/~nzdl/">Digital Library -- search for compression</a>
<br>
</dt>
<br>
<dt>
<i><b>Reports/Ph.D. Theses</b></i>
<dd>
<a href="http://www.cs.brown.edu/publications/techreports/reports/CS-93-28.html">Paul Howards Ph.D. thesis</a><br>
<dd><i>The Design and Analysis of Efficient Lossless Data Compression Systems</i>
<br>
</dt>
<br>
<dt>
<i><b>Source code</b></i>
<dd>
<a href="ftp://munnari.oz.au/pub/arith_coder">Arithmetic coding routines</a>
<dd><i>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp(from Moffat, Neal and Witten, Proc. DCC, April 1995)</i>
<br>
<dd>
<a href="ftp://ftp.cpsc.ucalgary.ca/pub/projects/ar.cod">CACM Arithmetic coding package</a>
<dd><i>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp(Witten, Neal and Cleary, CACM 30:520-541, June 1987)</i>
<br>
<dd>
<a href="ftp://nic.funet.fi/pub/graphics/misc/test-images/jbig.tar.gz">JBIG Source code</a> <i>Includes a Q-coder</i>
<br>
<dd><a href="http://wwwcip.informatik.uni-erlangen.de/user/mskuhn">Markus Kuhn's JBIG implementation</a>
<br>
<dd>
<a href="ftp://media-lab.media.mit.edu/pub/k-arith-code/">k-arithmetic coder</a>
<br>
<dd>
<a href="ftp://garbo.uwasa.fi/pc/programming/lds_11.zip">Lossless Data Compression toolkit 1.1</a>
<br>
<dd>
<a href="http://www.cs.uiowa.edu/~jones/compress/index.html">Splay Trees Code</a> -- <i>by Douglas W. Jones</i>
<br>
<dd><a href="ftp://ftp.cl.cam.ac.uk/users/djw3">Block compression code</a> -- <i>Excellent text compressor</i>
<br>
</dt>
<br>
<dt>
<i><b>Test Files</b></i>
<dd>
<a href="ftp://nic.funet.fi/pub/graphics/misc/test-images/">Test Images</a> -- <i>CCITT images (pbm), Lena etc. (Sun raster)</i>
<br>
<dd>
Stockholm test images -- <i>You have to buy a CDROM, thats all I know! :-(</i>
<dd>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp mail me at <a href="mailto:singlis@cs.waikato.ac.nz">singlis@cs.waikato.ac.nz</a> if you know anything about them.
<br>
<dd>
<a href="ftp://ftp.cpsc.ucalgary.ca/pub/projects/text.compression.corpus/">Calgary Text Compression Corpus</a><i> (Text Compression, Bell, Cleary and Witten, 1990)</i>
<br>
</dt>
<br>
<a name="Research">
<h2><i>Research Projects, Standards & Companies</i></h2>
<p>
<dt>
<i><b>Research/Free software Groups</b></i>
<dd><a href="http://www-isl.stanford.edu/~gray/compression.html">Compression and
Classification Group</a> -- <i>ISL,EE,Stanford (22th April 1996)</i><img src="new.gif">
<dd><a href="http://www.bonzi.com">Voice email</a> -- <i>Lossless audio compression (18th Feb 1996)</i>
<dd><a href="http://www.garlic.com/biz/eotek">Electro-Optical Technologies, Inc.</a> -- <i>Consultant (12th April 1996)</i> <img src="new.gif">
<dd><a href="http://quicktime.apple.com">quicktime.apple.com</a> -- <i>Quicktime site (11th Mar 1996)</i>
<dd><a href="http://www.atinternet.fr/image/">IMAGE etc.</a> -- <i>Commercial image compression software (Fractals/Wavelets) (29th Feb 1996)</i> <img src="new.gif">
<dd><a href="http://re7alpha.epm.ornl.gov/CcmDemo/">NCAR CCM Compression and Visualisation</a> -- <i>(18th Feb 1996)</i> <img src="new.gif">
<br>
<dd><a href="http://ipl.rpi.edu/SPIHT/">SPIHT</a> -- <I>Wavelet Natural Image Compressor (12th Feb 1996)</i> <img src="new.gif">
<br>
<dd><a href="http://info.lut.ac.uk/departments/el/research/sys/compression.html">Real-Time Lossless Compression Systems</a> -- <i>Loughborough University</i> <img src="new.gif">
<br>
<dd><a href="http://saigon.ece.wisc.edu/~waveweb/QMF.html">Web site for Multirate Signal Processing</a> -- <i>University of Wisconsin, Madison</i>
<br>
<dd><a href="http://quest.jpl.nasa.gov/Info-ZIP/">Info-ZIP</a> -- <i>free,
portable Zip and UnZip utilities</i>
<br>
<dd><a href="http://cesdis.gsfc.nasa.gov/">CEDIS</a> -- <i>NASA, Maryland, Image/data compression</i>
<br>
<dd><a href="http://www.c3.lanl.gov/~brislawn/ftp.html">CIC-3 Image Compression</a> -- <i>FBI Fingerprints</i>
<br>
<dd><a href="http://rainbow.ece.ucsb.edu/scl.html">Signal Compression Lab at UCSB</a>
<br>
<dd><a href="http://isdl.ee.washington.edu/COMPRESSION/homepage.html">University of
Washington compression lab</a> -- <I>VQ, Wavelets, Shlomo</i>
<br>
</dt>
<p>
<dt>
<i><b>Snippets</b></i>
<dd><a href="http://www-isl.stanford.edu/~gray/iii.html">Signal Processing
and the International Information Infrastructure</a> -- <i>Web sites (22th April 1996)</i> <img src="new.gif">
<dd><a href="http://www.scu.edu.au/ausweb95/papers/management/vanzyl/">Increasing Web bandwith</a> -- <i>comparing GIF, JPEG, Fractal compression</i>
<br>
<dd><a href="http://www.yahoo.com/Art/Computer_Generated/Fractals">Fractal Links on Yahoo</a>
<br>
<dd><a href="http://www.ddj.com/old/ddjw001d.htm">Digital Speech Compression GSM 06.10 RPE-LTP</a> -- <i>DDJ</i>
<br>
<dd><a href="http://www.crc.ricoh.com/CREW/">CREW</a> -- <i>Continuous tone loss(y/less) wavelet compression</i>
<br>
<dd><a href="ftp://ftp.csd.uwo.ca/pub/from_wu/">CALIC -- Context-based adaptive lossless image compressor</a>
<br>
<dd><a href="http://www-plateau.cs.berkeley.edu/mpeg/index.html">Berkeley MPEG</a> -- <i>MPEG tools</i>
<br>
<dd><a href="http://www.creative.net/~tristan/MPEG">MPEG Pointers and Resources</a>
<BR>
</dt>
<p>
<dt>
<i><b>Wavelets</b></i>
<dd>
<a href="http://www.cis.upenn.edu/~eero/epic.html">
EPIC (Efficient Pyramid Image Coder)</a> -- <i>by Eero Simoncelli</i>
<br>
<dd>
<a href="mailto://72234.2617@compuserve.com">Tucker, Michael</a> -- <i>FASTWAVE, audio/image compression</i>
<br>
<dd>
<a href="http://www.harc.edu">HARC</a> -- <i>Lossy Wavelet Compression technology</i>
<br>
<dd>
<a href="http://gabor.eecs.berkeley.edu/">UC Berkeley Wavelet Group</a>
<br>
<dd>
<a href="http://www.c3.lanl.gov/~cjhamil/Wavelets/main.html">Khoros Wavetlet and Compression Toolbox</a>
<br>
<dd>
<a href="http://arabigo.math.scarolina.edu:80/~wavelet/">The Wavelet Digest</a>
<br>
<dd>
<a href="http://jazz.rice.edu/publications.html">Rice DSP Publications Archive</a> -- <i>Wavelets, Time Frequency/Scale</i>
<br>
</dt>
<p>
<dt>
<i><b>Fractals</b></i>
<dd>
<a href="http://inls.ucsd.edu/y/Fractals/">Fractal Image Compression</a> -- <i>Software, Pointers, Conferences</i>
<br>
<dd>
<a href="http://www.fractal.com/">Fractal Design Corporation</a>
<br>
<dd>
<a href="http://www.webcom.com/~verrando/university/ifs.html">New Fractal Image Compression program</a>
<br>
</dt>
<p>
<dt>
<i><b>Companies</b></i>
<dd><a href="http://www.chips.ibm.com/products/aldc/index.html">IBM Hardware</a> -- <i>Compression chips (11th Mar 1996)</i> <img src="new.gif">
<dd><a href="http://www.summus.com">Summus Wavelet Technology</a> -- <i>Wavelet image and video compressors (11th Mar 1996)</i> <img src="new.gif">
<dd><a href="http://www.mitsubishi.co.jp/jp/fractal/fractal.html">Fractal Image Compression</a> -- <I>Mitsubishi (18th Feb 1996)</i> <img src="new.gif">
<dd><a href="http://www.terran-int.com/">Terran Interactive</a> -- <i>Video compression for the Mac (1st Feb 1996)</i> <img src="new.gif">
<br>
<dd><a href="http://darvision.kaist.ac.kr/dvmpeg.html">DV Mpeg</a> -- <i>Windows drivers (18th Feb 1996)</I> <img src="new.gif">
<br>
<dd><a href="http://www.crawford.com/cs/welcome.html">Crawford Compression Services</a> -- <i>MPEG post-production (18th Feb 1996)</i> <img src="new.gif">
<br>
<dd><a href="http://www.shore.net/~ict">Intelligent Compression Technologies</a> <i>(18th Feb 1996)</i> <img src="new.gif">
<br>
<dd><a href="http://www.jpg.com">Pegasus Imaging</a> -- <i>Compression software/dev. kits (12th Feb 1996)</i> <img src="new.gif">
<br>
<dd><a href="http://www.aladdinsys.com/">Aladdin Systems</a> -- <i>StuffIt compression products</i>
<br>
<dd><a href="http://www.stac.com/">Stac Electronics</a>
<br>
<dd><a href="http://www.ccinet.ab.ca/dcp.html">DCP Research</a> -- <i>Hardware solutions</i>
<br>
<dd><a href="http://www.aware.com/product_info/compression_overview.html">Aware Inc.</a> -- <i>Specialised compression company</i>
<br>
<dd><a href="http://www.inria.fr/rodeo/ivs.html">IVS - INRIA Videoconferencing System</a>
<br>
<dd><a href="http://sp25.ianus.cineca.it/telvox/telvoxen.htm">Telvox Teleinformatica</a> -- <i>Multiplatform Data Compressor</i>
<br>
<dd><a href="http://www.compression.com">Compression Technologies,
Inc</a> -- <i>Canada</i>
<br>
<dd><a href="http://www.optivision.com/">Optivision</a> -- <i>MPEG</i>
<br>
<dd><a href="http://www.pkware.com/">PKWARE</a> -- <i>Makers of PKZIP</i>
<br>
<dd><a href="http://www.infoanalytic.com/tayson/index.html">Multimedia Imaging Services</a>
<br>
</dt>
<p>
<dt>
<i><b>Audio compression</b></i>
<dd><a href="http://www.iis.fhg.de/departs/amm/index.html"> Fraunhofer Institut für Integrierte Schaltungen</a>
<br>
<dd><a href="http://svr-www.eng.cam.ac.uk/~ajr/speechCoding.html">Shorten</a>
<br>
<dd><a href="http://www.ddj.com/old/ddjw001d.htm">digital speech compression</a>
<br>
<dd><a href="http://www.cs.tu-berlin.de/~phade/audiowww.html">Audio compression references</a>
<br>
<dd><a href="http://www.fourmilab.ch/speakfree/windows/doc/compress.html">SpeakFreely - compression</a>
<br>
<dd><a href="http://www.fourmilab.ch/speakfree/windows/speak_freely.html#contents">SpeakFreely - Contents</a>
<br>

View File

@@ -0,0 +1,431 @@
#ifndef lint
static char Rcs_Id[] =
"$Id: fields.c,v 1.7 1994/01/06 05:26:37 geoff Exp $";
#endif
/*
* $Log: fields.c,v $
* Revision 1.7 1994/01/06 05:26:37 geoff
* Get rid of all references to System V string routines, for portability
* (sigh).
*
* Revision 1.6 1994/01/05 20:13:43 geoff
* Add the maxf parameter
*
* Revision 1.5 1994/01/04 02:40:21 geoff
* Make the increments settable (field_line_inc and field_field_inc).
* Add support for the FLD_NOSHRINK flag.
*
* Revision 1.4 1993/09/27 17:48:02 geoff
* Fix some lint complaints and some parenthesization errors.
*
* Revision 1.3 1993/09/09 01:11:11 geoff
* Add a return value to fieldwrite. Add support for backquotes and for
* unstripped backslashes.
*
* Revision 1.2 1993/08/26 00:02:50 geoff
* Fix a stupid null-pointer bug
*
* Revision 1.1 1993/08/25 21:32:05 geoff
* Initial revision
*
*/
#include <stdio.h>
#include "config.h"
#include "fields.h"
field_t * fieldread P ((FILE * file, char * delims,
int flags, int maxf));
/* Read a line with fields from a file */
field_t * fieldmake P ((char * line, int allocated, char * delims,
int flags, int maxf));
/* Make a field structure from a line */
static field_t * fieldparse P ((field_t * fieldp, char * line, char * delims,
int flags, int maxf));
/* Parse the fields in a line */
static int fieldbackch P ((char * str, char ** out, int strip));
/* Process backslash sequences */
int fieldwrite P ((FILE * file, field_t * fieldp, int delim));
/* Write a line with fields to a file */
void fieldfree P ((field_t * fieldp));
/* Free a field returned by fieldread */
unsigned int field_field_inc = 20; /* Increment to increase # fields by */
unsigned int field_line_inc = 512; /* Incr to increase line length by */
#ifndef USG
#define strchr index
#endif /* USG */
extern void free ();
extern char * malloc ();
extern char * realloc ();
extern char * strchr ();
extern int strlen ();
/*
* Read one line of the given file into a buffer, break it up into
* fields, and return them to the caller. The field_t structure
* returned must eventually be freed with fieldfree.
*/
field_t * fieldread (file, delims, flags, maxf)
FILE * file; /* File to read lines from */
char * delims; /* Characters to use for field delimiters */
int flags; /* Option flags; see fields.h */
int maxf; /* Maximum number of fields to parse */
{
register char * linebuf; /* Buffer to hold the line read in */
int linemax; /* Maximum line buffer size */
int linesize; /* Current line buffer size */
linebuf = (char *) malloc (field_line_inc);
if (linebuf == NULL)
return NULL;
linemax = field_line_inc;
linesize = 0;
/*
* Read in the line.
*/
while (fgets (&linebuf[linesize], linemax - linesize, file)
!= NULL)
{
linesize += strlen (&linebuf[linesize]);
if (linebuf[linesize - 1] == '\n')
break;
else
{
linemax += field_line_inc;
linebuf = (char *) realloc (linebuf, linemax);
if (linebuf == NULL)
return NULL;
}
}
if (linesize == 0)
{
free (linebuf);
return NULL;
}
return fieldmake (linebuf, 1, delims, flags, maxf);
}
field_t * fieldmake (line, allocated, delims, flags, maxf)
char * line; /* Line to make into a field structure */
int allocated; /* NZ if line allocated with malloc */
char * delims; /* Characters to use for field delimiters */
int flags; /* Option flags; see fields.h */
int maxf; /* Maximum number of fields to parse */
{
register field_t * fieldp; /* Structure describing the fields */
int linesize; /* Current line buffer size */
fieldp = (field_t *) malloc (sizeof (field_t));
if (fieldp == NULL)
return NULL;
fieldp->nfields = 0;
fieldp->linebuf = allocated ? line : NULL;
fieldp->fields = NULL;
fieldp->hadnl = 0;
linesize = strlen (line);
if (line[linesize - 1] == '\n')
{
line[--linesize] = '\0';
fieldp->hadnl = 1;
}
/*
* Shrink the line buffer if necessary.
*/
if (allocated && (flags & FLD_NOSHRINK) == 0)
{
line = fieldp->linebuf =
(char *) realloc (fieldp->linebuf, linesize + 1);
if (fieldp->linebuf == NULL)
{
fieldfree (fieldp);
return NULL;
}
}
return fieldparse (fieldp, line, delims, flags, maxf);
}
static field_t * fieldparse (fieldp, line, delims, flags, maxf)
register field_t * fieldp; /* Field structure to parse into */
register char * line; /* Line to be parsed */
char * delims; /* Characters to use for field delimiters */
int flags; /* Option flags; see fields.h */
int maxf; /* Maximum number of fields to parse */
{
int fieldmax; /* Max size of fields array */
char * lineout; /* Where to store xlated char in line */
char quote; /* Quote character in use */
fieldp->nfields = 0;
fieldmax =
(maxf != 0 && maxf < field_field_inc) ? maxf + 2 : field_field_inc;
fieldp->fields = (char **) malloc (fieldmax * sizeof (char *));
if (fieldp->fields == NULL)
{
fieldfree (fieldp);
return NULL;
}
if ((flags
& (FLD_SHQUOTES | FLD_SNGLQUOTES | FLD_BACKQUOTES | FLD_DBLQUOTES))
== FLD_SHQUOTES)
flags |= FLD_SNGLQUOTES | FLD_BACKQUOTES | FLD_DBLQUOTES;
while (1)
{
if (flags & FLD_RUNS)
{
while (*line != '\0' && strchr (delims, *line) != NULL)
line++; /* Skip runs of delimiters */
if (*line == '\0')
break;
}
fieldp->fields[fieldp->nfields] = lineout = line;
/*
* Skip to the next delimiter. At the end of skipping, "line" will
* point to either a delimiter or a null byte.
*/
if (flags
& (FLD_SHQUOTES | FLD_SNGLQUOTES | FLD_BACKQUOTES
| FLD_DBLQUOTES | FLD_BACKSLASH))
{
while (*line != '\0')
{
if (strchr (delims, *line) != NULL)
break;
else if (((flags & FLD_SNGLQUOTES) && *line == '\'')
|| ((flags & FLD_BACKQUOTES) && *line == '`')
|| ((flags & FLD_DBLQUOTES) && *line == '"'))
{
if ((flags & FLD_SHQUOTES) == 0
&& line != fieldp->fields[fieldp->nfields])
quote = '\0';
else
quote = *line;
}
else
quote = '\0';
if (quote == '\0')
{
if (*line == '\\' && (flags & FLD_BACKSLASH))
{
line++;
if (*line == '\0')
break;
line += fieldbackch (line, &lineout,
flags & FLD_STRIPQUOTES);
}
else
*lineout++ = *line++;
}
else
{
/* Process quoted string */
if ((flags & FLD_STRIPQUOTES) == 0)
*lineout++ = quote;
++line;
while (*line != '\0')
{
if (*line == quote)
{
if ((flags & FLD_STRIPQUOTES) == 0)
*lineout++ = quote;
line++; /* Go on past quote */
if ((flags & FLD_SHQUOTES) == 0)
{
while (*line != '\0'
&& strchr (delims, *line) == NULL)
line++; /* Skip to delimiter */
}
break;
}
else if (*line == '\\')
{
if (flags & FLD_BACKSLASH)
{
line++;
if (*line == '\0')
break;
else
line += fieldbackch (line, &lineout,
flags & FLD_STRIPQUOTES);
}
else
{
*lineout++ = '\\';
if (*++line == '\0')
break;
*lineout++ = *line;
}
}
else
*lineout++ = *line++;
}
}
}
}
else
{
while (*line != '\0' && strchr (delims, *line) == NULL)
line++; /* Skip to delimiter */
lineout = line;
}
fieldp->nfields++;
if (*line++ == '\0')
break;
if (maxf != 0 && fieldp->nfields > maxf)
break;
*lineout = '\0';
if (fieldp->nfields >= fieldmax)
{
fieldmax += field_field_inc;
fieldp->fields =
(char **) realloc (fieldp->fields, fieldmax * sizeof (char *));
if (fieldp->fields == NULL)
{
fieldfree (fieldp);
return NULL;
}
}
}
/*
* Shrink the field pointers and return the field structure.
*/
if ((flags & FLD_NOSHRINK) == 0 && fieldp->nfields >= fieldmax)
{
fieldp->fields = (char **) realloc (fieldp->fields,
(fieldp->nfields + 1) * sizeof (char *));
if (fieldp->fields == NULL)
{
fieldfree (fieldp);
return NULL;
}
}
fieldp->fields[fieldp->nfields] = NULL;
return fieldp;
}
static int fieldbackch (str, out, strip)
register char * str; /* First char of backslash sequence */
register char ** out; /* Where to store result */
int strip; /* NZ to convert the sequence */
{
register int ch; /* Character being developed */
char * origstr; /* Original value of str */
if (!strip)
{
*(*out)++ = '\\';
if (*str != 'x' && *str != 'X' && (*str < '0' || *str > '7'))
{
*(*out)++ = *str;
return *str != '\0';
}
}
switch (*str)
{
case '\0':
*(*out)++ = '\0';
return 0;
case 'a':
*(*out)++ = '\007';
return 1;
case 'b':
*(*out)++ = '\b';
return 1;
case 'f':
*(*out)++ = '\f';
return 1;
case 'n':
*(*out)++ = '\n';
return 1;
case 'r':
*(*out)++ = '\r';
return 1;
case 'v':
*(*out)++ = '\v';
return 1;
case 'X':
case 'x':
/* Hexadecimal sequence */
origstr = str++;
ch = 0;
if (*str >= '0' && *str <= '9')
ch = *str++ - '0';
else if (*str >= 'a' && *str <= 'f')
ch = *str++ - 'a' + 0xa;
else if (*str >= 'A' && *str <= 'F')
ch = *str++ - 'A' + 0xa;
if (*str >= '0' && *str <= '9')
ch = (ch << 4) | (*str++ - '0');
else if (*str >= 'a' && *str <= 'f')
ch = (ch << 4) | (*str++ - 'a' + 0xa);
else if (*str >= 'A' && *str <= 'F')
ch = (ch << 4) | (*str++ - 'A' + 0xa);
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
/* Octal sequence */
origstr = str;
ch = *str++ - '0';
if (*str >= '0' && *str <= '7')
ch = (ch << 3) | (*str++ - '0');
if (*str >= '0' && *str <= '7')
ch = (ch << 3) | (*str++ - '0');
break;
default:
*(*out)++ = *str;
return 1;
}
if (strip)
{
*(*out)++ = ch;
return str - origstr;
}
else
{
for (ch = 0; origstr < str; ch++)
*(*out)++ = *origstr++;
return ch;
}
}
int fieldwrite (file, fieldp, delim)
FILE * file; /* File to write to */
register field_t * fieldp; /* Field structure to write */
int delim; /* Delimiter to place between fields */
{
int error; /* NZ if an error occurs */
register int fieldno; /* Number of field being written */
error = 0;
for (fieldno = 0; fieldno < fieldp->nfields; fieldno++)
{
if (fieldno != 0)
error |= putc (delim, file) == EOF;
error |= fputs (fieldp->fields[fieldno], file) == EOF;
}
if (fieldp->hadnl)
error |= putc ('\n', file) == EOF;
return error;
}
void fieldfree (fieldp)
register field_t * fieldp; /* Field structure to free */
{
if (fieldp == NULL)
return;
if (fieldp->linebuf != NULL)
free ((char *) fieldp->linebuf);
if (fieldp->fields != NULL)
free ((char *) fieldp->fields);
free ((char *) fieldp);
}

Binary file not shown.

View File

@@ -0,0 +1,94 @@
;;; -*- Mode: Lisp; Syntax: Common-Lisp; -*-
(define-language
:grammar
'(((S $any) -> (S1 $any))
((S (Compound $s1 $s2)) -> (S1 $s1) (Conjunction) (S1 $s2))
((S1 (Statement $v)) -> (NP $subj) (VP $subj $tense $v))
((S1 (Acknowledge $a)) -> (Acknowledge $a))
((S1 (Command $v)) -> (VP Self present $v))
((S1 (Question $v)) -> (Aux $tense) (NP $subj) (VP $subj $tense $v))
((S1 (Question $v)) -> (Be $tense) (NP $subj) (Be-Arg $subj $tense $v))
((Be-Arg $subj $tense (Occur $tense (loc $subj $loc))) ->
(Loc-Adjunct $tense (loc $subj $loc)))
((VP $subj $tense (Occur $tense $v)) -> (VP1 $subj $tense $v))
((VP $subj $tense (Occur $tense $v)) -> (Aux $tense)(VP1 $subj present $v))
((VP1 $subj $tense $v) -> (VP2 $subj $tense $v) (Adjunct? $v))
((VP2 $subj $tense ($rel $subj $loc)) ->
(Verb/in $rel $tense))
((VP2 $subj $tense ($rel $subj $loc $obj)) ->
(Verb/tr $rel $tense) (NP $obj))
((VP2 $subj $tense ($rel $subj $loc $obj $obj2)) ->
(Verb/di $rel $tense) (NP $obj) (NP $obj2))
((VP2 $subj $tense (loc $subj $loc)) ->
(Be $tense) (Loc-Adjunct $tense (loc $subj $loc)))
((NP $n) -> (Pronoun $n))
((NP $n) -> (Article) (Noun $n))
((NP $n) -> (Noun $n))
((NP ($x $y)) -> (Number $x) (Number $y))
((PP ($prep $n)) -> (Prep $prep) (NP $n))
((Adjunct? $v) ->)
((Adjunct? $v) -> (Loc-Adjunct $tense $v))
#+Allegro ((Loc-Adjunct $tense ($rel $subj $loc @rest)) -> (PP $loc))
#+Allegro ((Loc-Adjunct $tense ($rel $subj $loc @rest)) -> (Adjunct $loc))
#+Lucid ((Loc-Adjunct $tense ($rel $subj $loc . $rest)) -> (PP $loc))
#+Lucid ((Loc-Adjunct $tense ($rel $subj $loc . $rest)) -> (Adjunct $loc))
)
:lexicon
'(
((Acknowledge $a) -> (yes true) (no false) (maybe unknown) (huh unparsed))
((Adjunct $loc) -> here there (nearby near) near left right up down)
((Article) -> a an the)
((Aux $tense) -> (will future) (did past) (do $finite))
((Be $tense) -> (am present) (are present) (is present) (be $finite)
(was past) (were past))
((Conjunction) -> and --)
((Noun $n) -> gold Wumpus pit breeze stench glitter nothing)
((Number $n) -> 0 1 2 3 4 5 6 7 8 9)
((Prep $prep) -> in at to near)
((Pronoun $n) -> (you self) (me master) (I master))
((Verb/in $rel $tense) -> (go move $finite) (went move past)
(move move $finite) (move move past) (shoot shoot $finite))
((Verb/tr $rel $tense) -> (move carry $finite) (moved carry past)
(carry carry $finite) (carry carried past)
(grab grab $finite) (grab grabbed past) (get grab $finite)
(got grab past) (release release $finite) (release release past)
(drop release $finite) (dropped release past) (shoot shoot-at $finite)
(shot shoot-at past) (kill shoot-at $finite) (killed shoot-at past)
(smell perceive $finite) (feel perceive $finite) (felt perceive past))
((Verb/di $rel $tense) -> (bring bring $finite) (brought bring past)
(get bring $finite) (got bring past))
))
(defparameter *sentences*
'((I will shoot the wumpus at 4 4)
(yes)
(You went right -- I will go left)
(carry the gold)
(yes and no)
(did you bring me the gold)
(a breeze is here -- I am near 5 3)
(a stench is in 3 5)
(a pit is nearby)
(is the wumpus near)
(Did you go to 3 8)
(Yes -- Nothing is there)
(Shoot -- Shoot left)
(Kill the wumpus -- shoot up)))
(defun ss (&optional (sentences *sentences*))
"Run some test sentences, and count how many were not parsed."
(count-if-not
#'(lambda (s)
(format t "~2&>>> ~(~{~a ~}~)~%" s)
(write (second (parse s)) :pretty t))
*sentences*))

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,112 @@
.TH XARGS 1L \" -*- nroff -*-
.SH NAME
xargs \- build and execute command lines from standard input
.SH SYNOPSIS
.B xargs
[\-0prtx] [\-e[eof-str]] [\-i[replace-str]] [\-l[max-lines]]
[\-n max-args] [\-s max-chars] [\-P max-procs] [\-\-null] [\-\-eof[=eof-str]]
[\-\-replace[=replace-str]] [\-\-max-lines[=max-lines]] [\-\-interactive]
[\-\-max-chars=max-chars] [\-\-verbose] [\-\-exit] [\-\-max-procs=max-procs]
[\-\-max-args=max-args] [\-\-no-run-if-empty] [\-\-version] [\-\-help]
[command [initial-arguments]]
.SH DESCRIPTION
This manual page
documents the GNU version of
.BR xargs .
.B xargs
reads arguments from the standard input, delimited by blanks (which can be
protected with double or single quotes or a backslash) or newlines,
and executes the
.I command
(default is /bin/echo) one or more times with any
.I initial-arguments
followed by arguments read from standard input. Blank lines on the
standard input are ignored.
.P
.B xargs
exits with the following status:
.nf
0 if it succeeds
123 if any invocation of the command exited with status 1-125
124 if the command exited with status 255
125 if the command is killed by a signal
126 if the command cannot be run
127 if the command is not found
1 if some other error occurred.
.fi
.SS OPTIONS
.TP
.I "\-\-null, \-0"
Input filenames are terminated by a null character instead of by
whitespace, and the quotes and backslash are not special (every
character is taken literally). Disables the end of file string, which
is treated like any other argument. Useful when arguments might
contain white space, quote marks, or backslashes. The GNU find
\-print0 option produces input suitable for this mode.
.TP
.I "\-\-eof[=eof-str], \-e[eof-str]"
Set the end of file string to \fIeof-str\fR. If the end of file
string occurs as a line of input, the rest of the input is ignored.
If \fIeof-str\fR is omitted, there is no end of file string. If this
option is not given, the end of file string defaults to "_".
.TP
.I "\-\-help"
Print a summary of the options to
.B xargs
and exit.
.TP
.I "\-\-replace[=replace-str], \-i[replace-str]"
Replace occurences of \fIreplace-str\fR in the initial arguments with
names read from standard input.
Also, unquoted blanks do not terminate arguments.
If \fIreplace-str\fR is omitted, it
defaults to "{}" (like for `find \-exec'). Implies \fI\-x\fP and
\fI\-l 1\fP.
.TP
.I "\-\-max-lines[=max-lines], -l[max-lines]"
Use at most \fImax-lines\fR nonblank input lines per command line;
\fImax-lines\fR defaults to 1 if omitted. Trailing blanks cause an
input line to be logically continued on the next input line. Implies
\fI\-x\fR.
.TP
.I "\-\-max-args=max-args, \-n max-args"
Use at most \fImax-args\fR arguments per command line. Fewer than
\fImax-args\fR arguments will be used if the size (see the \-s option)
is exceeded, unless the \-x option is given, in which case \fBxargs\fR
will exit.
.TP
.I "\-\-interactive, \-p"
Prompt the user about whether to run each command line and read a line
from the terminal. Only run the command line if the response starts
with `y' or `Y'. Implies \fI\-t\fR.
.TP
.I "\-\-no-run-if-empty, \-r"
If the standard input does not contain any nonblanks, do not run the
command. Normally, the command is run once even if there is no input.
.TP
.I "\-\-max-chars=max-chars, \-s max-chars"
Use at most \fImax-chars\fR characters per command line, including the
command and initial arguments and the terminating nulls at the ends of
the argument strings. The default is as large as possible, up to 20k
characters.
.TP
.I "\-\-verbose, \-t"
Print the command line on the standard error output before executing
it.
.TP
.I "\-\-version"
Print the version number of
.B xargs
and exit.
.TP
.I "\-\-exit, \-x"
Exit if the size (see the \fI\-s\fR option) is exceeded.
.TP
.I "\-\-max-procs=max-procs, \-P max-procs"
Run up to \fImax-procs\fR processes at a time; the default is 1. If
\fImax-procs\fR is 0, \fBxargs\fR will run as many processes as
possible at a time. Use the \fI\-n\fR option with \fI\-P\fR;
otherwise chances are that only one exec will be done.
.SH "SEE ALSO"
\fBfind\fP(1L), \fBlocate\fP(1L), \fBlocatedb\fP(5L), \fBupdatedb\fP(1)
\fBFinding Files\fP (on-line in Info, or printed)

View File

@@ -0,0 +1,37 @@
// OpenVPN -- An application to securely tunnel IP networks
// over a single port, with support for SSL/TLS-based
// session authentication and key exchange,
// packet encryption, packet authentication, and
// packet compression.
//
// Copyright (C) 2012-2019 OpenVPN Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License Version 3
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program in the COPYING file.
#include <gtest/gtest.h>
// We also need to import here all header files that
// define globals so that consumers that use them despite
// requesting them not to be declared with OPENVPN_EXTERN
#include <asio.hpp>
#include <openvpn/log/logbasesimple.hpp>
#include <openvpn/ssl/sslchoose.hpp>
int main (int argc, char **argv)
{
::testing::InitGoogleTest (&argc, argv);
return RUN_ALL_TESTS ();
}

181
test/unittests/test_b64.cpp Normal file
View File

@@ -0,0 +1,181 @@
// OpenVPN -- An application to securely tunnel IP networks
// over a single port, with support for SSL/TLS-based
// session authentication and key exchange,
// packet encryption, packet authentication, and
// packet compression.
//
// Copyright (C) 2012-2019 OpenVPN Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License Version 3
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program in the COPYING file.
#include "test_common.h"
#include <iostream>
#include <openvpn/common/exception.hpp>
#include <openvpn/common/base64.hpp>
using namespace openvpn;
#ifdef USE_OPENSSL
#include <openssl/bio.h>
#include <openssl/evp.h>
#include <openssl/buffer.h>
#include <stdint.h>
#include <cstdlib>
std::string ssllib_b64enc(const char* text, size_t textlen)
{
BIO *bio, *b64;
b64 = BIO_new(BIO_f_base64());
bio = BIO_new(BIO_s_mem());
bio = BIO_push(b64, bio);
BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL); //Ignore newlines - write everything in one line
BIO_write(bio, text, (int)textlen);
BIO_flush(bio);
const char* encdata;
long len = BIO_get_mem_data(bio, &encdata);
/* If there is nothing to encode OpenSSL gives back a nullptr */
if (len == 0)
encdata = "";
std::string ret(encdata, (size_t)len);
BIO_free_all(bio);
return ret;
}
#else
#include <mbedtls/base64.h>
std::string ssllib_b64enc(const char* text, size_t textlen)
{
size_t olen, outlen;
//make a pessimistic assumption about length always calculate 3 padding bytes
outlen = 3 + 4*(textlen+3)/3;
char *dst = new char[outlen];
EXPECT_EQ(mbedtls_base64_encode(reinterpret_cast<unsigned char*>(dst), outlen,
&olen, reinterpret_cast<const unsigned char*>(text), textlen), 0);
std::string ret(dst, olen);
delete[] dst;
return ret;
}
#endif
void b64_test(const Base64& b64, const std::string& text)
{
const std::string enc = b64.encode(text);
std::string dec = b64.decode(enc);
std::string libenc = ssllib_b64enc(text.c_str(), text.size());
EXPECT_EQ(text, dec) << "Encode/Decode results differ";
EXPECT_EQ(enc, libenc) << "Encode differs from Crypto lib result";
}
void b64_test_binary(const Base64& b64, const char* data, unsigned int len)
{
auto enc = b64.encode(data, len);
char* decdata = new char[len];
size_t decode_len = b64.decode(decdata, len, enc);
std::string libenc = ssllib_b64enc(data, len);
EXPECT_EQ(enc, libenc) << "Encode differs from Crypto lib result";
ASSERT_EQ(decode_len, len) << "Encode/decode length differs";
ASSERT_EQ(std::vector<uint8_t>(decdata, decdata + decode_len),
std::vector<uint8_t>(data, data + len)) << "Encode/Decode results differ";
delete[] decdata;
}
TEST(Base64, tooshortdest)
{
const Base64 b64;
auto enc = b64.encode(std::string("abc"));
char buf[2];
EXPECT_THROW(b64.decode(buf, 2, enc), Base64::base64_decode_out_of_bound_error);
}
void b64_test_bad(const Base64& b64, const std::string& text)
{
std::string dec;
EXPECT_THROW(b64.decode(dec, text), Base64::base64_decode_error);
}
TEST(Base64, badencode)
{
const Base64 b64;
b64_test_bad(b64, "plausible deniability");
b64_test_bad(b64, "plausible != deniability");
b64_test_bad(b64, "x");
b64_test_bad(b64, "====");
b64_test_bad(b64, "xxxx=");
b64_test_bad(b64, "01*=");
}
TEST(Base64, encode)
{
const Base64 b64;
b64_test(b64, "Hello world!");
b64_test(b64, "привет!");
b64_test(b64, "ûmbrellaûmbrella");
b64_test(b64, "一旦在一个蓝色的月亮");
b64_test(b64, "x");
b64_test(b64, "one two three");
b64_test(b64, "aa");
b64_test(b64, "get your kicks on ... route 66");
b64_test(b64, "fight the future");
b64_test(b64, "");
b64_test(b64, "I want to believe...");
b64_test(b64, "it was a weather balloon");
b64_test(b64, "hyperspatial bypass");
b64_test(b64, "ode to a vogon");
b64_test(b64, "Acme Travel");
b64_test(b64, "there's no sunshine when she's gone");
b64_test(b64, "??????????????????????");
b64_test(b64, "???????????????????????");
b64_test(b64, "????????????????????????");
b64_test(b64, "???x>>>>>>>>>?????????????");
b64_test(b64, "???x>>>>>>>>>??????????????");
b64_test(b64, "???x>>>>>>>>>?????????????x>>");
}
TEST(Base64, binary_data)
{
const Base64 b64;
std::srand(0);
for(unsigned int i=0;i<20;i++)
{
char* data = new char[i];
for (int j=0;j<i;j++)
{
data[j]=(char)(std::rand() & 0xff);
}
b64_test_binary(b64, data, i);
delete[] data;
}
}

View File

@@ -0,0 +1,36 @@
// OpenVPN -- An application to securely tunnel IP networks
// over a single port, with support for SSL/TLS-based
// session authentication and key exchange,
// packet encryption, packet authentication, and
// packet compression.
//
// Copyright (C) 2012-2019 OpenVPN Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License Version 3
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program in the COPYING file.
#pragma once
/* Globals get defined multiple times, normally we set this to extern
* in the part of the program that pulls in a subset of the other
* In the unit tests that does not work. So all unit tests are told not
* to include them and all includes are included in core_tests.cpp to pull
* them in
*/
#define OPENVPN_EXTERN extern
/* Without the asio.hpp include we get winsocket.h related errors
* See also https://stackoverflow.com/questions/9750344/boostasio-winsock-and-winsock-2-compatibility-issue
*/
#include <asio.hpp>
#include <openvpn/log/logbasesimple.hpp>
#include <gtest/gtest.h>

View File

@@ -0,0 +1,262 @@
// OpenVPN -- An application to securely tunnel IP networks
// over a single port, with support for SSL/TLS-based
// session authentication and key exchange,
// packet encryption, packet authentication, and
// packet compression.
//
// Copyright (C) 2012-2017 OpenVPN Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License Version 3
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program in the COPYING file.
// If not, see <http://www.gnu.org/licenses/>.
#include <iostream>
#include <algorithm> // for std::min
#ifndef BLOCK_SIZE
#define BLOCK_SIZE 1500
#endif
#ifndef N_COMPRESS
#define N_COMPRESS 1
#endif
#ifndef N_EXPAND
#define N_EXPAND 1
#endif
#ifndef SUPPORT_SWAP
#define SUPPORT_SWAP false
#endif
// other defines:
// must define TEST_x to define compressor/decompressor pair
// OPENVPN_DEBUG_COMPRESS = 0|1|2
#include "test_common.h"
#include <openvpn/common/size.hpp>
#include <openvpn/common/exception.hpp>
#include <openvpn/common/file.hpp>
#include <openvpn/buffer/buffer.hpp>
#include <openvpn/compress/compress.hpp>
#include <openvpn/compress/lzoasym.hpp>
#include <openvpn/frame/frame.hpp>
using namespace openvpn;
Frame::Ptr frame_init(const size_t payload)
{
const size_t headroom = 512;
const size_t tailroom = 512;
const size_t align_block = 16;
const unsigned int buffer_flags = 0;
Frame::Ptr frame(new Frame(Frame::Context(headroom, payload, tailroom, 0, align_block, buffer_flags)));
frame->standardize_capacity(~0);
return frame;
}
class MySessionStats : public SessionStats
{
public:
typedef RCPtr<MySessionStats> Ptr;
MySessionStats()
{
std::memset(errors, 0, sizeof(errors));
}
virtual void error(const size_t err_type, const std::string* text=NULL)
{
if (err_type < Error::N_ERRORS)
++errors[err_type];
}
count_t get_error_count(const Error::Type type) const
{
if (type < Error::N_ERRORS)
return errors[type];
else
return 0;
}
private:
count_t errors[Error::N_ERRORS];
};
inline void verify_eq(const Buffer& b1, const Buffer& b2)
{
ASSERT_EQ(b1, b2) << "decompressed data doesn't match original data";
}
void test(const std::string& filename,
Compress& compressor,
Compress& decompressor,
const Frame& frame,
const size_t block_size,
const size_t n_compress,
const size_t n_expand_per_compress,
size_t& bytes,
size_t& compress_bytes)
{
BufferPtr source_data = read_binary(filename);
for (size_t offset = 0; offset < source_data->size(); offset += block_size)
{
const size_t length = std::min(block_size, source_data->size() - offset);
BufferAllocated data_seg;
frame.prepare(Frame::DECRYPT_WORK, data_seg);
data_seg.write(source_data->data_raw() + offset, length);
for (size_t compress_iter = 0; compress_iter < n_compress; ++compress_iter)
{
BufferAllocated data1(data_seg);
bytes += data1.size();
compressor.compress(data1, true);
compress_bytes += data1.size();
if (n_expand_per_compress == 1)
{
decompressor.decompress(data1);
verify_eq(data_seg, data1);
}
else
{
for (size_t decompress_iter = 0; decompress_iter < n_expand_per_compress; ++decompress_iter)
{
BufferAllocated data2(data1);
decompressor.decompress(data2);
verify_eq(data_seg, data2);
}
}
}
}
}
void test_with_corpus(Compress& compressor,
Compress& decompressor,
const Frame& frame,
const size_t block_size,
const size_t n_compress,
const size_t n_expand_per_compress,
size_t& bytes,
size_t& compress_bytes)
{
static const std::vector<std::string> filenames = {
"comp-testdata/alice29.txt",
"comp-testdata/asyoulik.txt",
"comp-testdata/cp.html",
"comp-testdata/fields.c",
"comp-testdata/geo.protodata",
"comp-testdata/grammar.lsp",
"comp-testdata/house.jpg",
"comp-testdata/html",
"comp-testdata/html_x_4",
"comp-testdata/kennedy.xls",
"comp-testdata/kppkn.gtb",
"comp-testdata/lcet10.txt",
"comp-testdata/mapreduce-osdi-1.pdf",
"comp-testdata/plrabn12.txt",
"comp-testdata/ptt5",
"comp-testdata/sum",
"comp-testdata/urls.10K",
"comp-testdata/xargs.1",
};
for (auto fn: filenames) {
test(UNITTEST_SOURCE_DIR + fn, compressor, decompressor, frame, block_size, n_compress, n_expand_per_compress, bytes,
compress_bytes);
}
}
enum class comppair {
lzo,
lzoasym,
snappy,
lz4
};
void runTest(comppair alg, bool verbose=false)
{
CompressContext::init_static();
MySessionStats::Ptr stats(new MySessionStats);
Frame::Ptr frame = frame_init(BLOCK_SIZE);
Compress::Ptr compress;
Compress::Ptr decompress;
switch (alg) {
#if defined(HAVE_LZO)
case comppair::lzoasym:
compress.reset(new CompressLZO(frame, stats, SUPPORT_SWAP, false));
decompress.reset(new CompressLZOAsym(frame, stats, SUPPORT_SWAP, false));
break;
case comppair::lzo:
compress.reset(new CompressLZO(frame, stats, SUPPORT_SWAP, false));
decompress = compress;
break;
#endif
#if defined(HAVE_LZ4)
case comppair::lz4:
compress.reset(new CompressLZ4(frame, stats, false));
decompress = compress;
break;
#endif
#if defined(HAVE_SNAPPY)
case comppair::snappy:
compress.reset(new CompressSnappy(frame, stats, false));
decompress = compress;
break;
#endif
default:
ASSERT_TRUE(false) << "compressor/decompressor pair not supported";
}
size_t bytes = 0;
size_t compress_bytes = 0;
test_with_corpus(*compress, *decompress, *frame, BLOCK_SIZE, N_COMPRESS, N_EXPAND, bytes, compress_bytes);
if (verbose)
std::cout << "comp=" << compress->name() << '[' << N_COMPRESS << ']'
<< " decomp=" << decompress->name() << '[' << N_EXPAND << ']'
<< " blk=" << BLOCK_SIZE
<< " bytes=" << bytes
<< " comp-bytes=" << compress_bytes
<< " comp-ratio=" << (float) compress_bytes / bytes
<< std::endl;
}
namespace unittests
{
#if defined(HAVE_SNAPPY)
TEST(Compression, snappy)
{
runTest(comppair::snappy);
}
#endif
#if defined(HAVE_LZO)
TEST(Compression, lzo)
{
runTest(comppair::lzo);
}
TEST(Compression, lzoasym)
{
runTest(comppair::lzoasym);
}
#endif
#if defined(HAVE_LZ4)
TEST(Compression, lz4)
{
runTest(comppair::lz4);
}
#endif
}

View File

@@ -0,0 +1,222 @@
// OpenVPN -- An application to securely tunnel IP networks
// over a single port, with support for SSL/TLS-based
// session authentication and key exchange,
// packet encryption, packet authentication, and
// packet compression.
//
// Copyright (C) 2019 OpenVPN Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License Version 3
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program in the COPYING file.
// If not, see <http://www.gnu.org/licenses/>.
// We have two set of measurements for these tests
//
// 1. A coarse measurement based on time()
// These are tracked in 'chk_start' and 'chk_end'
//
// 2. A fine grained measurement from cpu_time()
// These are tracked in 'start' and 'end'
//
// We calculate the difference before and after a
// a workload has run, to measure how long it ran.
// This is done for both measurement approaches.
// The runtime is saved in runtime and chk_runtime
//
// To pass this test, absolute difference between
// runtime and chk_runtime must be less than 1 second.
//
//#define DEBUG // Define this macro to get more details
#include "test_common.h"
#include <stdint.h>
#include <unistd.h>
#include <mutex>
#include <openvpn/linux/cputime.hpp>
#ifdef DEBUG
#define DEBUG_DUMP(msg, st, en, rt, chst, chen, chrt, md) \
std::cout << msg << std::endl \
<< "start = " << std::to_string(st) << std::endl \
<< "end = " << std::to_string(en) << std::endl \
<< "runtime = " << std::to_string(rt) << std::endl \
<< "chk_start = " << std::to_string(chst) << std::endl \
<< "chk_end = " << std::to_string(chen) << std::endl \
<< "chk_runtime = " << std::to_string(chrt) << std::endl \
<< "measurement difference = " \
<< std::to_string(md) << std::endl \
<< "--------------------------------------" << std::endl
#else
#define DEBUG_DUMP(msg, st, en, rt, chst, chen, chrt, md) {}
#endif
#define MEASURE(v, chkv, thread) \
double v = openvpn::cpu_time(thread); \
ASSERT_GE(v, 0); \
double chkv = time(NULL)
#define CALCULATE(msg, st, en, rt, chst, chen, chrt, md) \
double rt = en - st; \
double chrt = chen - chst; \
double md = std::max(rt, chrt) - std::min(rt, chrt); \
DEBUG_DUMP(msg, st, en, rt, chst, chen, chrt, md)
typedef std::shared_ptr<std::thread> ThreadPtr;
// For simplicty, keep the total thread runtime
// in a global variable, protected by a mutex
// on updates
std::mutex update_guard;
double thread_runtime = 0;
void update_thread_runtime(double val)
{
std::lock_guard<std::mutex> ug(update_guard);
thread_runtime += val;
}
namespace unittests
{
static void workload(const uint16_t multiplier)
{
// A very simple busy loop workload
//
// We can't use sleep() or any similar timing
// as this does not increase the tracked runtime
// in the kernel; the process does not really run.
//
std::stringstream buf;
for (unsigned int i = UINT16_MAX * multiplier; i > 0; i--)
{
buf << ".";
// We do this clearing to not spend too much
// memory when running multiple threads
buf.str(std::string());
}
}
TEST(LinuxCPUTime, cpu_time_pid)
{
// Measure the runtime of the workload
MEASURE(start, chk_start, false);
workload(1500);
MEASURE(end, chk_end, false);
// Calculate runtimes and differences
CALCULATE("single PID",
start, end, runtime,
chk_start, chk_end, chk_runtime,
measurement_diff);
ASSERT_LT(measurement_diff, 1);
}
void worker_thread(const uint8_t id)
{
MEASURE(thr_start, chk_thr_start, true);
workload(1500);
MEASURE(thr_end, chk_thr_end, true);
CALCULATE("Worker thread " << std::to_string(id),
thr_start, thr_end, thr_runtime,
chk_thr_start, chk_thr_end, chk_thr_runtime,
thr_measurement_diff);
update_thread_runtime(thr_runtime);
// Since the chk_thr_runtime (chk_thr_end - chk_thr_start)
// is based on epoc seconds of the system, this doesn't
// give a too good number when running multiple threads.
//
// If more threads are running on the same CPU core,
// one of the threads might be preempted. The clock time
// (chk_thr_runtime) will continue to tick, but the real
// runtime (thr_runtime) will not. Which will increase
// the difference between the measured runtimes.
//
// The value of 5 is just an educated guess of what
// we might find acceptable. This might be too high
// on an idle system, but too low on a loaded system.
//
ASSERT_LT(thr_measurement_diff, 5);
}
void run_threads(const uint8_t num_threads)
{
std::vector<ThreadPtr> threads;
for (uint8_t i = 0; i < num_threads; i++)
{
ThreadPtr tp;
tp.reset(new std::thread([id=i](){ worker_thread(id); }));
threads.push_back(tp);
}
for (const auto& t : threads)
{
t->join();
}
}
TEST(LinuxCPUTime, cpu_time_thread_1)
{
// Meassure running a single worker thread
MEASURE(parent_start, chk_parent_start, false);
run_threads(1);
MEASURE(parent_end, chk_parent_end, false);
CALCULATE("Parent thread - 1 child thread",
parent_start, parent_end, runtime,
chk_parent_start, chk_parent_end, chk_runtime,
parent_diff);
ASSERT_LT(parent_diff, 1);
}
TEST(LinuxCPUTime, cpu_time_thread_numcores)
{
// Use number of available cores
int num_cores = sysconf(_SC_NPROCESSORS_ONLN);
// Meassure running a single worker thread
MEASURE(parent_start, chk_parent_start, false);
run_threads(num_cores);
MEASURE(parent_end, chk_parent_end, false);
CALCULATE("Parent thread - " << std::to_string(num_cores) << " child thread",
parent_start, parent_end, runtime,
chk_parent_start, chk_parent_end, chk_runtime,
parent_diff);
#ifdef DEBUG
std::cout << "Total thread runtime: " << std::to_string(thread_runtime) << std::endl;
#endif
// The main process (this PID) will have a total runtime
// which accounts for all runtime of the running threads.
// We still give a bit extra slack, to reduce the risk of
// false positives, due to the possibility of premption
// (see comment in worker_thread() for details). But
// the difference should not neccesarily deviate as much
// here.
ASSERT_LT(parent_diff, 3 + thread_runtime);
}
} // namespace

View File

@@ -0,0 +1,53 @@
// OpenVPN -- An application to securely tunnel IP networks
// over a single port, with support for SSL/TLS-based
// session authentication and key exchange,
// packet encryption, packet authentication, and
// packet compression.
//
// Copyright (C) 2012-2017 OpenVPN Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License Version 3
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program in the COPYING file.
// If not, see <http://www.gnu.org/licenses/>.
#include "test_common.h"
// The ovpncli.cpp file is not all OPENVPN_EXTERN safe and totally breaks
// if included in two files. We probably need to fix this or rename this
// file test_ovpncli and do ALL test that require ovpncli in this file
// (or have multiple test suites)
// This file needs to included with OPENVPN_EXTERN still defined otherwise
// the include from ovpncli.cpp breaks with duplicate symbols
#include <openvpn/common/base64.hpp>
#undef OPENVPN_EXTERN
#define OPENVPN_EXTERN
#include <client/ovpncli.cpp>
#include <string>
#include <sstream>
namespace unittests
{
TEST(LogInfoTest, TestLogInfo)
{
std::string msg("logMessage");
openvpn::ClientAPI::LogInfo logInfo(msg);
auto text = logInfo.text;
ASSERT_EQ(text, msg);
}
} // namespace

View File

@@ -0,0 +1,296 @@
// OpenVPN -- An application to securely tunnel IP networks
// over a single port, with support for SSL/TLS-based
// session authentication and key exchange,
// packet encryption, packet authentication, and
// packet compression.
//
// Copyright (C) 2012-2019 OpenVPN Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License Version 3
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program in the COPYING file.
/* Without doing this log dance core will not compile ... */
#include "test_common.h"
#include <openvpn/client/cliemuexr.hpp>
namespace unittests {
#define DEBUG_PRINT_ROUTES for(auto & rt: tb->routes) std::cout << rt << std::endl;
/* Helper function for quick result comparision */
std::string join_string_vector_sorted(std::vector<std::string> vec, const char* const delim = ", ")
{
std::sort(vec.begin(), vec.end());
std::ostringstream res;
std::copy(vec.begin(), vec.end(), std::ostream_iterator<std::string>(res, delim));
return res.str();
}
/* Simple class that just records */
class TunBuilderMock : public openvpn::TunBuilderBase {
public:
bool is_ipv6;
TunBuilderMock(bool ipv6)
:is_ipv6(ipv6)
{
}
bool tun_builder_add_route(const std::string& address,
int prefix_length,
int metric,
bool ipv6) override
{
auto rt = address+"/"+std::to_string(prefix_length);
routes.push_back(rt);
routesAddr.push_back(openvpn::IP::Route(rt));
return is_ipv6==ipv6;
}
bool tun_builder_set_remote_address(const std::string& address, bool ipv6) override
{
addresses.push_back(address);
return is_ipv6==ipv6;
}
std::vector<std::string> addresses;
std::vector<std::string> routes;
std::vector<openvpn::IP::Route> routesAddr;
bool containsIP(std::string ipaddr)
{
return containsIP(openvpn::IP::Addr(ipaddr));
}
bool containsIP(openvpn::IP::Addr ipaddr)
{
for (auto& rt: routesAddr) {
if (rt.contains(ipaddr))
return true;
}
return false;
}
};
class RouteEmulationTest : public testing::Test {
protected:
openvpn::IPVerFlags* ipflags;
openvpn::EmulateExcludeRoute::Ptr emu;
TunBuilderMock* tb;
openvpn::OptionList emptyOptionList;
RouteEmulationTest()
:tb(nullptr), ipflags(nullptr)
{
}
void teardown()
{
delete tb;
delete ipflags;
}
void setup(bool ipv6, bool excludeServer, bool keepEmu = false)
{
teardown();
tb = new TunBuilderMock(ipv6);
ipflags = new openvpn::IPVerFlags(emptyOptionList,
ipv6 ? openvpn::IP::Addr::V6_MASK : openvpn::IP::Addr::V4_MASK);
if (!keepEmu)
{
openvpn::EmulateExcludeRouteFactory::Ptr factory(
new openvpn::EmulateExcludeRouteFactoryImpl(excludeServer));
emu = factory->new_obj();
}
}
// Helper functions to make writing test suite a bit easier
void inclRoute(const std::string& incRoute)
{
addRoute(true, incRoute);
}
void exclRoute(const std::string& exclRoute)
{
addRoute(false, exclRoute);
}
void addRoute(bool include, const std::string& route)
{
std::string ipstr = route.substr(0, route.find('/'));
std::string mask = route.substr(route.find('/')+1);
emu->add_route(include, openvpn::IP::Addr(ipstr), std::stoi(mask));
}
void doEmulate(std::string serverip = "1.2.3.4")
{
emu->emulate(this->tb, *this->ipflags, openvpn::IP::Addr(serverip));
}
~RouteEmulationTest()
{
teardown();
}
};
TEST_F(RouteEmulationTest, ExcludeOneSubnet)
{
setup(false, false);
emu->add_default_routes(true, true);
emu->add_route(false, openvpn::IP::Addr("192.168.100.0"), 24);
doEmulate();
ASSERT_EQ (tb->routes.size(), 24);
}
TEST_F(RouteEmulationTest, ExcludeSubnetsNoDefault)
{
setup(false, false);
// include this net
emu->add_route(true, openvpn::IP::Addr("10.20.0.0"), 16);
// but not the first half
emu->add_route(false, openvpn::IP::Addr("10.20.0.0"), 17);
doEmulate();
ASSERT_EQ(tb->routes.size(), 1);
ASSERT_EQ(tb->routes.at(0), "10.20.128.0/17");
setup(true, false);
emu->add_route(true, openvpn::IP::Addr("2500:1000::"), 32);
// but not the first half
emu->add_route(false, openvpn::IP::Addr("2500:1000:8000::"), 33);
doEmulate();
ASSERT_EQ(tb->routes.size(), 1);
ASSERT_EQ(tb->routes.at(0), "2500:1000::/33");
}
TEST_F(RouteEmulationTest, excludeServer)
{
setup(false, true);
emu->add_default_routes(true, true);
doEmulate("1.2.3.4");
ASSERT_EQ(tb->routes.size(), 32);
ASSERT_FALSE(tb->containsIP("1.2.3.4"));
ASSERT_TRUE(tb->containsIP("1.2.3.5"));
ASSERT_TRUE(tb->containsIP("1.2.3.3"));
ASSERT_TRUE(tb->containsIP("4.3.2.1"));
setup(true, true);
emu->add_default_routes(true, true);
doEmulate("::1.2.3.4");
ASSERT_EQ(tb->routes.size(), 128);
ASSERT_FALSE(tb->containsIP("::1.2.3.4"));
ASSERT_TRUE(tb->containsIP("::1.2.3.5"));
ASSERT_TRUE(tb->containsIP("::1.2.3.3"));
ASSERT_TRUE(tb->containsIP("::4.3.2.1"));
}
TEST_F(RouteEmulationTest, nestedIPRoutes)
{
// This sets up a number of routes that are all included in each
setup(false, false);
inclRoute("192.64.0.0/16");
// second quarter.
exclRoute("192.64.64.0/18");
// last quarter
inclRoute("192.64.112.0/20");
// first quarter
exclRoute("192.64.112.0/22");
// first quarter again
inclRoute("192.64.112.0/24");
// second quarter
exclRoute("192.64.112.64/26");
doEmulate();
// Excluded by 192.64.112.64/26
ASSERT_FALSE(tb->containsIP("192.64.112.64"));
ASSERT_FALSE(tb->containsIP("192.64.112.87"));
// Included by 192.64.112.0/24
ASSERT_TRUE(tb->containsIP("192.64.112.5"));
ASSERT_TRUE(tb->containsIP("192.64.112.129"));
ASSERT_TRUE(tb->containsIP("192.64.112.255"));
// Excluded by 192.64.112.0/22
ASSERT_FALSE(tb->containsIP("192.64.113.91"));
ASSERT_FALSE(tb->containsIP("192.64.114.92"));
ASSERT_FALSE(tb->containsIP("192.64.115.93"));
// Included by 192.64.112.0/20
ASSERT_TRUE(tb->containsIP("192.64.116.94"));
ASSERT_TRUE(tb->containsIP("192.64.123.95"));
// Excluded by 192.64.64.0/18"
ASSERT_FALSE(tb->containsIP("192.64.64.96"));
ASSERT_FALSE(tb->containsIP("192.64.97.98"));
ASSERT_FALSE(tb->containsIP("192.64.111.99"));
// included in 192.64.0.0/16
ASSERT_TRUE(tb->containsIP("192.64.0.0"));
ASSERT_TRUE(tb->containsIP("192.64.1.2"));
// Not in the at all
ASSERT_FALSE(tb->containsIP("1.2.3.4"));
ASSERT_FALSE(tb->containsIP("192.63.255.255"));
ASSERT_FALSE(tb->containsIP("192.65.0.0"));
ASSERT_FALSE(tb->containsIP("128.0.0.0"));
ASSERT_FALSE(tb->containsIP("192.0.0.0"));
ASSERT_FALSE(tb->containsIP("255.255.255.255"));
}
TEST_F(RouteEmulationTest, DefaultRoute)
{
setup(false, false);
emu->add_default_routes(true, true);
doEmulate();
ASSERT_EQ(tb->routes.size(), 1);
ASSERT_EQ(tb->routes.at(0), "0.0.0.0/0");
// Now something more tricky add unnecessary extra route
// to confuse our emulation layer
setup(false, false, true);
inclRoute("192.168.0.0/24");
doEmulate();
ASSERT_EQ(tb->routes.size(), 2);
ASSERT_EQ(tb->routes.at(0), "0.0.0.0/0");
}
}

View File

@@ -0,0 +1,326 @@
// OpenVPN -- An application to securely tunnel IP networks
// over a single port, with support for SSL/TLS-based
// session authentication and key exchange,
// packet encryption, packet authentication, and
// packet compression.
//
// Copyright (C) 2012-2019 OpenVPN Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License Version 3
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program in the COPYING file.
#include <fstream>
#include "test_common.h"
#include "openvpn/common/argv.hpp"
#include "openvpn/common/process.hpp"
#include "openvpn/common/redir.hpp"
#include "openvpn/common/splitlines.hpp"
#include "openvpn/tun/linux/client/sitnl.hpp"
using namespace openvpn;
using namespace TunNetlink;
namespace unittests
{
static std::string path_to_ip;
class SitnlTest : public testing::Test
{
private:
void add_device(std::string name)
{
RedirectPipe::InOut pipe;
Argv argv;
argv.emplace_back(path_to_ip);
argv.emplace_back("tuntap");
argv.emplace_back("add");
argv.emplace_back("mode");
argv.emplace_back("tun");
argv.emplace_back(std::move(name));
system_cmd(argv[0], argv, nullptr, pipe, 0);
}
void remove_device(std::string name)
{
RedirectPipe::InOut pipe;
Argv argv;
argv.emplace_back(path_to_ip);
argv.emplace_back("tuntap");
argv.emplace_back("delete");
argv.emplace_back("mode");
argv.emplace_back("tun");
argv.emplace_back(std::move(name));
system_cmd(argv[0], argv, nullptr, pipe, 0);
}
protected:
static void SetUpTestSuite()
{
// different distros have ip tool in different places
std::vector<std::string> paths{"/bin/ip", "/sbin/ip", "/usr/bin/ip", "/usr/sbin/ip"};
for (const auto& path : paths)
{
std::ifstream f(path);
if (f)
{
path_to_ip = path;
break;
}
}
ASSERT_FALSE(path_to_ip.empty()) << "unable to find ip tool";
}
void SetUp() override
{
if (geteuid() != 0)
GTEST_SKIP() << "Need root to run this test";
add_device(dev);
add_device(dev2);
}
virtual void TearDown()
{
remove_device(dev);
remove_device(dev2);
}
template <typename CALLBACK>
void cmd(Argv argv, CALLBACK cb)
{
// runs command, reads output and calls a callback
RedirectPipe::InOut pipe;
ASSERT_EQ(system_cmd(argv[0], argv, nullptr, pipe, 0), 0) << "failed to run command " << argv[0];
SplitLines sl(pipe.out);
bool called = false;
while (sl()) {
const std::string &line = sl.line_ref();
std::vector<std::string> v = Split::by_space<std::vector<std::string>, NullLex, SpaceMatch, Split::NullLimit>(line);
// blank line?
if (v.empty())
continue;
cb(v, pipe.out, called);
}
ASSERT_TRUE(called) << pipe.out;
}
template <typename CALLBACK>
void ip_a_show_dev(CALLBACK cb)
{
// get addrs with "ip a show dev"
RedirectPipe::InOut pipe;
Argv argv;
argv.emplace_back(path_to_ip);
argv.emplace_back("a");
argv.emplace_back("show");
argv.emplace_back("dev");
argv.emplace_back(dev);
cmd(argv, cb);
}
template <typename CALLBACK>
void ip_route_get(std::string dst, CALLBACK cb)
{
// get route with "ip route get"
RedirectPipe::InOut pipe;
Argv argv;
argv.emplace_back(path_to_ip);
argv.emplace_back("route");
argv.emplace_back("get");
argv.emplace_back(std::move(dst));
cmd(argv, cb);
}
std::string dev = "tun999";
std::string dev2 = "tun9999";
std::string addr4 = "10.10.0.2";
std::string route4 = "10.110.0.0/24";
std::string gw4 = "10.10.0.1";
std::string addr6 = "fe80:20c3:aaaa:bbbb::cccc";
std::string route6 = "fe80:20c3:cccc:dddd::0/64";
std::string gw6 = "fe80:20c3:aaaa:bbbb:cccc:dddd:eeee:1";
int ipv4_prefix_len = 16;
int ipv6_prefix_len = 64;
int mtu = 1234;
};
TEST_F(SitnlTest, TestAddrAdd4)
{
auto broadcast = IPv4::Addr::from_string(addr4) | ~IPv4::Addr::netmask_from_prefix_len(ipv4_prefix_len);
ASSERT_EQ(SITNL::net_addr_add(dev, IPv4::Addr::from_string(addr4), ipv4_prefix_len, broadcast), 0);
ip_a_show_dev([this, &broadcast](std::vector<std::string>& v, const std::string& out, bool& called) {
if (v[0] == "inet")
{
called = true;
ASSERT_EQ(v[1], addr4 + "/" + std::to_string(ipv4_prefix_len)) << out;
ASSERT_EQ(v[3], broadcast.to_string()) << out;
}
});
}
TEST_F(SitnlTest, TestAddrAdd6)
{
ASSERT_EQ(SITNL::net_addr_add(dev, IPv6::Addr::from_string(addr6), ipv6_prefix_len), 0);
ip_a_show_dev([this](std::vector<std::string>& v, const std::string& out, bool& called) {
if (v[0] == "inet6")
{
called = true;
ASSERT_EQ(v[1], addr6 + "/" + std::to_string(ipv6_prefix_len)) << out;
}
});
}
TEST_F(SitnlTest, TestSetMTU)
{
ASSERT_EQ(SITNL::net_iface_mtu_set(dev, mtu), 0);
ip_a_show_dev([this](std::vector<std::string>& v, const std::string& out, bool& called) {
if (dev + ":" == v[1])
{
called = true;
ASSERT_EQ(v[4], std::to_string(mtu)) << out;
}
});
}
TEST_F(SitnlTest, TestAddRoute4)
{
// add address
auto broadcast = IPv4::Addr::from_string(addr4) | ~IPv4::Addr::netmask_from_prefix_len(ipv4_prefix_len);
ASSERT_EQ(SITNL::net_addr_add(dev, IPv4::Addr::from_string(addr4), ipv4_prefix_len, broadcast), 0);
// up interface
ASSERT_EQ(SITNL::net_iface_up(dev, true), 0);
// add route
ASSERT_EQ(SITNL::net_route_add(IP::Route4(route4), IPv4::Addr::from_string(gw4), dev, 0, 0), 0);
std::string dst{"10.110.0.100"};
ip_route_get(dst, [this, &dst](std::vector<std::string>& v, const std::string& out, bool& called) {
if (v[0] == dst)
{
called = true;
v.resize(7);
auto expected = std::vector<std::string>{dst, "via", gw4, "dev", dev, "src", addr4};
ASSERT_EQ(v, expected) << out;
}
});
}
TEST_F(SitnlTest, TestAddRoute6)
{
// add address
ASSERT_EQ(SITNL::net_addr_add(dev, IPv6::Addr::from_string(addr6), ipv6_prefix_len), 0);
// up interface
ASSERT_EQ(SITNL::net_iface_up(dev, true), 0);
// add route
ASSERT_EQ(SITNL::net_route_add(IP::Route6(route6), IPv6::Addr::from_string(gw6), dev, 0, 0), 0);
std::string dst{"fe80:20c3:cccc:dddd:cccc:dddd:eeee:ffff"};
ip_route_get(dst, [this, &dst](std::vector<std::string> &v1, const std::string &out, bool &called) {
if (v1[0] == dst)
{
called = true;
v1.resize(7);
// iptools 4.15 (Ubuntu 18)
auto expected1 = std::vector<std::string>{dst, "from", "::", "via", gw6, "dev", dev};
auto ok1 = (v1 == expected1);
auto v2 = v1;
v2.resize(5);
// iptools 4.11 (CentOS 7)
auto expected2 = std::vector<std::string>{dst, "via", gw6, "dev", dev};
auto ok2 = (v2 == expected2);
if (!ok1 && !ok2)
{
// this is just a way to print actual value and all expected values
EXPECT_EQ(v1, expected1);
EXPECT_EQ(v2, expected2);
}
}
});
}
TEST_F(SitnlTest, TestBestGw4)
{
// add address
auto broadcast = IPv4::Addr::from_string(addr4) | ~IPv4::Addr::netmask_from_prefix_len(ipv4_prefix_len);
ASSERT_EQ(SITNL::net_addr_add(dev, IPv4::Addr::from_string(addr4), ipv4_prefix_len, broadcast), 0);
// up interface
ASSERT_EQ(SITNL::net_iface_up(dev, true), 0);
// add routes
// shortest prefix
ASSERT_EQ(SITNL::net_route_add(IP::Route4("10.0.0.0/8"), IPv4::Addr::from_string("10.10.10.10"), dev, 0, 0), 0);
// longest prefix, lowest metric
ASSERT_EQ(SITNL::net_route_add(IP::Route4("10.10.10.0/24"), IPv4::Addr::from_string("10.10.10.13"), dev, 0, 0), 0);
// short prefix
ASSERT_EQ(SITNL::net_route_add(IP::Route4("10.10.0.0/16"), IPv4::Addr::from_string("10.10.10.11"), dev, 0, 0), 0);
// longest prefix, highest metric
ASSERT_EQ(SITNL::net_route_add(IP::Route4("10.10.10.0/24"), IPv4::Addr::from_string("10.10.10.12"), dev, 0, 10), 0);
IPv4::Addr best_gw;
std::string best_iface;
ASSERT_EQ(SITNL::net_route_best_gw(IP::Route4("10.10.10.1/32"), best_gw, best_iface), 0);
// we should get a gateway with longest prefix and lowest metric
ASSERT_EQ(best_gw.to_string(), "10.10.10.13");
ASSERT_EQ(best_iface, dev);
}
TEST_F(SitnlTest, TestBestGw4FilterIface)
{
// add addresses
auto broadcast = IPv4::Addr::from_string(addr4) | ~IPv4::Addr::netmask_from_prefix_len(ipv4_prefix_len);
ASSERT_EQ(SITNL::net_addr_add(dev, IPv4::Addr::from_string(addr4), ipv4_prefix_len, broadcast), 0);
broadcast = IPv4::Addr::from_string("10.20.0.2") | ~IPv4::Addr::netmask_from_prefix_len(ipv4_prefix_len);
ASSERT_EQ(SITNL::net_addr_add(dev2, IPv4::Addr::from_string("10.20.0.2"), ipv4_prefix_len, broadcast), 0);
// up interfaces
SITNL::net_iface_up(dev, true);
SITNL::net_iface_up(dev2, true);
// add routes
ASSERT_EQ(SITNL::net_route_add(IP::Route4("10.11.0.0/16"), IPv4::Addr::from_string("10.10.0.1"), dev, 0, 0), 0);
ASSERT_EQ(SITNL::net_route_add(IP::Route4("10.11.12.0/24"), IPv4::Addr::from_string("10.20.0.1"), dev2, 0, 0), 0);
IPv4::Addr best_gw;
std::string best_iface;
// filter out gateway with longest prefix route
SITNL::net_route_best_gw(IP::Route4("10.11.12.13/32"), best_gw, best_iface, dev2);
ASSERT_EQ(best_gw.to_string(), "10.10.0.1");
ASSERT_EQ(best_iface, dev);
}
}

View File

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ReleaseOpenSSL|x64">
<Configuration>ReleaseOpenSSL</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{18446924-20CC-4EB7-B639-A76C1422E5C2}</ProjectGuid>
<RootNamespace>unittests</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseOpenSSL|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseOpenSSL|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(OVPN3_ROOT)\deps\amd64\mbedtls\include;$(OVPN3_ROOT)\deps\amd64\lz4\lib;$(GTEST_ROOT)\googletest\include;$(OVPN3_ROOT)\core;$(OVPN3_ROOT)\deps\amd64\asio\asio\include;$(OVPN3_ROOT)\deps\amd64\tap-windows\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NOMINMAX;_WIN32_WINNT=0x0600;USE_ASIO;ASIO_STANDALONE;USE_MBEDTLS;HAVE_LZ4;OPENVPN_FORCE_TUN_NULL;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>lz4.lib;mbedtls.lib;Iphlpapi.lib;gtest.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OVPN3_ROOT)\deps\amd64\mbedtls\library;$(GTEST_ROOT)\googlemock\gtest\Debug\;%(AdditionalLibraryDirectories);$(OVPN3_ROOT)\deps\amd64\lz4\lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(OVPN3_ROOT)\deps\amd64\mbedtls\include;$(OVPN3_ROOT)\deps\amd64\lz4\lib;$(GTEST_ROOT)\googletest\include;$(OVPN3_ROOT)\core;$(OVPN3_ROOT)\deps\amd64\asio\asio\include;$(OVPN3_ROOT)\deps\amd64\tap-windows\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NOMINMAX;_WIN32_WINNT=0x0600;USE_ASIO;ASIO_STANDALONE;USE_MBEDTLS;HAVE_LZ4;OPENVPN_FORCE_TUN_NULL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>lz4.lib;mbedtls.lib;Iphlpapi.lib;gtest.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OVPN3_ROOT)\deps\amd64\mbedtls\library;$(GTEST_ROOT)\googlemock\gtest\Release\;%(AdditionalLibraryDirectories);$(OVPN3_ROOT)\deps\amd64\lz4\lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseOpenSSL|x64'">
<ClCompile>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(OVPN3_ROOT)\deps\amd64\mbedtls\include;$(OVPN3_ROOT)\deps\amd64\lz4\lib;$(GTEST_ROOT)\googletest\include;$(OVPN3_ROOT)\core;$(OVPN3_ROOT)\deps\amd64\asio\asio\include;$(OVPN3_ROOT)\deps\amd64\tap-windows\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NOMINMAX;_WIN32_WINNT=0x0600;USE_ASIO;ASIO_STANDALONE;USE_MBEDTLS;HAVE_LZ4;OPENVPN_FORCE_TUN_NULL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>lz4.lib;mbedtls.lib;Iphlpapi.lib;gtest.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OVPN3_ROOT)\deps\amd64\mbedtls\library;$(GTEST_ROOT)\googlemock\gtest\Release\;%(AdditionalLibraryDirectories);$(OVPN3_ROOT)\deps\amd64\lz4\lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="test_log.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="test_log.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

402
test/unused Normal file
View File

@@ -0,0 +1,402 @@
// OpenVPN -- An application to securely tunnel IP networks
// over a single port, with support for SSL/TLS-based
// session authentication and key exchange,
// packet encryption, packet authentication, and
// packet compression.
//
// Copyright (C) 2012-2017 OpenVPN Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License Version 3
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program in the COPYING file.
// If not, see <http://www.gnu.org/licenses/>.
// These classes define function objects to be used as asynchronous callbacks
// for Asio methods. Think of these as optimized special cases of function
// objects that could be more generally (but perhaps less optimally) defined
// with lambdas.
#ifndef OPENVPN_COMMON_ASIODISPATCH_H
#define OPENVPN_COMMON_ASIODISPATCH_H
#include <asio.hpp>
#include <openvpn/common/size.hpp>
#include <openvpn/common/rc.hpp>
namespace openvpn {
// Dispatcher for asio async_write
template <typename C, typename Handler>
class AsioDispatchWrite
{
public:
AsioDispatchWrite(Handler handle_write, C* obj)
: handle_write_(handle_write), obj_(obj) {}
void operator()(const asio::error_code& error, const size_t bytes_sent)
{
(obj_.get()->*handle_write_)(error, bytes_sent);
}
private:
Handler handle_write_;
RCPtr<C> obj_;
};
template <typename C, typename Handler>
AsioDispatchWrite<C, Handler> asio_dispatch_write(Handler handle_write, C* obj)
{
return AsioDispatchWrite<C, Handler>(handle_write, obj);
}
// Dispatcher for asio async_read with argument
template <typename C, typename Handler, typename Data>
class AsioDispatchRead
{
public:
AsioDispatchRead(Handler handle_read, C* obj, Data data)
: handle_read_(handle_read), obj_(obj), data_(data) {}
void operator()(const asio::error_code& error, const size_t bytes_recvd)
{
(obj_.get()->*handle_read_)(data_, error, bytes_recvd);
}
private:
Handler handle_read_;
RCPtr<C> obj_;
Data data_;
};
template <typename C, typename Handler, typename Data>
AsioDispatchRead<C, Handler, Data> asio_dispatch_read(Handler handle_read, C* obj, Data data)
{
return AsioDispatchRead<C, Handler, Data>(handle_read, obj, data);
}
// Dispatcher for asio async_read without argument
template <typename C, typename Handler>
class AsioDispatchReadNoArg
{
public:
AsioDispatchReadNoArg(Handler handle_read, C* obj)
: handle_read_(handle_read), obj_(obj) {}
void operator()(const asio::error_code& error, const size_t bytes_recvd)
{
(obj_.get()->*handle_read_)(error, bytes_recvd);
}
private:
Handler handle_read_;
RCPtr<C> obj_;
};
template <typename C, typename Handler>
AsioDispatchReadNoArg<C, Handler> asio_dispatch_read_noarg(Handler handle_read, C* obj)
{
return AsioDispatchReadNoArg<C, Handler>(handle_read, obj);
}
// Dispatcher for asio async_wait with argument
template <typename C, typename Handler, typename Data>
class AsioDispatchTimerArg
{
public:
AsioDispatchTimerArg(Handler handler, C* obj, Data data)
: handler_(handler), obj_(obj), data_(data) {}
void operator()(const asio::error_code& error)
{
(obj_.get()->*handler_)(data_, error);
}
private:
Handler handler_;
RCPtr<C> obj_;
Data data_;
};
template <typename C, typename Handler, typename Data>
AsioDispatchTimerArg<C, Handler, Data> asio_dispatch_timer_arg(Handler handler, C* obj, Data data)
{
return AsioDispatchTimerArg<C, Handler, Data>(handler, obj, data);
}
// Dispatcher for asio async_wait without argument
template <typename C, typename Handler>
class AsioDispatchTimer
{
public:
AsioDispatchTimer(Handler handler, C* obj)
: handler_(handler), obj_(obj) {}
void operator()(const asio::error_code& error)
{
(obj_.get()->*handler_)(error);
}
private:
Handler handler_;
RCPtr<C> obj_;
};
template <typename C, typename Handler>
AsioDispatchTimer<C, Handler> asio_dispatch_timer(Handler handler, C* obj)
{
return AsioDispatchTimer<C, Handler>(handler, obj);
}
// Dispatcher for asio async_connect with argument
template <typename C, typename Handler, typename Data>
class AsioDispatchConnectArg
{
public:
AsioDispatchConnectArg(Handler handler, C* obj, Data data)
: handler_(handler), obj_(obj), data_(data) {}
void operator()(const asio::error_code& error)
{
(obj_.get()->*handler_)(data_, error);
}
private:
Handler handler_;
RCPtr<C> obj_;
Data data_;
};
template <typename C, typename Handler, typename Data>
AsioDispatchConnectArg<C, Handler, Data> asio_dispatch_connect_arg(Handler handler, C* obj, Data data)
{
return AsioDispatchConnectArg<C, Handler, Data>(handler, obj, data);
}
// Dispatcher for asio async_connect without argument
template <typename C, typename Handler>
class AsioDispatchConnect
{
public:
AsioDispatchConnect(Handler handler, C* obj)
: handler_(handler), obj_(obj) {}
void operator()(const asio::error_code& error)
{
(obj_.get()->*handler_)(error);
}
private:
Handler handler_;
RCPtr<C> obj_;
};
template <typename C, typename Handler>
AsioDispatchConnect<C, Handler> asio_dispatch_connect(Handler handler, C* obj)
{
return AsioDispatchConnect<C, Handler>(handler, obj);
}
// Dispatcher for asio async_connect (ComposedConnectHandler) without argument
template <typename C, typename Handler>
class AsioDispatchComposedConnect
{
public:
AsioDispatchComposedConnect(Handler handler, C* obj)
: handler_(handler), obj_(obj) {}
void operator()(const asio::error_code& error, asio::ip::tcp::resolver::iterator endpoint_iterator)
{
(obj_.get()->*handler_)(error, endpoint_iterator);
}
private:
Handler handler_;
RCPtr<C> obj_;
};
template <typename C, typename Handler>
AsioDispatchComposedConnect<C, Handler> asio_dispatch_composed_connect(Handler handler, C* obj)
{
return AsioDispatchComposedConnect<C, Handler>(handler, obj);
}
// Dispatcher for asio async_accept with argument
template <typename C, typename Handler, typename Data>
class AsioDispatchAcceptArg
{
public:
AsioDispatchAcceptArg(Handler handler, C* obj, Data data)
: handler_(handler), obj_(obj), data_(data) {}
void operator()(const asio::error_code& error)
{
(obj_.get()->*handler_)(data_, error);
}
private:
Handler handler_;
RCPtr<C> obj_;
Data data_;
};
template <typename C, typename Handler, typename Data>
AsioDispatchAcceptArg<C, Handler, Data> asio_dispatch_accept_arg(Handler handler, C* obj, Data data)
{
return AsioDispatchAcceptArg<C, Handler, Data>(handler, obj, data);
}
// Dispatcher for asio post with argument
template <typename C, typename Handler, typename Data>
class AsioDispatchPostArg
{
public:
AsioDispatchPostArg(Handler handler, C* obj, Data data)
: handler_(handler), obj_(obj), data_(data) {}
void operator()()
{
(obj_.get()->*handler_)(data_);
}
private:
Handler handler_;
RCPtr<C> obj_;
Data data_;
};
template <typename C, typename Handler, typename Data>
AsioDispatchPostArg<C, Handler, Data> asio_dispatch_post_arg(Handler handler, C* obj, Data data)
{
return AsioDispatchPostArg<C, Handler, Data>(handler, obj, data);
}
// Dispatcher for asio post without argument
template <typename C, typename Handler>
class AsioDispatchPost
{
public:
AsioDispatchPost(Handler handler, C* obj)
: handler_(handler), obj_(obj) {}
void operator()()
{
(obj_.get()->*handler_)();
}
private:
Handler handler_;
RCPtr<C> obj_;
};
template <typename C, typename Handler>
AsioDispatchPost<C, Handler> asio_dispatch_post(Handler handler, C* obj)
{
return AsioDispatchPost<C, Handler>(handler, obj);
}
// Dispatcher for asynchronous resolver without argument
template <typename C, typename Handler, typename EndpointIterator>
class AsioDispatchResolve
{
public:
AsioDispatchResolve(Handler handler, C* obj)
: handler_(handler), obj_(obj) {}
void operator()(const asio::error_code& error, EndpointIterator iter)
{
(obj_.get()->*handler_)(error, iter);
}
private:
Handler handler_;
RCPtr<C> obj_;
};
// Dispatcher for asynchronous resolver with argument
template <typename C, typename Handler, typename EndpointIterator, typename Data>
class AsioDispatchResolveArg
{
public:
AsioDispatchResolveArg(Handler handler, C* obj, Data data)
: handler_(handler), obj_(obj), data_(data) {}
void operator()(const asio::error_code& error, EndpointIterator iter)
{
(obj_.get()->*handler_)(error, iter, data_);
}
private:
Handler handler_;
RCPtr<C> obj_;
Data data_;
};
// Dispatcher for asio signal
template <typename C, typename Handler>
class AsioDispatchSignal
{
public:
AsioDispatchSignal(Handler handler, C* obj)
: handler_(handler), obj_(obj) {}
void operator()(const asio::error_code& error, int signal_number)
{
(obj_.get()->*handler_)(error, signal_number);
}
private:
Handler handler_;
RCPtr<C> obj_;
};
template <typename C, typename Handler>
AsioDispatchSignal<C, Handler> asio_dispatch_signal(Handler handler, C* obj)
{
return AsioDispatchSignal<C, Handler>(handler, obj);
}
// General purpose dispatcher with data
template <typename C, typename Handler, typename Data>
class SimpleDispatch
{
public:
SimpleDispatch(Handler handler, C* obj)
: handler_(handler), obj_(obj) {}
void operator()(Data data)
{
(obj_->*handler_)(data);
}
private:
Handler handler_;
C* obj_;
};
} // namespace openvpn
#endif // OPENVPN_COMMON_ASIODISPATCH_H