<NME> mesh_core.c
<BEF> ADDFILE
<MSG> disable all the old v2 core code now, to begin updating mesh/link/pipe structures to v3

<DFF> @@ -0,0 +1,11 @@
+#include "mesh.h"
+#include "unit_test.h"
+
+int main(int argc, char **argv)
+{
+  mesh_t mesh = mesh_new(3);
+  fail_unless(mesh);
+  
+  return 0;
+}
+

{'commit': 'diff --git a/Makefile b/Makefile\nindex cb5dfb7..cd11ef3 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -4,6 +4,7 @@ INCLUDE+=-Iunix -Isrc -Isrc/lib -Isrc/ext -Isrc/e3x\n \n LIB = src/lib/util.c src/lib/lob.c src/lib/hashname.c src/lib/xht.c src/lib/js0n.c src/lib/base32.c\n E3X = src/e3x/e3x.c src/e3x/channel3.c src/e3x/self3.c src/e3x/exchange3.c src/e3x/event3.c src/e3x/cipher3.c\n+MESH = src/mesh.c src/link.c src/links.c src/pipe.c\n \n CS1a = src/e3x/cs1a/aes.c src/e3x/cs1a/hmac.c src/e3x/cs1a/aes128.c src/e3x/cs1a/cs1a.c src/e3x/cs1a/uECC.c src/e3x/cs1a/sha256.c\n CS2a = -ltomcrypt -ltommath -DLTM_DESC -DCS_2a src/e3x/cs2a/crypt_libtom_*.c\n@@ -24,7 +25,7 @@ UNIX1a = unix/platform.c src/e3x/cs2a_disabled.c src/e3x/cs3a_disabled.c  $(LIB)\n # all\n #ARCH = unix/platform.c $(JSON) $(CS1a) $(CS2a) $(CS3a) $(INCLUDE) $(LIBS)\n \n-TESTS = lib_base32 lib_lob lib_hashname lib_murmur lib_util e3x_core e3x_cs1a e3x_self3 e3x_exchange3 e3x_event3 e3x_channel3\n+TESTS = lib_base32 lib_lob lib_hashname lib_murmur lib_util e3x_core e3x_cs1a e3x_self3 e3x_exchange3 e3x_event3 e3x_channel3 mesh_core\n \n all: test\n \n@@ -78,6 +79,10 @@ e3x_event3:\n e3x_channel3:\n \t$(CC) $(CFLAGS) -o test/e3x_channel3 test/e3x_channel3.c $(UNIX1a)\n \n+mesh_core:\n+\t$(CC) $(CFLAGS) -o test/mesh_core test/mesh_core.c $(UNIX1a) $(MESH)\n+\n+\n idgen:\n \t$(CC) $(CFLAGS) -o bin/idgen util/idgen.c $(ARCH)\n \ndiff --git a/src/link.c b/src/link.c\nindex c2d3b9d..210aaed 100644\n--- a/src/link.c\n+++ b/src/link.c\n@@ -4,6 +4,7 @@\n #include "util.h"\n #include "mesh.h"\n \n+/*\n // flags channel as ended either in or out\n void doend(link_t c)\n {\n@@ -387,3 +388,5 @@ void link_ack(link_t c)\n   DEBUG_PRINTF("channel ack %d %.*s",c->id,p->json_len,p->json);\n   switch_send(c->s,p);\n }\n+\n+*/\n\\ No newline at end of file\ndiff --git a/src/link.h b/src/link.h\nindex a4cc461..70938b8 100644\n--- a/src/link.h\n+++ b/src/link.h\n@@ -1,7 +1,14 @@\n #ifndef link_h\n #define link_h\n #include <stdint.h>\n+#include "e3x.h"\n \n+typedef struct link_struct\n+{\n+  channel3_t chan;\n+} *link_t;\n+\n+/*\n // default channel inactivity timeout in seconds\n #define CHAN_TIMEOUT 10\n \n@@ -107,5 +114,6 @@ void link_miss_check(link_t c, packet_t p);\n \n void link_miss_init(link_t c);\n void link_miss_free(link_t c);\n+*/\n \n #endif\n\\ No newline at end of file\ndiff --git a/src/links.c b/src/links.c\nindex 486e08e..27013df 100644\n--- a/src/links.c\n+++ b/src/links.c\n@@ -9,7 +9,7 @@ links_t links_new()\n {\n   links_t b = malloc(sizeof (struct links_struct));\n   memset(b,0,sizeof (struct links_struct));\n-  b->hns = NULL;\n+  b->links = NULL;\n   b->args = NULL;\n   return b;\n }\n@@ -17,11 +17,12 @@ links_t links_new()\n void links_free(links_t b)\n {\n   if(!b) return;\n-  if(b->hns) free(b->hns);\n+  if(b->links) free(b->links);\n   if(b->args) free(b->args);\n   free(b);\n }\n \n+/*\n void links_add(links_t b, hashname_t hn)\n {\n   void *ptr;\n@@ -89,3 +90,4 @@ void *links_arg(links_t b, hashname_t hn)\n   return b->args[i];\n }\n \n+*/\n\\ No newline at end of file\ndiff --git a/src/links.h b/src/links.h\nindex bfbb0ed..9eb4c1f 100644\n--- a/src/links.h\n+++ b/src/links.h\n@@ -1,32 +1,32 @@\n #ifndef links_h\n #define links_h\n \n-#include "hashname.h"\n+#include "link.h"\n \n-// simple array of hashname management\n+// simple array of links management\n \n typedef struct links_struct\n {\n   int count;\n-  hashname_t *hns;\n+  link_t *links;\n   void **args;\n } *links_t;\n \n links_t links_new();\n void links_free(links_t b);\n \n-// adds/removes hashname\n-void links_add(links_t b, hashname_t h);\n-void links_rem(links_t b, hashname_t h);\n+// adds/removes link\n+void links_add(links_t b, link_t link);\n+void links_rem(links_t b, link_t link);\n \n-// returns index position if in the bucket, otherwise -1\n-int links_in(links_t b, hashname_t h);\n+// returns index position if in the list, otherwise -1\n+int links_in(links_t b, link_t link);\n \n-// these set and return an optional arg for the matching hashname\n-void links_set(links_t b, hashname_t h, void *arg);\n-void *links_arg(links_t b, hashname_t h);\n+// these set and return an optional arg for the matching link\n+void links_set(links_t b, link_t link, void *arg);\n+void *links_arg(links_t b, link_t link);\n \n // simple array index function\n-hashname_t links_get(links_t b, int index);\n+link_t links_get(links_t b, int index);\n \n #endif\n\\ No newline at end of file\ndiff --git a/src/mesh.c b/src/mesh.c\nindex a29ba4d..49c912b 100644\n--- a/src/mesh.c\n+++ b/src/mesh.c\n@@ -12,16 +12,28 @@ mesh_t mesh_new(uint32_t prime)\n   mesh_t s;\n   if(!(s = malloc(sizeof (struct mesh_struct)))) return NULL;\n   memset(s, 0, sizeof(struct mesh_struct));\n-  s->cap = 256; // default cap size\n-  s->window = 32; // default reliable window size\n+//  s->cap = 256; // default cap size\n+//  s->window = 32; // default reliable window size\n   s->index = xht_new(prime?prime:MAXPRIME);\n-  s->parts = lob_new();\n-  s->active = bucket_new();\n-  s->tick = platform_seconds();\n-  if(!s->index || !s->parts) return mesh_free(s);\n+//  s->parts = lob_new();\n+//  s->active = bucket_new();\n+//  s->tick = platform_seconds();\n+  if(!s->index) return mesh_free(s);\n   return s;\n }\n \n+mesh_t mesh_free(mesh_t s)\n+{\n+  if(!s) return NULL;\n+  xht_free(s->index);\n+//  lob_free(s->parts);\n+//  if(s->seeds) bucket_free(s->seeds);\n+//  bucket_free(s->active);\n+  free(s);\n+  return NULL;\n+}\n+\n+/*\n int mesh_init(mesh_t s, lob_t keys)\n {\n   int i = 0, err = 0;\n@@ -60,16 +72,6 @@ int mesh_init(mesh_t s, lob_t keys)\n   return 0;\n }\n \n-mesh_t mesh_free(mesh_t s)\n-{\n-  if(!s) return NULL;\n-  xht_free(s->index);\n-  lob_free(s->parts);\n-  if(s->seeds) bucket_free(s->seeds);\n-  bucket_free(s->active);\n-  free(s);\n-  return NULL;\n-}\n \n void mesh_capwin(mesh_t s, int cap, int window)\n {\n@@ -363,3 +365,4 @@ int mesh_note(mesh_t s, lob_t note)\n   return 0;\n \n }\n+*/\n\\ No newline at end of file\ndiff --git a/src/mesh.h b/src/mesh.h\nindex b112477..6af170c 100644\n--- a/src/mesh.h\n+++ b/src/mesh.h\n@@ -2,33 +2,32 @@\n #define mesh_h\n \n #include "hashname.h"\n-#include "bucket.h"\n #include "lob.h"\n #include "xht.h"\n-#include "chan.h"\n+#include "link.h"\n+#include "links.h"\n #include "util.h"\n #include "platform.h"\n-#include "crypt.h"\n-#include "path.h"\n \n typedef struct mesh_struct\n {\n   hashname_t id;\n-  bucket_t seeds, active;\n+//  bucket_t seeds, active;\n   lob_t out, last; // packets waiting to be delivered\n   lob_t parts;\n-  chan_t chans; // channels waiting to be processed\n+//  chan_t chans; // channels waiting to be processed\n   uint32_t uid, tick;\n   int cap, window;\n-  uint8_t isSeed;\n+//  uint8_t isSeed;\n   xht_t index;\n-  void (*handler)(struct mesh_struct *, hashname_t); // called w/ a hn that has no key info\n+//  void (*handler)(struct mesh_struct *, hashname_t); // called w/ a hn that has no key info\n } *mesh_t;\n \n // pass in a prime for the main index of hashnames+lines+channels, 0 to use default\n mesh_t mesh_new(uint32_t prime);\n mesh_t mesh_free(mesh_t s);\n \n+/*\n // must be called to initialize to a hashname from json keys, return !0 if failed, free\'s keys\n int mesh_init(mesh_t s, lob_t keys);\n \n@@ -63,5 +62,6 @@ void mesh_open(mesh_t s, hashname_t to, path_t direct);\n \n // sends a note packet to it\'s channel if it can, !0 for error\n int mesh_note(mesh_t s, lob_t note);\n+*/\n \n #endif\n\\ No newline at end of file\ndiff --git a/src/pipe.c b/src/pipe.c\nindex 193a810..e8655b8 100644\n--- a/src/pipe.c\n+++ b/src/pipe.c\n@@ -1,50 +1,49 @@\n-#include "path.h"\n+#include "pipe.h"\n #include <string.h>\n #include <stdlib.h>\n #include <stdio.h>\n #include <stdint.h>\n-#include "js0n.h"\n-#include "j0g.h"\n #include "util.h"\n \n-path_t path_new(char *type)\n+/*\n+pipe_t pipe_new(char *type)\n {\n   if(!strstr("ipv4 ipv6 relay local http", type)) return NULL;\n-  path_t p;\n-  if(!(p = malloc(sizeof (struct path_struct)))) return NULL;\n-  memset(p,0,sizeof (struct path_struct));\n+  pipe_t p;\n+  if(!(p = malloc(sizeof (struct pipe_struct)))) return NULL;\n+  memset(p,0,sizeof (struct pipe_struct));\n   memcpy(p->type,type,strlen(type)+1);\n   return p;\n }\n \n-void path_free(path_t p)\n+void pipe_free(pipe_t p)\n {\n   if(p->id) free(p->id);\n   if(p->json) free(p->json);\n   free(p);\n }\n \n-path_t path_parse(char *json, int len)\n+pipe_t pipe_parse(char *json, int len)\n {\n   unsigned short js[64];\n-  path_t p;\n+  pipe_t p;\n   \n   if(!json) return NULL;\n   if(!len) len = strlen(json);\n   js0n((unsigned char*)json, len, js, 64);\n   if(!j0g_val("type",json,js)) return NULL;\n-  p = path_new(j0g_str("type",json,js));\n+  p = pipe_new(j0g_str("type",json,js));\n \n   // just try to set all possible attributes\n-  path_ip(p, j0g_str("ip",json,js));\n-  if(j0g_str("port",json,js)) path_port(p, (uint16_t)strtol(j0g_str("port",json,js),NULL,10));\n-  path_id(p, j0g_str("id",json,js));\n-  path_http(p, j0g_str("http",json,js));\n+  pipe_ip(p, j0g_str("ip",json,js));\n+  if(j0g_str("port",json,js)) pipe_port(p, (uint16_t)strtol(j0g_str("port",json,js),NULL,10));\n+  pipe_id(p, j0g_str("id",json,js));\n+  pipe_http(p, j0g_str("http",json,js));\n   \n   return p;\n }\n \n-char *path_id(path_t p, char *id)\n+char *pipe_id(pipe_t p, char *id)\n {\n   if(!id) return p->id;\n   if(p->id) free(p->id);\n@@ -54,12 +53,12 @@ char *path_id(path_t p, char *id)\n }\n \n // overloads our .id for the http value\n-char *path_http(path_t p, char *http)\n+char *pipe_http(pipe_t p, char *http)\n {\n-  return path_id(p,http);\n+  return pipe_id(p,http);\n }\n \n-char *path_ip(path_t p, char *ip)\n+char *pipe_ip(pipe_t p, char *ip)\n {\n   if(!ip) return p->ip;\n   if(strlen(ip) > 45) return NULL;\n@@ -67,7 +66,7 @@ char *path_ip(path_t p, char *ip)\n   return p->ip;\n }\n \n-char *path_ip4(path_t p, uint32_t ip)\n+char *pipe_ip4(pipe_t p, uint32_t ip)\n {\n   uint8_t *ip4 = (uint8_t*)&ip;\n   if(!ip) return p->ip;\n@@ -75,14 +74,14 @@ char *path_ip4(path_t p, uint32_t ip)\n   return p->ip;\n }\n \n-uint16_t path_port(path_t p, uint16_t port)\n+uint16_t pipe_port(pipe_t p, uint16_t port)\n {\n   if(port) p->port = port;\n   return p->port;\n }\n \n \n-char *path_json(path_t p)\n+char *pipe_json(pipe_t p)\n {\n   int len;\n   char *json;\n@@ -119,7 +118,7 @@ char *path_json(path_t p)\n   return p->json;\n }\n \n-int path_match(path_t p1, path_t p2)\n+int pipe_match(pipe_t p1, pipe_t p2)\n {\n   if(!p1 || !p2) return 0;\n   if(p1 == p2) return 1;\n@@ -133,7 +132,7 @@ int path_match(path_t p1, path_t p2)\n   return 0;\n }\n \n-int path_alive(path_t p)\n+int pipe_alive(pipe_t p)\n {\n   unsigned long now;\n   if(!p) return 0;\n@@ -142,17 +141,18 @@ int path_alive(path_t p)\n   return 0;\n }\n \n-// tell if path is local or public, 1 = local 0 = public\n-int path_local(path_t p)\n+// tell if pipe is local or public, 1 = local 0 = public\n+int pipe_local(pipe_t p)\n {\n   if(!p) return -1;\n   // TODO, determine public types/IP ranges\n   return 1;\n }\n \n-path_t path_copy(path_t p)\n+pipe_t pipe_copy(pipe_t p)\n {\n-  path_t p2 = path_parse(path_json(p),0);\n+  pipe_t p2 = pipe_parse(pipe_json(p),0);\n   p2->arg = p->arg;\n   return p2;\n-}\n\\ No newline at end of file\n+}\n+*/\n\\ No newline at end of file\ndiff --git a/src/pipe.h b/src/pipe.h\nindex 0699005..ee6cf05 100644\n--- a/src/pipe.h\n+++ b/src/pipe.h\n@@ -1,9 +1,9 @@\n-#ifndef path_h\n-#define path_h\n+#ifndef pipe_h\n+#define pipe_h\n \n #include <stdint.h>\n-\n-typedef struct path_struct\n+/*\n+typedef struct pipe_struct\n {\n   char type[12];\n   char *json;\n@@ -12,35 +12,35 @@ typedef struct path_struct\n   uint16_t port;\n   uint32_t tin, tout;\n   void *arg; // for use by app/network transport\n-} *path_t;\n+} *pipe_t;\n \n-path_t path_new(char *type);\n-void path_free(path_t p);\n+pipe_t pipe_new(char *type);\n+void pipe_free(pipe_t p);\n \n-// create a new path from json\n-path_t path_parse(char *json, int len);\n-path_t path_copy(path_t p);\n+// create a new pipe from json\n+pipe_t pipe_parse(char *json, int len);\n+pipe_t pipe_copy(pipe_t p);\n \n-// return json for a path\n-char *path_json(path_t p);\n+// return json for a pipe\n+char *pipe_json(pipe_t p);\n \n-// these set and/or return path values\n-char *path_id(path_t p, char *id);\n-char *path_ip(path_t p, char *ip);\n-char *path_ip4(path_t p, uint32_t ip);\n-char *path_http(path_t p, char *http);\n-uint16_t path_port(path_t p, uint16_t port);\n+// these set and/or return pipe values\n+char *pipe_id(pipe_t p, char *id);\n+char *pipe_ip(pipe_t p, char *ip);\n+char *pipe_ip4(pipe_t p, uint32_t ip);\n+char *pipe_http(pipe_t p, char *http);\n+uint16_t pipe_port(pipe_t p, uint16_t port);\n \n // inits ip/port from .sa\n-void path_sa(path_t p);\n+void pipe_sa(pipe_t p);\n \n // compare to see if they\'re the same\n-int path_match(path_t p1, path_t p2);\n-\n-// tell if the path is alive (recently active), 1 = yes, 0 = no\n-int path_alive(path_t p);\n+int pipe_match(pipe_t p1, pipe_t p2);\n \n-// tell if path is local or public, 1 = local 0 = public\n-int path_local(path_t p);\n+// tell if the pipe is alive (recently active), 1 = yes, 0 = no\n+int pipe_alive(pipe_t p);\n \n+// tell if pipe is local or public, 1 = local 0 = public\n+int pipe_local(pipe_t p);\n+*/\n #endif\n\\ No newline at end of file\ndiff --git a/test/mesh_core.c b/test/mesh_core.c\nnew file mode 100644\nindex 0000000..14cde68\n--- /dev/null\n+++ b/test/mesh_core.c\n@@ -0,0 +1,11 @@\n+#include "mesh.h"\n+#include "unit_test.h"\n+\n+int main(int argc, char **argv)\n+{\n+  mesh_t mesh = mesh_new(3);\n+  fail_unless(mesh);\n+  \n+  return 0;\n+}\n+\n', 'commit_subject': 'disable all the old v2 core code now, to begin updating mesh/link/pipe structures to v3', 'repo_name': 'telehash/telehash-c', 'committer': {'name': 'Jeremie Miller', 'email': 'aa5d8c8bb73d4465608582ffc8dcd3cb76639f53@jabber.org', 'time_sec': '1413558229', 'tz_offset': '-360', 'date': {'seconds': '1413558229'}}, 'commit_tree': 'f493210cfd754599a7abd1936d97405e72442a0c', 'commit_message': 'disable all the old v2 core code now, to begin updating mesh/link/pipe structures to v3\n', 'language_name': 'C', 'license': 'mit', 'hunks': '@@ -0,0 +1,11 @@\n+#include "mesh.h"\n+#include "unit_test.h"\n+\n+int main(int argc, char **argv)\n+{\n+  mesh_t mesh = mesh_new(3);\n+  fail_unless(mesh);\n+  \n+  return 0;\n+}\n+\n', 'addition_count': 11, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/test/mesh_core.c', 'file_extension': '.c', 'before_file': 'ADDFILE', 'message': 'disable all the old v2 core code now, to begin updating mesh/link/pipe structures to v3\n', 'author_name': 'Jeremie Miller', 'lang': 'c'}