Permalink
Browse files

Included IpTunnel and did a refactoring of the codebase.

  • Loading branch information...
1 parent dc1319d commit 9b08100ec3ef1ddabe475fcd7fbaec2d29ef3b1a Caleb James DeLisle committed Nov 4, 2012
Showing with 811 additions and 343 deletions.
  1. +5 −2 admin/Admin.c
  2. +1 −1 admin/AdminClient.c
  3. +6 −2 admin/AdminLog.c
  4. +1 −1 admin/AuthorizedPasswords.c
  5. +1 −1 admin/Configurator.c
  6. +1 −1 admin/angel/Angel.c
  7. +1 −1 admin/angel/AngelInit.c
  8. +2 −0 admin/angel/Cjdns.c
  9. +1 −1 admin/angel/Waiter.c
  10. +6 −2 admin/angel/cjdroute2.c
  11. +3 −3 admin/test/Admin_test.c
  12. +6 −4 admin/testframework/AdminTestFramework.c
  13. +4 −3 benc/String.c
  14. +1 −0 benc/String.h
  15. +3 −2 benc/serialization/json/JsonBencSerializer.c
  16. +4 −2 benc/serialization/standard/StandardBencSerializer.c
  17. +4 −3 benc/serialization/standard/test/benc_serializeInteger_test.c
  18. +4 −4 benc/serialization/standard/test/benc_serializeList_test.c
  19. +10 −11 crypto/CryptoAuth.c
  20. +5 −1 crypto/test/CryptoAuth_test.c
  21. +14 −11 crypto/test/CryptoAuth_unit_test.c
  22. +1 −1 dht/AddressMapper.c
  23. +1 −1 dht/DHTModuleRegistry.c
  24. +1 −1 dht/ReplyModule.c
  25. +1 −1 dht/SerializationModule.c
  26. +5 −5 dht/dhtcore/DistanceNodeCollector.h
  27. +1 −1 dht/dhtcore/Janitor.c
  28. +7 −6 dht/dhtcore/LinkStateNodeCollector.h
  29. +8 −6 dht/dhtcore/NodeCollector.h
  30. +8 −4 dht/dhtcore/NodeStore.c
  31. +7 −5 dht/dhtcore/RouterModule.c
  32. +1 −1 dht/dhtcore/SearchStore.c
  33. +2 −2 dht/test/address_mapper_lru_test.c
  34. +1 −1 exception/Except.c
  35. +0 −126 interface/InterfaceMap.h
  36. +1 −1 interface/TUNConfigurator_FreeBSD.c
  37. +1 −1 interface/TUNConfigurator_Illumos.c
  38. +5 −4 interface/TUNConfigurator_Linux.c
  39. +1 −1 interface/TUNConfigurator_OSX.c
  40. +1 −1 interface/TUNConfigurator_OpenBSD.c
  41. +1 −1 interface/TUNInterface.c
  42. +1 −1 interface/TUNInterface_W32.c
  43. +0 −1 interface/UDPInterface_admin.c
  44. +4 −1 interface/test/UDPInterface_test.c
  45. +2 −2 io/test/FileReader_test.c
  46. +3 −3 memory/MallocAllocator.c
  47. +1 −1 memory/test/MallocAllocator_test.c
  48. +44 −45 net/DefaultInterfaceController.c
  49. +12 −13 net/Ducttape.c
  50. +3 −0 net/test/DefaultInterfaceController_test.c
  51. +1 −1 scripts/checkfiles.pl
  52. +5 −3 test/CryptoAddress_test.c
  53. +3 −0 test/cjdroute_injection_test.c
  54. +3 −0 test/cjdroute_routerPing_test.c
  55. +3 −0 tunnel/CMakeLists.txt
  56. +15 −19 tunnel/IpTunnel.c
  57. +0 −1 tunnel/IpTunnel_admin.c
  58. +27 −0 tunnel/test/CMakeLists.txt
  59. +151 −0 tunnel/test/IpTunnel_test.c
  60. +1 −1 util/AverageRoller.c
  61. +27 −8 util/Bits.h
  62. +3 −2 util/Identity.h
  63. +1 −1 util/Process_FreeBSD.c
  64. +1 −1 util/Process_Illumos.c
  65. +1 −1 util/Process_Linux.c
  66. +1 −1 util/Process_OSX.c
  67. +1 −1 util/Process_OpenBSD.c
  68. +1 −1 util/Process_W32.c
  69. +1 −1 util/Security.c
  70. +2 −1 util/Security_admin.c
  71. +3 −1 util/log/WriterLog.c
  72. +323 −0 util/platform/libc/string.h
  73. +20 −0 util/platform/libc/strlen.h
  74. +3 −3 util/test/Base32_test.c
  75. +6 −2 util/test/Hex_test.c
  76. +1 −1 util/test/Process_test.c
View
@@ -36,11 +36,14 @@
#include "util/Time.h"
#include "util/Timeout.h"
+#define string_strstr
+#define string_strcmp
+#define string_strlen
+#include "util/platform/libc/string.h"
#include <crypto_hash_sha256.h>
#include <event2/event.h>
#include <limits.h>
-#include <string.h>
#include <stdbool.h>
#include <unistd.h>
@@ -256,7 +259,7 @@ static inline bool authValid(Dict* message, struct Message* messageBytes, struct
crypto_hash_sha256(hash, messageBytes->bytes, messageBytes->length);
Hex_encode(hashPtr, 64, hash, 32);
- return memcmp(hashPtr, submittedHash->bytes, 64) == 0;
+ return Bits_memcmp(hashPtr, submittedHash->bytes, 64) == 0;
}
static bool checkArgs(Dict* args, struct Function* func, String* txid, struct Admin* admin)
View
@@ -19,12 +19,12 @@
#include "io/ArrayWriter.h"
#include "io/Reader.h"
#include "io/Writer.h"
+#include "util/platform/libc/strlen.h"
#include "util/Endian.h"
#include "util/Errno.h"
#include "util/Hex.h"
#include <crypto_hash_sha256.h>
-#include <string.h>
#include <unistd.h>
#include <event2/event.h>
View
@@ -22,10 +22,14 @@
#include "util/log/Log.h"
#include "util/Hex.h"
+#define string_strcmp
+#define string_strrchr
+#define string_strlen
+#include "util/platform/libc/string.h"
+
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
-#include <string.h>
#include <time.h>
#include <stdbool.h>
@@ -255,7 +259,7 @@ static void unsubscribe(Dict* args, void* vcontext, String* txid)
} else {
error = "No such subscription.";
for (int i = 0; i < (int)log->subscriptionCount; i++) {
- if (!memcmp(streamId, log->subscriptions[i].streamId, 8)) {
+ if (!Bits_memcmp(streamId, log->subscriptions[i].streamId, 8)) {
removeSubscription(log, &log->subscriptions[i]);
error = "none";
break;
@@ -15,7 +15,7 @@
#include "admin/AuthorizedPasswords.h"
#include "benc/Int.h"
#include "memory/BufferAllocator.h"
-#include <string.h>
+#include "util/platform/libc/strlen.h"
struct Context
{
View
@@ -18,10 +18,10 @@
#include "benc/Dict.h"
#include "benc/Int.h"
#include "memory/Allocator.h"
+#include "util/platform/libc/strlen.h"
#include "util/log/Log.h"
#include <event2/event.h>
-#include <string.h>
struct Context
{
View
@@ -18,6 +18,7 @@
#include "interface/Interface.h"
#include "interface/PipeInterface.h"
#include "interface/Interface.h"
+#include "util/platform/libc/strlen.h"
#include "util/Bits.h"
#include "util/Errno.h"
#include "util/log/Log.h"
@@ -27,7 +28,6 @@
#include "wire/Error.h"
#include <event2/event.h>
-#include <string.h>
#include <unistd.h>
struct AngelContext;
View
@@ -30,6 +30,7 @@
#include "exception/Jmp.h"
#include "exception/Except.h"
#include "util/events/EventBase.h"
+#include "util/platform/libc/strlen.h"
#include "util/Bits.h"
#include "util/Assert.h"
#include "util/Errno.h"
@@ -43,7 +44,6 @@
#include <unistd.h>
#include <stdint.h>
#include <event2/event.h>
-#include <string.h>
#ifdef BSD
#include <netinet/in.h>
View
@@ -12,8 +12,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#define string_strcmp
#include "admin/angel/AngelInit.h"
#include "admin/angel/Core.h"
+#include "util/platform/libc/string.h"
#include <stdio.h>
#include <unistd.h>
View
@@ -22,7 +22,7 @@
#include <event2/event.h>
#include <unistd.h>
-#include <string.h>
+#include "util/platform/libc/string.h"
struct Context
{
View
@@ -12,6 +12,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#define string_strcmp
+#define string_strrchr
+#define string_strlen
#include "admin/Admin.h"
#include "admin/angel/Waiter.h"
#include "admin/AuthorizedPasswords.h"
@@ -45,6 +48,7 @@
#include "net/SwitchPinger.h"
#include "net/SwitchPinger_admin.h"
#include "switch/SwitchCore.h"
+#include "util/platform/libc/string.h"
#include "util/events/EventBase.h"
#include "util/Assert.h"
#include "util/Base32.h"
@@ -293,7 +297,7 @@ static void reconf(struct event_base* eventbase,
}
struct sockaddr_storage addr;
- memset(&addr, 0, sizeof(struct sockaddr_storage));
+ Bits_memset(&addr, 0, sizeof(struct sockaddr_storage));
int addrLen = sizeof(struct sockaddr_storage);
if (evutil_parse_sockaddr_port(address->bytes, (struct sockaddr*) &addr, &addrLen)) {
Log_critical(logger, "Unable to parse [%s] as an ip address port, "
@@ -469,7 +473,7 @@ int main(int argc, char** argv)
Dict* responseFromAngelAdmin = Dict_getDict(&responseFromAngel, String_CONST("admin"));
adminBind = Dict_getString(responseFromAngelAdmin, String_CONST("bind"));
struct sockaddr_storage adminAddr;
- memset(&adminAddr, 0, sizeof(struct sockaddr_storage));
+ Bits_memset(&adminAddr, 0, sizeof(struct sockaddr_storage));
int adminAddrLen = sizeof(struct sockaddr_storage);
if (!adminBind) {
Except_raise(eh, -1, "didn't get address and port back from angel");
View
@@ -19,9 +19,9 @@
#include "benc/Int.h"
#include "memory/Allocator.h"
#include "util/Assert.h"
-#include <util/Errno.h>
+#include "util/Errno.h"
+#include "util/platform/libc/strlen.h"
-#include <string.h>
#include <event2/event.h>
struct Context {
@@ -75,7 +75,7 @@ static void slowClientIncoming(evutil_socket_t socket, short eventType, void* vc
&& ctx->slowClient.buf[ctx->slowClient.have-1] == 'e') {
Log_error(ctx->framework->logger, "Got cookie response '%s'", ctx->slowClient.buf);
- Assert_always(0 == memcmp("d6:cookie", ctx->slowClient.buf, 9));
+ Assert_always(0 == Bits_memcmp("d6:cookie", ctx->slowClient.buf, 9));
event_base_loopexit(ctx->framework->eventBase, NULL);
}
@@ -37,8 +37,10 @@
#include "util/log/WriterLog.h"
#include "util/Pipe.h"
#include "util/Process.h"
-
-#include <string.h>
+#define string_strlen
+#define string_strchr
+#define string_strcmp
+#include "util/platform/libc/string.h"
#include <unistd.h>
#include <event2/event.h>
@@ -106,7 +108,7 @@ static String* initAngel(int fromAngel,
// This is angel->core data, we can throw this away.
//Waiter_getData(buff, BUFFER_SZ, fromAngel, eventBase, NULL);
//Log_info(logger, "Init message from angel to core: [%s]", buff);
- memset(buff, 0, BUFFER_SZ);
+ Bits_memset(buff, 0, BUFFER_SZ);
struct PipeInterface* pi =
PipeInterface_new(FROM_ANGEL_AS_CORE, TO_ANGEL_AS_CORE, eventBase, logger, alloc, rand);
@@ -192,7 +194,7 @@ struct AdminTestFramework* AdminTestFramework_setUp(int argc, char** argv)
struct sockaddr_storage addr;
int addrLen = sizeof(struct sockaddr_storage);
- memset(&addr, 0, sizeof(struct sockaddr_storage));
+ Bits_memset(&addr, 0, sizeof(struct sockaddr_storage));
Assert_true(!evutil_parse_sockaddr_port(addrStr->bytes, (struct sockaddr*) &addr, &addrLen));
struct AdminClient* client =
View
@@ -16,7 +16,8 @@
#include "benc/String.h"
#include "util/Bits.h"
-#include <string.h>
+#define string_strlen
+#include "util/platform/libc/string.h"
#include <stdio.h>
#include <stdarg.h>
@@ -35,7 +36,7 @@ String* String_newBinary(const char* bytes, size_t length, const struct Allocato
if (bytes != NULL) {
Bits_memcpy(copy, bytes, length);
} else {
- memset(copy, '\0', length);
+ Bits_memset(copy, '\0', length);
}
String* string = allocator->malloc(sizeof(String), allocator);
string->len = length;
@@ -84,5 +85,5 @@ bool String_equals(const String* a, const String* b)
if (a == NULL || b == NULL) {
return a == NULL && b == NULL;
}
- return a->len == b->len && (memcmp(a->bytes, b->bytes, a->len) == 0);
+ return a->len == b->len && (Bits_memcmp(a->bytes, b->bytes, a->len) == 0);
}
View
@@ -16,6 +16,7 @@
#define String_H
#include "memory/Allocator.h"
+#include "util/platform/libc/strlen.h"
#include <stdbool.h>
#include <stdarg.h>
@@ -17,11 +17,12 @@
#include "io/Writer.h"
#include "benc/Object.h"
#include "benc/serialization/BencSerializer.h"
+#include "util/platform/libc/strlen.h"
+#include "util/Bits.h"
#include "util/Errno.h"
#include "util/Hex.h"
#include <stdio.h>
-#include <string.h>
#include <inttypes.h>
#include <stdbool.h>
@@ -150,7 +151,7 @@ static int32_t serializeint64_t(const struct Writer* writer,
int64_t integer)
{
char buffer[32];
- memset(buffer, 0, 32);
+ Bits_memset(buffer, 0, 32);
sprintf(buffer, "%" PRId64, integer);
@@ -13,16 +13,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
-#include <string.h>
/* for parseint64_t */
#include <limits.h>
+#include "util/Bits.h"
#include "memory/Allocator.h"
#include "io/Reader.h"
#include "io/Writer.h"
#include "benc/Object.h"
#include "benc/serialization/BencSerializer.h"
#include "util/Errno.h"
+#define string_strlen
+#include "util/platform/libc/string.h"
static int32_t parseGeneric(const struct Reader* reader,
const struct Allocator* allocator,
@@ -40,7 +42,7 @@ static int32_t writeint64_t(const struct Writer* writer,
int64_t integer)
{
char buffer[32];
- memset(buffer, 0, 32);
+ Bits_memset(buffer, 0, 32);
sprintf(buffer, "%" PRId64, integer);
@@ -12,9 +12,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <string.h>
-#include <stdio.h>
-
+#define string_strcmp
+#include "util/platform/libc/string.h"
#include "memory/Allocator.h"
#include "memory/BufferAllocator.h"
#include "io/Reader.h"
@@ -25,6 +24,8 @@
#include "benc/serialization/BencSerializer.h"
#include "benc/serialization/standard/StandardBencSerializer.h"
+#include <stdio.h>
+
int expect(char* str, struct Writer* writer, struct Reader* reader, int ret)
{
char buffer[32];
@@ -12,9 +12,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <string.h>
-#include <stdio.h>
-
#include "memory/Allocator.h"
#include "memory/BufferAllocator.h"
#include "io/Reader.h"
@@ -24,6 +21,9 @@
#include "benc/Object.h"
#include "benc/serialization/BencSerializer.h"
#include "benc/serialization/standard/StandardBencSerializer.h"
+#include "util/Bits.h"
+
+#include <stdio.h>
int parseEmptyList()
{
@@ -42,7 +42,7 @@ int parseEmptyList()
if (ret) {
return ret;
}
- return memcmp(test, out, strlen(test));
+ return Bits_memcmp(test, out, strlen(test));
}
int main()
Oops, something went wrong.

0 comments on commit 9b08100

Please sign in to comment.