summaryrefslogtreecommitdiff
path: root/src/lib/cacep.c
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-02-21 10:56:35 +0000
committerSander Vrijders <[email protected]>2017-02-21 10:56:35 +0000
commit91091367210ee204c4082a0da05eea3336674f19 (patch)
treecd0facb94108552b0b9e75619af4e42d77be1a17 /src/lib/cacep.c
parentbf27d8fec3c8051f0518420b4b0ef2957147a887 (diff)
parentadc6766221327f99ab484d66f6f92050ec9e62d7 (diff)
downloadouroboros-91091367210ee204c4082a0da05eea3336674f19.tar.gz
ouroboros-91091367210ee204c4082a0da05eea3336674f19.zip
Merged in dstaesse/ouroboros/be-cacep (pull request #383)
lib: Exchange protocol info during CACEP
Diffstat (limited to 'src/lib/cacep.c')
-rw-r--r--src/lib/cacep.c35
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);