Skip to content

Commit e019799

Browse files
author
Dmitri Tikhonov
committed
Latest changes
- Add support for Mac OS - Add support for Raspberry Pi - Fix BoringSSL compilation: include <openssl/hmac.h> explicitly
1 parent 50aadb3 commit e019799

16 files changed

+221
-75
lines changed

CHANGELOG

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2017-09-26
2+
3+
- Add support for Mac OS
4+
- Add support for Raspberry Pi
5+
- Fix BoringSSL compilation: include <openssl/hmac.h> explicitly
6+
7+
2017-09-22
8+
9+
- Initial release

CMakeLists.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ MESSAGE(STATUS "DEVEL_MODE: ${DEVEL_MODE}")
2828
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wall -Wextra -Wno-unused-parameter")
2929
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fno-omit-frame-pointer")
3030

31-
IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
31+
IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.3)
3232
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wno-missing-field-initializers")
3333
ENDIF()
3434
IF(DEVEL_MODE EQUAL 1)
@@ -58,12 +58,15 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_FLAGS} $ENV{EXTRA_CFLAGS}")
5858

5959
MESSAGE(STATUS "Compiler flags: ${CMAKE_C_FLAGS}")
6060

61+
IF(NOT DEFINED BORINGSSL_INCLUDE)
62+
include_directories( /usr/local/lib )
63+
ENDIF()
64+
IF(NOT DEFINED BORINGSSL_LIB)
65+
link_directories( /usr/local/include )
66+
ENDIF()
6167

6268
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
6369
include_directories( include )
64-
include_directories( ${BORINGSSL_INCLUDE} )
65-
66-
link_directories( ${BORINGSSL_LIB} )
6770

6871
IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
6972
# Find libevent on FreeBSD:
@@ -73,7 +76,7 @@ ENDIF()
7376

7477
add_executable(http_client test/http_client.c test/prog.c test/test_common.c test/test_cert.c)
7578

76-
target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a libdecrepit.a ${FIULIB} z m)
79+
target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a ${FIULIB} z m)
7780

7881
add_subdirectory(src)
7982

EXAMPLES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Fetch Google's home page:
1111

1212
./http_client -H www.google.com -s 74.125.22.106:443 -p /
1313

14+
or even
15+
16+
./http_client -H www.google.co.uk -s 2a00:1450:4009:80c::2003:443 -p /
17+
1418
In the example above, -H specifies the domain; it is also used as the value
1519
of SNI paramater in the handshake.
1620

README.md

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,100 @@ Documentation
2121

2222
The documentation for this module is admittedly sparse. The API is
2323
documented in include/lsquic.h. If you have doxygen, you can run
24-
`doxygen dox.cfg' or `make docs'. The example program is
24+
`doxygen dox.cfg` or `make docs`. The example program is
2525
test/http_client.c: a bare-bones, but working, QUIC client. Have a look
2626
in EXAMPLES.txt to see how it can be used.
2727

28-
Building
29-
--------
28+
Requirements
29+
------------
3030

31-
To build LSQUIC, you need CMake and BoringSSL. The example program
32-
uses libevent to provide the event loop. In short:
31+
To build LSQUIC, you need CMake, zlib, and BoringSSL. The example program
32+
uses libevent to provide the event loop.
3333

34-
cmake -DBORINGSSL_INCLUDE=/some/dir -DBORINGSSL_LIB=/some/other/dir .
34+
Building BoringSSL
35+
------------------
36+
37+
BoringSSL is not packaged; you have to build it yourself. The process is
38+
straightforward. You will need `go` installed.
39+
40+
1. Clone BoringSSL by issuing the following command:
41+
42+
```
43+
git clone https://boringssl.googlesource.com/boringssl
44+
cd boringssl
45+
```
46+
47+
2. Check out stable branch:
48+
49+
```
50+
git co chromium-stable
51+
```
52+
53+
3. Compile the library
54+
55+
```
56+
cmake . && make
57+
```
58+
59+
If you want to turn on optimizations, do
60+
61+
```
62+
cmake -DCMAKE_BUILD_TYPE=Release . && make
63+
```
64+
65+
4. Install the library
66+
67+
This is the manual step. You will need to copy library files manually.
68+
LSQUIC client library needs two: `ssl/libssl.a` and `crypto/libcrypto.a`.
69+
To install these in `/usr/local/lib`, you should do the following:
70+
71+
```
72+
BORINGSSL_SOURCE=$PWD
73+
cd /usr/local/lib
74+
sudo cp $BORINGSSL_SOURCE/ssl/libssl.a
75+
sudo cp $BORINGSSL_SOURCE/crypto/libcrypto.a
76+
```
77+
78+
If you do not want to install the library (or do not have root), you
79+
can do this instead:
80+
81+
```
82+
BORINGSSL_SOURCE=$PWD
83+
mkdir -p $HOME/tmp/boringssl-libs
84+
cd $HOME/tmp/boringssl-libs
85+
ln -s $BORINGSSL_SOURCE/ssl/libssl.a
86+
ln -s $BORINGSSL_SOURCE/crypto/libcrypto.a
87+
```
88+
89+
Building LSQUIC Client Library
90+
------------------------------
91+
92+
LSQUIC's `http_client` and the tests link BoringSSL libraries statically.
93+
Following previous section, you can build LSQUIC as follows:
94+
95+
```
96+
cmake -DBORINGSSL_INCLUDE=$BORINGSSL_SOURCE/include \
97+
-DBORINGSSL_LIB=$HOME/tmp/boringssl-libs .
98+
make
99+
```
100+
101+
Run tests:
102+
103+
```
104+
make test
105+
```
106+
107+
Platforms
108+
---------
109+
110+
The client library has been tested on the following platforms:
111+
- Linux
112+
- x86_64
113+
- ARM (Raspberry Pi 3)
114+
- FreeBSD
115+
- i386
116+
- MacOS
117+
- x86_64
35118

36119
Have fun,
37120

src/liblsquic/lsquic_crypto.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <openssl/x509.h>
99
#include <openssl/rand.h>
1010
#include <openssl/curve25519.h>
11+
#include <openssl/hmac.h>
1112

1213
#include <zlib.h>
1314

src/liblsquic/lsquic_full_conn.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,12 +1907,6 @@ process_stream_ready_to_send (struct full_conn *conn, lsquic_stream_t *stream,
19071907
{
19081908
if (LSQUIC_STREAM_HANDSHAKE == stream->id)
19091909
{
1910-
#if LSQUIC_STREAM_HANDSHAKE
1911-
/* Full connection implies that the server has completed the
1912-
* handshake:
1913-
*/
1914-
assert(0 == (conn->fc_flags & FC_SERVER));
1915-
#endif
19161910
/* Handshake messages are sent in brand-new packets. If handshake
19171911
* is not complete, the packet is zero-padded.
19181912
*/

src/liblsquic/lsquic_parse_gquic_be.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
#define bswap_16 bswap16
1414
#define bswap_32 bswap32
1515
#define bswap_64 bswap64
16+
#elif defined(__APPLE__)
17+
#include <libkern/OSByteOrder.h>
18+
#define bswap_16 OSSwapInt16
19+
#define bswap_32 OSSwapInt32
20+
#define bswap_64 OSSwapInt64
1621
#else
1722
#include <byteswap.h>
1823
#endif

src/liblsquic/lsquic_stream.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,13 +498,13 @@ lsquic_stream_write_avail (const lsquic_stream_t *stream)
498498
conn_avail = lsquic_conn_cap_avail(&stream->conn_pub->conn_cap);
499499
if (conn_avail < stream_avail)
500500
{
501-
LSQ_DEBUG("stream %u write buffer is limited by connection: %jd",
502-
stream->id, conn_avail);
501+
LSQ_DEBUG("stream %u write buffer is limited by connection: "
502+
"%"PRIu64, stream->id, conn_avail);
503503
return conn_avail;
504504
}
505505
}
506506

507-
LSQ_DEBUG("stream %u write buffer is limited by stream: %jd",
507+
LSQ_DEBUG("stream %u write buffer is limited by stream: %"PRIu64,
508508
stream->id, stream_avail);
509509
return stream_avail;
510510
}

test/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Copyright (c) 2017 LiteSpeed Technologies Inc. See LICENSE.
22

3+
INCLUDE(CheckSymbolExists)
4+
5+
CHECK_SYMBOL_EXISTS(
6+
IP_MTU_DISCOVER
7+
"netinet/in.h"
8+
HAVE_IP_MTU_DISCOVER
9+
)
10+
11+
CHECK_SYMBOL_EXISTS(
12+
IP_DONTFRAG
13+
"netinet/in.h"
14+
HAVE_IP_DONTFRAG
15+
)
16+
17+
18+
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test_config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/test_config.h)
19+
320

421
add_subdirectory(unittests)
522

test/prog.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "../src/liblsquic/lsquic_hash.h"
1616
#include "../src/liblsquic/lsquic_logger.h"
1717

18+
#include "test_config.h"
1819
#include "test_cert.h"
1920
#include "test_common.h"
2021
#include "prog.h"
@@ -86,7 +87,9 @@ prog_print_common_options (const struct prog *prog, FILE *out)
8687
" is used.\n"
8788
" -i USEC Library will `tick' every USEC microseconds. The default\n"
8889
" is %u\n"
90+
#if LSQUIC_DONTFRAG_SUPPORTED
8991
" -D Set `do not fragment' flag on outgoing UDP packets\n"
92+
#endif
9093
" -z BYTES Maximum size of outgoing UDP packets. The default is 1370\n"
9194
" bytes for IPv4 socket and 1350 bytes for IPv6 socket\n"
9295
" -L LEVEL Log level for all modules. Possible values are `debug',\n"
@@ -142,6 +145,7 @@ prog_set_opt (struct prog *prog, int opt, const char *arg)
142145
case 'i':
143146
prog->prog_period_usec = atoi(arg);
144147
return 0;
148+
#if LSQUIC_DONTFRAG_SUPPORTED
145149
case 'D':
146150
{
147151
struct service_port *sport = TAILQ_LAST(prog->prog_sports, sport_head);
@@ -150,6 +154,7 @@ prog_set_opt (struct prog *prog, int opt, const char *arg)
150154
sport->sp_flags |= SPORT_DONT_FRAGMENT;
151155
}
152156
return 0;
157+
#endif
153158
case 'm':
154159
prog->prog_packout_max = atoi(arg);
155160
return 0;

0 commit comments

Comments
 (0)