} state;
byte *error;
u64 req_start_time, resp_start_time;
- uns id;
+ uns conn_id;
struct mempool *pool;
list tx_queue, rx_queue;
+ uns xact_id;
byte *req_line, *resp_line;
list req_headers, resp_headers;
byte line[MAXLINE];
char *http_log_dir;
+static uns http_conn_counter;
+static uns http_xact_counter;
+
static void http_open(struct flow *f, u64 when)
{
- static int http_counter;
struct http_state *s = xmalloc_zero(sizeof(*s));
s->flow = f;
f->appl_data = s;
- s->id = http_counter++;
- DBG("HTTP: %d NEW %d.%d.%d.%d:%d -> %d.%d.%d.%d:%d\n", s->id,
+ s->conn_id = http_conn_counter++;
+ DBG("HTTP: %d NEW %d.%d.%d.%d:%d -> %d.%d.%d.%d:%d\n", s->conn_id,
IPQUAD(f->saddr), ntohs(f->sport), IPQUAD(f->daddr), ntohs(f->dport));
list_init(&s->tx_queue);
list_init(&s->rx_queue);
char name[256], stamp[TIMESTAMP_LEN];
struct flow *f = s->flow;
- sprintf(name, "%s/%06u-%d.%d.%d.%d:%d-%d.%d.%d.%d:%d", http_log_dir, s->id,
+ sprintf(name, "%s/%06u-%d.%d.%d.%d:%d-%d.%d.%d.%d:%d", http_log_dir, s->xact_id,
IPQUAD(f->saddr), ntohs(f->sport), IPQUAD(f->daddr), ntohs(f->dport));
if (!(s->log_file = fopen(name, "w")))
die("Unable to create %s: %m", name);
byte *sep;
if (sep = strchr(ctype, ';'))
*sep = 0;
- if (!s->id)
+ if (!s->xact_id)
printf("# id timestamp source destination forwarded-for res cac que length total time wait time ctype method URL\n");
/* 000000 2003-06-06 22:53:38.642 81.27.194.19:1175 205.217.153.53:80 123.123.123.123 200 ... 0 14030 0.957 0.444 text/plain GET http://... */
printf("%06u %s %-21s %-21s %-15s %-3s %c%c%c %3d %8d %6d.%03d %6d.%03d %-12s %s %s\n",
- s->id, stamp, src, dst, (ffor ? : "-"), reason,
+ s->xact_id, stamp, src, dst, (ffor ? : "-"), reason,
rq_cflag, rp_cflag, rp_hit,
s->req_counter,
s->body_total_size,
static void http_close(struct flow *f, int cause, u64 when)
{
struct http_state *s = f->appl_data;
- DBG("HTTP: %d CLOSE in state %d (cause %d)\n", s->id, s->state, cause);
+ DBG("HTTP: %d CLOSE in state %d (cause %d)\n", s->conn_id, s->state, cause);
if (cause != CAUSE_CLOSE)
{
if (s->state != HTTP_IDLE)
s->req_line = s->resp_line = NULL;
s->line_len = 0;
s->body_total_size = 0;
+ s->xact_id = http_xact_counter++;
http_log_start(s);
}
// DBG("dir=%d txf=%d rxf=%d len=%d\n", dir, fin_tx, fin_rx, pkt_len(p));
if (s->state == HTTP_ERROR || s->state == HTTP_CUT)
{
- DBG("HTTP: %d DROPPING INPUT\n", s->id);
+ DBG("HTTP: %d DROPPING INPUT\n", s->conn_id);
pkt_free(p);
return;
}
list_add_tail((dir ? &s->tx_queue : &s->rx_queue), &p->n);
for(;;)
{
- DBG("HTTP: %d STATE %d\n", s->id, s->state);
+ DBG("HTTP: %d STATE %d\n", s->conn_id, s->state);
switch (s->state)
{
case HTTP_IDLE:
}
err:
- DBG("HTTP: %d ERROR: PROTOCOL VIOLATION\n", s->id);
+ DBG("HTTP: %d ERROR: PROTOCOL VIOLATION\n", s->conn_id);
s->state = HTTP_ERROR;
return;
cut:
- DBG("HTTP: %d ERROR: UNEXPECTED EOF\n", s->id);
+ DBG("HTTP: %d ERROR: UNEXPECTED EOF\n", s->conn_id);
s->state = HTTP_CUT;
}