Zebra.h header cleanup (#4444)

Zebra.h header cleanup
This commit is contained in:
David Lamparter 2019-06-11 11:36:17 +02:00 committed by GitHub
commit 0afc154435
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 76 deletions

View File

@ -154,6 +154,25 @@ extern void zlog_hexdump(const void *mem, unsigned int len);
extern const char *zlog_sanitize(char *buf, size_t bufsz, const void *in,
size_t inlen);
/* Note: whenever a new route-type or zserv-command is added the
* corresponding {command,route}_types[] table in lib/log.c MUST be
* updated! */
/* Map a route type to a string. For example, ZEBRA_ROUTE_RIPNG -> "ripng". */
extern const char *zebra_route_string(unsigned int route_type);
/* Map a route type to a char. For example, ZEBRA_ROUTE_RIPNG -> 'R'. */
extern char zebra_route_char(unsigned int route_type);
/* Map a zserv command type to the same string,
* e.g. ZEBRA_INTERFACE_ADD -> "ZEBRA_INTERFACE_ADD" */
/* Map a protocol name to its number. e.g. ZEBRA_ROUTE_BGP->9*/
extern int proto_name2num(const char *s);
/* Map redistribute X argument to protocol number.
* unlike proto_name2num, this accepts shorthands and takes
* an AFI value to restrict input */
extern int proto_redistnum(int afi, const char *s);
extern const char *zserv_command_string(unsigned int command);
extern int vzlog_test(int priority);

View File

@ -38,6 +38,15 @@
#include "mlag.h"
/* Zebra types. Used in Zserv message header. */
typedef uint16_t zebra_size_t;
/* Marker value used in new Zserv, in the byte location corresponding
* the command value in the old zserv header. To allow old and new
* Zserv headers to be distinguished from each other.
*/
#define ZEBRA_HEADER_MARKER 254
/* For input/output buffer to zebra. */
#define ZEBRA_MAX_PACKET_SIZ 16384U
@ -322,6 +331,41 @@ struct zapi_route {
unsigned short instance;
uint32_t flags;
/*
* Cause Zebra to consider this routes nexthops recursively
*/
#define ZEBRA_FLAG_ALLOW_RECURSION 0x01
/*
* This is a route that is read in on startup that was left around
* from a previous run of FRR
*/
#define ZEBRA_FLAG_SELFROUTE 0x02
/*
* This flag is used to tell Zebra that the BGP route being passed
* down is a IBGP route
*/
#define ZEBRA_FLAG_IBGP 0x04
/*
* This is a route that has been selected for FIB installation.
* This flag is set in zebra and can be passed up to routing daemons
*/
#define ZEBRA_FLAG_SELECTED 0x08
/*
* This is a route that we are telling Zebra that this route *must*
* win and will be installed even over ZEBRA_FLAG_SELECTED
*/
#define ZEBRA_FLAG_FIB_OVERRIDE 0x10
/*
* This flag tells Zebra that the route is a EVPN route and should
* be treated specially
*/
#define ZEBRA_FLAG_EVPN_ROUTE 0x20
/*
* This flag tells Zebra that it should treat the distance passed
* down as an additional discriminator for route selection of the
* route entry. This mainly is used for backup static routes.
*/
#define ZEBRA_FLAG_RR_USE_DISTANCE 0x40
uint8_t message;

View File

@ -202,18 +202,12 @@ typedef unsigned char uint8_t;
/* Some systems do not define UINT32_MAX, etc.. from inttypes.h
* e.g. this makes life easier for FBSD 4.11 users.
*/
#ifndef INT8_MAX
#define INT8_MAX (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX (65535U)
#endif
@ -343,12 +337,6 @@ struct in_pktinfo {
/* default zebra TCP port for zclient */
#define ZEBRA_PORT 2600
/* Marker value used in new Zserv, in the byte location corresponding
* the command value in the old zserv header. To allow old and new
* Zserv headers to be distinguished from each other.
*/
#define ZEBRA_HEADER_MARKER 254
/*
* The compiler.h header is used for anyone using the CPP_NOTICE
* since this is universally needed, let's add it to zebra.h
@ -358,65 +346,8 @@ struct in_pktinfo {
/* Zebra route's types are defined in route_types.h */
#include "route_types.h"
/* Note: whenever a new route-type or zserv-command is added the
* corresponding {command,route}_types[] table in lib/log.c MUST be
* updated! */
/* Map a route type to a string. For example, ZEBRA_ROUTE_RIPNG -> "ripng". */
extern const char *zebra_route_string(unsigned int route_type);
/* Map a route type to a char. For example, ZEBRA_ROUTE_RIPNG -> 'R'. */
extern char zebra_route_char(unsigned int route_type);
/* Map a zserv command type to the same string,
* e.g. ZEBRA_INTERFACE_ADD -> "ZEBRA_INTERFACE_ADD" */
/* Map a protocol name to its number. e.g. ZEBRA_ROUTE_BGP->9*/
extern int proto_name2num(const char *s);
/* Map redistribute X argument to protocol number.
* unlike proto_name2num, this accepts shorthands and takes
* an AFI value to restrict input */
extern int proto_redistnum(int afi, const char *s);
extern const char *zserv_command_string(unsigned int command);
#define strmatch(a,b) (!strcmp((a), (b)))
/* Zebra message flags */
/*
* Cause Zebra to consider this routes nexthops recursively
*/
#define ZEBRA_FLAG_ALLOW_RECURSION 0x01
/*
* This is a route that is read in on startup that was left around
* from a previous run of FRR
*/
#define ZEBRA_FLAG_SELFROUTE 0x02
/*
* This flag is used to tell Zebra that the BGP route being passed
* down is a IBGP route
*/
#define ZEBRA_FLAG_IBGP 0x04
/*
* This is a route that has been selected for FIB installation.
* This flag is set in zebra and can be passed up to routing daemons
*/
#define ZEBRA_FLAG_SELECTED 0x08
/*
* This is a route that we are telling Zebra that this route *must*
* win and will be installed even over ZEBRA_FLAG_SELECTED
*/
#define ZEBRA_FLAG_FIB_OVERRIDE 0x10
/*
* This flag tells Zebra that the route is a EVPN route and should
* be treated specially
*/
#define ZEBRA_FLAG_EVPN_ROUTE 0x20
/*
* This flag tells Zebra that it should treat the distance passed
* down as an additional discriminator for route selection of the
* route entry. This mainly is used for backup static routes.
*/
#define ZEBRA_FLAG_RR_USE_DISTANCE 0x40
#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */
#endif
@ -501,10 +432,6 @@ typedef enum {
#define RESET_FLAG_ATOMIC(PV) \
((atomic_store_explicit(PV, 0, memory_order_seq_cst)))
/* Zebra types. Used in Zserv message header. */
typedef uint16_t zebra_size_t;
typedef uint16_t zebra_command_t;
/* VRF ID type. */
typedef uint32_t vrf_id_t;

View File

@ -17,9 +17,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <zebra.h>
#ifdef __linux__