Files
m241Neelima/components/ip_net2-6.9/ipmpls/include/ipmpls_netlink.h
T
2026-07-30 11:19:44 +05:30

244 lines
8.6 KiB
C

/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmpls_netlink.h,v $ $Revision: 1.2 $
* $Source:
* $Author: jonas $ $Date: 2006-06-01 11:58:53 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
******************************************************************************
*/
#ifndef IPMPLS_NETLINK_H
#define IPMPLS_NETLINK_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
* This is the IPMPLS header file for the Linux compatible NETLINK interface
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include "ipmpls.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/*
*===========================================================================
* IPMPLS_NETLINK_XXX
*===========================================================================
*/
#define IPMPLS_NETLINK_ROUTE 0 /* Routing/device hook */
/*
*===========================================================================
* IPMPLS_RTN_XXX
*===========================================================================
* IPMPLS message sub types for NETLINK RULE messages
*/
#define IPMPLS_RTN_ILM 1
#define IPMPLS_RTN_NHLFE 2
#define IPMPLS_RTN_XC 3
#define IPMPLS_RTN_LABELSPACE 4
#define IPMPLS_RTN_ILMFLUSH 5
#define IPMPLS_RTN_NHLFEFLUSH 6
#define IPMPLS_RTN_TUNNEL 7
#define IPMPLS_RTN_MAX 8
/*
*===========================================================================
* IPMPLS_RTA_XXX
*===========================================================================
* IPMPLS route message attribute values
*/
#define IPMPLS_RTA_ILM 1
#define IPMPLS_RTA_NHLFE 2
#define IPMPLS_RTA_XC 3
#define IPMPLS_RTA_LABELSPACE 4
#define IPMPLS_RTA_INSTR 5
#define IPMPLS_RTA_TUNNEL_NAME 7
#define IPMPLS_RTA_TUNNEL_DATA 8
#define IPMPLS_RTA_VR 9
#define IPMPLS_RTA_COOKIE 10
#define IPMPLS_RTA_MAX IPMPLS_RTA_COOKIE
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/*
*===========================================================================
* ipmpls_nlmsghdr
*===========================================================================
*/
struct Ipmpls_nlmsghdr
{
Ip_u32 nlmsg_len; /* Length of message including header */
Ip_u16 nlmsg_type; /* Message content */
Ip_u16 nlmsg_flags; /* Additional flags */
Ip_u32 nlmsg_seq; /* Sequence number */
Ip_pid_t nlmsg_pid; /* Sending process id */
};
/* Flags values */
#define IPMPLS_NLM_F_REQUEST 1 /* It is request message */
#define IPMPLS_NLM_F_MULTI 2 /* Multipart message, terminated by NLMSG_DONE */
#define IPMPLS_NLM_F_ACK 4 /* Reply with ack, with zero or error code */
#define IPMPLS_NLM_F_ECHO 8 /* Echo this request */
#define IPMPLS_NLM_F_ROOT 0x100 /* Specify tree root */
/* Modifiers to GET request */
#define IPMPLS_NLM_F_ROOT 0x100 /* Specify tree root */
#define IPMPLS_NLM_F_MATCH 0x200 /* Return all matching */
#define IPMPLS_NLM_F_ATOMIC 0x400 /* Atomic GET */
#define IPMPLS_NLM_F_DUMP (IPMPLS_NLM_F_ROOT | IPMPLS_NLM_F_MATCH)
/* Modifiers to NEW request */
#define IPMPLS_NLM_F_REPLACE 0x100 /* Override existing */
#define IPMPLS_NLM_F_EXCL 0x200 /* Do not touch, if it exists */
#define IPMPLS_NLM_F_CREATE 0x400 /* Create, if it does not exist */
#define IPMPLS_NLM_F_APPEND 0x800 /* Add to end of list */
#define IPMPLS_NLMSG_ALIGNTO 4
#define IPMPLS_NLMSG_ALIGN(len) (((len)+IPMPLS_NLMSG_ALIGNTO-1) & ~(IPMPLS_NLMSG_ALIGNTO-1))
#define IPMPLS_NLMSG_LENGTH(len) ((len)+IPMPLS_NLMSG_ALIGN(sizeof(struct Ipmpls_nlmsghdr)))
#define IPMPLS_NLMSG_SPACE(len) IPMPLS_NLMSG_ALIGN(IPMPLS_NLMSG_LENGTH(len))
#define IPMPLS_NLMSG_DATA(nlh) ((void*)(((char*)nlh) + IPMPLS_NLMSG_LENGTH(0)))
#define IPMPLS_NLMSG_NEXT(nlh,len) ((len) -= IPMPLS_NLMSG_ALIGN((nlh)->nlmsg_len), \
(struct Ipmpls_nlmsghdr*)(((char*)(nlh)) + IPMPLS_NLMSG_ALIGN((nlh)->nlmsg_len)))
#define IPMPLS_NLMSG_OK(nlh,len) ((len) > 0 \
&& (nlh)->nlmsg_len >= sizeof(struct Ipmpls_nlmsghdr) \
&& (nlh)->nlmsg_len <= (len))
#define IPMPLS_NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - IPMPLS_NLMSG_SPACE((len)))
#define IPMPLS_NLMSG_NOOP 0x1 /* Nothing */
#define IPMPLS_NLMSG_ERROR 0x2 /* Error */
#define IPMPLS_NLMSG_DONE 0x3 /* End of a dump */
#define IPMPLS_NLMSG_OVERRUN 0x4 /* Data lost */
#define IPMPLS_RTM_NEWRULE 32
#define IPMPLS_RTM_DELRULE 33
#define IPMPLS_RTM_GETRULE 34
/*
*===========================================================================
* ipmpls_netlink_callback
*===========================================================================
*/
struct Ipmpls_netlink_callback
{
Ip_u8 *buf;
struct Ipmpls_nlmsghdr *nlh;
int (*dump)(Ip_u8 *buf, Ip_size_t len, struct Ipmpls_netlink_callback *cb);
int (*done)(struct Ipmpls_netlink_callback *cb);
int family;
Ip_ptrdiff_t args[4];
};
/*
*===========================================================================
* ipmpls_rtattr
*===========================================================================
*/
struct Ipmpls_rtattr
{
Ip_u16 rta_len;
Ip_u16 rta_type;
};
#define IPMPLS_RTA_ALIGNTO 4
#define IPMPLS_RTA_ALIGN(len) (((len)+IPMPLS_RTA_ALIGNTO-1) & ~(IPMPLS_RTA_ALIGNTO-1))
#define IPMPLS_RTA_OK(rta,len) ((len) > 0 \
&& (rta)->rta_len >= sizeof(struct Ipmpls_rtattr) \
&& (rta)->rta_len <= (len))
#define IPMPLS_RTA_NEXT(rta,attrlen) \
((attrlen) -= IPMPLS_RTA_ALIGN((rta)->rta_len), \
(struct Ipmpls_rtattr *)(((char *)(rta)) + IPMPLS_RTA_ALIGN((rta)->rta_len)))
#define IPMPLS_RTA_LENGTH(len) (IPMPLS_RTA_ALIGN(sizeof(struct Ipmpls_rtattr)) + (len))
#define IPMPLS_RTA_SPACE(len) IPMPLS_RTA_ALIGN(IPMPLS_RTA_LENGTH(len))
#define IPMPLS_RTA_DATA(rta) ((void*)(((char*)(rta)) + IPMPLS_RTA_LENGTH(0)))
#define IPMPLS_RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - IPMPLS_RTA_LENGTH(0))
/*
*===========================================================================
* ipmpls_rtmsg
*===========================================================================
*/
struct Ipmpls_rtmsg
{
Ip_u8 rtm_family;
Ip_u8 rtm_dst_len;
Ip_u8 rtm_src_len;
Ip_u8 rtm_tos;
Ip_u8 rtm_table;
Ip_u8 rtm_protocol;
Ip_u8 rtm_scope;
Ip_u8 rtm_type;
Ip_u32 rtm_flags;
};
#define IPMPLS_RTM_RTA(r) ((struct Ipmpls_rtattr *)(((char *)(r)) + IPMPLS_NLMSG_ALIGN(sizeof(struct Ipmpls_rtmsg))))
#define IPMPLS_RTM_PAYLOAD(n) IPMPLS_NLMSG_PAYLOAD(n,sizeof(struct Ipmpls_rtmsg))
IP_PUBLIC void ipcom_netlink_post(int unit, void *data, Ip_size_t len, int msg_group, Ip_u16 vr);
IP_PUBLIC int ipmpls_netlink_rtm_new(Ip_u8 *data, Ip_size_t len, struct Ipmpls_nlmsghdr *nlh, void *arg, int vr);
IP_PUBLIC int ipmpls_netlink_rtm_del(Ip_u8 *data, Ip_size_t len, struct Ipmpls_nlmsghdr *nlh, void *arg, int vr);
IP_PUBLIC int ipmpls_netlink_rtm_get(Ip_u8 *data, Ip_size_t len, struct Ipmpls_nlmsghdr *nlh,
void *arg, void **out_msg, int s_vr);
IP_PUBLIC int ipmpls_netlink_rtm_dump(Ip_u8 *data, Ip_size_t len, struct Ipmpls_netlink_callback *cb, int vr);
#ifdef __cplusplus
}
#endif
#endif /* IPMPL_NETLINK_H */
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/