libvrrpadm.h revision 1cb875ae88fb9463b368e725c2444776595895cb
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _LIBVRRPADM_H
#define _LIBVRRPADM_H
#include <limits.h>
#include <syslog.h>
#include <libdladm.h>
#ifdef __cplusplus
extern "C" {
#endif
#define VRRP_NAME_MAX 32
#define VRRPD_SOCKET "/var/run/vrrpd.socket"
/*
* to store the IP addresses
*/
typedef struct vrrp_addr {
union {
struct sockaddr_in a4;
struct sockaddr_in6 a6;
} in;
} vrrp_addr_t;
/*
* VRRP instance (configuration information).
* Passed to vrrp_create(), returned by vrrp_query().
*/
typedef struct vrrp_vr_conf_s {
int vvc_pri;
/*
* VRRP state machine
*/
typedef enum {
VRRP_STATE_NONE = -1,
} vrrp_state_t;
/*
* VRRP status structure
* Returned by vrrp_query() as part of vrrp_queryinfo_t.
*/
typedef struct vrrp_statusinfo_s {
/*
* The information obtained from peer's advertisements
* Returned by vrrp_query() as part of vrrp_queryinfo_t.
*/
typedef struct vrrp_peer_s {
int vp_prio; /* priority in adv message */
int vp_adver_int; /* adv interval in adv message */
} vrrp_peer_t;
/*
* Useful timer information, in ms
*/
typedef struct vrrp_timeinfo_s {
int vt_since_last_tran; /* time since last state transition */
int vt_since_last_adv; /* time since last advertisement */
int vt_master_down_intv; /* timer interval for backup to */
/* declare master down */
/*
* Address information
*/
typedef struct vrrp_addrinfo_s {
char va_vnic[MAXLINKNAMELEN];
/*
* VRRP instance configuration and run-time states information
* Returned by vrrp_query().
*/
typedef struct vrrp_queryinfo {
/*
* flags sent with the VRRP_CMD_MODIFY command. Used in vrrp_setprop().
*/
#define VRRP_CONF_PRIORITY 0x01
#define VRRP_CONF_INTERVAL 0x02
#define VRRP_CONF_PREEMPT 0x04
#define VRRP_CONF_ACCEPT 0x08
/*
* Errors
*/
typedef enum {
VRRP_SUCCESS = 0,
VRRP_EINVAL, /* invalid parameter */
VRRP_EINVALVRNAME, /* invalid router name */
VRRP_ENOMEM, /* no memory */
VRRP_ENOVIRT, /* no virtual IP addresses */
VRRP_ENOPRIM, /* no primary IP address */
VRRP_ENOVNIC, /* no vnic created */
VRRP_ENOLINK, /* the link does not exist */
VRRP_EINVALLINK, /* invalid link */
VRRP_EINVALADDR, /* invalid IP address */
VRRP_EINVALAF, /* invalid IP address familty */
VRRP_EDB, /* configuration error */
VRRP_EPERM, /* permission denied */
VRRP_EBADSTATE, /* VRRP router in bad state */
VRRP_EVREXIST, /* <vrid, intf, af> three-tuple exists */
VRRP_EINSTEXIST, /* router name already exists */
VRRP_EEXIST, /* already exists */
VRRP_ENOTFOUND, /* vrrp router not found */
VRRP_ETOOSMALL, /* too small space */
VRRP_EAGAIN, /* Try again */
VRRP_EALREADY, /* already */
VRRP_EDLADM, /* dladm failure */
VRRP_EIPADM, /* ipadm failure */
VRRP_ESYS, /* system error */
VRRP_ECMD /* command request error */
} vrrp_err_t;
/*
* Internal commands used between vrrpadm and vrrpd.
*/
typedef enum {
VRRP_CMD_RETURN = 0,
char ap[INET6_ADDRSTRLEN]; \
\
INET6_ADDRSTRLEN); \
} else { \
INET6_ADDRSTRLEN); \
} \
if (append) \
else \
}
typedef struct vrrp_cmd_create_s {
typedef struct vrrp_ret_create_s {
typedef struct vrrp_cmd_delete_s {
char vcd_name[VRRP_NAME_MAX];
typedef struct vrrp_ret_delete_s {
typedef struct vrrp_cmd_enable_s {
char vcs_name[VRRP_NAME_MAX];
typedef struct vrrp_ret_enable_s {
typedef struct vrrp_cmd_disable_s {
char vcx_name[VRRP_NAME_MAX];
typedef struct vrrp_ret_disable_s {
typedef struct vrrp_cmd_modify_s {
typedef struct vrrp_ret_modify_s {
typedef struct vrrp_cmd_list_s {
char vcl_ifname[LIFNAMSIZ];
int vcl_af;
typedef struct vrrp_ret_list_s {
/*
* When vrl_cnt is non-zero, the return structure will be followed
* by the list of router names, separated by '\0'. Its size will
* be vrl_cnt * VRRP_NAME_MAX.
*/
typedef struct vrrp_cmd_query_s {
char vcq_name[VRRP_NAME_MAX];
typedef struct vrrp_ret_query_s {
/*
* Union of all VRRP commands
*/
typedef union vrrp_cmd_s {
} vrrp_cmd_t;
/*
* Union of all VRRP replies of the VRRP commands
*/
typedef union vrrp_ret_s {
} vrrp_ret_t;
/*
* Public APIs
*/
struct vrrp_handle {
};
typedef struct vrrp_handle *vrrp_handle_t;
const char *vrrp_err2str(vrrp_err_t);
const char *vrrp_state2str(vrrp_state_t);
void vrrp_close(vrrp_handle_t);
boolean_t vrrp_valid_name(const char *);
uint32_t *, char *);
#ifdef __cplusplus
}
#endif
#endif /* _LIBVRRPADM_H */