Skip to content

Commit

Permalink
Display milliseconds in packet timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
jbittel committed Oct 15, 2014
1 parent 5725ad1 commit 7cdad9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
/* HTTP specific constant; should never change! */
#define HTTP_STRING "HTTP/"

#define MAX_TIME_LEN 20
#define MAX_TIME_LEN 32
#define PORTSTRLEN 6

#endif /* ! _HAVE_CONFIG_H */
5 changes: 3 additions & 2 deletions httpry.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void parse_http_packet(u_char *args, const struct pcap_pkthdr *header, const u_c
char *header_line, *req_value;
char saddr[INET6_ADDRSTRLEN], daddr[INET6_ADDRSTRLEN];
char sport[PORTSTRLEN], dport[PORTSTRLEN];
char ts[MAX_TIME_LEN];
char ts[MAX_TIME_LEN], fmt[MAX_TIME_LEN];
int is_request = 0, is_response = 0;
unsigned int eth_type = 0, offset;

Expand Down Expand Up @@ -400,7 +400,8 @@ void parse_http_packet(u_char *args, const struct pcap_pkthdr *header, const u_c

/* Extract packet capture time */
pkt_time = localtime((time_t *) &header->ts.tv_sec);
strftime(ts, MAX_TIME_LEN, "%Y-%m-%d %H:%M:%S", pkt_time);
strftime(fmt, sizeof(fmt), "%Y-%m-%d %H:%M:%S.%%03u", pkt_time);
snprintf(ts, sizeof(ts), fmt, header->ts.tv_usec / 1000);
insert_value("timestamp", ts);

if (rate_stats) {
Expand Down

0 comments on commit 7cdad9d

Please sign in to comment.