2 * Copyright (C) 2017 Cumulus Networks Inc.
5 * This file is part of FRR
7 * FRR is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * FRR is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 #include "bgpd/bgpd.h"
33 #include "bgpd/bgp_open.h"
34 #include "bgpd/bgp_debug.h"
35 #include "bgpd/bgp_packet.h"
36 #include "bgpd/bgp_aspath.h"
37 #include "bgpd/bgp_network.h"
39 /* need these to link in libbgp */
40 struct zebra_privs_t
*bgpd_privs
= NULL
;
41 struct thread_master
*master
= NULL
;
43 static struct bgp
*bgp
;
44 static as_t asn
= 100;
46 extern int bgp_read_packet(struct peer
*peer
);
49 * This file is intended to be used as input for some sort of
50 * fuzzer. Specifically I had afl in mind when I wrote
53 int main(int argc
, char *argv
[])
61 master
= thread_master_create(NULL
);
62 bgp_master_init(master
, BGP_SOCKET_SNDBUF_SIZE
);
63 vrf_init(NULL
, NULL
, NULL
, NULL
, NULL
);
64 bgp_option_set(BGP_OPT_NO_LISTEN
);
66 if (bgp_get(&bgp
, &asn
, NULL
, BGP_INSTANCE_TYPE_DEFAULT
) < 0)
69 peer
= peer_create_accept(bgp
);
70 peer
->host
= (char *)"foo";
72 for (i
= AFI_IP
; i
< AFI_MAX
; i
++)
73 for (j
= SAFI_UNICAST
; j
< SAFI_MAX
; j
++) {
75 peer
->afc_adv
[i
][j
] = 1;
78 SET_FLAG(peer
->cap
, PEER_CAP_DYNAMIC_ADV
);
79 peer
->status
= Established
;
81 peer
->fd
= open(argv
[1], O_RDONLY
|O_NONBLOCK
);
85 // printf("bgp_read_packet returns: %d\n", bgp_read(&t));