diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2015-12-03 10:22:06 +0100 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2015-12-11 18:26:54 +0100 |
commit | 75749971e12ded8dfa69c48955fe68e2e6f9068b (patch) | |
tree | d40e15523eeab2340fc6df9b1a1d6a4198c4ddef /src | |
parent | 6789d79d467805d1bc484caa75de880955371e1f (diff) | |
download | strongswan-75749971e12ded8dfa69c48955fe68e2e6f9068b.tar.bz2 strongswan-75749971e12ded8dfa69c48955fe68e2e6f9068b.tar.xz |
Define VICI protocol versions
Diffstat (limited to 'src')
-rw-r--r-- | src/libcharon/plugins/vici/Makefile.am | 2 | ||||
-rw-r--r-- | src/libcharon/plugins/vici/libvici.c | 9 | ||||
-rw-r--r-- | src/libcharon/plugins/vici/libvici.h | 26 | ||||
-rw-r--r-- | src/libcharon/plugins/vici/vici_version.c | 21 | ||||
-rw-r--r-- | src/libcharon/plugins/vici/vici_version.h | 30 |
5 files changed, 88 insertions, 0 deletions
diff --git a/src/libcharon/plugins/vici/Makefile.am b/src/libcharon/plugins/vici/Makefile.am index 48e2f0cea..f152482a4 100644 --- a/src/libcharon/plugins/vici/Makefile.am +++ b/src/libcharon/plugins/vici/Makefile.am @@ -14,6 +14,7 @@ plugin_LTLIBRARIES = libstrongswan-vici.la endif libstrongswan_vici_la_SOURCES = \ + vici_version.c vici_version.h \ vici_socket.h vici_socket.c \ vici_message.h vici_message.c \ vici_builder.h vici_builder.c \ @@ -38,6 +39,7 @@ ipseclib_LTLIBRARIES = libvici.la libvici_la_SOURCES = \ vici_message.c vici_message.h \ vici_builder.c vici_builder.h \ + vici_version.c vici_version.h \ libvici.c libvici.h libvici_la_LIBADD = $(top_builddir)/src/libstrongswan/libstrongswan.la diff --git a/src/libcharon/plugins/vici/libvici.c b/src/libcharon/plugins/vici/libvici.c index 7c98c8b69..d8ccd482d 100644 --- a/src/libcharon/plugins/vici/libvici.c +++ b/src/libcharon/plugins/vici/libvici.c @@ -2,6 +2,9 @@ * Copyright (C) 2014 Martin Willi * Copyright (C) 2014 revosec AG * + * Copyright (C) 2015 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your @@ -17,6 +20,7 @@ #include "vici_builder.h" #include "vici_dispatcher.h" #include "vici_socket.h" +#include "vici_version.h" #include <library.h> #include <threading/mutex.h> @@ -329,6 +333,11 @@ void vici_add_key_valuef(vici_req_t *req, char *key, char *fmt, ...) va_end(args); } +void vici_add_version(vici_req_t *req, vici_version_t version) +{ + vici_add_key_valuef(req, "vici", "%N", vici_version_names, version); +} + void vici_begin_list(vici_req_t *req, char *name) { req->b->add(req->b, VICI_LIST_START, name); diff --git a/src/libcharon/plugins/vici/libvici.h b/src/libcharon/plugins/vici/libvici.h index 3ca9de424..57058e292 100644 --- a/src/libcharon/plugins/vici/libvici.h +++ b/src/libcharon/plugins/vici/libvici.h @@ -2,6 +2,9 @@ * Copyright (C) 2014 Martin Willi * Copyright (C) 2014 revosec AG * + * Copyright (C) 2015 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * libvici.h is MIT-licensed to simplify reuse, but please note that libvici.c * is not, as it depends on the GPLv2 licensed libstrongswan. * @@ -87,6 +90,21 @@ #include <stdio.h> /** + * Vici versions + */ +typedef enum { + /** default version if vici key/value pair is missing in message */ + VICI_1_0, + /** current version, vici key/value pair is explicitly sent in message */ + VICI_2_0, +} vici_version_t; + +/** + * Current vici version + */ +#define VICI_VERSION VICI_2_0 + +/** * Opaque vici connection contex. */ typedef struct vici_conn_t vici_conn_t; @@ -220,6 +238,14 @@ void vici_add_key_value(vici_req_t *req, char *key, void *buf, int len); void vici_add_key_valuef(vici_req_t *req, char *key, char *fmt, ...); /** + * Add a vici version key/value pair (not not needed for VICI 1.0) + * + * @param req request message to add vici version key/value pair to + * @param version vici version + */ +void vici_add_version(vici_req_t *req, vici_version_t version); + +/** * Begin a list in a request message. * * After starting a list, only list items can be added until the list gets diff --git a/src/libcharon/plugins/vici/vici_version.c b/src/libcharon/plugins/vici/vici_version.c new file mode 100644 index 000000000..70d52bf3f --- /dev/null +++ b/src/libcharon/plugins/vici/vici_version.c @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2015 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "vici_version.h" + +ENUM(vici_version_names, VICI_1_0, VICI_2_0, + "1.0", + "2.0" +); diff --git a/src/libcharon/plugins/vici/vici_version.h b/src/libcharon/plugins/vici/vici_version.h new file mode 100644 index 000000000..53e13dc95 --- /dev/null +++ b/src/libcharon/plugins/vici/vici_version.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2015 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +/** + * @defgroup vici_version vici_version + * @{ @ingroup vici + */ + +#ifndef VICI_VERSION_H_ +#define VICI_VERSION_H_ + +#include "libvici.h" + +#include <utils/utils.h> + +extern enum_name_t *vici_version_names; + +#endif /** VICI_VERSION_H_ @}*/ |