diff options
| author | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:03:14 +0200 | 
|---|---|---|
| committer | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:04:07 +0200 | 
| commit | d62a17aedeb0eebdba98238874bb13d62c48dbf9 (patch) | |
| tree | 3b319b1d61c8b85b4d1f06adf8b844bb8a9b5107 /lib/mpls.h | |
| parent | 888ac268a0077fc9ebd1218cec6ae472af0bfc40 (diff) | |
*: reindentreindent-master-after
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/mpls.h')
| -rw-r--r-- | lib/mpls.h | 137 | 
1 files changed, 65 insertions, 72 deletions
diff --git a/lib/mpls.h b/lib/mpls.h index 20315df7d6..025770d479 100644 --- a/lib/mpls.h +++ b/lib/mpls.h @@ -44,11 +44,12 @@  #define MPLS_DEFAULT_MIN_SRGB_LABEL        16000  #define MPLS_DEFAULT_MAX_SRGB_LABEL        23999 -#define IS_MPLS_RESERVED_LABEL(label) \ -        (label >= MPLS_MIN_RESERVED_LABEL && label <= MPLS_MAX_RESERVED_LABEL) +#define IS_MPLS_RESERVED_LABEL(label)                                          \ +	(label >= MPLS_MIN_RESERVED_LABEL && label <= MPLS_MAX_RESERVED_LABEL) -#define IS_MPLS_UNRESERVED_LABEL(label) \ -        (label >= MPLS_MIN_UNRESERVED_LABEL && label <= MPLS_MAX_UNRESERVED_LABEL) +#define IS_MPLS_UNRESERVED_LABEL(label)                                        \ +	(label >= MPLS_MIN_UNRESERVED_LABEL                                    \ +	 && label <= MPLS_MAX_UNRESERVED_LABEL)  /* Definitions for a MPLS label stack entry (RFC 3032). This encodes the   * label, EXP, BOS and TTL fields. @@ -64,14 +65,11 @@ typedef unsigned int mpls_lse_t;  #define MPLS_LS_TTL_MASK               0x000000FF  #define MPLS_LS_TTL_SHIFT              0 -#define MPLS_LABEL_VALUE(lse) \ -        ((lse & MPLS_LS_LABEL_MASK) >> MPLS_LS_LABEL_SHIFT) -#define MPLS_LABEL_EXP(lse) \ -        ((lse & MPLS_LS_EXP_MASK) >> MPLS_LS_EXP_SHIFT) -#define MPLS_LABEL_BOS(lse) \ -        ((lse & MPLS_LS_S_MASK) >> MPLS_LS_S_SHIFT) -#define MPLS_LABEL_TTL(lse) \ -        ((lse & MPLS_LS_TTL_MASK) >> MPLS_LS_TTL_SHIFT) +#define MPLS_LABEL_VALUE(lse)                                                  \ +	((lse & MPLS_LS_LABEL_MASK) >> MPLS_LS_LABEL_SHIFT) +#define MPLS_LABEL_EXP(lse) ((lse & MPLS_LS_EXP_MASK) >> MPLS_LS_EXP_SHIFT) +#define MPLS_LABEL_BOS(lse) ((lse & MPLS_LS_S_MASK) >> MPLS_LS_S_SHIFT) +#define MPLS_LABEL_TTL(lse) ((lse & MPLS_LS_TTL_MASK) >> MPLS_LS_TTL_SHIFT)  #define IS_MPLS_LABEL_BOS(ls)          (MPLS_LABEL_BOS(ls) == 1) @@ -89,12 +87,11 @@ typedef unsigned int mpls_label_t;  #define MPLS_INVALID_LABEL                 0xFFFDFFFF  /* LSP types. */ -enum lsp_types_t -{ -  ZEBRA_LSP_NONE = 0,        /* No LSP. */ -  ZEBRA_LSP_STATIC = 1,      /* Static LSP. */ -  ZEBRA_LSP_LDP = 2,         /* LDP LSP. */ -  ZEBRA_LSP_BGP = 3          /* BGP LSP. */ +enum lsp_types_t { +	ZEBRA_LSP_NONE = 0,   /* No LSP. */ +	ZEBRA_LSP_STATIC = 1, /* Static LSP. */ +	ZEBRA_LSP_LDP = 2,    /* LDP LSP. */ +	ZEBRA_LSP_BGP = 3     /* BGP LSP. */  };  /* Functions for basic label operations. */ @@ -102,33 +99,31 @@ enum lsp_types_t  /* Encode a label stack entry from fields; convert to network byte-order as   * the Netlink interface expects MPLS labels to be in this format.   */ -static inline mpls_lse_t -mpls_lse_encode (mpls_label_t label, u_int32_t ttl, -                 u_int32_t exp, u_int32_t bos) +static inline mpls_lse_t mpls_lse_encode(mpls_label_t label, u_int32_t ttl, +					 u_int32_t exp, u_int32_t bos)  { -  mpls_lse_t lse; -  lse = htonl ((label << MPLS_LS_LABEL_SHIFT) | -               (exp << MPLS_LS_EXP_SHIFT) | -               (bos ? (1 << MPLS_LS_S_SHIFT) : 0) | -               (ttl << MPLS_LS_TTL_SHIFT)); -  return lse; +	mpls_lse_t lse; +	lse = htonl((label << MPLS_LS_LABEL_SHIFT) | (exp << MPLS_LS_EXP_SHIFT) +		    | (bos ? (1 << MPLS_LS_S_SHIFT) : 0) +		    | (ttl << MPLS_LS_TTL_SHIFT)); +	return lse;  }  /* Extract the fields from a label stack entry after converting to host-byte   * order. This is expected to be called only for messages received over the   * Netlink interface.   */ -static inline void -mpls_lse_decode (mpls_lse_t lse, mpls_label_t *label, -                 u_int32_t *ttl, u_int32_t *exp, u_int32_t *bos) +static inline void mpls_lse_decode(mpls_lse_t lse, mpls_label_t *label, +				   u_int32_t *ttl, u_int32_t *exp, +				   u_int32_t *bos)  { -  mpls_lse_t local_lse; +	mpls_lse_t local_lse; -  local_lse = ntohl (lse); -  *label = MPLS_LABEL_VALUE(local_lse); -  *exp = MPLS_LABEL_EXP(local_lse); -  *bos = MPLS_LABEL_BOS(local_lse); -  *ttl = MPLS_LABEL_TTL(local_lse); +	local_lse = ntohl(lse); +	*label = MPLS_LABEL_VALUE(local_lse); +	*exp = MPLS_LABEL_EXP(local_lse); +	*bos = MPLS_LABEL_BOS(local_lse); +	*ttl = MPLS_LABEL_TTL(local_lse);  }  /* Invalid label index value (when used with BGP Prefix-SID). Should @@ -136,43 +131,41 @@ mpls_lse_decode (mpls_lse_t lse, mpls_label_t *label,   */  #define MPLS_INVALID_LABEL_INDEX   0xFFFFFFFF -  /* Printable string for labels (with consideration for reserved values). */ -static inline char * -label2str (mpls_label_t label, char *buf, size_t len) +static inline char *label2str(mpls_label_t label, char *buf, size_t len)  { -  switch(label) { -  case MPLS_V4_EXP_NULL_LABEL: -    strlcpy(buf, "IPv4 Explicit Null", len); -    return(buf); -  case MPLS_RA_LABEL: -    strlcpy(buf, "Router Alert", len); -    return(buf); -  case MPLS_V6_EXP_NULL_LABEL: -    strlcpy(buf, "IPv6 Explict Null", len); -    return(buf); -  case MPLS_IMP_NULL_LABEL: -    strlcpy(buf, "implicit-null", len); -    return(buf); -  case MPLS_ENTROPY_LABEL_INDICATOR: -    strlcpy(buf, "Entropy Label Indicator", len); -    return(buf); -  case MPLS_GAL_LABEL: -    strlcpy(buf, "Generic Associated Channel", len); -    return(buf); -  case MPLS_OAM_ALERT_LABEL: -    strlcpy(buf, "OAM Alert", len); -    return(buf); -  case MPLS_EXTENSION_LABEL: -    strlcpy(buf, "Extension", len); -    return(buf); -  default: -    if (label < 16) -      snprintf(buf, len, "Reserved (%u)", label); -    else -      snprintf(buf, len, "%u", label); -    return(buf); -  } +	switch (label) { +	case MPLS_V4_EXP_NULL_LABEL: +		strlcpy(buf, "IPv4 Explicit Null", len); +		return (buf); +	case MPLS_RA_LABEL: +		strlcpy(buf, "Router Alert", len); +		return (buf); +	case MPLS_V6_EXP_NULL_LABEL: +		strlcpy(buf, "IPv6 Explict Null", len); +		return (buf); +	case MPLS_IMP_NULL_LABEL: +		strlcpy(buf, "implicit-null", len); +		return (buf); +	case MPLS_ENTROPY_LABEL_INDICATOR: +		strlcpy(buf, "Entropy Label Indicator", len); +		return (buf); +	case MPLS_GAL_LABEL: +		strlcpy(buf, "Generic Associated Channel", len); +		return (buf); +	case MPLS_OAM_ALERT_LABEL: +		strlcpy(buf, "OAM Alert", len); +		return (buf); +	case MPLS_EXTENSION_LABEL: +		strlcpy(buf, "Extension", len); +		return (buf); +	default: +		if (label < 16) +			snprintf(buf, len, "Reserved (%u)", label); +		else +			snprintf(buf, len, "%u", label); +		return (buf); +	}  }  /* constants used by ldpd */ @@ -180,7 +173,7 @@ label2str (mpls_label_t label, char *buf, size_t len)  #define MPLS_LABEL_RTALERT	1               /* Router Alert Label       */  #define MPLS_LABEL_IPV6NULL	2               /* IPv6 Explicit NULL Label */  #define MPLS_LABEL_IMPLNULL	3               /* Implicit NULL Label      */ -/*      MPLS_LABEL_RESERVED	4-15 */		/* Values 4-15 are reserved */ +	/*      MPLS_LABEL_RESERVED	4-15 */ /* Values 4-15 are reserved */  #define MPLS_LABEL_RESERVED_MAX 15  #define MPLS_LABEL_MAX		((1 << 20) - 1)  | 
