diff options
author | dimitri staessens <[email protected]> | 2017-04-13 09:55:31 +0000 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-04-13 09:55:31 +0000 |
commit | 72c28d6173ade511e9dc6969e0fc66db2dbba38a (patch) | |
tree | 12756b89d8f4ce421c70d5cf05850b4968e76412 /src/ipcpd/normal/dir.c | |
parent | 2cc9c8d742e037c8a6ddc3eea4c05f4a905183d3 (diff) | |
parent | fc10a7587b1a642748ae0fd69f08d92b4a902248 (diff) | |
download | ouroboros-72c28d6173ade511e9dc6969e0fc66db2dbba38a.tar.gz ouroboros-72c28d6173ade511e9dc6969e0fc66db2dbba38a.zip |
Merged in dstaesse/ouroboros/be-hashes (pull request #479)
lib, ipcpd, irmd: Register hash instead of name
Diffstat (limited to 'src/ipcpd/normal/dir.c')
-rw-r--r-- | src/ipcpd/normal/dir.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/ipcpd/normal/dir.c b/src/ipcpd/normal/dir.c index ae9793c6..cbc50ba4 100644 --- a/src/ipcpd/normal/dir.c +++ b/src/ipcpd/normal/dir.c @@ -60,22 +60,23 @@ int dir_fini(void) return 0; } -int dir_name_reg(char * name) +int dir_reg(const uint8_t * hash) { + char hashstr[DIR_HASH_STRLEN + 1]; int ret; - assert(name); - - if (ipcp_get_state() != IPCP_OPERATIONAL) - return -EPERM; + assert(hash); dir_path_reset(); - ret = rib_add(dir_path, name); + ipcp_hash_str(hashstr, hash); + + ret = rib_add(dir_path, hashstr); if (ret == -ENOMEM) - return -ENOMEM; + return -ENOMEM; + + rib_path_append(dir_path, hashstr); - rib_path_append(dir_path, name); ret = rib_add(dir_path, ipcpi.name); if (ret == -EPERM) return -EPERM; @@ -88,18 +89,16 @@ int dir_name_reg(char * name) return 0; } -int dir_name_unreg(char * name) +int dir_unreg(const uint8_t * hash) { + char hashstr[DIR_HASH_STRLEN + 1]; size_t len; - assert(name); - - if (ipcp_get_state() != IPCP_OPERATIONAL) - return -EPERM; + assert(hash); dir_path_reset(); - rib_path_append(dir_path, name); + rib_path_append(dir_path, hashstr); if (!rib_has(dir_path)) return 0; @@ -118,16 +117,16 @@ int dir_name_unreg(char * name) return 0; } -int dir_name_query(char * name) +int dir_query(const uint8_t * hash) { + char hashstr[DIR_HASH_STRLEN + 1]; size_t len; - if (ipcp_get_state() != IPCP_OPERATIONAL) - return -EPERM; - dir_path_reset(); - rib_path_append(dir_path, name); + ipcp_hash_str(hashstr, hash); + + rib_path_append(dir_path, hashstr); if (!rib_has(dir_path)) return -1; |