Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions lib/io/bsrt/bgpview_io_bsrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ static int parse_args(bgpview_io_bsrt_t *bsrt, int argc, char **argv)
#define PREFIX_CMD_CNT 1000
#define COMMUNITY_CMD_CNT 1000
#define PEERASN_CMD_CNT 1000
#define NOT_PEERASN_CMD_CNT 1000
#define WINDOW_CMD_CNT 1024
#define OPTION_CMD_CNT 1024

Expand All @@ -657,6 +658,9 @@ static int parse_args(bgpview_io_bsrt_t *bsrt, int argc, char **argv)
char *peerasns[PEERASN_CMD_CNT];
int peerasns_cnt = 0;

char *not_peerasns[NOT_PEERASN_CMD_CNT];
int not_peerasns_cnt = 0;

char *prefixes[PREFIX_CMD_CNT];
int prefixes_cnt = 0;

Expand All @@ -675,7 +679,7 @@ static int parse_args(bgpview_io_bsrt_t *bsrt, int argc, char **argv)
optind = 1;

/* remember the argv strings DO NOT belong to us */
while ((opt = getopt(argc, argv, "d:o:p:c:t:w:j:k:y:P:i:ag:lLB:n:O:r:R:h")) >= 0) {
while ((opt = getopt(argc, argv, "d:o:p:c:t:w:j:J:k:y:P:i:ag:lLB:n:O:r:R:h")) >= 0) {
switch (opt) {
case 'd':
if (strcmp(optarg, "test") == 0) {
Expand Down Expand Up @@ -760,6 +764,17 @@ static int parse_args(bgpview_io_bsrt_t *bsrt, int argc, char **argv)
peerasns[peerasns_cnt++] = strdup(optarg);
break;

case 'J':
if (not_peerasns_cnt == NOT_PEERASN_CMD_CNT) {
fprintf(stderr, "ERROR: A maximum of %d not peer asns can be specified on "
"the command line\n",
NOT_PEERASN_CMD_CNT);
usage(bsrt);
exit(-1);
}
not_peerasns[not_peerasns_cnt++] = strdup(optarg);
break;

case 'k':
if (prefixes_cnt == PREFIX_CMD_CNT) {
fprintf(stderr, "ERROR: A maximum of %d peer asns can be specified on "
Expand Down Expand Up @@ -859,7 +874,7 @@ static int parse_args(bgpview_io_bsrt_t *bsrt, int argc, char **argv)

if (bsrt_get_next_record == test_get_next_record) {
if (projects_cnt || types_cnt || collectors_cnt || windows_cnt ||
peerasns_cnt || prefixes_cnt || communities_cnt ||
not_peerasns_cnt || peerasns_cnt || prefixes_cnt || communities_cnt ||
interface_options_cnt || rib_period)
{
fprintf(stderr, "ERROR: most options are not allowed with bsrt -dtest.\n");
Expand Down Expand Up @@ -945,6 +960,13 @@ static int parse_args(bgpview_io_bsrt_t *bsrt, int argc, char **argv)
free(peerasns[i]);
}

/* not peer asns */
for (int i = 0; i < not_peerasns_cnt; i++) {
bgpstream_add_filter(bsrt->stream, BGPSTREAM_FILTER_TYPE_ELEM_NOT_PEER_ASN,
not_peerasns[i]);
free(not_peerasns[i]);
}

/* prefixes */
for (int i = 0; i < prefixes_cnt; i++) {
bgpstream_add_filter(bsrt->stream, BGPSTREAM_FILTER_TYPE_ELEM_PREFIX,
Expand Down