def cmdline(cmdarg): route = ''.join(cmdarg.payload).replace(' ', '') if not is_bgp(route): # parser.print_usage() sys.stdout.write('Environment values are:\n%s\n\n' % '\n'.join(' - %s' % _ for _ in Env.default())) sys.stdout.write('The BGP message must be an hexadecimal string.\n\n') sys.stdout.write('All colons or spaces are ignored, for example:\n\n') sys.stdout.write(' 001E0200000007900F0003000101\n') sys.stdout.write(' 001E:02:0000:0007:900F:0003:0001:01\n') sys.stdout.write( ' FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF001E0200000007900F0003000101\n') sys.stdout.write( ' FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:001E:02:0000:0007:900F:0003:0001:01\n' ) sys.stdout.write( " FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 001E02 00000007900F0003000101\n" ) sys.stdout.flush() sys.exit(1) env = getenv() env.bgp.passive = True env.log.parser = True env.tcp.bind = '' if cmdarg.debug: env.log.all = True env.log.level = 'DEBUG' if cmdarg.pdb: env.debug.pdb = True log.init(env) trace_interceptor(env.debug.pdb) sanitized = ''.join(cmdarg.payload).replace(':', '').replace(' ', '') if cmdarg.configuration: configuration = Configuration([getconf(cmdarg.configuration)]) elif cmdarg.family: families = cmdarg.family.split() if len(families) % 2: sys.stdout.write('families provided are invalid') sys.stdout.flush() sys.exit(1) families_pair = [families[n:n + 2] for n in range(0, len(families), 2)] families_text = ';'.join([f'{a} {s}' for a, s in families_pair]) conf = conf_none.replace('[families]', families_text) configuration = Configuration([conf], text=True) else: configuration = Configuration([conf_all], text=True) valid_nlri = Reactor(configuration).check(sanitized, cmdarg.nlri) if valid_nlri: return 0 return 1
def cmdline(cmdarg): route = ''.join(cmdarg.payload).replace(' ', '') if not is_bgp(route): # parser.print_usage() sys.stdout.write('Environment values are:\n%s\n\n' % '\n'.join(' - %s' % _ for _ in Env.default())) sys.stdout.write('The BGP message must be an hexadecimal string.\n\n') sys.stdout.write('All colons or spaces are ignored, for example:\n\n') sys.stdout.write(' 001E0200000007900F0003000101\n') sys.stdout.write(' 001E:02:0000:0007:900F:0003:0001:01\n') sys.stdout.write( ' FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF001E0200000007900F0003000101\n') sys.stdout.write( ' FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:001E:02:0000:0007:900F:0003:0001:01\n' ) sys.stdout.write( " FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 001E02 00000007900F0003000101\n" ) sys.stdout.flush() sys.exit(1) env = getenv() env.bgp.passive = True env.log.parser = True env.tcp.bind = '' if cmdarg.debug: env.log.all = True env.log.level = 'DEBUG' if cmdarg.pdb: env.debug.pdb = True log.init(env) trace_interceptor(env.debug.pdb) sanitized = ''.join(cmdarg.payload).replace(':', '').replace(' ', '') Reactor([getconf(cmdarg.configuration)]).check(sanitized)
def cmdline(cmdarg): route = ''.join(cmdarg.payload).replace(' ', '') if not is_bgp(route): # parser.print_usage() sys.stdout.write('Environment values are:\n%s\n\n' % '\n'.join(' - %s' % _ for _ in Env.default())) sys.stdout.write('The BGP message must be an hexadecimal string.\n\n') sys.stdout.write('All colons or spaces are ignored, for example:\n\n') sys.stdout.write(' 001E0200000007900F0003000101\n') sys.stdout.write(' 001E:02:0000:0007:900F:0003:0001:01\n') sys.stdout.write( ' FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF001E0200000007900F0003000101\n') sys.stdout.write( ' FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:001E:02:0000:0007:900F:0003:0001:01\n' ) sys.stdout.write( " FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 001E02 00000007900F0003000101\n" ) sys.stdout.flush() sys.exit(1) env = getenv() env.log.parser = True env.debug.route = route env.tcp.bind = '' if cmdarg.debug: env.log.all = True env.log.level = syslog.LOG_DEBUG if cmdarg.pdb: env.debug.pdb = True log.init() Reactor([cmdarg.configuration]).run(False, ROOT)
def default(): sys.stdout.write('\nEnvironment values are:\n') sys.stdout.write('\n'.join(' %s' % _ for _ in Env.default())) sys.stdout.flush()