From adc6766221327f99ab484d66f6f92050ec9e62d7 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 21 Feb 2017 08:02:37 +0100 Subject: lib: Exchange protocol info during CACEP This exchanges a protocol name, a protocol version and concrete syntax for the protocol upon CACEP. For CDAP, only version 1 and GPB are supported. No lists for other supported versions or syntaxes are exchanged (but the proto file supports it). CACEP fails if there is a mismatch between the protocol names, version and syntax specified by the communicating parties. --- src/lib/cacep.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/lib/cacep.c') diff --git a/src/lib/cacep.c b/src/lib/cacep.c index 3d556d8f..92c028af 100644 --- a/src/lib/cacep.c +++ b/src/lib/cacep.c @@ -36,10 +36,40 @@ #define BUF_SIZE 2048 +int cacep_info_init(struct cacep_info * info) +{ + if (info == NULL) + return -EINVAL; + + info->proto.protocol = NULL; + info->name = NULL; + info->data = NULL; + + return 0; +} + +void cacep_info_fini(struct cacep_info * info) +{ + if (info->proto.protocol != NULL) + free(info->proto.protocol); + if (info->name != NULL) + free(info->name); + if (info->data != NULL) + free(info->data); + + info->name = NULL; + info->data = NULL; +} + struct cacep_info * cacep_auth(int fd, enum pol_cacep pc, const struct cacep_info * info) { + if (info == NULL) { + log_err("No info provided."); + return NULL; + } + switch (pc) { case ANONYMOUS_AUTH: return cacep_anonymous_auth(fd, info); @@ -57,6 +87,11 @@ struct cacep_info * cacep_auth_wait(int fd, enum pol_cacep pc, const struct cacep_info * info) { + if (info == NULL) { + log_err("No info provided."); + return NULL; + } + switch (pc) { case ANONYMOUS_AUTH: return cacep_anonymous_auth_wait(fd, info); -- cgit v1.2.3