1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2017 Cumulus Networks Inc.
6 * This file is part of FRR
19 #include "bgpd/bgpd.h"
20 #include "bgpd/bgp_open.h"
21 #include "bgpd/bgp_debug.h"
22 #include "bgpd/bgp_packet.h"
23 #include "bgpd/bgp_aspath.h"
24 #include "bgpd/bgp_network.h"
26 /* need these to link in libbgp */
27 struct zebra_privs_t bgpd_privs
= {};
28 struct thread_master
*master
= NULL
;
30 static struct bgp
*bgp
;
31 static as_t asn
= 100;
33 extern int bgp_read_packet(struct peer
*peer
);
36 * This file is intended to be used as input for some sort of
37 * fuzzer. Specifically I had afl in mind when I wrote
40 int main(int argc
, char *argv
[])
48 master
= thread_master_create(NULL
);
49 bgp_master_init(master
, BGP_SOCKET_SNDBUF_SIZE
, list_new());
50 vrf_init(NULL
, NULL
, NULL
, NULL
);
51 bgp_option_set(BGP_OPT_NO_LISTEN
);
53 if (bgp_get(&bgp
, &asn
, NULL
, BGP_INSTANCE_TYPE_DEFAULT
, NULL
,
54 ASNOTATION_PLAIN
) < 0)
57 peer
= peer_create_accept(bgp
);
58 peer
->host
= (char *)"foo";
60 for (i
= AFI_IP
; i
< AFI_MAX
; i
++)
61 for (j
= SAFI_UNICAST
; j
< SAFI_MAX
; j
++) {
63 peer
->afc_adv
[i
][j
] = 1;
66 SET_FLAG(peer
->cap
, PEER_CAP_DYNAMIC_ADV
);
67 peer
->status
= Established
;
69 peer
->fd
= open(argv
[1], O_RDONLY
|O_NONBLOCK
);
73 // printf("bgp_read_packet returns: %d\n", bgp_read(&t));