summaryrefslogtreecommitdiffstats
path: root/agents/virt/include
diff options
context:
space:
mode:
Diffstat (limited to 'agents/virt/include')
-rw-r--r--agents/virt/include/bcast.h16
-rw-r--r--agents/virt/include/client.h9
-rw-r--r--agents/virt/include/debug.h31
-rw-r--r--agents/virt/include/fdops.h14
-rw-r--r--agents/virt/include/history.h25
-rw-r--r--agents/virt/include/ip_lookup.h40
-rw-r--r--agents/virt/include/list.h84
-rw-r--r--agents/virt/include/mcast.h32
-rw-r--r--agents/virt/include/options.h99
-rw-r--r--agents/virt/include/server_plugin.h130
-rw-r--r--agents/virt/include/simple_auth.h35
-rw-r--r--agents/virt/include/simpleconfig.h56
-rw-r--r--agents/virt/include/static_map.h34
-rw-r--r--agents/virt/include/tcp.h27
-rw-r--r--agents/virt/include/tcp_listener.h7
-rw-r--r--agents/virt/include/xvm.h158
16 files changed, 797 insertions, 0 deletions
diff --git a/agents/virt/include/bcast.h b/agents/virt/include/bcast.h
new file mode 100644
index 0000000..5113f04
--- /dev/null
+++ b/agents/virt/include/bcast.h
@@ -0,0 +1,16 @@
+#ifndef _XVM_MCAST_H
+#define _XVM_MCAST_H
+
+#define IPV4_MCAST_DEFAULT "225.0.0.12"
+#define IPV6_MCAST_DEFAULT "ff05::3:1"
+
+int ipv4_recv_sk(char *addr, int port);
+int ipv4_send_sk(char *src_addr, char *addr, int port,
+ struct sockaddr *src, socklen_t slen,
+ int ttl);
+int ipv6_recv_sk(char *addr, int port);
+int ipv6_send_sk(char *src_addr, char *addr, int port,
+ struct sockaddr *src, socklen_t slen,
+ int ttl);
+
+#endif
diff --git a/agents/virt/include/client.h b/agents/virt/include/client.h
new file mode 100644
index 0000000..48b92c3
--- /dev/null
+++ b/agents/virt/include/client.h
@@ -0,0 +1,9 @@
+#ifndef _CLIENT_H
+#define _CLIENT_H
+
+int tcp_fence_virt(fence_virt_args_t *args);
+int serial_fence_virt(fence_virt_args_t *args);
+int mcast_fence_virt(fence_virt_args_t *args);
+int vsock_fence_virt(fence_virt_args_t *args);
+void do_read_hostlist(int fd, int timeout);
+#endif
diff --git a/agents/virt/include/debug.h b/agents/virt/include/debug.h
new file mode 100644
index 0000000..d6a5416
--- /dev/null
+++ b/agents/virt/include/debug.h
@@ -0,0 +1,31 @@
+/*
+ Copyright Red Hat, Inc. 2007
+
+ 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, or (at your option) any
+ later version.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ MA 02139, USA.
+*/
+#ifndef _DBG_H
+#define _DBG_H
+
+void dset(int);
+int dget(void);
+
+#define dbg_printf(level, fmt, args...) \
+do { \
+ if (dget()>=level) \
+ printf(fmt, ##args); \
+} while(0)
+
+#endif
diff --git a/agents/virt/include/fdops.h b/agents/virt/include/fdops.h
new file mode 100644
index 0000000..f3194de
--- /dev/null
+++ b/agents/virt/include/fdops.h
@@ -0,0 +1,14 @@
+#ifndef _FDOPS_H
+#define _FDOPS_H
+#include <unistd.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <errno.h>
+
+int _select_retry(int fdmax, fd_set * rfds, fd_set * wfds, fd_set * xfds,
+ struct timeval *timeout);
+ssize_t _write_retry(int fd, void *buf, int count, struct timeval * timeout);
+ssize_t _read_retry(int sockfd, void *buf, int count,
+ struct timeval * timeout);
+
+#endif
diff --git a/agents/virt/include/history.h b/agents/virt/include/history.h
new file mode 100644
index 0000000..3d28518
--- /dev/null
+++ b/agents/virt/include/history.h
@@ -0,0 +1,25 @@
+#ifndef _HISTORY_H
+#define _HISTORY_H
+
+typedef struct _history_node {
+ list_head();
+ void *data;
+ time_t when;
+} history_node;
+
+typedef int (*history_compare_fn)(void *, void *);
+
+typedef struct _history_info {
+ history_node *hist;
+ history_compare_fn compare_func;
+ time_t timeout;
+ size_t element_size;
+} history_info_t;
+
+history_info_t *history_init(history_compare_fn func,
+ time_t expiration, size_t element_size);
+int history_check(history_info_t *hinfo, void *stuff);
+int history_record(history_info_t *hinfo, void *data);
+int history_wipe(history_info_t *hinfo);
+
+#endif
diff --git a/agents/virt/include/ip_lookup.h b/agents/virt/include/ip_lookup.h
new file mode 100644
index 0000000..3386c71
--- /dev/null
+++ b/agents/virt/include/ip_lookup.h
@@ -0,0 +1,40 @@
+/*
+ Copyright Red Hat, Inc. 2004,2006
+
+ The Magma Cluster API Library is free software; you can redistribute
+ it and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either version
+ 2.1 of the License, or (at your option) any later version.
+
+ The Magma Cluster API Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+*/
+/** @file
+ * Header for ip_lookup.c
+ */
+#ifndef _IP_LOOKUP_H
+#define _IP_LOOKUP_H
+
+#include <sys/queue.h>
+
+typedef struct _ip_address {
+ TAILQ_ENTRY(_ip_address) ipa_entries;
+ char ipa_family;
+ char *ipa_address;
+} ip_addr_t;
+
+typedef TAILQ_HEAD(_ip_list, _ip_address) ip_list_t;
+
+int ip_search(ip_list_t *ipl, char *ip_name);
+int ip_free_list(ip_list_t *ipl);
+int ip_build_list(ip_list_t *ipl);
+int ip_lookup(char *, struct addrinfo **);
+
+#endif
diff --git a/agents/virt/include/list.h b/agents/virt/include/list.h
new file mode 100644
index 0000000..01340d6
--- /dev/null
+++ b/agents/virt/include/list.h
@@ -0,0 +1,84 @@
+#ifndef _LIST_H
+#define _LIST_H
+
+/**
+ Simple list handlig macros.
+ Needs rewrite or inclusion of /usr/include/linux/list.h as a replacement.
+ */
+
+/* Must be first if structure is going to use it. */
+struct list_entry {
+ struct list_entry *le_next, *le_prev;
+};
+
+#define list_head() struct list_entry _list_head
+
+#define le(p) (&((*p)._list_head))
+
+#define list_insert(list, newnode) \
+do { \
+ if (!(*list)) { \
+ le(newnode)->le_next = \
+ le(newnode)->le_prev = le(newnode); \
+ *list = (void *)le(newnode); \
+ } else { \
+ le(*list)->le_prev->le_next = le(newnode); \
+ le(newnode)->le_next = le(*list); \
+ le(newnode)->le_prev = le(*list)->le_prev; \
+ le(*list)->le_prev = le(newnode); \
+ } \
+} while (0)
+
+
+#define list_prepend(list, newnode) \
+do { \
+ list_insert(list, newnode); \
+ *list = newnode; \
+} while (0)
+
+
+#define list_remove(list, oldnode) \
+do { \
+ if (le(oldnode) == le(*list)) { \
+ *list = (void *)le(*list)->le_next; \
+ } \
+ if (le(oldnode) == le(*list)) { \
+ le(oldnode)->le_next = NULL; \
+ le(oldnode)->le_prev = NULL; \
+ *list = NULL; \
+ } else { \
+ le(oldnode)->le_next->le_prev = le(oldnode)->le_prev; \
+ le(oldnode)->le_prev->le_next = le(oldnode)->le_next; \
+ le(oldnode)->le_prev = NULL; \
+ le(oldnode)->le_next = NULL; \
+ } \
+} while (0)
+
+
+/*
+ * list_for(list, tmp, counter) {
+ * stuff;
+ * }
+ *
+ * counter = # of items in list when done.
+ * * sets cnt to 0 before even checking list;
+ * * checks for valid list
+ * * traverses list, incrementing counter. If we get to the for loop,
+ * there must be at least one item in the list
+ * * cnt ends up being the number of items in the list.
+ */
+#define list_for(list, curr, cnt) \
+ if ((!(cnt=0)) && (*list != NULL)) \
+ for (curr = *list; \
+ (cnt == 0) || (curr != *list); \
+ curr = (void*)le(curr)->le_next, \
+ cnt++)
+
+#define list_for_rev(list, curr, cnt) \
+ if ((!(cnt=0)) && (*list != NULL)) \
+ for (curr = (void *)(le(*list)->le_prev); \
+ (cnt == 0) || ((void *)curr != le(*list)->le_prev); \
+ curr = (void*)(le(curr)->le_prev), \
+ cnt++)
+
+#endif
diff --git a/agents/virt/include/mcast.h b/agents/virt/include/mcast.h
new file mode 100644
index 0000000..f86ad96
--- /dev/null
+++ b/agents/virt/include/mcast.h
@@ -0,0 +1,32 @@
+/*
+ Copyright Red Hat, Inc. 2006
+
+ 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, or (at your option) any
+ later version.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ MA 02139, USA.
+*/
+#ifndef _XVM_MCAST_H
+#define _XVM_MCAST_H
+
+#define IPV4_MCAST_DEFAULT "225.0.0.12"
+#define IPV6_MCAST_DEFAULT "ff05::3:1"
+
+int ipv4_recv_sk(char *addr, int port, unsigned int ifindex);
+int ipv4_send_sk(char *src_addr, char *addr, int port,
+ struct sockaddr *src, socklen_t slen);
+int ipv6_recv_sk(char *addr, int port, unsigned int ifindex);
+int ipv6_send_sk(char *src_addr, char *addr, int port,
+ struct sockaddr *src, socklen_t slen);
+
+#endif
diff --git a/agents/virt/include/options.h b/agents/virt/include/options.h
new file mode 100644
index 0000000..6e2c1c1
--- /dev/null
+++ b/agents/virt/include/options.h
@@ -0,0 +1,99 @@
+/*
+ Copyright Red Hat, Inc. 2006
+
+ 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, or (at your option) any
+ later version.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ MA 02139, USA.
+*/
+#ifndef _XVM_OPTIONS_H
+#define _XVM_OPTIONS_H
+
+typedef enum {
+ F_FOREGROUND = 0x1,
+ F_NOCCS = 0x2,
+ F_ERR = 0x4,
+ F_HELP = 0x8,
+ F_USE_UUID = 0x10,
+ F_VERSION = 0x20,
+ F_CCSERR = 0x40,
+ F_CCSFAIL = 0x80,
+ F_NOCLUSTER = 0x100
+} arg_flags_t;
+
+typedef enum {
+ MODE_MULTICAST = 0,
+ /*MODE_BROADCAST = 1,*/
+ MODE_SERIAL = 2,
+ MODE_VMCHANNEL = 3,
+ MODE_TCP = 4,
+ MODE_VSOCK = 5
+} client_mode_t;
+
+typedef struct {
+ char *domain;
+ fence_cmd_t op;
+ client_mode_t mode;
+ int debug;
+ int timeout;
+ int delay;
+ int retr_time;
+ arg_flags_t flags;
+
+ struct network_args {
+ char *addr;
+ char *ipaddr;
+ char *key_file;
+ uint32_t cid;
+ int port;
+ fence_hash_t hash;
+ fence_auth_type_t auth;
+ int family;
+ unsigned int ifindex;
+ } net;
+
+ struct serial_args {
+ char *device; /* Serial device */
+ char *speed;
+ char *address; /* vmchannel IP */
+ } serial;
+} fence_virt_args_t;
+
+/* Private structure for commandline / stdin fencing args */
+struct arg_info {
+ const char opt;
+ const char *opt_desc;
+ const char *stdin_opt;
+ const char *obsoletes;
+ int deprecated;
+ int eh;
+ const char *content_type;
+ const char *default_value;
+ const char *desc;
+ void (*assign)(fence_virt_args_t *, struct arg_info *, char *);
+};
+
+
+/* Get options */
+void args_init(fence_virt_args_t *args);
+void args_finalize(fence_virt_args_t *args);
+
+void args_get_getopt(int argc, char **argv, const char *optstr,
+ fence_virt_args_t *args);
+void args_get_stdin(const char *optstr, fence_virt_args_t *args);
+void args_get_ccs(const char *optstr, fence_virt_args_t *args);
+void args_usage(char *progname, const char *optstr, int print_stdin);
+void args_print(fence_virt_args_t *args);
+void args_metadata(char *progname, const char *optstr);
+
+#endif
diff --git a/agents/virt/include/server_plugin.h b/agents/virt/include/server_plugin.h
new file mode 100644
index 0000000..04ceae0
--- /dev/null
+++ b/agents/virt/include/server_plugin.h
@@ -0,0 +1,130 @@
+/* */
+
+#ifndef _SERVER_PLUGIN_H
+#define _SERVER_PLUGIN_H
+
+#include "config.h"
+
+#define PLUGIN_VERSION_LISTENER ((double)0.3)
+#define PLUGIN_VERSION_BACKEND ((double)0.2)
+
+typedef void * listener_context_t;
+typedef void * backend_context_t;
+
+/* These callbacks hand requests off to the
+ appropriate backend. */
+
+/* Do nothing. Returns 1 (failure) to caller */
+typedef int (*fence_null_callback)(const char *vm_name,
+ void *priv);
+
+/* Turn the VM 'off'. Returns 0 to caller if successful or
+ nonzero if unsuccessful. */
+typedef int (*fence_off_callback)(const char *vm_name, const char *src,
+ uint32_t seqno, void *priv);
+
+/* Turn the VM 'on'. Returns 0 to caller if successful or
+ nonzero if unsuccessful. */
+typedef int (*fence_on_callback)(const char *vm_name, const char *src,
+ uint32_t seqno, void *priv);
+
+/* Reboot a VM. Returns 0 to caller if successful or
+ nonzero if unsuccessful. */
+typedef int (*fence_reboot_callback)(const char *vm_name, const char *src,
+ uint32_t seqno, void *priv);
+
+/* Get status of a VM. Returns 0 to caller if VM is alive or
+ nonzero if VM is not alive. */
+typedef int (*fence_status_callback)(const char *vm_name,
+ void *priv);
+
+/* Get status of backend. Returns 0 to caller if backend
+ is responding to requests. */
+typedef int (*fence_devstatus_callback)(void *priv);
+
+
+/* VMs available to fence. Returns 0 to caller if backend
+ is responding to requests and a host list can be produced */
+typedef int (*hostlist_callback)(const char *vm_name, const char *uuid,
+ int state, void *arg);
+typedef int (*fence_hostlist_callback)(hostlist_callback cb,
+ void *arg, void *priv);
+
+typedef int (*backend_init_fn)(backend_context_t *c,
+ config_object_t *config);
+typedef int (*backend_cleanup_fn)(backend_context_t c);
+
+typedef struct _fence_callbacks {
+ fence_null_callback null;
+ fence_off_callback off;
+ fence_on_callback on;
+ fence_reboot_callback reboot;
+ fence_status_callback status;
+ fence_devstatus_callback devstatus;
+ fence_hostlist_callback hostlist;
+} fence_callbacks_t;
+
+typedef struct backend_plugin {
+ const char *name;
+ const char *version;
+ const fence_callbacks_t *callbacks;
+ backend_init_fn init;
+ backend_cleanup_fn cleanup;
+} backend_plugin_t;
+
+double backend_plugin_version(void);
+const backend_plugin_t * backend_plugin_info(void);
+
+#define BACKEND_VER_SYM backend_plugin_version
+#define BACKEND_INFO_SYM backend_plugin_info
+#define BACKEND_VER_STR "backend_plugin_version"
+#define BACKEND_INFO_STR "backend_plugin_info"
+
+typedef int (*listener_init_fn)(listener_context_t *c,
+ const fence_callbacks_t *cb,
+ config_object_t *config,
+ map_object_t *map,
+ void *priv);
+typedef int (*listener_dispatch_fn)(listener_context_t c,
+ struct timeval *timeout);
+typedef int (*listener_cleanup_fn)(listener_context_t c);
+
+
+typedef struct listener_plugin {
+ const char *name;
+ const char *version;
+ listener_init_fn init;
+ listener_dispatch_fn dispatch;
+ listener_cleanup_fn cleanup;
+} listener_plugin_t;
+
+double listener_plugin_version(void);
+const listener_plugin_t * listener_plugin_info(void);
+
+#define LISTENER_VER_SYM listener_plugin_version
+#define LISTENER_INFO_SYM listener_plugin_info
+#define LISTENER_VER_STR "listener_plugin_version"
+#define LISTENER_INFO_STR "listener_plugin_info"
+
+typedef enum {
+ PLUGIN_NONE = 0,
+ PLUGIN_LISTENER = 1,
+ PLUGIN_BACKEND = 2
+} plugin_type_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const backend_plugin_t *plugin_find_backend(const char *name);
+const listener_plugin_t *plugin_find_listener(const char *name);
+
+void plugin_dump(void);
+int plugin_load(const char *filename);
+void plugin_unload(void);
+int plugin_search(const char *pathname);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/agents/virt/include/simple_auth.h b/agents/virt/include/simple_auth.h
new file mode 100644
index 0000000..4cd57ed
--- /dev/null
+++ b/agents/virt/include/simple_auth.h
@@ -0,0 +1,35 @@
+/*
+ Copyright Red Hat, Inc. 2006
+
+ 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, or (at your option) any
+ later version.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ MA 02139, USA.
+*/
+#ifndef _XVM_SIMPLE_AUTH_H
+#define _XVM_SIMPLE_AUTH_H
+
+#include <sys/types.h>
+
+/* 2-way challenge/response simple auth */
+#define DEFAULT_KEY_FILE "/etc/cluster/fence_xvm.key"
+
+int read_key_file(char *, char *, size_t);
+int sock_challenge(int, fence_auth_type_t, void *, size_t, int);
+int sock_response(int, fence_auth_type_t, void *, size_t, int);
+int sign_request(fence_req_t *, void *, size_t);
+int verify_request(fence_req_t *, fence_hash_t, void *, size_t);
+
+/* SSL certificate-based authentication TBD */
+
+#endif
diff --git a/agents/virt/include/simpleconfig.h b/agents/virt/include/simpleconfig.h
new file mode 100644
index 0000000..6aba85f
--- /dev/null
+++ b/agents/virt/include/simpleconfig.h
@@ -0,0 +1,56 @@
+#ifndef _SIMPLECONFIG_H
+#define _SIMPLECONFIG_H
+
+typedef int (*config_get_t)(void *config, const char *key,
+ char *value, size_t valuesz);
+typedef int (*config_set_t)(void *config, const char *key,
+ const char *value);
+typedef int (*config_parse_t)(const char *filename, void **config);
+typedef int (*config_free_t)(void *config);
+typedef void (*config_dump_t)(void *config, FILE *fp);
+
+/*
+ * We use an abstract object here so we do not have to link loadable
+ * modules against the configuration library.
+ */
+
+typedef struct {
+ config_get_t get;
+ config_set_t set;
+ config_parse_t parse;
+ config_free_t free;
+ config_dump_t dump;
+ void *info;
+} config_object_t;
+
+/*
+ * These macros may be called from within a loadable module
+ */
+#define sc_get(obj, key, value, valuesz) \
+ obj->get(obj->info, key, value, valuesz)
+#define sc_set(obj, key, value) \
+ obj->set(obj->info, key, value)
+#define sc_parse(obj, filename) \
+ obj->parse(filename, &obj->info)
+#define sc_free(obj) \
+ obj->free(obj->info)
+#define sc_dump(obj, fp) \
+ obj->dump(obj->info, fp)
+
+/*
+ * Do not call the below functions from loadable modules. Doing so
+ * requires linking the configuration library in to the modules, which
+ * is what we want to avoid.
+ */
+
+/* Returns a copy of our simple config object */
+config_object_t *sc_init(void);
+
+/* Frees a previously-allocated copy of our simple config object */
+void sc_release(config_object_t *c);
+
+int check_file_permissions(const char *fname);
+
+int do_configure(config_object_t *config, const char *filename);
+
+#endif
diff --git a/agents/virt/include/static_map.h b/agents/virt/include/static_map.h
new file mode 100644
index 0000000..736e823
--- /dev/null
+++ b/agents/virt/include/static_map.h
@@ -0,0 +1,34 @@
+#ifndef _STATIC_MAP_H
+#define _STATIC_MAP_H
+
+typedef int (*map_load_t)(void *config, void **perm_info);
+typedef int (*map_check_t)(void *info, const char *src, const char *tgt_uuid, const char *tgt_name);
+typedef void (*map_cleanup_t)(void **info);
+
+typedef struct {
+ map_load_t load;
+ map_check_t check;
+ map_cleanup_t cleanup;
+ void *info;
+} map_object_t;
+
+/*
+ * These macros may be called from within a loadable module
+ */
+#define map_load(obj, config) \
+ obj->load(config, &obj->info)
+#define map_check(obj, src, tgt_uuid) \
+ obj->check(obj->info, src, tgt_uuid, NULL)
+#define map_check2(obj, src, tgt_uuid, tgt_name) \
+ obj->check(obj->info, src, tgt_uuid, tgt_name)
+#define map_free(obj) \
+ obj->cleanup(obj->info)
+
+/* Returns a copy of our simple config object */
+void *map_init(void);
+
+/* Frees a previously-allocated copy of our simple config object */
+void map_release(void *c);
+
+
+#endif
diff --git a/agents/virt/include/tcp.h b/agents/virt/include/tcp.h
new file mode 100644
index 0000000..609f3e9
--- /dev/null
+++ b/agents/virt/include/tcp.h
@@ -0,0 +1,27 @@
+/*
+ Copyright Red Hat, Inc. 2006
+
+ 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, or (at your option) any
+ later version.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ MA 02139, USA.
+*/
+#ifndef _XVM_TCP_H
+#define _XVM_TCP_H
+
+int ipv4_connect(struct in_addr *in_addr, uint16_t port, int timeout);
+int ipv6_connect(struct in6_addr *in6_addr, uint16_t port, int timeout);
+int ipv4_listen(const char *addr_str, uint16_t port, int backlog);
+int ipv6_listen(const char *addr_str, uint16_t port, int backlog);
+
+#endif
diff --git a/agents/virt/include/tcp_listener.h b/agents/virt/include/tcp_listener.h
new file mode 100644
index 0000000..75dec93
--- /dev/null
+++ b/agents/virt/include/tcp_listener.h
@@ -0,0 +1,7 @@
+#ifndef __TCP_LISTENER_H
+#define __TCP_LISTENER_H
+
+#define IPV4_TCP_ADDR_DEFAULT "127.0.0.1"
+#define IPV6_TCP_ADDR_DEFAULT "::1"
+
+#endif
diff --git a/agents/virt/include/xvm.h b/agents/virt/include/xvm.h
new file mode 100644
index 0000000..bcd7db2
--- /dev/null
+++ b/agents/virt/include/xvm.h
@@ -0,0 +1,158 @@
+/*
+ Copyright Red Hat, Inc. 2006
+
+ 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, or (at your option) any
+ later version.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ MA 02139, USA.
+*/
+#ifndef _XVM_H
+#define _XVM_H
+
+#include <stdint.h>
+#include <sechash.h>
+#include <netinet/in.h>
+#include <byteswap.h>
+#include <endian.h>
+
+#define XVM_VERSION "1.9.0"
+
+#define MAX_DOMAINNAME_LENGTH 64 /* XXX MAXHOSTNAMELEN */
+#define MAX_ADDR_LEN sizeof(struct sockaddr_in6)
+#define DOMAIN0NAME "Domain-0"
+#define DOMAIN0UUID "00000000-0000-0000-0000-000000000000"
+
+typedef enum {
+ HASH_NONE = 0x0, /* No packet signing */
+ HASH_SHA1 = 0x1, /* SHA1 signing */
+ HASH_SHA256 = 0x2, /* SHA256 signing */
+ HASH_SHA512 = 0x3 /* SHA512 signing */
+} fence_hash_t;
+
+#define DEFAULT_HASH HASH_SHA256
+
+typedef enum {
+ AUTH_NONE = 0x0, /* Plain TCP */
+ AUTH_SHA1 = 0x1, /* Challenge-response (SHA1) */
+ AUTH_SHA256 = 0x2, /* Challenge-response (SHA256) */
+ AUTH_SHA512 = 0x3 /* Challenge-response (SHA512) */
+ /* AUTH_SSL_X509 = 0x10 SSL X509 certificates */
+} fence_auth_type_t;
+
+#define DEFAULT_AUTH AUTH_SHA256
+
+typedef enum {
+ FENCE_NULL = 0x0,
+ FENCE_OFF = 0x1, /* Turn the VM off */
+ FENCE_REBOOT = 0x2, /* Hit the reset button */
+ FENCE_ON = 0x3, /* Turn the VM on */
+ FENCE_STATUS = 0x4, /* virtual machine status (off/on) */
+ FENCE_DEVSTATUS = 0x5, /* Status of the fencing device */
+ FENCE_HOSTLIST = 0x6, /* List VMs controllable */
+ FENCE_METADATA = 0x7, /* Print fence agent metadata */
+ FENCE_VALIDATEALL = 0x8 /* Validate command-line or stdin arguments and exit */
+} fence_cmd_t;
+
+#define DEFAULT_TTL 4
+
+#ifndef DEFAULT_HYPERVISOR_URI
+#define DEFAULT_HYPERVISOR_URI "qemu:///system"
+#endif
+
+#define MAX_HASH_LENGTH SHA512_LENGTH
+#define MAX_KEY_LEN 4096
+
+typedef struct __attribute__ ((packed)) _fence_req {
+ uint8_t request; /* Fence request */
+ uint8_t hashtype; /* Hash type used */
+ uint8_t addrlen; /* Length of address */
+ uint8_t flags; /* Special flags */
+#define RF_UUID 0x1 /* Flag specifying UUID */
+ uint8_t domain[MAX_DOMAINNAME_LENGTH]; /* Domain to fence*/
+ uint8_t address[MAX_ADDR_LEN]; /* We're this IP */
+#define DEFAULT_MCAST_PORT 1229
+ uint16_t port; /* Port we bound to */
+ uint8_t random[6]; /* Random Data */
+ uint32_t seqno; /* Request identifier; can be random */
+ uint32_t family; /* Address family */
+ uint8_t hash[MAX_HASH_LENGTH]; /* Binary hash */
+} fence_req_t;
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define swab_fence_req_t(req) \
+do { \
+ (req)->seqno = bswap_32((req)->seqno); \
+ (req)->family = bswap_32((req)->family); \
+ (req)->port = bswap_32((req)->port); \
+} while(0)
+#else
+#define swab_fence_req_t(req)
+#endif
+
+
+/* for host list */
+typedef struct __attribute__ ((packed)) _host_info {
+ uint8_t domain[MAX_DOMAINNAME_LENGTH];
+ uint8_t uuid[MAX_DOMAINNAME_LENGTH];
+ uint8_t state;
+ uint8_t pad;
+} host_state_t;
+
+
+#define DEFAULT_SERIAL_DEVICE "/dev/ttyS1"
+#define DEFAULT_SERIAL_SPEED "115200,8N1"
+#define DEFAULT_CHANNEL_IP "10.0.2.179"
+#define SERIAL_MAGIC 0x61626261 /* endian doesn't matter */
+
+typedef struct __attribute__((packed)) _serial_fence_req {
+ uint32_t magic;
+ uint8_t request;
+ uint8_t flags;
+ uint8_t domain[MAX_DOMAINNAME_LENGTH];
+ uint32_t seqno;
+} serial_req_t;
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define swab_serial_req_t(req) \
+do { \
+ (req)->magic = bswap_32((req)->magic); \
+ (req)->seqno = bswap_32((req)->seqno); \
+} while(0)
+#else
+#define swab_serial_req_t(req)
+#endif
+
+
+typedef struct __attribute__((packed)) _serial_fense_resp {
+ uint32_t magic;
+ uint8_t response;
+} serial_resp_t;
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define swab_serial_resp_t(req) \
+do { \
+ (req)->magic = bswap_32((req)->magic); \
+} while(0)
+#else
+#define swab_serial_resp_t(req)
+#endif
+
+
+#define RESP_SUCCESS 0
+#define RESP_FAIL 1
+#define RESP_OFF 2
+#define RESP_PERM 3
+#define RESP_HOSTLIST 253
+
+
+#endif