Permalink
Browse files

more work done on the build

  • Loading branch information...
1 parent 97b7cb9 commit fffb92caa871caa9c081f6d3ab601d83760beafc Caleb James DeLisle committed Dec 1, 2013
Showing with 531 additions and 410 deletions.
  1. +1 −1 admin/test/Admin_test.c
  2. +9 −6 admin/testframework/AdminTestFramework.c
  3. +1 −1 admin/testframework/AdminTestFramework.h
  4. +23 −0 crypto/CryptoAuth.c
  5. +1 −1 crypto/CryptoAuth_benchmark.c
  6. +11 −0 crypto/CryptoAuth_pvt.h
  7. +4 −15 crypto/random/seed/BsdKernArndSysctlRandomSeed.c
  8. +6 −2 crypto/random/seed/BsdKernArndSysctlRandomSeed.h
  9. +0 −9 crypto/random/seed/DevUrandomRandomSeed.c
  10. +6 −2 crypto/random/seed/DevUrandomRandomSeed.h
  11. +0 −9 crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.c
  12. +6 −2 crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.h
  13. +0 −8 crypto/random/seed/ProcSysKernelRandomUuidRandomSeed.c
  14. +6 −2 crypto/random/seed/ProcSysKernelRandomUuidRandomSeed.h
  15. +5 −14 crypto/{test/Exports.h → random/seed/RandomSeedProvider.h}
  16. +0 −12 crypto/random/seed/RtlGenRandomSeed.c
  17. +6 −2 crypto/random/seed/RtlGenRandomSeed.h
  18. +3 −18 crypto/random/seed/SystemRandomSeed.c
  19. +1 −1 crypto/random/test/Random_test.c
  20. +0 −1 crypto/test/CryptoAuth_test.c
  21. +14 −13 crypto/test/CryptoAuth_unit_test.c
  22. +0 −56 crypto/test/Exports.c
  23. +2 −0 dht/dhtcore/NodeStore.c
  24. +1 −1 dht/dhtcore/test/NodeStore_test.c
  25. 0 interface/{ETHInterface_Linux.c → ETHInterface_linux.c}
  26. +4 −2 interface/ICMP6Generator.c
  27. +1 −1 interface/test/FramingInterface_test.c
  28. +5 −4 interface/test/TUNInterface_ipv4_root_test.c
  29. +7 −6 interface/test/TUNInterface_ipv6_root_test.c
  30. +2 −2 interface/test/UDPInterface_communication_test.c
  31. +1 −1 interface/test/UDPInterface_test.c
  32. 0 interface/tuntap/{TUNInterface_Darwin.c → TUNInterface_darwin.c}
  33. 0 interface/tuntap/{TUNInterface_FreeBSD.c → TUNInterface_freebsd.c}
  34. 0 interface/tuntap/{TUNInterface_Linux.c → TUNInterface_linux.c}
  35. 0 interface/tuntap/{TUNInterface_OpenBSD.c → TUNInterface_openbsd.c}
  36. 0 interface/tuntap/{TUNInterface_Illumos.c → TUNInterface_sunos.c}
  37. 0 interface/tuntap/{TUNInterface_Windows.c → TUNInterface_win32.c}
  38. +11 −2 interface/tuntap/windows/test/TAPDevice_root_test.c
  39. +14 −7 interface/tuntap/windows/test/TAPInterface_root_test.c
  40. +11 −45 memory/Allocator.c
  41. +0 −4 memory/Allocator.h
  42. +4 −4 memory/Allocator_pvt.h
  43. +7 −5 net/Ducttape.c
  44. +1 −1 net/test/DefaultInterfaceController_multiIface_test.c
  45. +2 −2 node_build/Tests.js
  46. +96 −26 node_build/builder.js
  47. +33 −6 node_build/make.js
  48. +1 −1 switch/test/LabelSplicer_test.c
  49. +56 −0 test/RootTest.h
  50. +1 −1 test/cjdroute_routerPing_test.c
  51. +3 −3 test/threeNodes_test.c
  52. +2 −2 test/twoNodes_test.c
  53. +64 −8 testcjdroute.c
  54. +2 −2 tunnel/IpTunnel_admin.c
  55. +2 −2 tunnel/test/IpTunnel_test.c
  56. +2 −0 util/Assert.h
  57. +1 −2 util/Bits.h
  58. +32 −0 util/CompileTimeRandom.h
  59. +3 −3 util/Endian.h
  60. +11 −10 util/Gcc.h
  61. +6 −5 util/Identity.h
  62. +1 −1 util/events/libuv/Event.c
  63. +5 −0 util/events/libuv/EventBase.c
  64. +2 −0 util/events/libuv/EventBase_pvt.h
  65. +3 −3 util/events/libuv/Pipe.c
  66. +1 −1 util/events/libuv/Process.c
  67. +1 −1 util/events/libuv/Time.c
  68. +1 −1 util/events/libuv/Timeout.c
  69. +1 −1 util/events/libuv/UDPAddrInterface.c
  70. +1 −1 util/platform/Sockaddr.c
  71. +6 −1 util/platform/libc/strlen.h
  72. +0 −51 util/platform/netdev/NetPlatform_Win32.c
  73. 0 util/platform/netdev/{NetPlatform_Darwin.c → NetPlatform_darwin.c}
  74. 0 util/platform/netdev/{NetPlatform_FreeBSD.c → NetPlatform_freebsd.c}
  75. 0 util/platform/netdev/{NetPlatform_Linux.c → NetPlatform_linux.c}
  76. 0 util/platform/netdev/{NetPlatform_OpenBSD.c → NetPlatform_openbsd.c}
  77. 0 util/platform/netdev/{NetPlatform_Illumos.c → NetPlatform_sunos.c}
  78. 0 util/platform/netdev/{NetPlatform_Windows.c → NetPlatform_win32.c}
  79. +2 −2 util/test/AddrTools_test.c
  80. +2 −2 util/test/AverageRoller_test.c
  81. +1 −1 util/test/Bits_test.c
  82. +2 −2 util/test/Map_test.c
  83. +11 −9 util/test/Process_test.c
View
@@ -53,7 +53,7 @@ static void standardClient(struct Context* ctx)
int main(int argc, char** argv)
{
- struct AdminTestFramework* framework = AdminTestFramework_setUp(argc, argv);
+ struct AdminTestFramework* framework = AdminTestFramework_setUp(argc, argv, "Admin_test");
struct Context ctx = {
.framework = framework
};
@@ -44,9 +44,12 @@
#include <unistd.h>
#include <stdlib.h>
-static void spawnAngel(char* asClientPipeName, struct EventBase* base, struct Allocator* alloc)
+static void spawnAngel(char* testName,
+ char* asClientPipeName,
+ struct EventBase* base,
+ struct Allocator* alloc)
{
- char* args[] = { "angel", asClientPipeName, NULL };
+ char* args[] = { testName, "angel", asClientPipeName, NULL };
struct Allocator* tempAlloc = Allocator_child(alloc);
char* path = Process_getPath(tempAlloc);
@@ -131,10 +134,10 @@ static void initAngel(struct Pipe* asClientPipe,
* The "core process" pipes all of its inputs back to the originating process
*/
-struct AdminTestFramework* AdminTestFramework_setUp(int argc, char** argv)
+struct AdminTestFramework* AdminTestFramework_setUp(int argc, char** argv, char* testName)
{
- if (argc > 1 && !strcmp("angel", argv[1])) {
- exit(AngelInit_main(argc, argv));
+ if (argc > 2 && !strcmp(testName, argv[1]) && !strcmp("angel", argv[2])) {
+ exit(AngelInit_main(argc-1, &argv[1]));
}
struct Allocator* alloc = MallocAllocator_new(1<<20);
@@ -158,7 +161,7 @@ struct AdminTestFramework* AdminTestFramework_setUp(int argc, char** argv)
asCorePipe->logger = logger;
struct Interface* asCoreIface = FramingInterface_new(65535, &asCorePipe->iface, alloc);
- spawnAngel(asClientPipeName, eventBase, alloc);
+ spawnAngel(testName, asClientPipeName, eventBase, alloc);
Log_info(logger, "Initializing Angel");
initAngel(asClientPipe, asCoreIface, (char*)asCorePipe->name, eventBase, logger, alloc, rand);
@@ -35,6 +35,6 @@ struct AdminTestFramework
struct Interface* angelInterface;
};
-struct AdminTestFramework* AdminTestFramework_setUp(int argc, char** argv);
+struct AdminTestFramework* AdminTestFramework_setUp(int argc, char** argv, char* testName);
void AdminTestFramework_tearDown(struct AdminTestFramework* framework);
#endif
View
@@ -1159,3 +1159,26 @@ struct ReplayProtector* CryptoAuth_getReplayProtector(struct Interface* iface)
Identity_cast((struct CryptoAuth_Wrapper*)iface->senderContext);
return &wrapper->replayProtector;
}
+
+// For testing:
+void CryptoAuth_encryptRndNonce(uint8_t nonce[24], struct Message* msg, uint8_t secret[32])
+{
+ encryptRndNonce(nonce, msg, secret);
+}
+
+int CryptoAuth_decryptRndNonce(uint8_t nonce[24], struct Message* msg, uint8_t secret[32])
+{
+ return decryptRndNonce(nonce, msg, secret);
+}
+
+uint8_t CryptoAuth_encryptHandshake(struct Message* message,
+ struct CryptoAuth_Wrapper* wrapper,
+ int setupMessage)
+{
+ return encryptHandshake(message, wrapper, setupMessage);
+}
+
+uint8_t CryptoAuth_receiveMessage(struct Message* received, struct Interface* interface)
+{
+ return receiveMessage(received, interface);
+}
@@ -14,7 +14,7 @@
*/
#include "crypto/random/Random.h"
#include "crypto/CryptoAuth.h"
-#include "crypto/test/Exports.h"
+#include "crypto/CryptoAuth_pvt.h"
#include "io/FileWriter.h"
#include "benc/Object.h"
#include "memory/MallocAllocator.h"
View
@@ -119,4 +119,15 @@ struct CryptoAuth_Wrapper
Identity
};
+
+uint8_t CryptoAuth_receiveMessage(struct Message* received, struct Interface* interface);
+
+uint8_t CryptoAuth_encryptHandshake(struct Message* message,
+ struct CryptoAuth_Wrapper* wrapper,
+ int setupMessage);
+
+int CryptoAuth_decryptRndNonce(uint8_t nonce[24], struct Message* msg, uint8_t secret[32]);
+
+void CryptoAuth_encryptRndNonce(uint8_t nonce[24], struct Message* msg, uint8_t secret[32]);
+
#endif
@@ -16,19 +16,14 @@
#include "util/Identity.h"
#include "util/Bits.h"
-#ifndef Windows
- #include <unistd.h>
- #include <errno.h>
- #include <sys/types.h>
- #ifndef Illumos
- #include <sys/sysctl.h>
- #endif
-#endif
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
/** Number of times to try each operation. */
#define MAX_TRIES 10
-#ifdef KERN_ARND
static int get(struct RandomSeed* randomSeed, uint64_t output[8])
{
int mib[] = { CTL_KERN, KERN_ARND };
@@ -56,12 +51,6 @@ static int get(struct RandomSeed* randomSeed, uint64_t output[8])
}
return Bits_isZero(output, 64) ? -1 : 0;
}
-#else
-static int get(struct RandomSeed* randomSeed, uint64_t output[8])
-{
- return -1;
-}
-#endif
struct RandomSeed* BsdKernArndSysctlRandomSeed_new(struct Allocator* alloc)
{
@@ -16,10 +16,14 @@
#define BsdKernArndSysctlRandomSeed_H
#include "crypto/random/seed/RandomSeed.h"
+#include "crypto/random/seed/RandomSeedProvider.h"
#include "memory/Allocator.h"
#include "util/Linker.h"
-Linker_require("crypto/random/seed/BsdKernArndSysctlRandomSeed.c")
-struct RandomSeed* BsdKernArndSysctlRandomSeed_new(struct Allocator* alloc);
+#if defined(freebsd) || defined(openbsd)
+ Linker_require("crypto/random/seed/BsdKernArndSysctlRandomSeed.c")
+ struct RandomSeed* BsdKernArndSysctlRandomSeed_new(struct Allocator* alloc);
+ RandomSeedProvider_register(BsdKernArndSysctlRandomSeed_new)
+#endif
#endif
@@ -16,8 +16,6 @@
#include "util/Identity.h"
#include "util/Bits.h"
-#ifndef Windows
-
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -60,13 +58,6 @@ static int get(struct RandomSeed* randomSeed, uint64_t output[8])
return -1;
}
-#else
-static int get(struct RandomSeed* randomSeed, uint64_t output[8])
-{
- return -1;
-}
-#endif
-
struct RandomSeed* DevUrandomRandomSeed_new(struct Allocator* alloc)
{
return Allocator_clone(alloc, (&(struct RandomSeed) {
@@ -16,10 +16,14 @@
#define DevUrandomRandomSeed_H
#include "crypto/random/seed/RandomSeed.h"
+#include "crypto/random/seed/RandomSeedProvider.h"
#include "memory/Allocator.h"
#include "util/Linker.h"
-Linker_require("crypto/random/seed/DevUrandomRandomSeed.c")
-struct RandomSeed* DevUrandomRandomSeed_new(struct Allocator* alloc);
+#ifndef win32
+ Linker_require("crypto/random/seed/DevUrandomRandomSeed.c")
+ struct RandomSeed* DevUrandomRandomSeed_new(struct Allocator* alloc);
+ RandomSeedProvider_register(DevUrandomRandomSeed_new)
+#endif
#endif
@@ -17,8 +17,6 @@
#include "util/Bits.h"
#include "util/Hex.h"
-#ifdef Linux
-
#include <unistd.h>
#include <sys/sysctl.h>
@@ -44,13 +42,6 @@ static int get(struct RandomSeed* randomSeed, uint64_t output[8])
return 0;
}
-#else
-static int get(struct RandomSeed* randomSeed, uint64_t output[8])
-{
- return -1;
-}
-#endif
-
struct RandomSeed* LinuxRandomUuidSysctlRandomSeed_new(struct Allocator* alloc)
{
return Allocator_clone(alloc, (&(struct RandomSeed) {
@@ -16,10 +16,14 @@
#define LinuxRandomUuidSysctlRandomSeed_H
#include "crypto/random/seed/RandomSeed.h"
+#include "crypto/random/seed/RandomSeedProvider.h"
#include "memory/Allocator.h"
#include "util/Linker.h"
-Linker_require("crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.c")
-struct RandomSeed* LinuxRandomUuidSysctlRandomSeed_new(struct Allocator* alloc);
+#ifdef linux
+ Linker_require("crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.c")
+ struct RandomSeed* LinuxRandomUuidSysctlRandomSeed_new(struct Allocator* alloc);
+ RandomSeedProvider_register(LinuxRandomUuidSysctlRandomSeed_new)
+#endif
#endif
@@ -26,8 +26,6 @@
/** Number of times to try each operation. */
#define MAX_TRIES 10
-#ifndef Windows
-
static int getUUID(uint64_t output[2])
{
uint8_t buffer[40] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
@@ -91,12 +89,6 @@ static int get(struct RandomSeed* randomSeed, uint64_t output[8])
}
return 0;
}
-#else // Windows
-static int get(struct RandomSeed* randomSeed, uint64_t output[8])
-{
- return -1;
-}
-#endif
struct RandomSeed* ProcSysKernelRandomUuidRandomSeed_new(struct Allocator* alloc)
{
@@ -16,10 +16,14 @@
#define ProcSysKernelRandomUuidRandomSeed_H
#include "crypto/random/seed/RandomSeed.h"
+#include "crypto/random/seed/RandomSeedProvider.h"
#include "memory/Allocator.h"
#include "util/Linker.h"
-Linker_require("crypto/random/seed/ProcSysKernelRandomUuidRandomSeed.c")
-struct RandomSeed* ProcSysKernelRandomUuidRandomSeed_new(struct Allocator* alloc);
+#ifdef linux
+ Linker_require("crypto/random/seed/ProcSysKernelRandomUuidRandomSeed.c")
+ struct RandomSeed* ProcSysKernelRandomUuidRandomSeed_new(struct Allocator* alloc);
+ RandomSeedProvider_register(ProcSysKernelRandomUuidRandomSeed_new)
+#endif
#endif
@@ -12,22 +12,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef Exports_H
-#define Exports_H
+#ifndef RandomSeedProvider_H
+#define RandomSeedProvider_H
-#include <stdint.h>
+<?js file.RandomSeedProvider_providers = []; ?>
-#include "crypto/CryptoAuth.h"
-#include "wire/Message.h"
-#include "util/Linker.h"
-Linker_require("crypto/test/Exports.c")
+#define RandomSeedProvider_register(name) <?js file.RandomSeedProvider_providers.push(#name) ?>
-void Exports_encryptRndNonce(uint8_t nonce[24], struct Message* msg, uint8_t secret[32]);
-
-int Exports_decryptRndNonce(uint8_t nonce[24], struct Message* msg, uint8_t secret[32]);
-
-uint8_t Exports_encryptHandshake(struct Message* message, struct CryptoAuth_Wrapper* wrapper);
-
-void Exports_receiveMessage(struct Message* received, struct Interface* iface);
+#define RandomSeedProvider_list() <?js return file.RandomSeedProvider_providers.join(','); ?>
#endif
@@ -15,7 +15,6 @@
#include "crypto/random/seed/RtlGenRandomSeed.h"
#include "util/Bits.h"
-#ifdef Windows
#include <stdint.h>
#include <windows.h>
@@ -40,17 +39,6 @@ static void init()
RtlGenRandom = (BOOLEAN (APIENTRY *)(void*,ULONG))GetProcAddress(hLib,"SystemFunction036");
}
-#else
-static void init()
-{
-}
-
-static int get(struct RandomSeed* rand, uint64_t buff[8])
-{
- return -1;
-}
-#endif
-
struct RandomSeed* RtlGenRandomSeed_new(struct Allocator* alloc)
{
init();
@@ -16,10 +16,14 @@
#define RtlGenRandomSeed_H
#include "crypto/random/seed/RandomSeed.h"
+#include "crypto/random/seed/RandomSeedProvider.h"
#include "memory/Allocator.h"
#include "util/Linker.h"
-Linker_require("crypto/random/seed/RtlGenRandomSeed.c")
-struct RandomSeed* RtlGenRandomSeed_new(struct Allocator* alloc);
+#ifdef win32
+ Linker_require("crypto/random/seed/RtlGenRandomSeed.c")
+ struct RandomSeed* RtlGenRandomSeed_new(struct Allocator* alloc);
+ RandomSeedProvider_register(RtlGenRandomSeed_new)
+#endif
#endif
@@ -15,30 +15,15 @@
#include "crypto/random/seed/RandomSeed.h"
#include "util/log/Log.h"
+#include "crypto/random/seed/RandomSeedProvider.h"
#include "crypto/random/seed/RtlGenRandomSeed.h"
#include "crypto/random/seed/BsdKernArndSysctlRandomSeed.h"
#include "crypto/random/seed/DevUrandomRandomSeed.h"
#include "crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.h"
#include "crypto/random/seed/ProcSysKernelRandomUuidRandomSeed.h"
-static RandomSeed_Provider PROVIDERS[] = {
- /** windows */
- RtlGenRandomSeed_new,
-
- /** bsd syscall(KERN_ARND) */
- BsdKernArndSysctlRandomSeed_new,
-
- /** /dev/urandom */
- DevUrandomRandomSeed_new,
-
- /** linux syscall(RANDOM_UUID) */
- LinuxRandomUuidSysctlRandomSeed_new,
-
- /** linux /proc/sys/kernel/random/uuid */
- ProcSysKernelRandomUuidRandomSeed_new
-};
-#define PROVIDERS_COUNT 5
-Assert_compileTime(PROVIDERS_COUNT == (sizeof(PROVIDERS) / sizeof(RandomSeed_Provider)));
+static RandomSeed_Provider PROVIDERS[] = { RandomSeedProvider_list() };
+#define PROVIDERS_COUNT ((int)(sizeof(PROVIDERS) / sizeof(RandomSeed_Provider)))
struct RandomSeed* SystemRandomSeed_new(RandomSeed_Provider* additionalProviders,
int additionalProviderCount,
@@ -84,7 +84,7 @@ static void test179(struct Allocator* alloc, struct Log* logger)
Random_bytes(rand, buff, 32);
Random_bytes(rand2, buff, 32);
- Assert_true(Bits_memcmp(buff, buff2, 32));
+ Assert_always(Bits_memcmp(buff, buff2, 32));
}
int main()
Oops, something went wrong.

0 comments on commit fffb92c

Please sign in to comment.