From fadeddfbb2aa38a980dd959b5ec1ffba7afd43cb Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 20:02:34 +0200 Subject: Adding upstream version 1.0.18. Signed-off-by: Daniel Baumann --- src/ctl.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/ctl.h (limited to 'src/ctl.h') diff --git a/src/ctl.h b/src/ctl.h new file mode 100644 index 0000000..7e5b076 --- /dev/null +++ b/src/ctl.h @@ -0,0 +1,64 @@ +/* -*- mode: c; c-file-style: "openbsd" -*- */ +/* + * Copyright (c) 2012 Vincent Bernat + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _CTL_H +#define _CTL_H + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include "marshal.h" + +enum hmsg_type { + NONE, + GET_CONFIG, /* Get global configuration */ + SET_CONFIG, /* Change global configuration */ + GET_INTERFACES, /* Get list of interfaces */ + SET_CHASSIS, /* Set local chassis */ + GET_CHASSIS, /* Get local chassis */ + GET_INTERFACE, /* Get all information related to an interface */ + GET_DEFAULT_PORT, /* Get all information related to default port */ + SET_PORT, /* Set port-related information (location, power, policy) */ + SUBSCRIBE, /* Subscribe to neighbor changes */ + NOTIFICATION, /* Notification message (sent by lldpd!) */ +}; + +/** Header for the control protocol. + * + * The protocol is pretty simple. We send a single message containing the + * provided message type with the message length, followed by the message + * content. + */ +struct hmsg_header { + enum hmsg_type type; + size_t len; +}; +#define HMSG_MAX_SIZE (1 << 19) + +/* ctl.c */ +int ctl_create(const char *); +int ctl_connect(const char *); +void ctl_cleanup(const char *); + +int ctl_msg_send_unserialized(uint8_t **, size_t *, enum hmsg_type, void *, + struct marshal_info *); +size_t ctl_msg_recv_unserialized(uint8_t **, size_t *, enum hmsg_type, void **, + struct marshal_info *); + +#endif -- cgit v1.2.3