|
Packit |
e9ba0d |
/* -*- mode: c; c-file-style: "openbsd" -*- */
|
|
Packit |
e9ba0d |
/*
|
|
Packit |
e9ba0d |
* Copyright (c) 2012 Vincent Bernat <bernat@luffy.cx>
|
|
Packit |
e9ba0d |
*
|
|
Packit |
e9ba0d |
* Permission to use, copy, modify, and/or distribute this software for any
|
|
Packit |
e9ba0d |
* purpose with or without fee is hereby granted, provided that the above
|
|
Packit |
e9ba0d |
* copyright notice and this permission notice appear in all copies.
|
|
Packit |
e9ba0d |
*
|
|
Packit |
e9ba0d |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
Packit |
e9ba0d |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
Packit |
e9ba0d |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
Packit |
e9ba0d |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
Packit |
e9ba0d |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
Packit |
e9ba0d |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
Packit |
e9ba0d |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
Packit |
e9ba0d |
*/
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
#ifndef _CTL_H
|
|
Packit |
e9ba0d |
#define _CTL_H
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
#if HAVE_CONFIG_H
|
|
Packit |
e9ba0d |
# include <config.h>
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
#include <stdint.h>
|
|
Packit |
e9ba0d |
#include "marshal.h"
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
enum hmsg_type {
|
|
Packit |
e9ba0d |
NONE,
|
|
Packit |
e9ba0d |
GET_CONFIG, /* Get global configuration */
|
|
Packit |
e9ba0d |
SET_CONFIG, /* Change global configuration */
|
|
Packit |
e9ba0d |
GET_INTERFACES, /* Get list of interfaces */
|
|
Packit |
e9ba0d |
GET_CHASSIS, /* Get local chassis */
|
|
Packit |
e9ba0d |
GET_INTERFACE, /* Get all information related to an interface */
|
|
Packit |
e9ba0d |
GET_DEFAULT_PORT, /* Get all information related to default port */
|
|
Packit |
e9ba0d |
SET_PORT, /* Set port-related information (location, power, policy) */
|
|
Packit |
e9ba0d |
SUBSCRIBE, /* Subscribe to neighbor changes */
|
|
Packit |
e9ba0d |
NOTIFICATION, /* Notification message (sent by lldpd!) */
|
|
Packit |
e9ba0d |
};
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
/** Header for the control protocol.
|
|
Packit |
e9ba0d |
*
|
|
Packit |
e9ba0d |
* The protocol is pretty simple. We send a single message containing the
|
|
Packit |
e9ba0d |
* provided message type with the message length, followed by the message
|
|
Packit |
e9ba0d |
* content.
|
|
Packit |
e9ba0d |
*/
|
|
Packit |
e9ba0d |
struct hmsg_header {
|
|
Packit |
e9ba0d |
enum hmsg_type type;
|
|
Packit |
e9ba0d |
size_t len;
|
|
Packit |
e9ba0d |
};
|
|
Packit |
e9ba0d |
#define HMSG_MAX_SIZE (1<<19)
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
/* ctl.c */
|
|
Packit |
e9ba0d |
int ctl_create(const char *);
|
|
Packit |
e9ba0d |
int ctl_connect(const char *);
|
|
Packit |
e9ba0d |
void ctl_cleanup(const char *);
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
int ctl_msg_send_unserialized(uint8_t **, size_t *,
|
|
Packit |
e9ba0d |
enum hmsg_type,
|
|
Packit |
e9ba0d |
void *, struct marshal_info *);
|
|
Packit |
e9ba0d |
size_t ctl_msg_recv_unserialized(uint8_t **, size_t *,
|
|
Packit |
e9ba0d |
enum hmsg_type,
|
|
Packit |
e9ba0d |
void **, struct marshal_info *);
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
#endif
|