for nexttkn in token.next():
get_always_args(nexttkn, always_args, args, stack)
-def process_file(fn, ofd, dumpfd, all_defun):
+class Macros(dict):
+ def load(self, filename):
+ filedata = clippy.parse(filename)
+ for entry in filedata['data']:
+ if entry['type'] != 'PREPROC':
+ continue
+ ppdir = entry['line'].lstrip().split(None, 1)
+ if ppdir[0] != 'define' or len(ppdir) != 2:
+ continue
+ ppdef = ppdir[1].split(None, 1)
+ name = ppdef[0]
+ if '(' in name:
+ continue
+ val = ppdef[1] if len(ppdef) == 2 else ''
+
+ val = val.strip(' \t\n\\')
+ if name in self:
+ sys.stderr.write('warning: macro %s redefined!\n' % (name))
+ self[name] = val
+
+def process_file(fn, ofd, dumpfd, all_defun, macros):
errors = 0
filedata = clippy.parse(fn)
continue
cmddef = entry['args'][2]
+ cmddefx = []
for i in cmddef:
- if not (i.startswith('"') and i.endswith('"')):
- sys.stderr.write('%s:%d: DEFPY command string not parseable (%r)\n' % (fn, entry['lineno'], cmddef))
- errors += 1
- cmddef = None
- break
- if cmddef is None:
+ while i in macros:
+ i = macros[i]
+ if i.startswith('"') and i.endswith('"'):
+ cmddefx.append(i[1:-1])
+ continue
+
+ sys.stderr.write('%s:%d: DEFPY command string not parseable (%r)\n' % (fn, entry['lineno'], cmddef))
+ errors += 1
+ cmddefx = None
+ break
+ if cmddefx is None:
continue
- cmddef = ''.join([i[1:-1] for i in cmddef])
+ cmddef = ''.join([i for i in cmddefx])
graph = clippy.Graph(cmddef)
args = OrderedDict()
if args.show:
dumpfd = sys.stderr
- errors = process_file(args.cfile, ofd, dumpfd, args.all_defun)
+ macros = Macros()
+ macros.load('lib/route_types.h')
+ macros.load('lib/command.h')
+ # sigh :(
+ macros['PROTO_REDIST_STR'] = 'FRR_REDIST_STR_ISISD'
+
+ errors = process_file(args.cfile, ofd, dumpfd, args.all_defun, macros)
if errors != 0:
sys.exit(1)
DEFPY (show_evpn_mac_vni_dad,
show_evpn_mac_vni_dad_cmd,
- "show evpn mac vni " CMD_VNI_RANGE " duplicate" "[json]",
+ "show evpn mac vni " CMD_VNI_RANGE " duplicate [json]",
SHOW_STR
"EVPN\n"
"MAC addresses\n"
JSON_STR)
{
struct zebra_vrf *zvrf;
- vni_t vni;
bool uj = use_json(argc, argv);
- vni = strtoul(argv[4]->arg, NULL, 10);
zvrf = zebra_vrf_get_evpn();
zebra_vxlan_print_macs_vni_dad(vty, zvrf, vni, uj);
DEFPY (show_evpn_neigh_vni_dad,
show_evpn_neigh_vni_dad_cmd,
- "show evpn arp-cache vni " CMD_VNI_RANGE "duplicate" "[json]",
+ "show evpn arp-cache vni " CMD_VNI_RANGE "duplicate [json]",
SHOW_STR
"EVPN\n"
"ARP and ND cache\n"
JSON_STR)
{
struct zebra_vrf *zvrf;
- vni_t vni;
bool uj = use_json(argc, argv);
- vni = strtoul(argv[4]->arg, NULL, 10);
zvrf = zebra_vrf_get_evpn();
zebra_vxlan_print_neigh_vni_dad(vty, zvrf, vni, uj);
return CMD_SUCCESS;
DEFPY (clear_evpn_dup_addr,
clear_evpn_dup_addr_cmd,
- "clear evpn dup-addr vni <all$vni_all |" CMD_VNI_RANGE"$vni_val [mac M:A:C$mac_val | ip <A.B.C.D|X:X::X:X>]>",
+ "clear evpn dup-addr vni <all$vni_all |" CMD_VNI_RANGE"$vni [mac M:A:C$mac_val | ip <A.B.C.D|X:X::X:X>]>",
CLEAR_STR
"EVPN\n"
"Duplicate address \n"
"IPv6 address\n")
{
struct zebra_vrf *zvrf;
- vni_t vni = 0;
struct ipaddr host_ip = {.ipa_type = IPADDR_NONE };
struct ethaddr mac_addr;
int ret = CMD_SUCCESS;
zvrf = zebra_vrf_get_evpn();
- if (vni_val) {
- vni = strtoul(vni_val, NULL, 10);
-
+ if (vni_str) {
if (mac_val) {
prefix_str2mac(mac_val, &mac_addr);
ret = zebra_vxlan_clear_dup_detect_vni_mac(vty, zvrf,