summaryrefslogtreecommitdiff
path: root/print-bgp.c
diff options
context:
space:
mode:
authorFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2022-09-02 08:52:13 +0200
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2022-09-02 08:54:35 +0200
commit188080f7d757e86a8b5384d3167448f62432d30e (patch)
treef3f737f0066dc4905185d92781aa751ec64da6b3 /print-bgp.c
parent699711dfb3ebdfb063c4718e94ae57d2ed6e3c47 (diff)
downloadtcpdump-188080f7d757e86a8b5384d3167448f62432d30e.tar.gz
BGP: Use a 'struct tok' for the flags
Diffstat (limited to 'print-bgp.c')
-rw-r--r--print-bgp.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/print-bgp.c b/print-bgp.c
index 76126897..c52fff83 100644
--- a/print-bgp.c
+++ b/print-bgp.c
@@ -1889,6 +1889,14 @@ trunc: /* we rely on the caller to recognize -2 return value */
return -2;
}
+static const struct tok bgp_flags[] = {
+ { 0x80, "O"},
+ { 0x40, "T"},
+ { 0x20, "P"},
+ { 0x10, "E"},
+ { 0, NULL }
+};
+
static int
bgp_attr_print(netdissect_options *ndo,
uint8_t atype, const u_char *pptr, u_int len,
@@ -2465,11 +2473,8 @@ bgp_attr_print(netdissect_options *ndo,
alen);
if (aflags) {
- ND_PRINT(", Flags [%s%s%s%s",
- aflags & 0x80 ? "O" : "",
- aflags & 0x40 ? "T" : "",
- aflags & 0x20 ? "P" : "",
- aflags & 0x10 ? "E" : "");
+ ND_PRINT(", Flags [%s",
+ bittok2str_nosep(bgp_flags, "", aflags));
if (aflags & 0xf)
ND_PRINT("+%x", aflags & 0xf);
ND_PRINT("]");
@@ -2886,11 +2891,8 @@ bgp_update_print(netdissect_options *ndo,
alen);
if (aflags) {
- ND_PRINT(", Flags [%s%s%s%s",
- aflags & 0x80 ? "O" : "",
- aflags & 0x40 ? "T" : "",
- aflags & 0x20 ? "P" : "",
- aflags & 0x10 ? "E" : "");
+ ND_PRINT(", Flags [%s",
+ bittok2str_nosep(bgp_flags, "", aflags));
if (aflags & 0xf)
ND_PRINT("+%x", aflags & 0xf);
ND_PRINT("]: ");