diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2015-06-13 15:30:46 +0300 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2015-06-18 00:41:20 +0200 |
commit | da8fcdd7d8ce59ea334ec24cdaddcc02eb611f04 (patch) | |
tree | fc38360ff15125e052d81d74c49972f3f85dd645 /pcap_io.h | |
parent | 41ce2d49645c6eb87f751c4df0b554f4388e73c3 (diff) |
netsniff-ng: Add cooked cmdline option.
Add a --cooked option that we later on use for capturing in cooked
header. For now, this only captures with a dgram packet socket, but
the remaining logic will follow up.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
[ dbkm: split out patch ]
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'pcap_io.h')
-rw-r--r-- | pcap_io.h | 75 |
1 files changed, 51 insertions, 24 deletions
@@ -150,9 +150,9 @@ static inline uint16_t tp_to_pcap_tsource(uint32_t status) return 0; } -static inline int pcap_devtype_to_linktype(const char *ifname) +static inline int pcap_devtype_to_linktype(int dev_type) { - switch (device_type(ifname)) { + switch (dev_type) { case ARPHRD_TUNNEL: case ARPHRD_TUNNEL6: case ARPHRD_LOOPBACK: @@ -160,38 +160,65 @@ static inline int pcap_devtype_to_linktype(const char *ifname) case ARPHRD_IPDDP: case ARPHRD_IPGRE: case ARPHRD_IP6GRE: - case ARPHRD_ETHER: return LINKTYPE_EN10MB; - case ARPHRD_IEEE80211_RADIOTAP: return LINKTYPE_IEEE802_11_RADIOTAP; + case ARPHRD_ETHER: + return LINKTYPE_EN10MB; + case ARPHRD_IEEE80211_RADIOTAP: + return LINKTYPE_IEEE802_11_RADIOTAP; case ARPHRD_IEEE80211_PRISM: - case ARPHRD_IEEE80211: return LINKTYPE_IEEE802_11; - case ARPHRD_NETLINK: return LINKTYPE_NETLINK; - case ARPHRD_EETHER: return LINKTYPE_EN3MB; - case ARPHRD_AX25: return LINKTYPE_AX25; - case ARPHRD_CHAOS: return LINKTYPE_CHAOS; - case ARPHRD_PRONET: return LINKTYPE_PRONET; + case ARPHRD_IEEE80211: + return LINKTYPE_IEEE802_11; + case ARPHRD_NETLINK: + return LINKTYPE_NETLINK; + case ARPHRD_EETHER: + return LINKTYPE_EN3MB; + case ARPHRD_AX25: + return LINKTYPE_AX25; + case ARPHRD_CHAOS: + return LINKTYPE_CHAOS; + case ARPHRD_PRONET: + return LINKTYPE_PRONET; case ARPHRD_IEEE802_TR: - case ARPHRD_IEEE802: return LINKTYPE_IEEE802; - case ARPHRD_INFINIBAND: return LINKTYPE_INFINIBAND; - case ARPHRD_ATM: return LINKTYPE_ATM_CLIP; - case ARPHRD_DLCI: return LINKTYPE_FRELAY; - case ARPHRD_ARCNET: return LINKTYPE_ARCNET_LINUX; + case ARPHRD_IEEE802: + return LINKTYPE_IEEE802; + case ARPHRD_INFINIBAND: + return LINKTYPE_INFINIBAND; + case ARPHRD_ATM: + return LINKTYPE_ATM_CLIP; + case ARPHRD_DLCI: + return LINKTYPE_FRELAY; + case ARPHRD_ARCNET: + return LINKTYPE_ARCNET_LINUX; case ARPHRD_CSLIP: case ARPHRD_CSLIP6: case ARPHRD_SLIP6: - case ARPHRD_SLIP: return LINKTYPE_SLIP; - case ARPHRD_PPP: return LINKTYPE_PPP; - case ARPHRD_CAN: return LINKTYPE_CAN20B; - case ARPHRD_ECONET: return LINKTYPE_ECONET; + case ARPHRD_SLIP: + return LINKTYPE_SLIP; + case ARPHRD_PPP: + return LINKTYPE_PPP; + case ARPHRD_CAN: + return LINKTYPE_CAN20B; + case ARPHRD_ECONET: + return LINKTYPE_ECONET; case ARPHRD_RAWHDLC: - case ARPHRD_CISCO: return LINKTYPE_C_HDLC; - case ARPHRD_FDDI: return LINKTYPE_FDDI; + case ARPHRD_CISCO: + return LINKTYPE_C_HDLC; + case ARPHRD_FDDI: + return LINKTYPE_FDDI; case ARPHRD_IEEE802154_MONITOR: - case ARPHRD_IEEE802154: return LINKTYPE_IEEE802_15_4_LINUX; - case ARPHRD_IRDA: return LINKTYPE_LINUX_IRDA; - default: return LINKTYPE_NULL; + case ARPHRD_IEEE802154: + return LINKTYPE_IEEE802_15_4_LINUX; + case ARPHRD_IRDA: + return LINKTYPE_LINUX_IRDA; + default: + return LINKTYPE_NULL; } } +static inline int pcap_dev_to_linktype(const char *ifname) +{ + return pcap_devtype_to_linktype(device_type(ifname)); +} + static inline void pcap_check_magic(uint32_t magic) { switch (magic) { |