]> git.ipfire.org Git - thirdparty/lldpd.git/blob - src/ctl.h
Be more defensive when parsing PRETTY_NAME out of os-release
[thirdparty/lldpd.git] / src / ctl.h
1 /* -*- mode: c; c-file-style: "openbsd" -*- */
2 /*
3 * Copyright (c) 2012 Vincent Bernat <bernat@luffy.cx>
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18 #ifndef _CTL_H
19 #define _CTL_H
20
21 #if HAVE_CONFIG_H
22 # include <config.h>
23 #endif
24
25 #include <stdint.h>
26 #include "marshal.h"
27
28 enum hmsg_type {
29 NONE,
30 GET_CONFIG, /* Get global configuration */
31 SET_CONFIG, /* Change global configuration */
32 GET_INTERFACES, /* Get list of interfaces */
33 SET_CHASSIS, /* Set local chassis */
34 GET_CHASSIS, /* Get local chassis */
35 GET_INTERFACE, /* Get all information related to an interface */
36 GET_DEFAULT_PORT, /* Get all information related to default port */
37 SET_PORT, /* Set port-related information (location, power, policy) */
38 SUBSCRIBE, /* Subscribe to neighbor changes */
39 NOTIFICATION, /* Notification message (sent by lldpd!) */
40 };
41
42 /** Header for the control protocol.
43 *
44 * The protocol is pretty simple. We send a single message containing the
45 * provided message type with the message length, followed by the message
46 * content.
47 */
48 struct hmsg_header {
49 enum hmsg_type type;
50 size_t len;
51 };
52 #define HMSG_MAX_SIZE (1 << 19)
53
54 /* ctl.c */
55 int ctl_create(const char *);
56 int ctl_connect(const char *);
57 void ctl_cleanup(const char *);
58
59 int ctl_msg_send_unserialized(uint8_t **, size_t *, enum hmsg_type, void *,
60 struct marshal_info *);
61 size_t ctl_msg_recv_unserialized(uint8_t **, size_t *, enum hmsg_type, void **,
62 struct marshal_info *);
63
64 #endif