summaryrefslogtreecommitdiff
path: root/src/lib/pol/cacep_anonymous_auth.c
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-02-24 10:39:53 +0000
committerSander Vrijders <[email protected]>2017-02-24 10:39:53 +0000
commit75cf809a95b75f09ff805b3872dcb71b80fef586 (patch)
treed8ba1df7003cff248be613425da0bb26e2865303 /src/lib/pol/cacep_anonymous_auth.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/pol/cacep_anonymous_auth.c')
-rw-r--r--src/lib/pol/cacep_anonymous_auth.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/lib/pol/cacep_anonymous_auth.c b/src/lib/pol/cacep_anonymous_auth.c
index 1fcc730a..44c7bd17 100644
--- a/src/lib/pol/cacep_anonymous_auth.c
+++ b/src/lib/pol/cacep_anonymous_auth.c
@@ -43,16 +43,16 @@ typedef CacepProtoMsg cacep_proto_msg_t;
#define NAME_LEN 8
/* this policy generates a hex string */
-static struct cacep_info * anonymous_info(void)
+static struct conn_info * anonymous_info(void)
{
- struct cacep_info * info;
+ struct conn_info * info;
struct timespec t;
info = malloc(sizeof(*info));
if (info == NULL)
return NULL;
- cacep_info_init(info);
+ conn_info_init(info);
info->name = malloc(NAME_LEN + 1);
if (info->name == NULL) {
@@ -71,9 +71,9 @@ static struct cacep_info * anonymous_info(void)
return info;
}
-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_anonymous_auth_msg_t * msg;
ssize_t len;
@@ -113,8 +113,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_anonymous_auth_msg_t msg = CACEP_ANONYMOUS_AUTH_MSG__INIT;
cacep_proto_msg_t cmsg = CACEP_PROTO_MSG__INIT;
@@ -148,13 +148,16 @@ static int send_msg(int fd,
return ret;
}
-struct cacep_info * cacep_anonymous_auth(int fd,
- const struct cacep_info * info)
+struct conn_info * cacep_anonymous_auth(int fd,
+ const struct conn_info * info,
+ const void * auth)
{
- struct cacep_info * tmp;
+ struct conn_info * tmp;
assert(info);
+ (void) auth;
+
if (send_msg(fd, info))
return NULL;
@@ -165,30 +168,31 @@ struct cacep_info * cacep_anonymous_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;
}
- tmp->data = NULL;
-
return tmp;
}
-struct cacep_info * cacep_anonymous_auth_wait(int fd,
- const struct cacep_info * info)
+struct conn_info * cacep_anonymous_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;
}
@@ -196,7 +200,7 @@ struct cacep_info * cacep_anonymous_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;
}