diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-02-24 11:32:24 +0100 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@ugent.be> | 2017-02-24 11:34:38 +0100 |
commit | 48599a14144725dedc45f7558d814950791d069d (patch) | |
tree | f169d40a128459419181cb2d83efe1916a67f5a1 /src/lib/cacep.c | |
parent | 41704c2379eda1124c5fc94d5589be6951e5b7ee (diff) | |
download | ouroboros-48599a14144725dedc45f7558d814950791d069d.tar.gz ouroboros-48599a14144725dedc45f7558d814950791d069d.zip |
Revise CACEP API
The information passed to CACEP is split between the information about
the connection and the information to be used during the
authentication exchange.
Diffstat (limited to 'src/lib/cacep.c')
-rw-r--r-- | src/lib/cacep.c | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/src/lib/cacep.c b/src/lib/cacep.c index 92c028af..89bd05e7 100644 --- a/src/lib/cacep.c +++ b/src/lib/cacep.c @@ -28,42 +28,45 @@ #include <ouroboros/errno.h> #include <ouroboros/logs.h> -#include <pol/cacep_anonymous_auth.h> -#include <pol/cacep_simple_auth.h> +#include "pol/cacep_anonymous_auth.h" +#include "pol/cacep_simple_auth.h" #include <stdlib.h> #include <string.h> #define BUF_SIZE 2048 -int cacep_info_init(struct cacep_info * info) +int conn_info_init(struct conn_info * info) { if (info == NULL) return -EINVAL; info->proto.protocol = NULL; - info->name = NULL; - info->data = NULL; + info->name = NULL; return 0; } -void cacep_info_fini(struct cacep_info * info) +void conn_info_fini(struct conn_info * info) { - if (info->proto.protocol != NULL) + if (info == NULL) + return; + + if (info->proto.protocol != NULL) { free(info->proto.protocol); - if (info->name != NULL) - free(info->name); - if (info->data != NULL) - free(info->data); + info->proto.protocol = NULL; + } - info->name = NULL; - info->data = NULL; + if (info->name != NULL) { + free(info->name); + info->name = NULL; + } } -struct cacep_info * cacep_auth(int fd, - enum pol_cacep pc, - const struct cacep_info * info) +struct conn_info * cacep_auth(int fd, + enum pol_cacep pc, + const struct conn_info * info, + const void * auth) { if (info == NULL) { log_err("No info provided."); @@ -72,20 +75,21 @@ struct cacep_info * cacep_auth(int fd, switch (pc) { case ANONYMOUS_AUTH: - return cacep_anonymous_auth(fd, info); + return cacep_anonymous_auth(fd, info, auth); case SIMPLE_AUTH: if (info == NULL) return NULL; - return cacep_simple_auth_auth(fd, info); + return cacep_simple_auth_auth(fd, info, auth); default: log_err("Unsupported CACEP policy."); return NULL; } } -struct cacep_info * cacep_auth_wait(int fd, - enum pol_cacep pc, - const struct cacep_info * info) +struct conn_info * cacep_auth_wait(int fd, + enum pol_cacep pc, + const struct conn_info * info, + const void * auth) { if (info == NULL) { log_err("No info provided."); @@ -94,11 +98,11 @@ struct cacep_info * cacep_auth_wait(int fd, switch (pc) { case ANONYMOUS_AUTH: - return cacep_anonymous_auth_wait(fd, info); + return cacep_anonymous_auth_wait(fd, info, auth); case SIMPLE_AUTH: if (info == NULL) return NULL; - return cacep_simple_auth_auth_wait(fd, info); + return cacep_simple_auth_auth_wait(fd, info, auth); default: log_err("Unsupported CACEP policy."); return NULL; |