/* Copyright (C) 2000-2006 Boris Wesslowski */
/* $Id: output.c,v 1.67 2006/03/08 19:36:03 bw Exp $ */
#include ", opt.html);
} else {
fprintf(fd, " \n");
}
void output_text_entry(struct conn_data *input, FILE *fd)
{
char *proto, time[TIMESIZE], buf[HOSTLEN];
unsigned char first = 1;
if(opt.stimes) {
strftime(time, TIMESIZE, _("%b %d %H:%M:%S"), localtime(&input->start_time));
fprintf(fd, "%s", time);
first = 0;
}
if(opt.etimes) {
if(!first)
fprintf(fd, _(" to "));
if(input->end_time != 0) {
strftime(time, TIMESIZE, _("%b %d %H:%M:%S"), localtime(&input->end_time));
fprintf(fd, "%s", time);
} else {
fprintf(fd, "-");
}
first = 0;
}
if(opt.duration) {
if(!first)
fprintf(fd, " ");
output_timediff(input->start_time, input->end_time, time);
fprintf(fd, "%s", time);
first = 0;
}
if(opt.loghost) {
if(!first)
fprintf(fd, " ");
fprintf(fd, "%s", input->hostname);
first = 0;
}
if(opt.chains) {
if(!first)
fprintf(fd, " ");
fprintf(fd, "%s", input->chainlabel);
first = 0;
}
if(opt.branches) {
if(!first)
fprintf(fd, " ");
fprintf(fd, "%s", input->branchname);
first = 0;
}
if(opt.ifs) {
if(!first)
fprintf(fd, " ");
fprintf(fd, "%s", input->interface);
first = 0;
}
if(!first)
fprintf(fd, " ");
fprintf(fd, "%d", input->count);
proto = resolve_protocol(input->protocol);
if(opt.proto)
fprintf(fd, " %s", proto);
if(input->count == 1) {
fprintf(fd, _(" packet"));
} else {
fprintf(fd, _(" packets"));
}
if (opt.datalen)
fprintf(fd, _(" (%d bytes)"), input->datalen);
if (opt.src_ip) {
fprintf(fd, _(" from %s"), inet_ntoa(input->shost));
if(opt.resolve)
fprintf(fd, " (%s)", resolve_hostname(input->shost));
if(opt.whois_lookup) {
struct whois_entry *we;
we = whois(input->shost);
if (we != NULL) {
snprintf(buf, HOSTLEN, "%s %s AS%d %s", we->ip_route, we->ip_descr, we->as_number, we->as_descr);
} else {
snprintf(buf, HOSTLEN, "-");
}
fprintf(fd, " [%s]", buf);
}
}
if (opt.src_port) {
fprintf(fd, _(" port %d"), input->sport);
if (opt.sresolve)
fprintf(fd, " (%s)", resolve_service(input->sport, proto));
}
if (opt.dst_ip) {
fprintf(fd, _(" to %s"), inet_ntoa(input->dhost));
if(opt.resolve) {
fprintf(fd, " (%s)", resolve_hostname(input->dhost));
}
}
if (opt.dst_port) {
fprintf(fd, _(" port %d"), input->dport);
if (opt.sresolve)
fprintf(fd, " (%s)", resolve_service(input->dport, proto));
}
if(opt.opts) {
output_tcp_opts(input, buf);
fprintf(fd, " %s", buf);
}
fprintf(fd, "\n");
}
void output_html_table(FILE *fd)
{
fprintf(fd, "", opt.html);
}
fprintf(fd, "%d", input->count);
if(opt.stimes) {
strftime(time, TIMESIZE, _("%b %d %H:%M:%S"), localtime(&input->start_time));
fprintf(fd, " %s", time);
}
if(opt.etimes) {
fprintf(fd, " ");
if(input->end_time != 0) {
strftime(time, TIMESIZE, _("%b %d %H:%M:%S"), localtime(&input->end_time));
fprintf(fd, "%s", time);
} else {
fprintf(fd, "-");
}
}
if(opt.duration) {
output_timediff(input->start_time, input->end_time, time);
fprintf(fd, " %s", time);
}
if(opt.loghost)
fprintf(fd, " %s", input->hostname);
if(opt.chains)
fprintf(fd, " %s", input->chainlabel);
if(opt.branches)
fprintf(fd, " %s", input->branchname);
if(opt.ifs)
fprintf(fd, " %s", input->interface);
if(opt.proto) {
proto = resolve_protocol(input->protocol);
fprintf(fd, " %s", proto);
}
if (opt.datalen)
fprintf(fd, " %d", input->datalen);
if (opt.src_ip) {
fprintf(fd, " %s", inet_ntoa(input->shost));
if(opt.resolve)
fprintf(fd, " %s", resolve_hostname(input->shost));
if(opt.whois_lookup) {
struct whois_entry *we;
we = whois(input->shost);
if (we != NULL) {
snprintf(buf, HOSTLEN, "%s %s AS%d %s", we->ip_route, we->ip_descr, we->as_number, we->as_descr);
} else {
snprintf(buf, HOSTLEN, "-");
}
fprintf(fd, " %s", buf);
}
}
if (opt.src_port) {
fprintf(fd, " %d", input->sport);
if (opt.sresolve)
fprintf(fd, " %s", resolve_service(input->sport, proto));
}
if (opt.dst_ip) {
fprintf(fd, " %s", inet_ntoa(input->dhost));
if(opt.resolve)
fprintf(fd, " %s", resolve_hostname(input->dhost));
}
if (opt.dst_port) {
fprintf(fd, " %d", input->dport);
if (opt.sresolve)
fprintf(fd, " %s", resolve_service(input->dport, proto));
}
if(opt.opts) {
output_tcp_opts(input, buf);
fprintf(fd, " %s", buf);
}
fprintf(fd, "
| # | "); if(opt.stimes) fprintf(fd, _("start | ")); if(opt.etimes) fprintf(fd, _("end | ")); if(opt.duration) fprintf(fd, _("interval | ")); if(opt.loghost) fprintf(fd, _("loghost | ")); if(opt.chains) fprintf(fd, _("chain | ")); if(opt.branches) fprintf(fd, _("target | ")); if(opt.ifs) fprintf(fd, _("interface | ")); if(opt.proto) fprintf(fd, _("proto | ")); if(opt.datalen) fprintf(fd, _("bytes | ")); if(opt.src_ip) { fprintf(fd, _("source | ")); if(opt.resolve) fprintf(fd, _("hostname | ")); if(opt.whois_lookup) fprintf(fd, _("whois information | ")); } if (opt.src_port) { fprintf(fd, _("port | ")); if (opt.sresolve) fprintf(fd, _("service | ")); } if(opt.dst_ip) { fprintf(fd, _("destination | ")); if(opt.resolve) fprintf(fd, _("hostname | ")); } if (opt.dst_port) { fprintf(fd, _("port | ")); if (opt.sresolve) fprintf(fd, _("service | ")); } if (opt.opts) fprintf(fd, _("opts | ")); fprintf(fd, "
|---|