summaryrefslogtreecommitdiff
path: root/src/lib/pol/cacep_simple_auth.c
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-02-24 11:32:24 +0100
committerdimitri staessens <[email protected]>2017-02-24 11:34:38 +0100
commit48599a14144725dedc45f7558d814950791d069d (patch)
treef169d40a128459419181cb2d83efe1916a67f5a1 /src/lib/pol/cacep_simple_auth.c
parent41704c2379eda1124c5fc94d5589be6951e5b7ee (diff)
downloadouroboros-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/pol/cacep_simple_auth.c')
-rw-r--r--src/lib/pol/cacep_simple_auth.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/lib/pol/cacep_simple_auth.c b/src/lib/pol/cacep_simple_auth.c
index 65c510a2..69189114 100644
--- a/src/lib/pol/cacep_simple_auth.c
+++ b/src/lib/pol/cacep_simple_auth.c
@@ -38,9 +38,9 @@ typedef CacepProtoMsg cacep_proto_msg_t;
#define BUF_SIZE 2048
-static struct cacep_info * read_msg(int fd)
+static struct conn_info * read_msg(int fd)
{
- struct cacep_info * tmp;
+ struct conn_info * tmp;
uint8_t buf[BUF_SIZE];
cacep_simple_auth_msg_t * msg;
ssize_t len;
@@ -59,7 +59,7 @@ static struct cacep_info * read_msg(int fd)
return NULL;
}
- cacep_info_init(tmp);
+ conn_info_init(tmp);
tmp->addr = msg->addr;
tmp->name = strdup(msg->name);
@@ -71,7 +71,7 @@ static struct cacep_info * read_msg(int fd)
tmp->proto.protocol = strdup(msg->proto->protocol);
if (tmp->proto.protocol == NULL) {
- free(tmp->name);
+ conn_info_fini(tmp);
free(tmp);
cacep_simple_auth_msg__free_unpacked(msg, NULL);
return NULL;
@@ -80,7 +80,7 @@ static struct cacep_info * read_msg(int fd)
tmp->proto.pref_version = msg->proto->pref_version;
tmp->proto.pref_syntax = code_to_syntax(msg->proto->pref_syntax);
if (tmp->proto.pref_syntax < 0) {
- cacep_info_fini(tmp);
+ conn_info_fini(tmp);
free(tmp);
cacep_simple_auth_msg__free_unpacked(msg, NULL);
return NULL;
@@ -91,8 +91,8 @@ static struct cacep_info * read_msg(int fd)
return tmp;
}
-static int send_msg(int fd,
- const struct cacep_info * info)
+static int send_msg(int fd,
+ const struct conn_info * info)
{
cacep_simple_auth_msg_t msg = CACEP_SIMPLE_AUTH_MSG__INIT;
cacep_proto_msg_t cmsg = CACEP_PROTO_MSG__INIT;
@@ -128,13 +128,17 @@ static int send_msg(int fd,
return ret;
}
-struct cacep_info * cacep_simple_auth_auth(int fd,
- const struct cacep_info * info)
+struct conn_info * cacep_simple_auth_auth(int fd,
+ const struct conn_info * info,
+ const void * auth)
{
- struct cacep_info * tmp;
+ struct conn_info * tmp;
assert(info);
+ /* This policy does not need info to authenticate */
+ (void) auth;
+
if (send_msg(fd, info))
return NULL;
@@ -145,7 +149,7 @@ struct cacep_info * cacep_simple_auth_auth(int fd,
if (strcmp(info->proto.protocol, tmp->proto.protocol) ||
info->proto.pref_version != tmp->proto.pref_version ||
info->proto.pref_syntax != tmp->proto.pref_syntax) {
- cacep_info_fini(tmp);
+ conn_info_fini(tmp);
free(tmp);
return NULL;
}
@@ -154,19 +158,22 @@ struct cacep_info * cacep_simple_auth_auth(int fd,
}
-struct cacep_info * cacep_simple_auth_auth_wait(int fd,
- const struct cacep_info * info)
+struct conn_info * cacep_simple_auth_auth_wait(int fd,
+ const struct conn_info * info,
+ const void * auth)
{
- struct cacep_info * tmp;
+ struct conn_info * tmp;
assert(info);
+ (void) auth;
+
tmp = read_msg(fd);
if (tmp == NULL)
return NULL;
if (send_msg(fd, info)) {
- cacep_info_fini(tmp);
+ conn_info_fini(tmp);
free(tmp);
return NULL;
}
@@ -174,7 +181,7 @@ struct cacep_info * cacep_simple_auth_auth_wait(int fd,
if (strcmp(info->proto.protocol, tmp->proto.protocol) ||
info->proto.pref_version != tmp->proto.pref_version ||
info->proto.pref_syntax != tmp->proto.pref_syntax) {
- cacep_info_fini(tmp);
+ conn_info_fini(tmp);
free(tmp);
return NULL;
}