Move to liberty

This commit is contained in:
Přemysl Eric Janouch 2015-02-28 21:57:57 +01:00
parent 2dccb650bb
commit 2e44af621d
11 changed files with 25 additions and 2196 deletions

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "http-parser"] [submodule "http-parser"]
path = http-parser path = http-parser
url = git://github.com/joyent/http-parser.git url = git://github.com/joyent/http-parser.git
[submodule "liberty"]
path = liberty
url = git://github.com/pjanouch/liberty.git

View File

@ -51,7 +51,7 @@ list (APPEND project_libraries
include_directories (${libssl_INCLUDE_DIRS} ${jansson_INCLUDE_DIRS}) include_directories (${libssl_INCLUDE_DIRS} ${jansson_INCLUDE_DIRS})
# Project source files # Project source files
set (project_sources ${PROJECT_NAME}.c siphash.c) set (project_sources ${PROJECT_NAME}.c)
set (project_headers ${PROJECT_BINARY_DIR}/config.h) set (project_headers ${PROJECT_BINARY_DIR}/config.h)
# Generate a configuration file # Generate a configuration file

1
liberty Submodule

@ -0,0 +1 @@
Subproject commit 087645848baec5e59e4296817850bd5dd240cbb2

View File

@ -18,8 +18,10 @@
* *
*/ */
#include "../utils.c" #include "config.h"
#include "../liberty/liberty.c"
#include "../plugin-api.h" #include "../plugin-api.h"
#include "../http-parser/http_parser.h" #include "../http-parser/http_parser.h"
// --- Service detection ------------------------------------------------------- // --- Service detection -------------------------------------------------------

View File

@ -18,7 +18,8 @@
* *
*/ */
#include "../utils.c" #include "config.h"
#include "../liberty/liberty.c"
#include "../plugin-api.h" #include "../plugin-api.h"
// --- IRC utilities ----------------------------------------------------------- // --- IRC utilities -----------------------------------------------------------

View File

@ -20,7 +20,8 @@
// I can't really recommend using this interface as it adds a lot of overhead // I can't really recommend using this interface as it adds a lot of overhead
#include "../utils.c" #include "config.h"
#include "../liberty/liberty.c"
#include "../plugin-api.h" #include "../plugin-api.h"
#include <dirent.h> #include <dirent.h>

View File

@ -18,7 +18,8 @@
* *
*/ */
#include "../utils.c" #include "config.h"
#include "../liberty/liberty.c"
#include "../plugin-api.h" #include "../plugin-api.h"
// --- Service detection ------------------------------------------------------- // --- Service detection -------------------------------------------------------

View File

@ -18,8 +18,13 @@
* *
*/ */
#include "utils.c" #define LIBERTY_WANT_SSL
#define LIBERTY_WANT_POLLER
#include "config.h"
#include "liberty/liberty.c"
#include "plugin-api.h" #include "plugin-api.h"
#include <inttypes.h> #include <inttypes.h>
#include <dirent.h> #include <dirent.h>
@ -150,7 +155,7 @@ print_bold (FILE *stream, const char *s)
struct port_range struct port_range
{ {
LIST_HEADER (port_range) LIST_HEADER (struct port_range)
uint16_t start; ///< The beginning of the range uint16_t start; ///< The beginning of the range
uint16_t end; ///< The end of the range uint16_t end; ///< The end of the range
}; };
@ -165,7 +170,7 @@ port_range_delete (struct port_range *self)
struct ip_range struct ip_range
{ {
LIST_HEADER (ip_range) LIST_HEADER (struct ip_range)
uint32_t start; ///< The beginning of the range uint32_t start; ///< The beginning of the range
uint32_t end; ///< The end of the range uint32_t end; ///< The end of the range
@ -184,7 +189,7 @@ ip_range_delete (struct ip_range *self)
struct target struct target
{ {
LIST_HEADER (target) LIST_HEADER (struct target)
size_t ref_count; ///< Reference count size_t ref_count; ///< Reference count
struct app_context *ctx; ///< Application context struct app_context *ctx; ///< Application context
@ -210,7 +215,7 @@ static void target_unref (struct target *self);
struct unit struct unit
{ {
LIST_HEADER (unit) LIST_HEADER (struct unit)
size_t ref_count; ///< Reference count size_t ref_count; ///< Reference count
struct target *target; ///< Target context struct target *target; ///< Target context
@ -250,7 +255,7 @@ enum transport_io_result
// The only real purpose of this is to abstract away TLS/SSL // The only real purpose of this is to abstract away TLS/SSL
struct transport struct transport
{ {
LIST_HEADER (transport) LIST_HEADER (struct transport)
const char *name; ///< Name of the transport const char *name; ///< Name of the transport

View File

@ -1,87 +0,0 @@
// Code taken from https://github.com/floodyberry/siphash with some edits.
//
// To the extent possible under law, the author(s) have dedicated all copyright
// and related and neighboring rights to this software to the public domain
// worldwide. This software is distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along
// with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
#include "siphash.h"
inline static uint64_t
u8to64_le (const unsigned char *p)
{
return
(uint64_t) p[0] |
(uint64_t) p[1] << 8 |
(uint64_t) p[2] << 16 |
(uint64_t) p[3] << 24 |
(uint64_t) p[4] << 32 |
(uint64_t) p[5] << 40 |
(uint64_t) p[6] << 48 |
(uint64_t) p[7] << 56 ;
}
uint64_t
siphash (const unsigned char key[16], const unsigned char *m, size_t len)
{
uint64_t v0, v1, v2, v3;
uint64_t mi, k0, k1;
uint64_t last7;
size_t i, blocks;
k0 = u8to64_le (key + 0);
k1 = u8to64_le (key + 8);
v0 = k0 ^ 0x736f6d6570736575ull;
v1 = k1 ^ 0x646f72616e646f6dull;
v2 = k0 ^ 0x6c7967656e657261ull;
v3 = k1 ^ 0x7465646279746573ull;
last7 = (uint64_t) (len & 0xff) << 56;
#define ROTL64(a,b) (((a)<<(b))|((a)>>(64-b)))
#define COMPRESS \
v0 += v1; v2 += v3; \
v1 = ROTL64 (v1,13); v3 = ROTL64 (v3,16); \
v1 ^= v0; v3 ^= v2; \
v0 = ROTL64 (v0,32); \
v2 += v1; v0 += v3; \
v1 = ROTL64 (v1,17); v3 = ROTL64 (v3,21); \
v1 ^= v2; v3 ^= v0; \
v2 = ROTL64(v2,32);
for (i = 0, blocks = (len & ~(size_t) 7); i < blocks; i += 8)
{
mi = u8to64_le (m + i);
v3 ^= mi;
COMPRESS
COMPRESS
v0 ^= mi;
}
switch (len - blocks)
{
case 7: last7 |= (uint64_t) m[i + 6] << 48;
case 6: last7 |= (uint64_t) m[i + 5] << 40;
case 5: last7 |= (uint64_t) m[i + 4] << 32;
case 4: last7 |= (uint64_t) m[i + 3] << 24;
case 3: last7 |= (uint64_t) m[i + 2] << 16;
case 2: last7 |= (uint64_t) m[i + 1] << 8;
case 1: last7 |= (uint64_t) m[i + 0] ;
default:;
};
v3 ^= last7;
COMPRESS
COMPRESS
v0 ^= last7;
v2 ^= 0xff;
COMPRESS
COMPRESS
COMPRESS
COMPRESS
return v0 ^ v1 ^ v2 ^ v3;
}

View File

@ -1,10 +0,0 @@
#ifndef SIPHASH_H
#define SIPHASH_H
#include <stdint.h>
#include <stdlib.h>
uint64_t siphash (const unsigned char key[16],
const unsigned char *m, size_t len);
#endif // SIPHASH_H

2088
utils.c

File diff suppressed because it is too large Load Diff