diff options
Diffstat (limited to 'tests/bgpd/test_capability.c')
-rw-r--r-- | tests/bgpd/test_capability.c | 762 |
1 files changed, 355 insertions, 407 deletions
diff --git a/tests/bgpd/test_capability.c b/tests/bgpd/test_capability.c index 9ec2b5df1..2b515b0f7 100644 --- a/tests/bgpd/test_capability.c +++ b/tests/bgpd/test_capability.c @@ -216,439 +216,387 @@ static struct test_segment mp_segments[] = { }, {NULL, NULL, {0}, 0, 0}}; -static struct test_segment misc_segments[] = +static struct test_segment misc_segments[] = { + /* 13 */ { - /* 13 */ - { - "ORF", - "ORF, simple, single entry, single tuple", - {/* hdr */ CAPABILITY_CODE_ORF, 0x7, - /* mpc */ 0x0, 0x1, 0x0, 0x1, - /* num */ 0x1, - /* tuples */ 0x40, 0x3}, - 9, - SHOULD_PARSE, - }, - /* 14 */ - { - "ORF-many", - "ORF, multi entry/tuple", - { - /* hdr */ CAPABILITY_CODE_ORF, - 0x21, - /* mpc */ 0x0, - 0x1, - 0x0, - 0x1, - /* num */ 0x3, - /* tuples */ 0x40, - ORF_MODE_BOTH, - 0x80, - ORF_MODE_RECEIVE, - 0x80, - ORF_MODE_SEND, - /* mpc */ 0x0, - 0x2, - 0x0, - 0x1, - /* num */ 0x3, - /* tuples */ 0x40, - ORF_MODE_BOTH, - 0x80, - ORF_MODE_RECEIVE, - 0x80, - ORF_MODE_SEND, - /* mpc */ 0x0, - 0x2, - 0x0, - 0x2, - /* num */ 0x3, - /* tuples */ 0x40, - ORF_MODE_RECEIVE, - 0x80, - ORF_MODE_SEND, - 0x80, - ORF_MODE_BOTH, - }, - 35, - SHOULD_PARSE, - }, - /* 15 */ - { - "ORFlo", - "ORF, multi entry/tuple, hdr length too short", - { - /* hdr */ CAPABILITY_CODE_ORF, - 0x15, - /* mpc */ 0x0, - 0x1, - 0x0, - 0x1, - /* num */ 0x3, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - /* mpc */ 0x0, - 0x1, - 0x0, - 0x1, - /* num */ 0x3, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - /* mpc */ 0x0, - 0x2, - 0x0, - 0x2, - /* num */ 0x3, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - }, - 35, - SHOULD_ERR, /* It should error on invalid - Route-Refresh.. */ - }, - /* 16 */ - {"ORFlu", - "ORF, multi entry/tuple, length too long", - { - /* hdr */ 0x3, - 0x22, - /* mpc */ 0x0, - 0x1, - 0x0, - 0x1, - /* num */ 0x3, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - /* mpc */ 0x0, - 0x2, - 0x0, - 0x1, - /* num */ 0x3, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - /* mpc */ 0x0, - 0x2, - 0x0, - 0x2, - /* num */ 0x3, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - }, - 35, - SHOULD_ERR}, - /* 17 */ - { - "ORFnu", - "ORF, multi entry/tuple, entry number too long", - { - /* hdr */ 0x3, - 0x21, - /* mpc */ 0x0, - 0x1, - 0x0, - 0x1, - /* num */ 0x3, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - /* mpc */ 0x0, - 0x2, - 0x0, - 0x1, - /* num */ 0x4, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - /* mpc */ 0x0, - 0x2, - 0x0, - 0x2, - /* num */ 0x3, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - }, - 35, - SHOULD_PARSE, /* parses, but last few tuples should be - gibberish */ - }, - /* 18 */ - { - "ORFno", - "ORF, multi entry/tuple, entry number too short", - { - /* hdr */ 0x3, - 0x21, - /* mpc */ 0x0, - 0x1, - 0x0, - 0x1, - /* num */ 0x3, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - /* mpc */ 0x0, - 0x2, - 0x0, - 0x1, - /* num */ 0x1, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - /* mpc */ 0x0, - 0x2, - 0x0, - 0x2, - /* num */ 0x3, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - }, - 35, - SHOULD_PARSE, /* Parses, but should get gibberish - afi/safis */ - }, - /* 17 */ + "ORF", + "ORF, simple, single entry, single tuple", + {/* hdr */ CAPABILITY_CODE_ORF, 0x7, + /* mpc */ 0x0, 0x1, 0x0, 0x1, + /* num */ 0x1, + /* tuples */ 0x40, 0x3}, + 9, + SHOULD_PARSE, + }, + /* 14 */ + { + "ORF-many", + "ORF, multi entry/tuple", { - "ORFpad", - "ORF, multi entry/tuple, padded to align", - { - /* hdr */ 0x3, - 0x22, - /* mpc */ 0x0, - 0x1, - 0x0, - 0x1, - /* num */ 0x3, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - /* mpc */ 0x0, - 0x2, - 0x0, - 0x1, - /* num */ 0x3, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - /* mpc */ 0x0, - 0x2, - 0x0, - 0x2, - /* num */ 0x3, - /* tuples */ 0x40, - 0x3, - 0x80, - 0x1, - 0x80, - 0x2, - 0x00, - }, - 36, - SHOULD_PARSE, + /* hdr */ CAPABILITY_CODE_ORF, + 0x21, + /* mpc */ 0x0, + 0x1, + 0x0, + 0x1, + /* num */ 0x3, + /* tuples */ 0x40, + ORF_MODE_BOTH, + 0x80, + ORF_MODE_RECEIVE, + 0x80, + ORF_MODE_SEND, + /* mpc */ 0x0, + 0x2, + 0x0, + 0x1, + /* num */ 0x3, + /* tuples */ 0x40, + ORF_MODE_BOTH, + 0x80, + ORF_MODE_RECEIVE, + 0x80, + ORF_MODE_SEND, + /* mpc */ 0x0, + 0x2, + 0x0, + 0x2, + /* num */ 0x3, + /* tuples */ 0x40, + ORF_MODE_RECEIVE, + 0x80, + ORF_MODE_SEND, + 0x80, + ORF_MODE_BOTH, }, - /* 19 */ + 35, + SHOULD_PARSE, + }, + /* 15 */ + { + "ORFlo", + "ORF, multi entry/tuple, hdr length too short", { - "AS4", - "AS4 capability", - {0x41, 0x4, 0xab, 0xcd, 0xef, - 0x12}, /* AS: 2882400018 */ - 6, - SHOULD_PARSE, - 2882400018, + /* hdr */ CAPABILITY_CODE_ORF, + 0x15, + /* mpc */ 0x0, + 0x1, + 0x0, + 0x1, + /* num */ 0x3, + /* tuples */ 0x40, + 0x3, + 0x80, + 0x1, + 0x80, + 0x2, + /* mpc */ 0x0, + 0x1, + 0x0, + 0x1, + /* num */ 0x3, + /* tuples */ 0x40, + 0x3, + 0x80, + 0x1, + 0x80, + 0x2, + /* mpc */ 0x0, + 0x2, + 0x0, + 0x2, + /* num */ 0x3, + /* tuples */ 0x40, + 0x3, + 0x80, + 0x1, + 0x80, + 0x2, }, + 35, + SHOULD_ERR, /* It should error on invalid + Route-Refresh.. */ + }, + /* 16 */ + {"ORFlu", + "ORF, multi entry/tuple, length too long", + { + /* hdr */ 0x3, 0x22, + /* mpc */ 0x0, 0x1, 0x0, 0x1, + /* num */ 0x3, + /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2, + /* mpc */ 0x0, 0x2, 0x0, 0x1, + /* num */ 0x3, + /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2, + /* mpc */ 0x0, 0x2, 0x0, 0x2, + /* num */ 0x3, + /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2, + }, + 35, + SHOULD_ERR}, + /* 17 */ + { + "ORFnu", + "ORF, multi entry/tuple, entry number too long", { - "AS4", - "AS4 capability: short", - {0x41, 0x4, 0xab, 0xcd, 0xef}, /* AS: 2882400018 */ - 5, - SHOULD_ERR, + /* hdr */ 0x3, 0x21, + /* mpc */ 0x0, 0x1, 0x0, 0x1, + /* num */ 0x3, + /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2, + /* mpc */ 0x0, 0x2, 0x0, 0x1, + /* num */ 0x4, + /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2, + /* mpc */ 0x0, 0x2, 0x0, 0x2, + /* num */ 0x3, + /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2, }, + 35, + SHOULD_PARSE, /* parses, but last few tuples should be + gibberish */ + }, + /* 18 */ + { + "ORFno", + "ORF, multi entry/tuple, entry number too short", { - "AS4", - "AS4 capability: long", - {0x41, 0x4, 0xab, 0xcd, 0xef, 0x12, 0x12}, - 7, - SHOULD_ERR, - 2882400018, + /* hdr */ 0x3, 0x21, + /* mpc */ 0x0, 0x1, 0x0, 0x1, + /* num */ 0x3, + /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2, + /* mpc */ 0x0, 0x2, 0x0, 0x1, + /* num */ 0x1, + /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2, + /* mpc */ 0x0, 0x2, 0x0, 0x2, + /* num */ 0x3, + /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2, }, + 35, + SHOULD_PARSE, /* Parses, but should get gibberish + afi/safis */ + }, + /* 17 */ + { + "ORFpad", + "ORF, multi entry/tuple, padded to align", { - "GR", - "GR capability", - { - /* hdr */ CAPABILITY_CODE_RESTART, 0xe, - /* R-bit, time */ 0xf1, 0x12, - /* afi */ 0x0, 0x1, - /* safi */ 0x1, - /* flags */ 0xf, - /* afi */ 0x0, 0x2, - /* safi */ 0x1, - /* flags */ 0x0, - /* afi */ 0x0, 0x2, - /* safi */ 0x2, - /* flags */ 0x1, - }, - 16, - SHOULD_PARSE, + /* hdr */ 0x3, + 0x22, + /* mpc */ 0x0, + 0x1, + 0x0, + 0x1, + /* num */ 0x3, + /* tuples */ 0x40, + 0x3, + 0x80, + 0x1, + 0x80, + 0x2, + /* mpc */ 0x0, + 0x2, + 0x0, + 0x1, + /* num */ 0x3, + /* tuples */ 0x40, + 0x3, + 0x80, + 0x1, + 0x80, + 0x2, + /* mpc */ 0x0, + 0x2, + 0x0, + 0x2, + /* num */ 0x3, + /* tuples */ 0x40, + 0x3, + 0x80, + 0x1, + 0x80, + 0x2, + 0x00, }, + 36, + SHOULD_PARSE, + }, + /* 19 */ + { + "AS4", + "AS4 capability", + {0x41, 0x4, 0xab, 0xcd, 0xef, 0x12}, /* AS: 2882400018 */ + 6, + SHOULD_PARSE, + 2882400018, + }, + { + "AS4", + "AS4 capability: short", + {0x41, 0x4, 0xab, 0xcd, 0xef}, /* AS: 2882400018 */ + 5, + SHOULD_ERR, + }, + { + "AS4", + "AS4 capability: long", + {0x41, 0x4, 0xab, 0xcd, 0xef, 0x12, 0x12}, + 7, + SHOULD_ERR, + 2882400018, + }, + { + "GR", + "GR capability", { - "GR-short", - "GR capability, but header length too short", - { - /* hdr */ 0x40, 0xa, - /* R-bit, time */ 0xf1, 0x12, - /* afi */ 0x0, 0x1, - /* safi */ 0x1, - /* flags */ 0xf, - /* afi */ 0x0, 0x2, - /* safi */ 0x1, - /* flags */ 0x0, - /* afi */ 0x0, 0x2, - /* safi */ 0x2, - /* flags */ 0x1, - }, - 15 /* array is 16 though */, - SHOULD_ERR, + /* hdr */ CAPABILITY_CODE_RESTART, + 0xe, + /* R-bit, time */ 0xf1, + 0x12, + /* afi */ 0x0, + 0x1, + /* safi */ 0x1, + /* flags */ 0xf, + /* afi */ 0x0, + 0x2, + /* safi */ 0x1, + /* flags */ 0x0, + /* afi */ 0x0, + 0x2, + /* safi */ 0x2, + /* flags */ 0x1, }, + 16, + SHOULD_PARSE, + }, + { + "GR-short", + "GR capability, but header length too short", { - "GR-long", - "GR capability, but header length too long", - { - /* hdr */ 0x40, 0xf, - /* R-bit, time */ 0xf1, 0x12, - /* afi */ 0x0, 0x1, - /* safi */ 0x1, - /* flags */ 0xf, - /* afi */ 0x0, 0x2, - /* safi */ 0x1, - /* flags */ 0x0, - /* afi */ 0x0, 0x2, - /* safi */ 0x2, - /* flags */ 0x01, - }, - 16, - SHOULD_ERR, + /* hdr */ 0x40, + 0xa, + /* R-bit, time */ 0xf1, + 0x12, + /* afi */ 0x0, + 0x1, + /* safi */ 0x1, + /* flags */ 0xf, + /* afi */ 0x0, + 0x2, + /* safi */ 0x1, + /* flags */ 0x0, + /* afi */ 0x0, + 0x2, + /* safi */ 0x2, + /* flags */ 0x1, }, + 15 /* array is 16 though */, + SHOULD_ERR, + }, + { + "GR-long", + "GR capability, but header length too long", { - "GR-trunc", - "GR capability, but truncated", - { - /* hdr */ 0x40, 0xf, - /* R-bit, time */ 0xf1, 0x12, - /* afi */ 0x0, 0x1, - /* safi */ 0x1, - /* flags */ 0xf, - /* afi */ 0x0, 0x2, - /* safi */ 0x1, - /* flags */ 0x0, - /* afi */ 0x0, 0x2, - /* safi */ 0x2, - /* flags */ 0x1, - }, - 15, - SHOULD_ERR, + /* hdr */ 0x40, + 0xf, + /* R-bit, time */ 0xf1, + 0x12, + /* afi */ 0x0, + 0x1, + /* safi */ 0x1, + /* flags */ 0xf, + /* afi */ 0x0, + 0x2, + /* safi */ 0x1, + /* flags */ 0x0, + /* afi */ 0x0, + 0x2, + /* safi */ 0x2, + /* flags */ 0x01, }, + 16, + SHOULD_ERR, + }, + { + "GR-trunc", + "GR capability, but truncated", { - "GR-empty", - "GR capability, but empty.", - { - /* hdr */ 0x40, 0x0, - }, - 2, - SHOULD_ERR, + /* hdr */ 0x40, + 0xf, + /* R-bit, time */ 0xf1, + 0x12, + /* afi */ 0x0, + 0x1, + /* safi */ 0x1, + /* flags */ 0xf, + /* afi */ 0x0, + 0x2, + /* safi */ 0x1, + /* flags */ 0x0, + /* afi */ 0x0, + 0x2, + /* safi */ 0x2, + /* flags */ 0x1, }, + 15, + SHOULD_ERR, + }, + { + "GR-empty", + "GR capability, but empty.", { - "MP-empty", - "MP capability, but empty.", - { - /* hdr */ 0x1, 0x0, - }, - 2, - SHOULD_ERR, + /* hdr */ 0x40, + 0x0, }, + 2, + SHOULD_ERR, + }, + { + "MP-empty", + "MP capability, but empty.", { - "ORF-empty", - "ORF capability, but empty.", - { - /* hdr */ 0x3, 0x0, - }, - 2, - SHOULD_ERR, + /* hdr */ 0x1, + 0x0, }, + 2, + SHOULD_ERR, + }, + { + "ORF-empty", + "ORF capability, but empty.", { - "AS4-empty", - "AS4 capability, but empty.", - { - /* hdr */ 0x41, 0x0, - }, - 2, - SHOULD_ERR, + /* hdr */ 0x3, + 0x0, }, + 2, + SHOULD_ERR, + }, + { + "AS4-empty", + "AS4 capability, but empty.", { - "dyn-empty", - "Dynamic capability, but empty.", - { - /* hdr */ 0x42, 0x0, - }, - 2, - SHOULD_PARSE, + /* hdr */ 0x41, + 0x0, }, + 2, + SHOULD_ERR, + }, + { + "dyn-empty", + "Dynamic capability, but empty.", { - "dyn-old", - "Dynamic capability (deprecated version)", - {CAPABILITY_CODE_DYNAMIC, 0x0}, - 2, - SHOULD_PARSE, + /* hdr */ 0x42, + 0x0, }, - {NULL, NULL, {0}, 0, 0}}; + 2, + SHOULD_PARSE, + }, + { + "dyn-old", + "Dynamic capability (deprecated version)", + {CAPABILITY_CODE_DYNAMIC, 0x0}, + 2, + SHOULD_PARSE, + }, + {NULL, NULL, {0}, 0, 0}}; /* DYNAMIC message */ struct test_segment dynamic_cap_msgs[] = { @@ -871,9 +819,9 @@ static void parse_test(struct peer *peer, struct test_segment *t, int type) failed++; if (tty) - printf("%s", - (failed > oldfailed) ? VT100_RED "failed!" VT100_RESET - : VT100_GREEN "OK" VT100_RESET); + printf("%s", (failed > oldfailed) + ? VT100_RED "failed!" VT100_RESET + : VT100_GREEN "OK" VT100_RESET); else printf("%s", (failed > oldfailed) ? "failed!" : "OK"); |