/* * netsniff-ng - the packet sniffing beast * Copyright 2009 - 2013 Daniel Borkmann. * Subject to the GPL, version 2. */ #ifndef DISSECTOR_H #define DISSECTOR_H #include #include #include #include #include #include "ring.h" #include "tprintf.h" #include "pcap_io.h" #include "built_in.h" #define PRINT_NORM 0 #define PRINT_LESS 1 #define PRINT_HEX 2 #define PRINT_ASCII 3 #define PRINT_HEX_ASCII 4 #define PRINT_NONE 5 static const char * const packet_types[256]={ "<", /* Incoming */ "B", /* Broadcast */ "M", /* Multicast */ "P", /* Promisc */ ">", /* Outgoing */ "?", /* Unknown */ }; extern char *if_indextoname(unsigned ifindex, char *ifname); static inline const char *__show_ts_source(uint32_t status) { if (status & TP_STATUS_TS_RAW_HARDWARE) return "(raw hw ts)"; else if (status & TP_STATUS_TS_SYS_HARDWARE) return "(sys hw ts)"; else if (status & TP_STATUS_TS_SOFTWARE) return "(sw ts)"; else return ""; } static inline void __show_frame_hdr(struct sockaddr_ll *s_ll, void *raw, int mode, bool v3) { char tmp[IFNAMSIZ]; union tpacket_uhdr hdr; if (mode == PRINT_NONE) return; hdr.raw = raw; switch (mode) { case PRINT_LESS: tprintf("%s %s %u", packet_types[s_ll->sll_pkttype] ? : "?", if_indextoname(s_ll->sll_ifindex, tmp) ? : "?", v3 ? hdr.h3->tp_len : hdr.h2->tp_len); break; default: tprintf("%s %s %u %us.%uns %s\n", packet_types[s_ll->sll_pkttype] ? : "?", if_indextoname(s_ll->sll_ifindex, tmp) ? : "?", v3 ? hdr.h3->tp_len : hdr.h2->tp_len, v3 ? hdr.h3->tp_sec : hdr.h2->tp_sec, v3 ? hdr.h3->tp_nsec : hdr.h2->tp_nsec, v3 ? "" : __show_ts_source(hdr.h2->tp_status)); break; } } static inline void show_frame_hdr(struct frame_map *hdr, int mode) { __show_frame_hdr(&hdr->s_ll, &hdr->tp_h, mode, false); } extern void dissector_init_all(int fnttype); extern void dissector_entry_point(uint8_t *packet, size_t len, int linktype, int mode); extern void dissector_cleanup_all(void); extern int dissector_set_print_type(void *ptr, int type); #endif /* DISSECTOR_H */ 852b74bec0117b888da39d070c323ea1cb7f4c'>diff
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2016-04-18 01:27:03 +0200
committerIngo Molnar <mingo@kernel.org>2016-06-16 10:48:34 +0200
commitf9852b74bec0117b888da39d070c323ea1cb7f4c (patch)
tree7a0414aeaa3fd15a67754f8f87ce511fff8dc0d6
parent4ec45856b698c37e73d973fb4b1a094dfb9d5732 (diff)
locking/atomic, arch/qrwlock: Employ atomic_fetch_add_acquire()
The only reason for the current code is to make GCC emit only the "LOCK XADD" instruction on x86 (and not do a pointless extra ADD on the result), do so nicer. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Waiman Long <waiman.long@hpe.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-arch@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>