diff options
author | dimitri staessens <[email protected]> | 2017-02-21 08:02:37 +0100 |
---|---|---|
committer | dimitri staessens <[email protected]> | 2017-02-21 11:55:36 +0100 |
commit | adc6766221327f99ab484d66f6f92050ec9e62d7 (patch) | |
tree | cd0facb94108552b0b9e75619af4e42d77be1a17 /src/lib/cacep.c | |
parent | 354554c76cc2f9f30c7fd8edaeb2e3cc91c85332 (diff) | |
download | ouroboros-adc6766221327f99ab484d66f6f92050ec9e62d7.tar.gz ouroboros-adc6766221327f99ab484d66f6f92050ec9e62d7.zip |
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.
Diffstat (limited to 'src/lib/cacep.c')
-rw-r--r-- | src/lib/cacep.c | 35 |
1 files changed, 35 insertions, 0 deletions
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); |