ongrep

A cleaned up fork of ngrep for OpenBSD
git clone git://git.sgregoratto.me/ongrep
Log | Files | Refs | README | LICENSE

commit a98d946d5e7464b29c91c818ec5e50d7a8197c47
parent 627fe9ae40619adf9b025523384a5770b9b79bc9
Author: Stephen Gregoratto <dev@sgregoratto.me>
Date:   Thu, 25 Jun 2020 17:02:04 +1000

Reformat sources again with clang-format

I couldn't handle having to look at these remaining formatting errors,
so I modified NetBSD's clang-format settings[1] and ran it through the
file. I also modified all global variables so that one is assigned per
line.

[1] https://blog.netbsd.org/tnf/entry/gsoc_2019_report_adding_netbsd1

Diffstat:
Mngrep.c | 397+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Mngrep.h | 20++++++++++----------
2 files changed, 215 insertions(+), 202 deletions(-)

diff --git a/ngrep.c b/ngrep.c @@ -5,26 +5,24 @@ * Please refer to the LICENSE file for more information. * */ +#include <sys/types.h> #include <sys/ioctl.h> #include <sys/limits.h> #include <sys/socket.h> #include <sys/stat.h> -#include <sys/time.h> -#include <sys/types.h> -#include <net/if.h> #include <net/ethertypes.h> - +#include <net/if.h> #include <netinet/in.h> -#include <netinet/ip.h> #include <netinet/icmp6.h> #include <netinet/igmp.h> +#include <netinet/ip.h> #include <netinet/ip6.h> #include <netinet/ip_icmp.h> #include <netinet/tcp.h> #include <netinet/udp.h> -#include <arpa/inet.h> +#include <arpa/inet.h> #include <ctype.h> #include <err.h> #include <errno.h> @@ -43,17 +41,31 @@ #include "ngrep.h" /* Configuration Options */ -uint32_t snaplen = 65535, limitlen = 65535, promisc = 1, to = 100; -uint32_t match_after = 0, keep_matching = 0, matches = 0, max_matches = 0; +uint32_t snaplen = 65535; +uint32_t limitlen = 65535; +uint32_t promisc = 1; +uint32_t to = 100; +uint32_t match_after = 0; +uint32_t keep_matching = 0; +uint32_t matches = 0; +uint32_t max_matches = 0; uint32_t seen_frames = 0; -uint8_t re_match_word = 0, re_ignore_case = 0, re_multiline_match = 1; -uint8_t show_empty = 0, show_hex = 0, show_proto = 0, quiet = 0; -uint8_t invert_match = 0, bin_match = 0; -uint8_t live_read = 1, want_delay = 0; +uint8_t re_match_word = 0; +uint8_t re_ignore_case = 0; +uint8_t re_multiline_match = 1; +uint8_t show_empty = 0; +uint8_t show_hex = 0; +uint8_t show_proto = 0; +uint8_t quiet = 0; +uint8_t invert_match = 0; +uint8_t bin_match = 0; +uint8_t live_read = 1; +uint8_t want_delay = 0; uint8_t enable_hilite = 0; -char *read_file = NULL, *dump_file = NULL; +char *read_file = NULL; +char *dump_file = NULL; char *usedev = NULL; char nonprint_char = '.'; @@ -65,7 +77,8 @@ const char *re_err = NULL; pcre *pattern = NULL; pcre_extra *pattern_extra = NULL; -char *match_data = NULL, *bin_data = NULL; +char *match_data = NULL; +char *bin_data = NULL; int hex_exp_pfx = 1; uint16_t match_len = 0; match_func matcher = blank_match_func; @@ -74,19 +87,22 @@ int8_t dump_single = 0; dump_func dumper = &dump_formatted; /* BPF/Network */ -char *filter = NULL, *filter_file = NULL; -char pc_err[PCAP_ERRBUF_SIZE]; -uint8_t link_offset; -uint8_t radiotap_present = 0; -uint8_t include_vlan = 1; - -pcap_t *pd = NULL, *pd_dumppcap = NULL; -pcap_dumper_t *pd_dump = NULL; -struct bpf_program pcapfilter; -struct in_addr net, mask; +char *filter = NULL; +char *filter_file = NULL; +char pc_err[PCAP_ERRBUF_SIZE]; +uint8_t link_offset; +uint8_t radiotap_present = 0; +uint8_t include_vlan = 1; + +pcap_t *pd = NULL; +pcap_t *pd_dumppcap = NULL; +pcap_dumper_t *pd_dump = NULL; +struct bpf_program pcapfilter; +struct in_addr net, mask; /* Timestamp/delay functionality */ -struct timeval prev_ts = {0, 0}, prev_delay_ts = {0,0}; +struct timeval prev_ts = {0, 0}; +struct timeval prev_delay_ts = {0, 0}; delay_func dump_delay = dump_delay_proc_init; ts_func print_time = NULL; @@ -323,7 +339,8 @@ main(int argc, char **argv) } update_windowsize(0); - while (pcap_loop(pd, -1, (pcap_handler)process, 0)); + while (pcap_loop(pd, -1, (pcap_handler)process, 0)) + ; clean_exit(0); @@ -432,7 +449,7 @@ setup_bpf_filter(char **argv) return -1; } else if (argv[optind]) { /* - * XXX: Find a smarter way of doing this that doesn't eat memory. + * XXX: Find a better way of doing this that doesn't eat memory. * * If the filter doesn't compile the first time, * we assume that there is no match expression and include the @@ -444,14 +461,15 @@ setup_bpf_filter(char **argv) free(filter); filter = get_filter_from_argv(&argv[optind - 1]); - if (pcap_compile(pd, &pcapfilter, filter, 0, mask.s_addr)) + if (pcap_compile(pd, &pcapfilter, filter, 0, + mask.s_addr)) return -1; match_data = NULL; } } else { - filter = include_vlan ? - strdup(BPF_TEMPLATE_IP_VLAN) : strdup(BPF_TEMPLATE_IP); + filter = include_vlan ? strdup(BPF_TEMPLATE_IP_VLAN) + : strdup(BPF_TEMPLATE_IP); if (filter == NULL) err(2, "strdup"); @@ -577,13 +595,13 @@ setup_pattern_match(void) } static inline uint8_t -vlan_frame_count(u_char * p, uint16_t limit) +vlan_frame_count(u_char *p, uint16_t limit) { - uint8_t *et = (uint8_t *) (p + 12); + uint8_t *et = (uint8_t *)(p + 12); uint16_t ether_type = EXTRACT_16BITS(et); uint8_t count = 0; - while ((void *) et < (void *) (p + limit) && + while ((void *)et < (void *)(p + limit) && ether_type != ETHERTYPE_IP && ether_type != ETHERTYPE_IPV6) { count++; @@ -597,11 +615,12 @@ vlan_frame_count(u_char * p, uint16_t limit) void process(UNUSED u_char *d, struct pcap_pkthdr *h, u_char *p) { - uint8_t vlan_offset = include_vlan ? - vlan_frame_count(p, h->caplen) * VLANHDR_SIZE : 0; + uint8_t vlan_offset = + include_vlan ? vlan_frame_count(p, h->caplen) * VLANHDR_SIZE : 0; struct ip *ip4_pkt = (struct ip *)(p + link_offset + vlan_offset); - struct ip6_hdr *ip6_pkt = (struct ip6_hdr *)(p + link_offset + vlan_offset); + struct ip6_hdr *ip6_pkt = + (struct ip6_hdr *)(p + link_offset + vlan_offset); uint32_t ip_ver; @@ -629,36 +648,39 @@ process(UNUSED u_char *d, struct pcap_pkthdr *h, u_char *p) ip_ver = ip4_pkt->ip_v; switch (ip_ver) { - case 4:{ - ip_hl = ip4_pkt->ip_hl * 4; - ip_proto = ip4_pkt->ip_p; - ip_off = ntohs(ip4_pkt->ip_off); - - fragmented = ip_off & (IP_MF | IP_OFFMASK); - frag_offset = (fragmented) ? (ip_off & IP_OFFMASK) * 8 : 0; - frag_id = ntohs(ip4_pkt->ip_id); - - inet_ntop(AF_INET, &ip4_pkt->ip_src, ip_src, sizeof(ip_src)); - inet_ntop(AF_INET, &ip4_pkt->ip_dst, ip_dst, sizeof(ip_dst)); - } break; - case 6:{ - ip_hl = sizeof(struct ip6_hdr); - ip_proto = ip6_pkt->ip6_nxt; - - if (ip_proto == IPPROTO_FRAGMENT) { - struct ip6_frag *ip6_fraghdr; - - ip6_fraghdr = (struct ip6_frag *)((unsigned char *)ip6_pkt + ip_hl); - ip_hl += sizeof(struct ip6_frag); - ip_proto = ip6_fraghdr->ip6f_nxt; - - fragmented = 1; - frag_offset = ntohs(ip6_fraghdr->ip6f_offlg & IP6F_OFF_MASK); - frag_id = ntohl(ip6_fraghdr->ip6f_ident); - } - inet_ntop(AF_INET6, &ip6_pkt->ip6_src, ip_src, sizeof(ip_src)); - inet_ntop(AF_INET6, &ip6_pkt->ip6_dst, ip_dst, sizeof(ip_dst)); - } break; + case 4: { + ip_hl = ip4_pkt->ip_hl * 4; + ip_proto = ip4_pkt->ip_p; + ip_off = ntohs(ip4_pkt->ip_off); + + fragmented = ip_off & (IP_MF | IP_OFFMASK); + frag_offset = (fragmented) ? (ip_off & IP_OFFMASK) * 8 : 0; + frag_id = ntohs(ip4_pkt->ip_id); + + inet_ntop(AF_INET, &ip4_pkt->ip_src, ip_src, sizeof(ip_src)); + inet_ntop(AF_INET, &ip4_pkt->ip_dst, ip_dst, sizeof(ip_dst)); + } break; + case 6: { + ip_hl = sizeof(struct ip6_hdr); + ip_proto = ip6_pkt->ip6_nxt; + + if (ip_proto == IPPROTO_FRAGMENT) { + struct ip6_frag *ip6_fraghdr; + + ip6_fraghdr = + (struct ip6_frag *)((unsigned char *)ip6_pkt + + ip_hl); + ip_hl += sizeof(struct ip6_frag); + ip_proto = ip6_fraghdr->ip6f_nxt; + + fragmented = 1; + frag_offset = + ntohs(ip6_fraghdr->ip6f_offlg & IP6F_OFF_MASK); + frag_id = ntohl(ip6_fraghdr->ip6f_ident); + } + inet_ntop(AF_INET6, &ip6_pkt->ip6_src, ip_src, sizeof(ip_src)); + inet_ntop(AF_INET6, &ip6_pkt->ip6_dst, ip_dst, sizeof(ip_dst)); + } break; } if (quiet < 1) { @@ -667,99 +689,94 @@ process(UNUSED u_char *d, struct pcap_pkthdr *h, u_char *p) } switch (ip_proto) { - case IPPROTO_TCP:{ - struct tcphdr *tcp_pkt - = (struct tcphdr *)((unsigned char *)ip4_pkt + ip_hl); - uint16_t tcphdr_offset = frag_offset ? 0 : tcp_pkt->th_off * 4; - - data = (unsigned char *)tcp_pkt + tcphdr_offset; - len -= link_offset + ip_hl + tcphdr_offset; - - if ((int32_t) len < 0) - len = 0; - - dump_packet(h, p, ip_proto, data, len, ip_src, ip_dst, - ntohs(tcp_pkt->th_sport), - ntohs(tcp_pkt->th_dport), tcp_pkt->th_flags, - tcphdr_offset, fragmented, frag_offset, frag_id); - } break; - case IPPROTO_UDP:{ - struct udphdr *udp_pkt - = (struct udphdr *)((unsigned char *)ip4_pkt + ip_hl); - uint16_t udphdr_offset = frag_offset ? 0 : sizeof(*udp_pkt); - - data = (unsigned char *)udp_pkt + udphdr_offset; - len -= link_offset + ip_hl + udphdr_offset; - - if ((int32_t) len < 0) - len = 0; - - dump_packet(h, p, ip_proto, data, len, ip_src, ip_dst, - ntohs(udp_pkt->uh_sport), - ntohs(udp_pkt->uh_dport), 0, udphdr_offset, - fragmented, frag_offset, frag_id); - } break; - - case IPPROTO_ICMP:{ - struct icmp *icmp4_pkt - = (struct icmp *)((unsigned char *)ip4_pkt + ip_hl); - uint16_t icmp4hdr_offset = frag_offset ? 0 : 4; - - data = (unsigned char *)icmp4_pkt + icmp4hdr_offset; - len -= link_offset + ip_hl + icmp4hdr_offset; - - if ((int32_t) len < 0) - len = 0; - - dump_packet(h, p, ip_proto, data, len, ip_src, ip_dst, - icmp4_pkt->icmp_type, icmp4_pkt->icmp_code, 0, - icmp4hdr_offset, fragmented, frag_offset, - frag_id); - } break; - case IPPROTO_ICMPV6:{ - struct icmp6_hdr *icmp6_pkt - = (struct icmp6_hdr *)((unsigned char *)ip6_pkt + ip_hl); - uint16_t icmp6hdr_offset = frag_offset ? 0 : 4; - - data = (unsigned char *)icmp6_pkt + icmp6hdr_offset; - len -= link_offset + ip_hl + icmp6hdr_offset; - - if ((int32_t) len < 0) - len = 0; - - dump_packet(h, p, ip_proto, data, len, ip_src, ip_dst, - icmp6_pkt->icmp6_type, icmp6_pkt->icmp6_code, - 0, icmp6hdr_offset, fragmented, frag_offset, - frag_id); - } break; - case IPPROTO_IGMP:{ - struct igmp *igmp_pkt - = (struct igmp *)((unsigned char *)ip4_pkt + ip_hl); - uint16_t igmphdr_offset = frag_offset ? 0 : 4; - - data = (unsigned char *)igmp_pkt + igmphdr_offset; - len -= link_offset + ip_hl + igmphdr_offset; - - if ((int32_t) len < 0) - len = 0; - - dump_packet(h, p, ip_proto, data, len, - ip_src, ip_dst, igmp_pkt->igmp_type, - igmp_pkt->igmp_code, 0, igmphdr_offset, - fragmented, frag_offset, frag_id); - } break; - - default:{ - data = (unsigned char *)ip4_pkt + ip_hl; - len -= link_offset + ip_hl; - - if ((int32_t) len < 0) - len = 0; - - dump_packet(h, p, ip_proto, data, len, ip_src, ip_dst, - 0, 0, 0, 0, fragmented, frag_offset, frag_id); - } break; - + case IPPROTO_TCP: { + struct tcphdr *tcp_pkt = + (struct tcphdr *)((unsigned char *)ip4_pkt + ip_hl); + uint16_t tcphdr_offset = frag_offset ? 0 : tcp_pkt->th_off * 4; + + data = (unsigned char *)tcp_pkt + tcphdr_offset; + len -= link_offset + ip_hl + tcphdr_offset; + + if ((int32_t)len < 0) + len = 0; + + dump_packet(h, p, ip_proto, data, len, ip_src, ip_dst, + ntohs(tcp_pkt->th_sport), ntohs(tcp_pkt->th_dport), + tcp_pkt->th_flags, tcphdr_offset, fragmented, + frag_offset, frag_id); + } break; + case IPPROTO_UDP: { + struct udphdr *udp_pkt = + (struct udphdr *)((unsigned char *)ip4_pkt + ip_hl); + uint16_t udphdr_offset = frag_offset ? 0 : sizeof(*udp_pkt); + + data = (unsigned char *)udp_pkt + udphdr_offset; + len -= link_offset + ip_hl + udphdr_offset; + + if ((int32_t)len < 0) + len = 0; + + dump_packet(h, p, ip_proto, data, len, ip_src, ip_dst, + ntohs(udp_pkt->uh_sport), ntohs(udp_pkt->uh_dport), + 0, udphdr_offset, fragmented, frag_offset, frag_id); + } break; + + case IPPROTO_ICMP: { + struct icmp *icmp4_pkt = + (struct icmp *)((unsigned char *)ip4_pkt + ip_hl); + uint16_t icmp4hdr_offset = frag_offset ? 0 : 4; + + data = (unsigned char *)icmp4_pkt + icmp4hdr_offset; + len -= link_offset + ip_hl + icmp4hdr_offset; + + if ((int32_t)len < 0) + len = 0; + + dump_packet(h, p, ip_proto, data, len, ip_src, ip_dst, + icmp4_pkt->icmp_type, icmp4_pkt->icmp_code, 0, + icmp4hdr_offset, fragmented, frag_offset, frag_id); + } break; + case IPPROTO_ICMPV6: { + struct icmp6_hdr *icmp6_pkt = + (struct icmp6_hdr *)((unsigned char *)ip6_pkt + ip_hl); + uint16_t icmp6hdr_offset = frag_offset ? 0 : 4; + + data = (unsigned char *)icmp6_pkt + icmp6hdr_offset; + len -= link_offset + ip_hl + icmp6hdr_offset; + + if ((int32_t)len < 0) + len = 0; + + dump_packet(h, p, ip_proto, data, len, ip_src, ip_dst, + icmp6_pkt->icmp6_type, icmp6_pkt->icmp6_code, 0, + icmp6hdr_offset, fragmented, frag_offset, frag_id); + } break; + case IPPROTO_IGMP: { + struct igmp *igmp_pkt = + (struct igmp *)((unsigned char *)ip4_pkt + ip_hl); + uint16_t igmphdr_offset = frag_offset ? 0 : 4; + + data = (unsigned char *)igmp_pkt + igmphdr_offset; + len -= link_offset + ip_hl + igmphdr_offset; + + if ((int32_t)len < 0) + len = 0; + + dump_packet(h, p, ip_proto, data, len, ip_src, ip_dst, + igmp_pkt->igmp_type, igmp_pkt->igmp_code, 0, + igmphdr_offset, fragmented, frag_offset, frag_id); + } break; + + default: { + data = (unsigned char *)ip4_pkt + ip_hl; + len -= link_offset + ip_hl; + + if ((int32_t)len < 0) + len = 0; + + dump_packet(h, p, ip_proto, data, len, ip_src, ip_dst, 0, 0, 0, + 0, fragmented, frag_offset, frag_id); + } break; } if (max_matches && matches >= max_matches) @@ -771,10 +788,10 @@ process(UNUSED u_char *d, struct pcap_pkthdr *h, u_char *p) void dump_packet(struct pcap_pkthdr *h, u_char *p, uint8_t proto, - unsigned char *data, uint32_t len, const char *ip_src, - const char *ip_dst, uint16_t sport, uint16_t dport, uint8_t flags, - uint16_t hdr_offset, uint8_t frag, uint16_t frag_offset, - uint32_t frag_id) + unsigned char *data, uint32_t len, const char *ip_src, + const char *ip_dst, uint16_t sport, uint16_t dport, uint8_t flags, + uint16_t hdr_offset, uint8_t frag, uint16_t frag_offset, + uint32_t frag_id) { uint16_t match_size, match_index; char ident = '?'; @@ -821,8 +838,7 @@ dump_packet(struct pcap_pkthdr *h, u_char *p, uint8_t proto, print_time(h); if ((proto == IPPROTO_TCP || proto == IPPROTO_UDP) && - (sport || dport) && - (hdr_offset || frag_offset == 0)) + (sport || dport) && (hdr_offset || frag_offset == 0)) printf("%s:%u -> %s:%u", ip_src, sport, ip_dst, dport); else printf("%s -> %s", ip_src, ip_dst); @@ -848,8 +864,8 @@ dump_packet(struct pcap_pkthdr *h, u_char *p, uint8_t proto, } if (frag) - printf(" %s%u@%u:%u", - frag_offset ? "+" : "", frag_id, frag_offset, len); + printf(" %s%u@%u:%u", frag_offset ? "+" : "", + frag_id, frag_offset, len); if (dump_single) printf(" "); @@ -860,12 +876,12 @@ dump_packet(struct pcap_pkthdr *h, u_char *p, uint8_t proto, dumper(data, len, match_index, match_size); if (pd_dump) - pcap_dump((u_char *) pd_dump, h, p); + pcap_dump((u_char *)pd_dump, h, p); } int8_t re_match_func(unsigned char *data, uint32_t len, uint16_t *mindex, - uint16_t *msize) + uint16_t *msize) { static int matchpos[2] = {0}; int did_match = pcre_exec(pattern, 0, (const char *)data, (int)len, @@ -891,7 +907,7 @@ re_match_func(unsigned char *data, uint32_t len, uint16_t *mindex, int8_t bin_match_func(unsigned char *data, uint32_t len, uint16_t *mindex, - uint16_t *msize) + uint16_t *msize) { int32_t stop = len - match_len; int32_t i = 0; @@ -917,12 +933,12 @@ bin_match_func(unsigned char *data, uint32_t len, uint16_t *mindex, int8_t blank_match_func(UNUSED unsigned char *data, UNUSED uint32_t len, - uint16_t *mindex, uint16_t *msize) + uint16_t *mindex, uint16_t *msize) { matches++; *mindex = 0; - *msize = 0; + *msize = 0; return 1; } @@ -939,8 +955,7 @@ dump_byline(unsigned char *data, uint32_t len, uint16_t mindex, uint16_t msize) if (should_hilite && s == hilite_start) printf("%s", ANSI_hilite); - printf("%c", - (*s == '\n' || isprint(*s)) ? *s : nonprint_char); + printf("%c", (*s == '\n' || isprint(*s)) ? *s : nonprint_char); s++; if (should_hilite && s == hilite_end) @@ -952,12 +967,12 @@ dump_byline(unsigned char *data, uint32_t len, uint16_t mindex, uint16_t msize) void dump_unwrapped(unsigned char *data, uint32_t len, uint16_t mindex, - uint16_t msize) + uint16_t msize) { const unsigned char *s = data; - uint8_t should_hilite = (msize && enable_hilite); - unsigned char * hilite_start = data + mindex; - unsigned char * hilite_end = hilite_start + msize; + uint8_t should_hilite = (msize && enable_hilite); + unsigned char *hilite_start = data + mindex; + unsigned char *hilite_end = hilite_start + msize; while (s < data + len) { if (should_hilite && s == hilite_start) @@ -975,12 +990,12 @@ dump_unwrapped(unsigned char *data, uint32_t len, uint16_t mindex, void dump_formatted(unsigned char *data, uint32_t len, uint16_t mindex, - uint16_t msize) + uint16_t msize) { - uint8_t should_hilite = (msize && enable_hilite); + uint8_t should_hilite = (msize && enable_hilite); unsigned char *str = data; - uint8_t hiliting = 0; - uint8_t width = show_hex ? 16 : (ws_col - 5); + uint8_t hiliting = 0; + uint8_t width = show_hex ? 16 : (ws_col - 5); uint32_t i = 0, j = 0; while (i < len) { @@ -1017,9 +1032,8 @@ dump_formatted(unsigned char *data, uint32_t len, uint16_t mindex, } if (i + j < len) - printf("%c", isprint(str[j]) - ? str[j] - : nonprint_char); + printf("%c", isprint(str[j]) ? str[j] + : nonprint_char); else printf(" "); @@ -1129,9 +1143,9 @@ get_filter_from_argv(char **argv) } void -print_time_absolute(struct pcap_pkthdr * h) +print_time_absolute(struct pcap_pkthdr *h) { - struct tm *t = localtime((const time_t *) & h->ts.tv_sec); + struct tm *t = localtime((const time_t *)&h->ts.tv_sec); printf("%02u/%02u/%02u %02u:%02u:%02u.%06u ", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, @@ -1139,7 +1153,7 @@ print_time_absolute(struct pcap_pkthdr * h) } void -print_time_diff(struct pcap_pkthdr * h) +print_time_diff(struct pcap_pkthdr *h) { uint32_t secs, usecs; @@ -1158,7 +1172,7 @@ print_time_diff(struct pcap_pkthdr * h) } void -print_time_offset(struct pcap_pkthdr * h) +print_time_offset(struct pcap_pkthdr *h) { uint32_t secs, usecs; @@ -1180,7 +1194,7 @@ print_time_offset(struct pcap_pkthdr * h) } void -dump_delay_proc_init(struct pcap_pkthdr * h) +dump_delay_proc_init(struct pcap_pkthdr *h) { dump_delay = &dump_delay_proc; @@ -1191,7 +1205,7 @@ dump_delay_proc_init(struct pcap_pkthdr * h) } void -dump_delay_proc(struct pcap_pkthdr * h) +dump_delay_proc(struct pcap_pkthdr *h) { uint32_t secs, usecs; @@ -1225,7 +1239,6 @@ update_windowsize(int32_t e) ws_row = 24; ws_col = 80; } - } } diff --git a/ngrep.h b/ngrep.h @@ -23,9 +23,9 @@ #define VLANHDR_SIZE 4 #define IPNETHDR_SIZE 24 -#define EXTRACT_16BITS(p) \ - ((uint16_t)((uint16_t)*((const uint8_t *)(p) + 0) << 8 | \ - (uint16_t)*((const uint8_t *)(p) + 1))) +#define EXTRACT_16BITS(p) \ + ((uint16_t)((uint16_t) * ((const uint8_t *)(p) + 0) << 8 | \ + (uint16_t) * ((const uint8_t *)(p) + 1))) #define UNUSED __attribute__((__unused__)) @@ -102,14 +102,14 @@ uint8_t strishex(char *); void drop_privs(void); struct NGREP_rtaphdr_t { - uint8_t it_version; - uint8_t it_pad; - uint16_t it_len; - uint32_t it_present; + uint8_t it_version; + uint8_t it_pad; + uint16_t it_len; + uint32_t it_present; }; /* ANSI color/hilite stuff. */ -const char ANSI_red[] = "\33[01;31m"; -const char ANSI_bold[] = "\33[01m"; +const char ANSI_red[] = "\33[01;31m"; +const char ANSI_bold[] = "\33[01m"; const char *ANSI_hilite = ANSI_red; -const char ANSI_off[] = "\33[00m"; +const char ANSI_off[] = "\33[00m";