/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2000-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
#include <ptv.h>
#include <ip6.h>
#include <error.h>
#include <option.h>
#include <ctype.h>
static const char usage[] =
"[-?\n@(#)$Id: testptv (AT&T Research) 2009-07-22 $\n]"
"[+NAME?testptv - ptv ipv6 longest prefix match test harness]"
"[+DESCRIPTION?\btestptv\b loads the ipv6 prefixes in \aprefix-file\a "
"and then does a longest prefix match for each ipv6 address in each "
"\aaddress-file\a. If \aaddress-file\a is omitted or \b-\b then the "
"standard input is read. Matched addresses are listed with the min and max "
"rangepoints of the matching interval, one line per match. \b-\b is "
"listed instead of rangepoints for unmatched addresses.]"
"[+?\aprefix-file\a must contain a sequence of lines with the \bipv6\b "
"prefix in the first space separated field. Each \aaddress-file\a must "
"contain a sequence of lines with the \bipv6\b address in the first "
"space separated field.]"
"[d:dump?Dump the prefix table before matching the addresses.]"
"\n"
"\nprefix-file [ address-file ... ]\n"
"\n"
"[+SEE ALSO?\alpm\a(1), \apta\a(1)]"
;
int
{
char* file;
char* s;
int dump = 0;
for (;;)
{
{
case 'd':
dump = 1;
continue;
case '?':
continue;
case ':':
continue;
}
break;
}
else
{
if (dump)
sfprintf(sfstderr, "insert %s %s\n", fmtip6(ptvmin(ptv->size, ptv->r[0], prefix, prefix[IP6BITS]), prefix[IP6BITS]), fmtip6(ptvmax(ptv->size, ptv->r[1], prefix, prefix[IP6BITS]), prefix[IP6BITS]));
if (!ptvinsert(ptv, ptvmin(ptv->size, ptv->r[0], prefix, prefix[IP6BITS]), ptvmax(ptv->size, ptv->r[1], prefix, prefix[IP6BITS])))
{
break;
}
}
if (dump)
do
{
sfprintf(sfstdout, "%-38s %-38s %-38s\n", fmtip6(addr, -1), fmtip6(pp->min, -1), fmtip6(pp->max, -1));
else
return 0;
}