#include <u.h>
#include <libc.h>
#include <ip.h>
#include "a1.h"
int chatty = 0;
void
usage(void)
{
fprint(2, "usage: fmt <file\n");
exits("usage");
}
char*
ct(ulong t)
{
char *p;
p = ctime(t);
if(p[strlen(p)-1] == '\n')
p[strlen(p)-1] = '\0';
return p;
}
void
main(int argc, char **argv)
{
int n, m;
uchar *p;
uchar buf[65536];
Snmp s;
fmtinstall('I', eipfmt);
fmtinstall('E', eipfmt);
ARGBEGIN{
default:
usage();
}ARGEND
if(argc != 0)
usage();
n = readn(0, buf, sizeof buf);
for(p=buf; p<buf+n; p+=m+8){
m = nhgetl(p+4);
print("#%ld. %s %I/%d -> %I/%d ", p-buf, ct(nhgetl(p)),
p+8, nhgets(p+8+16+16),
p+8+16, nhgets(p+8+16+16+2));
if(Sparse(p+8+36, m-36, &s) < 0)
print("format error\n");
else
Sprint(&s);
}
}
|