"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/bgpctl/parser.c" between
openbgpd-6.7p0.tar.gz and openbgpd-6.8p0.tar.gz

About: OpenBGPD is a Border Gateway Protocol (BGP) daemon which manages the network routing tables. Its main purpose is to exchange information concerning "network reachability" with other BGP systems.

parser.c  (openbgpd-6.7p0):parser.c  (openbgpd-6.8p0)
/* $OpenBSD: parser.c,v 1.101 2020/01/22 07:52:38 deraadt Exp $ */ /* $OpenBSD: parser.c,v 1.104 2020/05/12 13:26:02 claudio Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
* Copyright (c) 2016 Job Snijders <job@instituut.net> * Copyright (c) 2016 Job Snijders <job@instituut.net>
* Copyright (c) 2016 Peter Hessler <phessler@openbsd.org> * Copyright (c) 2016 Peter Hessler <phessler@openbsd.org>
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies. * copyright notice and this permission notice appear in all copies.
* *
skipping to change at line 49 skipping to change at line 49
KEYWORD, KEYWORD,
ADDRESS, ADDRESS,
PEERADDRESS, PEERADDRESS,
FLAG, FLAG,
ASNUM, ASNUM,
ASTYPE, ASTYPE,
PREFIX, PREFIX,
PEERDESC, PEERDESC,
GROUPDESC, GROUPDESC,
RIBNAME, RIBNAME,
SHUTDOWN_COMMUNICATION, COMMUNICATION,
COMMUNITY, COMMUNITY,
EXTCOMMUNITY, EXTCOMMUNITY,
EXTCOM_SUBTYPE, EXTCOM_SUBTYPE,
LARGE_COMMUNITY, LARGE_COMMUNITY,
LOCALPREF, LOCALPREF,
MED, MED,
NEXTHOP, NEXTHOP,
PFTABLE, PFTABLE,
PREPNBR, PREPNBR,
PREPSELF, PREPSELF,
WEIGHT, WEIGHT,
RD, RD,
FAMILY, FAMILY,
RTABLE, RTABLE,
FILENAME, FILENAME
BULK
}; };
struct token { struct token {
enum token_type type; enum token_type type;
const char *keyword; const char *keyword;
int value; int value;
const struct token *next; const struct token *next;
}; };
static const struct token t_main[]; static const struct token t_main[];
skipping to change at line 117 skipping to change at line 116
static const struct token t_localpref[]; static const struct token t_localpref[];
static const struct token t_med[]; static const struct token t_med[];
static const struct token t_nexthop[]; static const struct token t_nexthop[];
static const struct token t_pftable[]; static const struct token t_pftable[];
static const struct token t_prepnbr[]; static const struct token t_prepnbr[];
static const struct token t_prepself[]; static const struct token t_prepself[];
static const struct token t_weight[]; static const struct token t_weight[];
static const struct token t_log[]; static const struct token t_log[];
static const struct token t_fib_table[]; static const struct token t_fib_table[];
static const struct token t_show_fib_table[]; static const struct token t_show_fib_table[];
static const struct token t_communication[];
static const struct token t_main[] = { static const struct token t_main[] = {
{ KEYWORD, "reload", RELOAD, NULL}, { KEYWORD, "reload", RELOAD, t_communication},
{ KEYWORD, "show", SHOW, t_show}, { KEYWORD, "show", SHOW, t_show},
{ KEYWORD, "fib", FIB, t_fib}, { KEYWORD, "fib", FIB, t_fib},
{ KEYWORD, "neighbor", NEIGHBOR, t_neighbor}, { KEYWORD, "neighbor", NEIGHBOR, t_neighbor},
{ KEYWORD, "network", NONE, t_network}, { KEYWORD, "network", NONE, t_network},
{ KEYWORD, "log", NONE, t_log}, { KEYWORD, "log", NONE, t_log},
{ ENDTOKEN, "", NONE, NULL} { ENDTOKEN, "", NONE, NULL}
}; };
static const struct token t_show[] = { static const struct token t_show[] = {
{ NOTOKEN, "", NONE, NULL}, { NOTOKEN, "", NONE, NULL},
skipping to change at line 279 skipping to change at line 279
{ ENDTOKEN, "", NONE, NULL} { ENDTOKEN, "", NONE, NULL}
}; };
static const struct token t_neighbor[] = { static const struct token t_neighbor[] = {
{ KEYWORD, "group", NONE, t_neighbor_group}, { KEYWORD, "group", NONE, t_neighbor_group},
{ PEERADDRESS, "", NONE, t_neighbor_modifiers}, { PEERADDRESS, "", NONE, t_neighbor_modifiers},
{ PEERDESC, "", NONE, t_neighbor_modifiers}, { PEERDESC, "", NONE, t_neighbor_modifiers},
{ ENDTOKEN, "", NONE, NULL} { ENDTOKEN, "", NONE, NULL}
}; };
static const struct token t_nei_mod_shutc[] = { static const struct token t_communication[] = {
{ NOTOKEN, "", NONE, NULL}, { NOTOKEN, "", NONE, NULL},
{ SHUTDOWN_COMMUNICATION, "", NONE, NULL}, { COMMUNICATION, "", NONE, NULL},
{ ENDTOKEN, "", NONE, NULL} { ENDTOKEN, "", NONE, NULL}
}; };
static const struct token t_neighbor_modifiers[] = { static const struct token t_neighbor_modifiers[] = {
{ KEYWORD, "up", NEIGHBOR_UP, NULL}, { KEYWORD, "up", NEIGHBOR_UP, NULL},
{ KEYWORD, "down", NEIGHBOR_DOWN, t_nei_mod_shutc}, { KEYWORD, "down", NEIGHBOR_DOWN, t_communication},
{ KEYWORD, "clear", NEIGHBOR_CLEAR, t_nei_mod_shutc}, { KEYWORD, "clear", NEIGHBOR_CLEAR, t_communication},
{ KEYWORD, "refresh", NEIGHBOR_RREFRESH, NULL}, { KEYWORD, "refresh", NEIGHBOR_RREFRESH, NULL},
{ KEYWORD, "destroy", NEIGHBOR_DESTROY, NULL}, { KEYWORD, "destroy", NEIGHBOR_DESTROY, NULL},
{ ENDTOKEN, "", NONE, NULL} { ENDTOKEN, "", NONE, NULL}
}; };
static const struct token t_show_rib_as[] = { static const struct token t_show_rib_as[] = {
{ ASNUM, "", NONE, t_show_rib}, { ASNUM, "", NONE, t_show_rib},
{ ENDTOKEN, "", NONE, NULL} { ENDTOKEN, "", NONE, NULL}
}; };
skipping to change at line 584 skipping to change at line 584
!strcasecmp(word, "IPv6")) { !strcasecmp(word, "IPv6")) {
match++; match++;
t = &table[i]; t = &table[i];
res.aid = AID_INET6; res.aid = AID_INET6;
} }
if (!strcasecmp(word, "VPNv4")) { if (!strcasecmp(word, "VPNv4")) {
match++; match++;
t = &table[i]; t = &table[i];
res.aid = AID_VPN_IPv4; res.aid = AID_VPN_IPv4;
} }
if (!strcasecmp(word, "VPNv6")) {
match++;
t = &table[i];
res.aid = AID_VPN_IPv6;
}
break; break;
case ADDRESS: case ADDRESS:
if (parse_addr(word, &res.addr)) { if (parse_addr(word, &res.addr)) {
match++; match++;
t = &table[i]; t = &table[i];
if (t->value)
res.action = t->value;
} }
break; break;
case PEERADDRESS: case PEERADDRESS:
if (parse_addr(word, &res.peeraddr)) { if (parse_addr(word, &res.peeraddr)) {
match++; match++;
t = &table[i]; t = &table[i];
if (t->value)
res.action = t->value;
} }
break; break;
case PREFIX: case PREFIX:
if (parse_prefix(word, wordlen, &res.addr, &res.prefixlen )) { if (parse_prefix(word, wordlen, &res.addr, &res.prefixlen )) {
match++; match++;
t = &table[i]; t = &table[i];
if (t->value)
res.action = t->value;
} }
break; break;
case ASTYPE: case ASTYPE:
if (word != NULL && strncmp(word, table[i].keyword, if (word != NULL && strncmp(word, table[i].keyword,
wordlen) == 0) { wordlen) == 0) {
match++; match++;
t = &table[i]; t = &table[i];
res.as.type = t->value; res.as.type = t->value;
} }
break; break;
skipping to change at line 647 skipping to change at line 646
break; break;
case RIBNAME: case RIBNAME:
if (!match && word != NULL && wordlen > 0) { if (!match && word != NULL && wordlen > 0) {
if (strlcpy(res.rib, word, sizeof(res.rib)) >= if (strlcpy(res.rib, word, sizeof(res.rib)) >=
sizeof(res.rib)) sizeof(res.rib))
errx(1, "rib name too long"); errx(1, "rib name too long");
match++; match++;
t = &table[i]; t = &table[i];
} }
break; break;
case SHUTDOWN_COMMUNICATION: case COMMUNICATION:
if (!match && word != NULL && wordlen > 0) { if (!match && word != NULL && wordlen > 0) {
if (strlcpy(res.shutcomm, word, if (strlcpy(res.reason, word,
sizeof(res.shutcomm)) >= sizeof(res.reason)) >=
sizeof(res.shutcomm)) sizeof(res.reason))
errx(1, "shutdown reason too long"); errx(1, "shutdown reason too long");
match++; match++;
t = &table[i]; t = &table[i];
} }
break; break;
case COMMUNITY: case COMMUNITY:
case LARGE_COMMUNITY: case LARGE_COMMUNITY:
if (word != NULL && wordlen > 0) { if (word != NULL && wordlen > 0) {
int type = COMMUNITY_TYPE_BASIC; int type = COMMUNITY_TYPE_BASIC;
char *p = strdup(word); char *p = strdup(word);
skipping to change at line 794 skipping to change at line 793
*/ */
if (errno == ENOENT && if (errno == ENOENT &&
!strchr(word, '/')) !strchr(word, '/'))
break; break;
err(1, "mrt open(%s)", word); err(1, "mrt open(%s)", word);
} }
match++; match++;
t = &table[i]; t = &table[i];
} }
break; break;
case BULK:
match++;
t = &table[i];
break;
case ENDTOKEN: case ENDTOKEN:
break; break;
} }
} }
if (match != 1) { if (match != 1) {
if (word == NULL) if (word == NULL)
fprintf(stderr, "missing argument:\n"); fprintf(stderr, "missing argument:\n");
else if (match > 1) else if (match > 1)
fprintf(stderr, "ambiguous argument: %s\n", word); fprintf(stderr, "ambiguous argument: %s\n", word);
skipping to change at line 849 skipping to change at line 844
case ASNUM: case ASNUM:
fprintf(stderr, " <asnum>\n"); fprintf(stderr, " <asnum>\n");
break; break;
case GROUPDESC: case GROUPDESC:
case PEERDESC: case PEERDESC:
fprintf(stderr, " <neighbor description>\n"); fprintf(stderr, " <neighbor description>\n");
break; break;
case RIBNAME: case RIBNAME:
fprintf(stderr, " <rib name>\n"); fprintf(stderr, " <rib name>\n");
break; break;
case SHUTDOWN_COMMUNICATION: case COMMUNICATION:
fprintf(stderr, " <shutdown reason>\n"); fprintf(stderr, " <reason>\n");
break; break;
case COMMUNITY: case COMMUNITY:
fprintf(stderr, " <community>\n"); fprintf(stderr, " <community>\n");
break; break;
case LARGE_COMMUNITY: case LARGE_COMMUNITY:
fprintf(stderr, " <large-community>\n"); fprintf(stderr, " <large-community>\n");
break; break;
case EXTCOMMUNITY: case EXTCOMMUNITY:
fprintf(stderr, " <extended-community>\n"); fprintf(stderr, " <extended-community>\n");
break; break;
skipping to change at line 881 skipping to change at line 876
case RTABLE: case RTABLE:
fprintf(stderr, " <rtableid>\n"); fprintf(stderr, " <rtableid>\n");
break; break;
case NEXTHOP: case NEXTHOP:
fprintf(stderr, " <address>\n"); fprintf(stderr, " <address>\n");
break; break;
case PFTABLE: case PFTABLE:
fprintf(stderr, " <pftable>\n"); fprintf(stderr, " <pftable>\n");
break; break;
case FAMILY: case FAMILY:
fprintf(stderr, " [ inet | inet6 | IPv4 | IPv6 | VPNv4 ] fprintf(stderr, " [ inet | inet6 | IPv4 | IPv6 | "
\n"); "VPNv4 | VPNv6 ]\n");
break; break;
case FILENAME: case FILENAME:
fprintf(stderr, " <filename>\n"); fprintf(stderr, " <filename>\n");
break; break;
case BULK:
case ENDTOKEN: case ENDTOKEN:
break; break;
} }
} }
} }
int int
parse_addr(const char *word, struct bgpd_addr *addr) parse_addr(const char *word, struct bgpd_addr *addr)
{ {
struct in_addr ina; struct in_addr ina;
 End of changes. 18 change blocks. 
28 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)