// must be called to initialize to a hashname from keys/secrets, return !0 if failed uint8_t mesh_load(mesh_t mesh, lob_t secrets, lob_t keys) { if(!mesh || !secrets || !keys) return 1; if(!(mesh->self = e3x_self_new(secrets, keys))) return 2; mesh->keys = lob_copy(keys); mesh->id = hashname_dup(hashname_vkeys(mesh->keys)); LOG_INFO("mesh is %s",hashname_short(mesh->id)); return 0; }
link_t link_new(mesh_t mesh, hashname_t id) { link_t link; if(!mesh || !id) return LOG("invalid args"); LOG("adding link %s",hashname_short(id)); if(!(link = malloc(sizeof (struct link_struct)))) return LOG("OOM"); memset(link,0,sizeof (struct link_struct)); link->id = hashname_dup(id); link->csid = 0x01; // default state link->mesh = mesh; link->next = mesh->links; mesh->links = link; return link; }