original files of m241
This commit is contained in:
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipnet_vrrpd.h,v $ $Revision: 1.1.2.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipnet2/include/ipnet_vrrpd.h,v $
|
||||
* $Author: jren $ $Date: 2015-02-28 08:46:04 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef IPNET_VRRPD_H
|
||||
#define IPNET_VRRPD_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Implementation of RFC5798 - Virtual Router Redundancy Protocol (VRRP)
|
||||
* This file contains helper functions used within the stack.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipnet_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_tmo2.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_pqueue.h>
|
||||
|
||||
#ifdef IPCOM_USE_INET6
|
||||
#include "ipcom_sock6.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef IPNET_USE_VRRP
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPNET_VRRP_BUF_SIZE 1000
|
||||
|
||||
/* Authentication mechanisms */
|
||||
#define IPNET_VRRP_AUTH_TYPE_0 0
|
||||
#define IPNET_VRRP_AUTH_TYPE_1 1 /* simple text password rfc2338#section-5.3.6 */
|
||||
|
||||
#define IPNET_VRRP_AUTH_DATA_SIZE 8
|
||||
|
||||
|
||||
/* VRRP states */
|
||||
#define IPNET_VRRPD_STATE_UNINITIALIZED 0
|
||||
#define IPNET_VRRPD_STATE_MASTER 1
|
||||
#define IPNET_VRRPD_STATE_BACKUP 2
|
||||
|
||||
/* VRRP group control cmd */
|
||||
#define IPNET_VRRPD_STOP_VRRP_GROUP 1
|
||||
#define IPNET_VRRPD_START_VRRP_GROUP 2
|
||||
#define IPNET_VRRPD_RESTART_VRRP_GROUP 3
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* VRRP daemon info */
|
||||
typedef struct Ipnet_vrrpd_struct
|
||||
{
|
||||
struct Ipnet_vrrpd_struct *next;
|
||||
int vr;
|
||||
int ipd;
|
||||
int version;
|
||||
int sock;
|
||||
int sock6;
|
||||
int control_sock;
|
||||
Ipcom_hash *conf_head;
|
||||
Ipcom_pqueue *tmo_head;
|
||||
Ipcom_tmo2 tmo; /* tmo to handle ipc message */
|
||||
char buf[IPNET_VRRP_BUF_SIZE];
|
||||
}
|
||||
Ipnet_vrrpd_t;
|
||||
|
||||
/* Forward declaration */
|
||||
struct Ipnet_vrrpd_conf_struct;
|
||||
|
||||
typedef void (*Ipnet_vrrpd_get_virtual_link_addr)
|
||||
(struct Ipnet_vrrpd_conf_struct *conf, struct Ip_sockaddr_dl *dl);
|
||||
|
||||
|
||||
/* Configuration parameters for one interface/VRID pair */
|
||||
typedef struct Ipnet_vrrpd_conf_struct
|
||||
{
|
||||
Ipnet_vrrpd_t *v; /* The virtual router daemon this entry is part of */
|
||||
Ip_sa_family_t sa_family; /* IP_AF_INET or IP_AF_INET6 */
|
||||
int sock_index; /* sock index for this interface, used in v->sock/sock6 */
|
||||
char ifname[IP_IFNAMSIZ]; /* Interface name */
|
||||
Ip_u32 ifindex; /* ifindex of this interface */
|
||||
Ip_u8 vrid; /* VRID 1-255 */
|
||||
Ip_u8 priority; /* Priority 1-254. If this host owns the address, we will set priority to be 255
|
||||
when sending advertisement during run-time. */
|
||||
Ip_u8 num_addresses; /* Number of elements in the 'addrs' array */
|
||||
Ip_u8 state; /* The current state (one for the IPNET_VRRPD_STATE_xxx) */
|
||||
Ip_u16 adv_interval; /* Interval between advertisements when running as master in centiseconds */
|
||||
Ip_u16 master_adv_Interval; /* Interval saved by virtual routers in the Backup state in centiseconds */
|
||||
Ipcom_tmo2 tmo; /* Handle to the current running timeout */
|
||||
Ip_bool preempt; /* IP_TRUE if we should go to backup state when a higher prio is seen */
|
||||
/*Ip_bool accept; Controls whether a virtual router in Master state will accept packets addressed to
|
||||
the address owner's IPvX address as its own if it is not the IPvX address owner.
|
||||
The default is False. Deployments that rely on, for example, pinging the address
|
||||
owner's IPvX address may wish to configure Accept_Mode to be True.
|
||||
Note: IPv6 Neighbor Solicitations and Neighbor Advertisements MUST NOT be
|
||||
dropped when Accept_Mode is False. */
|
||||
Ip_bool promisc; /* Promiscuous mode has been entered due to this virtual ID */
|
||||
Ipnet_vrrpd_get_virtual_link_addr get_virtual_link_addr;
|
||||
int auth_type;
|
||||
char auth_data[IPNET_VRRP_AUTH_DATA_SIZE];
|
||||
union {
|
||||
#ifdef IPCOM_USE_INET
|
||||
struct Ip_in_addr addrs[1]; /* Array of addresses associated with this interface/VRID */
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
struct Ip_in6_addr ipv6addrs[1]; /* Array of IPv6 addresses associated with this interface/VRID */
|
||||
#endif
|
||||
}virtual_addrs;
|
||||
}
|
||||
Ipnet_vrrpd_conf_t;
|
||||
|
||||
#define virtual_ipv4addrs virtual_addrs.addrs
|
||||
#define virtual_ipv6addrs virtual_addrs.ipv6addrs
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipnet_vrrpd_statechange_callback - The callback routine if the state of vrrp group is changed
|
||||
*
|
||||
* The callback routine if the state of vrrp group is changed.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <conf>
|
||||
* The pointer of a virtual router conf entry.
|
||||
* \i <state>
|
||||
* The state this virtual router should enter.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC void ipnet_vrrpd_statechange_callback
|
||||
(
|
||||
Ipnet_vrrpd_conf_t *conf,
|
||||
Ip_u8 state
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipnet_vrrpd_show - Show current vrrp daemon status
|
||||
*
|
||||
* This function shows current vrrp daemon status.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC void ipnet_vrrpd_show
|
||||
(
|
||||
void
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipnet_vrrpd_reconfigure_vrrp_group - reconfigure a VRRP group
|
||||
*
|
||||
* This function is used to reconfigure a VRRP group.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <cmd>
|
||||
* The reconfigure cmd. 1 for stop vrrp group, 2 for start vrrp group
|
||||
* and 3 for restart vrrp group.
|
||||
* \i <ifname>
|
||||
* The interface name to run VRRP protocol.
|
||||
* \i <vrid>
|
||||
* The vrid number(1-255), or 0 for all possible vrid groups.
|
||||
* \i <sa_family>
|
||||
* IP_AF_INET for ipv4 vrrp group or IP_AF_INET6 for ipv6 vrrp group,
|
||||
* or 0 for both.
|
||||
* \i <vr>
|
||||
* The virtual router number.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
* \is
|
||||
* \i IPCOM_SUCCESS
|
||||
* Reconfiguring vrrp group was done successfully.
|
||||
* \i IPCOM_ERR_FAILED
|
||||
* Reconfiguring vrrp group was done unsuccessfully.
|
||||
* \ie
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipnet_vrrpd_reconfigure_vrrp_group
|
||||
(
|
||||
Ip_u8 cmd,
|
||||
char *ifname,
|
||||
Ip_u8 vrid,
|
||||
Ip_sa_family_t sa_family,
|
||||
int vr
|
||||
);
|
||||
|
||||
|
||||
#endif /* IPNET_USE_VRRP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user