summaryrefslogtreecommitdiff
path: root/src/lib/cacep.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2017-02-24 10:39:53 +0000
committerSander Vrijders <sander.vrijders@intec.ugent.be>2017-02-24 10:39:53 +0000
commit75cf809a95b75f09ff805b3872dcb71b80fef586 (patch)
treed8ba1df7003cff248be613425da0bb26e2865303 /src/lib/cacep.c
parent8907220599bec8067c1701c3d8bd19f9bcb19275 (diff)
parent48599a14144725dedc45f7558d814950791d069d (diff)
downloadouroboros-75cf809a95b75f09ff805b3872dcb71b80fef586.tar.gz
ouroboros-75cf809a95b75f09ff805b3872dcb71b80fef586.zip
Merged in dstaesse/ouroboros/be-cacep (pull request #391)
lib: Revise CACEP API
Diffstat (limited to 'src/lib/cacep.c')
-rw-r--r--src/lib/cacep.c50
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;