MIT License
-Copyright (c) 2018 NIC Mexico
+Copyright (c) 2019 NIC Mexico
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
# Man, GNU conventions need a 21 century overhaul badly.
AUTOMAKE_OPTIONS = foreign
-SUBDIRS = src man $(MAYBE_TESTS)
-DIST_SUBDIRS = src man
+SUBDIRS = src man test
# Run this file to generate the configure script.
# You'll need Autoconf and Automake installed!
-autoreconf --install
+autoreconf --install --force
)
# Dependencies managed by pkg-config
-
-PKG_CHECK_MODULES([JANSSON], [jansson])
-
# By the way: Apparently PKG_CHECK_MODULES is poor practice now. I can't tell;
# it's always the same guy complaining about it in Stack Overflow.
# (Main one: https://stackoverflow.com/questions/10220946)
# But I couldn't make check work with AC_SEARCH_LIBS, and (probably due to
# typical obscure bullshit autotools reasoning) I have no idea why.
-
-AC_ARG_WITH(
- [unit-tests],
- AS_HELP_STRING(
- [--with-unit-tests],
- [Generate unit tests. (Requires check)]
- )
-)
-
-# https://www.gnu.org/software/automake/manual/html_node/Conditional-Subdirectories.html
-# "Subdirectories with AM_CONDITIONAL" never worked for me. The problem might
-# be that it puts `MAYBE_TESTS` in `.PRECIOUS`, which maybe is a bug in the
-# autotools. (I honestly can't tell. They are so incredibly poorly designed.)
-# The code below is implemented as "Subdirectories with AC_SUBST."
-if test "x$with_unit_tests" = "xyes"; then
- PKG_CHECK_MODULES([CHECK], [check])
- MAYBE_TESTS=test
-else
- MAYBE_TESTS=
-fi
-AC_SUBST([MAYBE_TESTS])
+PKG_CHECK_MODULES([JANSSON], [jansson])
+PKG_CHECK_MODULES([CHECK], [check], [usetests=yes], [usetests=no])
+AM_CONDITIONAL([USE_TESTS], [test "x$usetests" = "xyes"])
# Spit out the makefiles.
AC_OUTPUT(Makefile src/Makefile man/Makefile test/Makefile)
2. [Debian-based distributions](#debian-based-distributions)
3. [OpenBSD](#openbsd)
+## Introduction
+
+Currently, you have three options:
+
+- The Debian package: Easiest; for Debian-based distributions only.
+- The generic autotools-based "upstream" tarball: For most (if not all) other users.
+- Compiling on the git repository: Best for developers.
+
+## Debian package
+
+
+
## Dependencies
> Note: I'm only including this section in case you intend to install Fort in an unlisted OS (and therefore need a little research). For Debians and OpenBSD, just follow the steps in the sections below.
-man_MANS = rtr_server.8
+dist_man_MANS = fort.8
fort_SOURCES += rtr/db/delta.c rtr/db/delta.h
fort_SOURCES += rtr/db/roa_table.c rtr/db/roa_table.h
fort_SOURCES += rtr/db/roa.c rtr/db/roa.h
+fort_SOURCES += rtr/db/vrp.h
fort_SOURCES += rtr/db/vrps.c rtr/db/vrps.h
fort_SOURCES += slurm/slurm_db.c slurm/slurm_db.h
#include "incidence/incidence.h"
/*
- * __dead is supposed to be defined in sys/cdefs.h, but is apparently not
- * portable.
+ * According to BSD style, __dead is supposed to be defined in sys/cdefs.h,
+ * but it doesn't exist in Linux.
*/
#ifndef __dead
#if __GNUC__
#define __dead __attribute__((noreturn))
#else
-#define __dead
+#define __dead /* Nothing */
#endif
#endif
+if USE_TESTS
+
# Reminder: `make check`
-# Your `./configure` needs to have included the `--with-unit-tests` flag.
# If you want to only run one test, do `make check TESTS=<test>`.
# Example: `make check TESTS=address`
# "my" own "ldadd". Unlike AM_CFLAGS, it needs to be manually added to every
# target.
MY_LDADD = ${CHECK_LIBS}
-BASIC_MODULES = ../src/log.c ../src/log.h
-BASIC_MODULES += impersonator.c
-
-SLURM_SOURCES = ../src/address.c ../src/address.h
-SLURM_SOURCES += ../src/json_parser.c ../src/json_parser.h
-SLURM_SOURCES += ../src/crypto/base64.c ../src/crypto/base64.h
-SLURM_SOURCES += ../src/slurm/slurm_db.c ../src/slurm/slurm_db.h
-SLURM_SOURCES += ../src/slurm/slurm_loader.c
-SLURM_SOURCES += ../src/slurm/slurm_loader.h
-SLURM_SOURCES += ../src/slurm/slurm_parser.c
-SLURM_SOURCES += ../src/slurm/slurm_parser.h
check_PROGRAMS = address.test
check_PROGRAMS += clients.test
#check_PROGRAMS += rtr/primitive_reader.test
TESTS = ${check_PROGRAMS}
-address_test_SOURCES = ${BASIC_MODULES}
-address_test_SOURCES += ../src/address.h
-address_test_SOURCES += address_test.c
+address_test_SOURCES = address_test.c
address_test_LDADD = ${MY_LDADD}
-clients_test_SOURCES = ${BASIC_MODULES}
-clients_test_SOURCES += ../src/clients.c
-clients_test_SOURCES += ../src/common.c
-clients_test_SOURCES += client_test.c
+clients_test_SOURCES = client_test.c
clients_test_LDADD = ${MY_LDADD}
-line_file_test_SOURCES = ${BASIC_MODULES}
-line_file_test_SOURCES += ../src/file.c ../src/file.h
-line_file_test_SOURCES += ../src/line_file.c ../src/line_file.h
-line_file_test_SOURCES += line_file_test.c
+line_file_test_SOURCES = line_file_test.c
line_file_test_LDADD = ${MY_LDADD}
-pdu_handler_test_SOURCES = ${BASIC_MODULES}
-pdu_handler_test_SOURCES += ${SLURM_SOURCES}
-pdu_handler_test_SOURCES += ../src/common.c
-pdu_handler_test_SOURCES += ../src/file.c
-pdu_handler_test_SOURCES += ../src/output_printer.c
-pdu_handler_test_SOURCES += ../src/rtr/pdu_handler.c
-pdu_handler_test_SOURCES += ../src/rtr/err_pdu.c
-pdu_handler_test_SOURCES += ../src/rtr/db/delta.c
-pdu_handler_test_SOURCES += ../src/rtr/db/roa_table.c
-pdu_handler_test_SOURCES += ../src/rtr/db/vrps.c
-pdu_handler_test_SOURCES += rtr/db/impersonator.c
-pdu_handler_test_SOURCES += rtr/pdu_handler_test.c
+pdu_handler_test_SOURCES = rtr/pdu_handler_test.c
pdu_handler_test_LDADD = ${MY_LDADD} ${JANSSON_LIBS}
-roa_table_test_SOURCES = ${BASIC_MODULES}
-roa_table_test_SOURCES += ../src/address.c
-roa_table_test_SOURCES += ../src/rtr/db/delta.c
-roa_table_test_SOURCES += ../src/rtr/db/roa_table.c
-roa_table_test_SOURCES += rtr/db/roa_table_test.c
+roa_table_test_SOURCES = rtr/db/roa_table_test.c
roa_table_test_LDADD = ${MY_LDADD}
-rsync_test_SOURCES = ${BASIC_MODULES}
-rsync_test_SOURCES += ../src/str.c ../src/str.h
-rsync_test_SOURCES += ../src/uri.c ../src/uri.h
-rsync_test_SOURCES += rsync_test.c
+rsync_test_SOURCES = rsync_test.c
rsync_test_LDADD = ${MY_LDADD}
#tal_test_SOURCES = ${BASIC_MODULES}
-#tal_test_SOURCES += ../src/file.c ../src/file.h
-#tal_test_SOURCES += ../src/crypto/base64.c ../src/crypto/base64.h
-#tal_test_SOURCES += ../src/random.c ../src/random.h
-#tal_test_SOURCES += ../src/str.c ../src/str.h
-#tal_test_SOURCES += ../src/uri.c ../src/uri.h
-#tal_test_SOURCES += ../src/line_file.c ../src/line_file.h
+#tal_test_SOURCES += ../src/file.c
+#tal_test_SOURCES += ../src/crypto/base64.c
+#tal_test_SOURCES += ../src/random.c
+#tal_test_SOURCES += ../src/str.c
+#tal_test_SOURCES += ../src/uri.c
+#tal_test_SOURCES += ../src/line_file.c
#tal_test_SOURCES += tal_test.c
#tal_test_LDADD = ${MY_LDADD}
-vcard_test_SOURCES = ${BASIC_MODULES}
-vcard_test_SOURCES += vcard_test.c
+vcard_test_SOURCES = vcard_test.c
vcard_test_LDADD = ${MY_LDADD}
-vrps_test_SOURCES = ${BASIC_MODULES}
-vrps_test_SOURCES += ${SLURM_SOURCES}
-vrps_test_SOURCES += ../src/common.c
-vrps_test_SOURCES += ../src/file.c
-vrps_test_SOURCES += ../src/output_printer.c
-vrps_test_SOURCES += ../src/rtr/db/delta.c
-vrps_test_SOURCES += ../src/rtr/db/roa_table.c
-vrps_test_SOURCES += ../src/rtr/db/vrps.c
-vrps_test_SOURCES += rtr/db/impersonator.c
-vrps_test_SOURCES += rtr/db/vrps_test.c
+vrps_test_SOURCES = rtr/db/vrps_test.c
vrps_test_LDADD = ${MY_LDADD} ${JANSSON_LIBS}
#rtr_pdu_test_SOURCES = ${BASIC_MODULES}
#rtr_primitive_reader_test_SOURCES += rtr/primitive_reader_test.c
#rtr_primitive_reader_test_SOURCES += rtr/stream.c
#rtr_primitive_reader_test_LDADD = ${MY_LDADD}
+
+EXTRA_DIST = impersonator.c
+EXTRA_DIST += rtr/db/rtr_db_impersonator.c
+EXTRA_DIST += line_file/core.txt
+EXTRA_DIST += line_file/empty.txt
+EXTRA_DIST += line_file/error.txt
+
+endif
# Unit Tests
-This code is left out of the build by default. If you want to run the tests, configure like this (in the parent directory):
-
- ./configure --with-unit-tests
-
-Then, to actually run the tests, use
+Run with
make check
-#include "address.c"
-
#include <check.h>
#include <errno.h>
#include <stdlib.h>
+#include "address.c"
+#include "log.c"
+#include "impersonator.c"
+
static void
test_range4(uint32_t min, uint32_t max, bool valid)
{
-#include "clients.h"
-
#include <check.h>
#include <stdlib.h>
+#include "clients.c"
+#include "common.c"
+#include "log.c"
+#include "impersonator.c"
+
static int
handle_foreach(struct client const *client, void *arg)
{
static char addr_buffer2[INET6_ADDRSTRLEN];
char const *
-v4addr2str(struct in_addr *addr)
+v4addr2str(struct in_addr const *addr)
{
return inet_ntop(AF_INET, addr, addr_buffer1, sizeof(addr_buffer1));
}
char const *
-v4addr2str2(struct in_addr *addr)
+v4addr2str2(struct in_addr const *addr)
{
return inet_ntop(AF_INET, addr, addr_buffer2, sizeof(addr_buffer2));
}
char const *
-v6addr2str(struct in6_addr *addr)
+v6addr2str(struct in6_addr const *addr)
{
return inet_ntop(AF_INET6, addr, addr_buffer1, sizeof(addr_buffer1));
}
char const *
-v6addr2str2(struct in6_addr *addr)
+v6addr2str2(struct in6_addr const *addr)
{
return inet_ntop(AF_INET6, addr, addr_buffer2, sizeof(addr_buffer2));
}
-#include "line_file.h"
-
#include <check.h>
#include <errno.h>
#include <stdlib.h>
+#include "file.c"
+#include "impersonator.c"
+#include "line_file.c"
+#include "log.c"
+
START_TEST(file_line_normal)
{
struct line_file *lfile;
-#include "rsync/rsync.c"
-
#include <check.h>
#include <errno.h>
#include <stdlib.h>
-#include "common.h"
+#include "log.c"
+#include "impersonator.c"
+#include "str.c"
+#include "uri.c"
+#include "rsync/rsync.c"
START_TEST(rsync_load_normal)
{
#include <check.h>
#include <stdlib.h>
-#include "thread_var.h"
-#include "rtr/db/roa_table.h"
+
+#include "address.c"
+#include "log.c"
+#include "impersonator.c"
+#include "rtr/db/delta.c"
+#include "rtr/db/roa_table.c"
#define ADDR1 htonl(0xC0000201) /* 192.0.2.1 */
#define ADDR2 htonl(0xC0000202) /* 192.0.2.2 */
-#include "object/tal.h"
-
#include <check.h>
+#include "object/tal.h"
static int iteration = 0;
#include <stdbool.h>
#include <stdlib.h>
-#include "common.h"
-#include "thread_var.h"
-#include "validation_handler.h"
-#include "rtr/db/vrps.h"
+#include "address.c"
+#include "crypto/base64.c"
+#include "common.c"
+#include "file.c"
+#include "impersonator.c"
+#include "json_parser.c"
+#include "log.c"
+#include "output_printer.c"
+#include "rtr/db/delta.c"
+#include "rtr/db/roa_table.c"
+#include "rtr/db/rtr_db_impersonator.c"
+#include "rtr/db/vrps.c"
+#include "slurm/slurm_db.c"
+#include "slurm/slurm_loader.c"
+#include "slurm/slurm_parser.c"
/* -- Expected database descriptors -- */
serial_t current_min_serial = 0;
-serial_t
+int
clients_get_min_serial(serial_t *result)
{
*result = current_min_serial;
#include <stdlib.h>
#include <sys/queue.h>
-#include "validation_handler.h"
-#include "rtr/pdu.h"
-#include "rtr/pdu_handler.h"
-#include "rtr/pdu_sender.h"
-#include "rtr/db/vrps.h"
+#include "address.c"
+#include "common.c"
+#include "file.c"
+#include "impersonator.c"
+#include "json_parser.c"
+#include "log.c"
+#include "output_printer.c"
+#include "crypto/base64.c"
+#include "rtr/pdu_handler.c"
+#include "rtr/err_pdu.c"
+#include "rtr/db/delta.c"
+#include "rtr/db/roa_table.c"
+#include "rtr/db/rtr_db_impersonator.c"
+#include "rtr/db/vrps.c"
+#include "slurm/slurm_db.c"
+#include "slurm/slurm_loader.c"
+#include "slurm/slurm_parser.c"
/* Helper functions */
/* Impersonator functions */
-serial_t
+int
clients_get_min_serial(serial_t *result)
{
*result = 0;
-#include "object/vcard.c"
-
#include <check.h>
+#include "log.c"
+#include "impersonator.c"
+#include "object/vcard.c"
+
#define VC_BEGIN "BEGIN:VCARD\r\n"
#define VC_VERSION "VERSION:4.0\r\n"
#define VC_FN "FN:name\r\n"