--- embedaddon/quagga/tests/bgp_capability_test.c 2012/02/21 17:26:11 1.1 +++ embedaddon/quagga/tests/bgp_capability_test.c 2016/11/02 10:09:12 1.1.1.4 @@ -1,13 +1,36 @@ +/* + * Copyright (C) 2007 Sun Microsystems, Inc. + * + * This file is part of Quagga. + * + * Quagga is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * Quagga is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Quagga; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + #include #include "vty.h" #include "stream.h" #include "privs.h" #include "memory.h" +#include "filter.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_open.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_packet.h" #define VT100_RESET "\x1b[0m" #define VT100_RED "\x1b[31m" @@ -35,7 +58,7 @@ static struct test_segment { #define SHOULD_PARSE 0 #define SHOULD_ERR -1 int parses; /* whether it should parse or not */ - int peek_for; /* what peek_for_as4_capability should say */ + as_t peek_for; /* what peek_for_as4_capability should say */ /* AFI/SAFI validation */ int validate_afi; @@ -96,10 +119,10 @@ static struct test_segment mp_segments[] = }, /* 6 */ { "MP3", - "MP IP6/VPNv4", + "MP IP6/MPLS-labeled VPN", { CAPABILITY_CODE_MP, 0x4, 0x0, 0x2, 0x0, 0x80 }, - 6, SHOULD_PARSE, 0, /* parses, but invalid afi,safi */ - 1, AFI_IP6, BGP_SAFI_VPNV4, INVALID_AFI, + 6, SHOULD_PARSE, 0, + 1, AFI_IP6, SAFI_MPLS_LABELED_VPN, VALID_AFI, }, /* 7 */ { "MP5", @@ -110,21 +133,14 @@ static struct test_segment mp_segments[] = }, /* 8 */ { "MP6", - "MP IP4/VPNv4", + "MP IP4/MPLS-laveled VPN", { CAPABILITY_CODE_MP, 0x4, 0x0, 0x1, 0x0, 0x80 }, 6, SHOULD_PARSE, 0, - 1, AFI_IP, BGP_SAFI_VPNV4, VALID_AFI, + 1, AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, }, - /* 9 */ - { "MP7", - "MP IP4/VPNv6", - { CAPABILITY_CODE_MP, 0x4, 0x0, 0x1, 0x0, 0x81 }, - 6, SHOULD_PARSE, 0, /* parses, but invalid afi,safi tuple */ - 1, AFI_IP, BGP_SAFI_VPNV6, INVALID_AFI, - }, /* 10 */ { "MP8", - "MP unknown AFI", + "MP unknown AFI/SAFI", { CAPABILITY_CODE_MP, 0x4, 0x0, 0xa, 0x0, 0x81 }, 6, SHOULD_PARSE, 0, 1, 0xa, 0x81, INVALID_AFI, /* parses, but unknown */ @@ -296,7 +312,16 @@ static struct test_segment misc_segments[] = { 0x41, 0x4, 0xab, 0xcd, 0xef, 0x12 }, /* AS: 2882400018 */ 6, SHOULD_PARSE, 2882400018, }, - /* 20 */ + { "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", { /* hdr */ CAPABILITY_CODE_RESTART, 0xe, @@ -313,7 +338,6 @@ static struct test_segment misc_segments[] = }, 16, SHOULD_PARSE, }, - /* 21 */ { "GR-short", "GR capability, but header length too short", { /* hdr */ 0x40, 0xa, @@ -328,9 +352,8 @@ static struct test_segment misc_segments[] = /* safi */ 0x2, /* flags */ 0x1, }, - 16, SHOULD_PARSE, + 15 /* array is 16 though */, SHOULD_ERR, }, - /* 22 */ { "GR-long", "GR capability, but header length too long", { /* hdr */ 0x40, 0xf, @@ -343,6 +366,7 @@ static struct test_segment misc_segments[] = /* flags */ 0x0, /* afi */ 0x0, 0x2, /* safi */ 0x2, + /* flags */ 0x01, }, 16, SHOULD_ERR, }, @@ -624,6 +648,7 @@ main (void) master = thread_master_create (); bgp_master_init (); + bgp_option_set (BGP_OPT_NO_LISTEN); if (fileno (stdout) >= 0) tty = isatty (fileno (stdout)); @@ -632,7 +657,7 @@ main (void) return -1; peer = peer_create_accept (bgp); - peer->host = "foo"; + peer->host = (char *) "foo"; for (i = AFI_IP; i < AFI_MAX; i++) for (j = SAFI_UNICAST; j < SAFI_MAX; j++)