net->frnd_msgs = l_queue_new();
net->destinations = l_queue_new();
net->app_keys = l_queue_new();
+ net->replay_cache = l_queue_new();
if (!nets)
nets = l_queue_new();
mesh_config_write_iv_index(cfg, iv_index, ivu);
/* Cleanup Replay Protection List NVM */
- rpl_init(net->node, iv_index);
+ rpl_update(net->node, iv_index);
}
node_property_changed(net->node, "IVIndex");
if (!net || !net->node)
return true;
- if (!net->replay_cache) {
- net->replay_cache = l_queue_new();
- rpl_init(net->node, net->iv_index);
- rpl_get_list(net->node, net->replay_cache);
- }
-
rpe = l_queue_find(net->replay_cache, match_replay_cache,
L_UINT_TO_PTR(src));
/* TODO: Save to node config */
return MESH_STATUS_SUCCESS;
}
+
+bool mesh_net_load_rpl(struct mesh_net *net)
+{
+ return rpl_get_list(net->node, net->replay_cache);
+}
uint16_t crpl, uint32_t seq, uint32_t iv_index);
void net_msg_add_replay_cache(struct mesh_net *net, uint16_t src, uint32_t seq,
uint32_t iv_index);
+bool mesh_net_load_rpl(struct mesh_net *net);
#include "mesh/dbus.h"
#include "mesh/agent.h"
#include "mesh/manager.h"
+#include "mesh/rpl.h"
#include "mesh/node.h"
#define MESH_NODE_PATH_PREFIX "/node"
node->storage_dir = l_strdup(dir_name);
- return true;
+ /* Initialize directory for storing RPL info */
+ return rpl_init(node->storage_dir);
}
static void update_net_settings(struct mesh_node *node)
mesh_net_set_iv_index(node->net, db_node->iv_index, db_node->iv_update);
+ /* Initialize directory for storing keyring and RPL info */
+ if (!init_storage_dir(node) || !mesh_net_load_rpl(node->net))
+ goto fail;
+
if (db_node->net_transmit)
mesh_net_transmit_params_set(node->net,
db_node->net_transmit->count,
node->cfg = cfg;
- /* Initialize directory for storing keyring info */
- init_storage_dir(node);
-
return true;
fail:
node_remove(node);
DIR *dir;
int fd;
- if (!node || !IS_UNICAST(src))
+ if (!IS_UNICAST(src))
return false;
node_path = node_get_storage_dir(node);
struct dirent *entry;
DIR *dir;
- if (!node || !IS_UNICAST(src))
+ if (!IS_UNICAST(src))
return;
node_path = node_get_storage_dir(node);
size_t len;
DIR *dir;
- if (!node || !rpl_list)
+ if (!rpl_list)
return false;
node_path = node_get_storage_dir(node);
- len = strlen(node_path) + strlen(rpl_dir) + 14;
+ len = strlen(node_path) + strlen(rpl_dir) + 15;
if (len > PATH_MAX)
return false;
return true;
}
-void rpl_init(struct mesh_node *node, uint32_t cur)
+void rpl_update(struct mesh_node *node, uint32_t cur)
{
uint32_t old = cur - 1;
const char *node_path;
char path[PATH_MAX];
DIR *dir;
- if (!node)
- return;
-
node_path = node_get_storage_dir(node);
+ if (!node_path)
+ return;
- if (strlen(node_path) + strlen(rpl_dir) + 10 >= PATH_MAX)
+ if (strlen(node_path) + strlen(rpl_dir) + 15 >= PATH_MAX)
return;
/* Make sure path exists */
closedir(dir);
}
+
+bool rpl_init(const char *node_path)
+{
+ char path[PATH_MAX];
+
+ if (strlen(node_path) + strlen(rpl_dir) + 15 >= PATH_MAX)
+ return false;
+
+ snprintf(path, PATH_MAX, "%s%s", node_path, rpl_dir);
+ mkdir(path, 0755);
+ return true;
+}
uint32_t seq);
void rpl_del_entry(struct mesh_node *node, uint16_t src);
bool rpl_get_list(struct mesh_node *node, struct l_queue *rpl_list);
-void rpl_init(struct mesh_node *node, uint32_t iv_index);
+void rpl_update(struct mesh_node *node, uint32_t iv_index);
+bool rpl_init(const char *node_path);