summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/addr_auth.c
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2017-02-21 14:10:53 +0000
committerdimitri staessens <[email protected]>2017-02-21 14:10:53 +0000
commit198e319d14af53891b81cca36fe92e06d5d7d67d (patch)
treeffe86d4470e121c47fa11faf8dd5f921f1b6de1f /src/ipcpd/normal/addr_auth.c
parent91091367210ee204c4082a0da05eea3336674f19 (diff)
parent64f2b95f622a3c2b16e4dbdc8553d506ef870a8c (diff)
downloadouroboros-198e319d14af53891b81cca36fe92e06d5d7d67d.tar.gz
ouroboros-198e319d14af53891b81cca36fe92e06d5d7d67d.zip
Merged in sandervrijders/ouroboros/be-addr (pull request #384)
ipcpd: normal: Change address authority policy
Diffstat (limited to 'src/ipcpd/normal/addr_auth.c')
-rw-r--r--src/ipcpd/normal/addr_auth.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/src/ipcpd/normal/addr_auth.c b/src/ipcpd/normal/addr_auth.c
index 210744af..8469e95e 100644
--- a/src/ipcpd/normal/addr_auth.c
+++ b/src/ipcpd/normal/addr_auth.c
@@ -3,7 +3,8 @@
*
* Address authority
*
- * Sander Vrijders <[email protected]>
+ * Sander Vrijders <[email protected]>
+ * Dimitri Staessens <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -25,47 +26,36 @@
#include <ouroboros/logs.h>
#include "addr_auth.h"
+#include "pol-addr-auth-ops.h"
#include "pol/flat.h"
#include <stdlib.h>
#include <assert.h>
-struct addr_auth * addr_auth_create(enum pol_addr_auth type)
-{
- struct addr_auth * tmp;
-
- tmp = malloc(sizeof(*tmp));
- if (tmp == NULL) {
- log_err("Failed to malloc addr auth.");
- return NULL;
- }
+struct addr_auth {
+ struct pol_addr_auth_ops * ops;
+} addr_auth;
+int addr_auth_init(enum pol_addr_auth type)
+{
switch (type) {
case FLAT_RANDOM:
- tmp->address = flat_address;
- tmp->type = type;
+ addr_auth.ops = &flat_ops;
break;
default:
log_err("Unknown address authority type.");
- free(tmp);
- return NULL;
+ return -1;
}
- return tmp;
+ return addr_auth.ops->init();
}
-int addr_auth_destroy(struct addr_auth * instance)
+uint64_t addr_auth_address(void)
{
- assert(instance);
-
- switch (instance->type) {
- case FLAT_RANDOM:
- break;
- default:
- log_err("Unknown address authority type.");
- }
-
- free(instance);
+ return addr_auth.ops->address();
+}
- return 0;
+int addr_auth_fini(void)
+{
+ return addr_auth.ops->fini();
}