summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChris Hall <chris.hall@highwayman.com>2012-03-23 12:15:00 +0000
committerChris Hall <chris.hall@highwayman.com>2012-03-23 12:15:00 +0000
commit4526b03b4c1ac32588cd8f9a3ea71bafe72db9ef (patch)
tree48c05781305667727e1dcd2207df6c25976bb488 /tests
parent97f375b3e02e0f4ec18f68fbe36fc5ae16693d26 (diff)
parentaee567450eaf32877d00f47c4cc5d05c5fb85a51 (diff)
downloadquagga-ex23b.tar.bz2
quagga-ex23b.tar.xz
Merge branch 'master' into euro_ix_bex23b
v0.99.20ex23b -- Quagga 'master' as at 23-Mar-2012 Conflicts: bgpd/bgp_attr.c bgpd/bgp_attr.h Difference between 'master' and 0.99.20.1 is in these files. Handling of attributes has been worked over again to common up checks of the flags, and to use a common parsing structure, which reduces the clutter of parameters for the individual attribute parsing functions. bgpd/bgp_open.c bgpd/bgp_packet.c lib/thread.c ospfd/ospf_packet.c These were artifacts, caused by common patches in master and 0.99.20.1 -- and some twitchy-ness about whitespace !
Diffstat (limited to 'tests')
-rw-r--r--tests/aspath_test.c21
-rw-r--r--tests/bgp_mp_attr_test.c27
2 files changed, 29 insertions, 19 deletions
diff --git a/tests/aspath_test.c b/tests/aspath_test.c
index 96cc5464..5b6de518 100644
--- a/tests/aspath_test.c
+++ b/tests/aspath_test.c
@@ -1197,13 +1197,12 @@ handle_attr_test (struct aspath_tests *t)
{
struct bgp bgp = { 0 };
struct peer peer = { 0 };
- struct attr attr = { 0 };
int ret;
int initfail = failed;
struct aspath *asp;
size_t datalen, endp;
char host[] = { "none" } ;
- bool mp_eor ;
+ bgp_attr_parser_args_t args[1] ;
asp = make_aspath (t->segment->asdata, t->segment->len, 0);
@@ -1216,12 +1215,17 @@ handle_attr_test (struct aspath_tests *t)
#endif
peer.cap = t->cap;
+ memset (args, 0, sizeof (args));
+
+ args->peer = &peer ;
+ args->s = peer.ibuf ;
+
stream_put (peer.ibuf, t->attrheader, t->len);
datalen = aspath_put (peer.ibuf, asp, t->as4 == AS4_DATA);
endp = stream_push_endp(peer.ibuf, t->len + datalen) ;
- ret = bgp_attr_parse (&peer, &attr, NULL, NULL, &mp_eor);
+ ret = bgp_attr_parse (args);
if (ret != t->result)
{
@@ -1232,23 +1236,24 @@ handle_attr_test (struct aspath_tests *t)
if (ret != 0)
goto out;
- if (attr.aspath == NULL)
+ if (args->attr.aspath == NULL)
{
printf ("aspath is NULL!\n");
failed++;
}
- if (attr.aspath && strcmp (attr.aspath->str, t->shouldbe))
+
+ if (args->attr.aspath && strcmp (args->attr.aspath->str, t->shouldbe))
{
printf ("attr str and 'shouldbe' mismatched!\n"
"attr str: %s\n"
"shouldbe: %s\n",
- attr.aspath->str, t->shouldbe);
+ args->attr.aspath->str, t->shouldbe);
failed++;
}
out:
- if (attr.aspath)
- aspath_unintern (&attr.aspath);
+ if (args->attr.aspath)
+ aspath_unintern (&args->attr.aspath);
if (asp)
aspath_unintern (&asp);
return failed - initfail;
diff --git a/tests/bgp_mp_attr_test.c b/tests/bgp_mp_attr_test.c
index 2219ea47..1b3ebed4 100644
--- a/tests/bgp_mp_attr_test.c
+++ b/tests/bgp_mp_attr_test.c
@@ -437,23 +437,21 @@ static struct test_segment mp_unreach_segments [] =
static void
parse_test (struct peer *peer, struct test_segment *t, int type)
{
- byte flag ;
+ byte flags ;
int ret;
int oldfailed = failed;
- struct attr attr;
- struct bgp_nlri nlri;
- bool mp_eor ;
+ bgp_attr_parser_args_t args[1] ;
#define RANDOM_FUZZ 35
stream_reset (peer->ibuf);
stream_put (peer->ibuf, NULL, RANDOM_FUZZ);
stream_set_getp (peer->ibuf, RANDOM_FUZZ);
- flag = BGP_ATTR_FLAG_OPTIONAL | ((t->len < 256) ? 0 : BGP_ATTR_FLAG_EXTLEN) ;
+ flags = BGP_ATTR_FLAG_OPTIONAL | ((t->len < 256) ? 0 : BGP_ATTR_FLAG_EXTLEN) ;
- stream_putc(peer->ibuf, flag) ;
+ stream_putc(peer->ibuf, flags) ;
stream_putc(peer->ibuf, type) ;
- if (flag & BGP_ATTR_FLAG_EXTLEN)
+ if (flags & BGP_ATTR_FLAG_EXTLEN)
stream_putw(peer->ibuf, t->len) ;
else
stream_putc(peer->ibuf, t->len) ;
@@ -463,12 +461,19 @@ parse_test (struct peer *peer, struct test_segment *t, int type)
printf ("%s: %s\n", t->name, t->desc);
- mp_eor = false ;
+ memset (args, 0, sizeof (args));
+
+ args->peer = peer ;
+ args->s = peer->ibuf ;
+
+ args->type = type ;
+ args->flags = flags ;
+ args->length = t->len ;
if (type == BGP_ATTR_MP_REACH_NLRI)
- ret = bgp_mp_reach_parse (peer, t->len, &attr, flag, &nlri);
+ ret = bgp_mp_reach_parse (args);
else
- ret = bgp_mp_unreach_parse (peer, t->len, flag, &nlri, &mp_eor);
+ ret = bgp_mp_unreach_parse (args);
if (!ret)
{
@@ -490,7 +495,7 @@ parse_test (struct peer *peer, struct test_segment *t, int type)
if (tty)
printf ("%s", (failed > oldfailed) ? VT100_RED "failed!" VT100_RESET
- : VT100_GREEN "OK" VT100_RESET);
+ : VT100_GREEN "OK" VT100_RESET);
else
printf ("%s", (failed > oldfailed) ? "failed!" : "OK" );