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/pol/cacep_anonymous_auth.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/pol/cacep_anonymous_auth.c')
-rw-r--r-- | src/lib/pol/cacep_anonymous_auth.c | 40 |
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; } |