Skip to content

Commit

Permalink
Added LillyPass (levels 0,1,2) and CMakeLists.txt with CTest / CPack …
Browse files Browse the repository at this point in the history
…support

This is getting good enough to call it a 0.3 release, I suppose.
  • Loading branch information
vanrein committed Jan 29, 2017
1 parent 9a00e83 commit 6ae4440
Show file tree
Hide file tree
Showing 18 changed files with 759 additions and 113 deletions.
139 changes: 109 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,68 @@ pkg_search_module (
)


#
# Version Information
#

find_package (Git)

exec_program (
${GIT_EXECUTABLE}
ARGS diff --quiet
RETURN_VALUE GIT_HAVE_CHANGES
)

exec_program (
${GIT_EXECUTABLE}
ARGS describe --tags --match 'version-*.*-*'
OUTPUT_VARIABLE GIT_VERSION_INFO
)

string (
REGEX REPLACE "^version-([1-9][0-9]*|0)[.]([1-9][0-9]*|0)-(.*)$"
"\\1"
GIT_VERSION_MAJOR
${GIT_VERSION_INFO}
)

string (
REGEX REPLACE "^version-([1-9][0-9]*|0)[.]([1-9][0-9]*|0)-(.*)$"
"\\2"
GIT_VERSION_MINOR
${GIT_VERSION_INFO}
)

if (GIT_HAVE_CHANGES EQUAL 0)

string (
REGEX REPLACE "^version-([1-9][0-9]*|0)[.]([1-9][0-9]*|0)-(.*)$"
"\\3"
GIT_VERSION_PATCHLEVEL
${GIT_VERSION_INFO}
)

set (
USER_SUPPLIED_PATCHLEVEL
"${GIT_VERSION_PATCHLEVEL}"
CACHE STRING "User-override for patch level under ${GIT_VERSION_MAJOR}.${GIT_VERSION_MINOR}"
)

else()

exec_program (
date
ARGS '+%Y%m%d-%H%M%S'
OUTPUT_VARIABLE GIT_CHANGES_TIMESTAMP
)
set (GIT_VERSION_PATCHLEVEL "local-${GIT_CHANGES_TIMESTAMP}")
message (WARNING "Git reports local changes, fixing patch level to local-${GIT_CHANGES_TIMESTAMP}")

unset (USER_SUPPLIED_PATCHLEVEL CACHE)

endif()


#
# Building
#
Expand Down Expand Up @@ -98,10 +160,13 @@ add_custom_target (
SOURCES lib/msgop.gperf
)

add_dependencies (lillydapStatic msgop.tab openpa)
add_dependencies (lillydapShared msgop.tab openpa)
add_dependencies (lillydapStatic msgop.tab)
add_dependencies (lillydapShared msgop.tab)
if (NOT ${BUILD_SINGLE_THREADED})
add_dependencies (lillydapStatic openpa)
add_dependencies (lillydapShared openpa)
endif()

#TODO# Dit komt met /usr/local onterecht ook in CPack terecht
configure_file (
contrib/pkgconfig/lillydap.pc.in
${PROJECT_BINARY_DIR}/lillydap.pc
Expand All @@ -116,7 +181,7 @@ configure_file (
enable_testing ()

add_executable (
lillydump.test #TODO# EXCLUDE_FROM_ALL
lillydump.test
test/lillydump.c
lib/mem.c
lib/derbuf.c
Expand All @@ -135,30 +200,32 @@ target_link_libraries (
${QuickDER_LDFLAGS} #TODO# Proper form, _LDFLAGS???
)

add_executable (
stampede.test #TODO# EXCLUDE_FROM_ALL
test/stampede.c
lib/mem.c
lib/queue.c
lib/sillymem.c
)
set_target_properties (
stampede.test
PROPERTIES COMPILE_DEFINITIONS USE_SILLYMEM
)
#TODO# Really -pthread, literally?!?
if(THREADS_HAVE_PTHREAD_ARG)
target_compile_options(stampede.test "-pthread")
if (NOT ${BUILD_SINGLE_THREADED})
add_executable (
stampede.test
test/stampede.c
lib/mem.c
lib/queue.c
lib/sillymem.c
)
set_target_properties (
stampede.test
PROPERTIES COMPILE_DEFINITIONS USE_SILLYMEM
)
#TODO# Really -pthread, literally?!?
if(THREADS_HAVE_PTHREAD_ARG)
target_compile_options(stampede.test "-pthread")
endif()
target_link_libraries (
stampede.test
lillydapStatic
${QuickDER_LDFLAGS} #TODO# Proper form, _LDFLAGS???
${CMAKE_THREAD_LIBS_INIT} -lpthread
)
endif()
target_link_libraries (
stampede.test
lillydapStatic
${QuickDER_LDFLAGS} #TODO# Proper form, _LDFLAGS???
${CMAKE_THREAD_LIBS_INIT} -lpthread
)

add_executable (
lillypass.test #TODO# EXCLUDE_FROM_ALL
lillypass.test
test/lillypass.c
lib/mem.c
lib/derbuf.c
Expand Down Expand Up @@ -190,15 +257,18 @@ foreach (netpkg ${netpkgs})
endforeach()

#TODO# Test that all serials exist, in proper order, for each threadid
add_test (
NAME stampede.test
COMMAND stampede.test 250
)
if (NOT ${BUILD_SINGLE_THREADED})
# This is a test of lock-free concurrency, useless when single-threaded
add_test (
NAME stampede.test
COMMAND stampede.test 250
)
endif()

#TODO# Test that the output matches expectations
foreach (netpkg ${netpkgs})
get_filename_component (netpkgname ${netpkg} NAME)
foreach (level 0 1 2 3 4)
foreach (level 0 1 2) #TODO# 3 4
add_test (
NAME lillypass-level${level}-netpkg-${netpkgname}
COMMAND lillypass.test ${level} ${netpkg}
Expand Down Expand Up @@ -239,12 +309,21 @@ install (
# PACKAGING
#

set (CPACK_PACKAGE_VERSION_MAJOR ${GIT_VERSION_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${GIT_VERSION_MINOR})
if (GIT_HAVE_CHANGES EQUAL 0)
set (CPACK_PACKAGE_VERSION_PATCH ${USER_SUPPLIED_PATCHLEVEL})
else()
set (CPACK_PACKAGE_VERSION_PATCH "local-${GIT_CHANGES_TIMESTAMP}")
endif()

set (CPACK_BUNDLE_NAME "LillyDAP")
set (CPACK_PACKAGE_CONTACT "Rick van Rein <rick@openfortress.nl>")
set (CPACK_PACKAGE_VENDOR "ARPA2.net")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "LDAP devkit, turns LDAP operations into functions/callbacks")
set (CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README.MD)
set (CPACK_GENERATOR DEB RPM)
set (CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})

include (CPack)

Expand Down
86 changes: 86 additions & 0 deletions INSTALL.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Installing LillyDAP

> *You should be able to get started with LillyDAP quite easily.*

## Requirements

Runtime requirements:

* [Quick DER](http://github.com/vanrein/quick-der)
* We may add `libpcre` later, for optional attrtype syntax checking

Building requirements:

* C compiler (we test with `gcc`)
* [CMake](https://cmake.org)

Packaging requirements:

* `rpmbuild` to build an RPM package for RedHat, SuSe, Fedora
* `dpkg-buildpackage` to build a DEB package for Debian, Ubuntu, Mint
* `makensis` to build a Nullsoft Installer for Windows

By default, both the generators `RPM` and `DEB` are used.
You can select what packages to provide by selecting a generator in the
CPack command, for instance

cpack -G NSIS


## Configuration Choices

We use atomic operations to achieve lock-free concurrency. If you are in a
single-threaded environment, you do not need those. You will be able to set
the `BUILD_SINGLE_THREADED` option to replace atomic operations with simpler
ones. You will break the lock-free concurrency model if you use
multi-threading on any such setups.

The major and minor version will be derived from Git automatically. The
same goes for the patch level, which may however be locally overridden by
package makers if they so desire. The one exception is when Git has local
changes; in that case, the patch level must be supplied by the user; a
warning will be emitted from CMake and the string is set to `local-` and
a timestamp in `YYYYMMDD-hhmmss` notation.

To make configuration changes, use either `ccmake` or `cmake-gui` instead
of `cmake` when building. A first pass gives you the option that you can
override. Or, to automate this choice, you could use

cmake -D BUILD_SINGLE_THREADED:BOOL=ON ..


## Building, Testing and Packaging

We advise out-of-source builds, even though we have a few items on our
TODO list that require preparations inside the code tree for now.

cd lillydap
mkdir build
cd build

In this build directory, configure using defaults, or use a variant as
described under configuration. You need to reference the source tree
relative to the build directory, so `..` after the preparation above,

cmake ..

Then proceed to building,

make

You can now run the package's tests,

ctest

Finally, you can create packages, using `DEB` and `RPM` generators by
default, using

cpack

We will work to integrate LillyDAP with the [MXE](http://mxe.cc)
cross-building environment for Windows. You will then be able to
cross-package using

cpack -G NSIS

13 changes: 11 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Most of today's developers focus solely on HTTP to carry their data
definitions. This even happens when LDAP would be a better carrier, which
it usually is, due to much richer and finer-grained syntax and semantics.
it usually is because of its richer and finer-grained syntax and semantics.

But this isn't just about standards; it's also about the technology
implementing it. The most well-known open source directory is
Expand All @@ -19,7 +19,7 @@ and
storage-centric, though they add dynamicity options through mechanisms like
[overlays](http://www.openldap.org/doc/admin24/overlays.html)
and
[stored procedures with triggers](https://people.apache.org/~ersiner/ldapcon.2007/LDAPcon.2007_LDAP.Stored.Procedures.and.Triggers.in.ApacheDS_by.Ersin.Er_Paper.pdf)
[stored procedures with triggers](https://people.apache.org/~ersiner/ldapcon.2007/LDAPcon.2007_LDAP.Stored.Procedures.and.Triggers.in.ApacheDS_by.Ersin.Er_Paper.pdf).
In all cases, dynamicity is a bit of an afterthought, storage is central and
there is only limited facilitation for dynamicity.

Expand Down Expand Up @@ -353,3 +353,12 @@ The reverse flow direction will normally not be used until an
has asked for it, but as should be clear from this, Nginx holds good cards
for formulating treatment of the Turn operation in its configuration files.

## Related Work

* [ldapjs](http://ldapjs.org)
implements LDAP in JavaScript; it can use Node.JS to run as a server.
It can support middleware such as filters and proxies.

* [SteamWorks Crank](http://steamworks.arpa2.net/crank.html)
makes LDAP content available as JSON structures over a RESTful API.

26 changes: 25 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,31 @@
- the data will always be needed anyway
- generic handling: opcode table entry can list <index,subparse>

* Consider regex-checking text fields with constraining syntax
* Support individual operations such as lillyput_BindRequest()
- a generic version goes into opswi.c, as it reverses lillyget_operation()
- let's name the generic version lillyput_generic_operation()
- in addition, there are wrapper functions lillyput_BindRequest()
- wrappers can come as static inline functions, but can you point to them?
- http://stackoverflow.com/questions/8885665/c-pointer-to-inline-function
- should test this at varying -O levels and on various compilers == trouble
- it is simple to provide additional non-inlined functions in the library
- this is cheap in both .so and .a flavours -- the latter with inidividual .o

* Advance the testing framework
- check not only the exit code, but also the generated output
- see test/CMatch.c which starts off this idea
- wrap it in add_test() around lillydump.test and lillypass.test

* Consider regex-checking attributes with constraining syntax
- Ragel would be interesting to use, but we don't need to intersperse code
- libprce is probably more compact; it is already present in Nginx
- Would be friendly as a syntax checking conveniency, in style of LillyDAP
- Parts of the fields could be harvested (e.g. labeledURI's two pieces)
- This is probably best as a separate wrapper API calling generic code
- Split into separate .o as much as possible, for compaction of .a

* Have a dictionary API to manipulate controls; gperf may be used here too

* Support builds to be completely out-of-source
- Broken by the mapping from `.gperf` to `.tab`
- Broken by the imported `openpa` which is extracted and configured
11 changes: 11 additions & 0 deletions contrib/pkgconfig/lillydap.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib

Name: LillyDAP
Description: Little LDAP kernel: Event-based, lock-free, LDAP as storage RPC
Version: 0.1.1
Requires: Quick-DER
Cflags: -I${includedir}
Libs: -L${libdir} -llillydap
10 changes: 8 additions & 2 deletions include/lillydap/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct LillyConnection {
int (*lillyget_ldapmessage) (); //TODO//TYPING//MOVE_TO_STATIC
int (*lillyget_operation) (); //TODO//TYPING//MOVE_TO_STATIC
int (*lillyput_operation) (); //TODO//TYPING//MOVE_TO_STATIC
int (*lillyput_ldapmessage) (); //TODO//TYPING//MOVE_TO_STATIC
int (*lillyput_dercursor) (); //TODO//TYPING//MOVE_TO_STATIC
// Functions to implement the standard API
// (RFC-compatible wrappers are defined below)
Expand Down Expand Up @@ -125,12 +126,17 @@ int lillyget_operation (LDAP *lil,
* to the network.
*/
int lillyput_operation (LDAP *lil,
const LillyPool qpool,
LillyPool qpool,
const LillyMsgId msgid,
const uint8_t opcode,
const dercursor *data,
const dercursor controls);
int lillyput_dercursor (LDAP *lil, const dercursor dermsg); //TODO//
int lillyput_ldapmessage (LDAP *lil,
LillyPool qpool,
const LillyMsgId msgid,
const dercursor operation,
const dercursor controls);
int lillyput_dercursor (LillyDAP *lil, LillyPool qpool, dercursor dermsg);
void lillyput_enqueue (LillyDAP *lil, struct LillySend *addend);
bool lillyput_cansend (LillyDAP *lil);
int lillyput_event (LDAP *lil);
Expand Down
7 changes: 7 additions & 0 deletions include/lillydap/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ typedef struct LillySend {
void lillyput_enqueue (struct LillyConnection *lil, struct LillySend *addend);


/* Enqueue a message in a single dercursor. Normally, we supply a series of
* dermessages, so this is just there to mirror properly; it may actually be
* useful as a value for a lillyget_dercursor() pointer.
*/
int lillyput_dercursor (LillyDAP *lil, LillyPool qpool, dercursor dermsg);


/* Test if there is anything in the queue for LillyPut
*/
bool lillyput_cansend (struct LillyConnection *lil);
Expand Down
Loading

0 comments on commit 6ae4440

Please sign in to comment.