11 #ifndef PACKET_DECODER_H
12 #define PACKET_DECODER_H
18 #include "../../../utils/allocs.h"
19 #include "../../../utils/attributes.h"
20 #include "../../../utils/net.h"
21 #include "../../../utils/os.h"
23 #define MAX_QUESTION_LEN 255
346 int extract_packets(
const char *ltype,
const struct pcap_pkthdr *header,
347 const uint8_t *packet,
char *interface, UT_array *tp_array);
#define OS_INET_ADDRSTRLEN
Definition: net.h:25
#define OS_INET6_ADDRSTRLEN
Definition: net.h:26
#define MACSTR_LEN
Definition: net.h:31
#define MAX_RANDOM_UUID_LEN
Definition: os.h:31
int extract_packets(const char *ltype, const struct pcap_pkthdr *header, const uint8_t *packet, char *interface, UT_array *tp_array)
Extract packets from pcap packet data.
Definition: packet_decoder.c:349
#define MAX_QUESTION_LEN
Definition: packet_decoder.h:23
packet_types
Definition: packet_decoder.h:25
@ PACKET_UDP
Definition: packet_decoder.h:32
@ PACKET_DHCP
Definition: packet_decoder.h:37
@ PACKET_NONE
Definition: packet_decoder.h:26
@ PACKET_ETHERNET
Definition: packet_decoder.h:27
@ PACKET_DNS
Definition: packet_decoder.h:35
@ PACKET_ARP
Definition: packet_decoder.h:28
@ PACKET_MDNS
Definition: packet_decoder.h:36
@ PACKET_ICMP6
Definition: packet_decoder.h:34
@ PACKET_IP4
Definition: packet_decoder.h:29
@ PACKET_IP6
Definition: packet_decoder.h:30
@ PACKET_ICMP4
Definition: packet_decoder.h:33
@ PACKET_TCP
Definition: packet_decoder.h:31
struct mdns_query_meta STRUCT_PACKED
enum packet_types PACKET_TYPES
ARP protocol schema definition.
Definition: packet_decoder.h:64
char arp_spa[OS_INET_ADDRSTRLEN]
Definition: packet_decoder.h:72
uint16_t ar_op
Definition: packet_decoder.h:70
uint8_t ar_hln
Definition: packet_decoder.h:68
uint16_t ar_pro
Definition: packet_decoder.h:67
uint16_t ar_hrd
Definition: packet_decoder.h:66
char arp_sha[MACSTR_LEN]
Definition: packet_decoder.h:71
char arp_tha[MACSTR_LEN]
Definition: packet_decoder.h:73
char arp_tpa[OS_INET_ADDRSTRLEN]
Definition: packet_decoder.h:74
uint8_t ar_pln
Definition: packet_decoder.h:69
Capture structure definition.
Definition: packet_decoder.h:306
struct dns_header * dnsh
Definition: packet_decoder.h:315
struct mdns_schema mdnss
Definition: packet_decoder.h:327
struct dhcp_header * dhcph
Definition: packet_decoder.h:317
struct tcp_schema tcps
Definition: packet_decoder.h:322
struct tcphdr * tcph
Definition: packet_decoder.h:311
char ifname[IF_NAMESIZE]
Definition: packet_decoder.h:332
struct mdns_header * mdnsh
Definition: packet_decoder.h:316
struct icmp * icmp4h
Definition: packet_decoder.h:313
struct udphdr * udph
Definition: packet_decoder.h:312
struct ether_header * ethh
Definition: packet_decoder.h:307
struct icmp6_hdr * icmp6h
Definition: packet_decoder.h:314
struct icmp6_schema icmp6s
Definition: packet_decoder.h:325
struct udp_schema udps
Definition: packet_decoder.h:323
uint32_t caplen
Definition: packet_decoder.h:330
struct dhcp_schema dhcps
Definition: packet_decoder.h:328
struct ip * ip4h
Definition: packet_decoder.h:309
struct arp_schema arps
Definition: packet_decoder.h:319
struct ip6_schema ip6s
Definition: packet_decoder.h:321
struct ether_arp * arph
Definition: packet_decoder.h:308
struct icmp4_schema icmp4s
Definition: packet_decoder.h:324
uint32_t length
Definition: packet_decoder.h:331
struct eth_schema eths
Definition: packet_decoder.h:318
struct ip4_schema ip4s
Definition: packet_decoder.h:320
struct dns_schema dnss
Definition: packet_decoder.h:326
uint64_t timestamp
Definition: packet_decoder.h:329
struct ip6_hdr * ip6h
Definition: packet_decoder.h:310
DHCP protocol schema definition.
Definition: packet_decoder.h:206
uint8_t hops
Definition: packet_decoder.h:212
uint8_t hlen
Definition: packet_decoder.h:211
uint32_t xid
Definition: packet_decoder.h:214
char ciaddr[OS_INET_ADDRSTRLEN]
Definition: packet_decoder.h:217
uint16_t flags
Definition: packet_decoder.h:216
char yiaddr[OS_INET_ADDRSTRLEN]
Definition: packet_decoder.h:219
char siaddr[OS_INET_ADDRSTRLEN]
Definition: packet_decoder.h:221
uint16_t secs
Definition: packet_decoder.h:215
uint8_t htype
Definition: packet_decoder.h:209
char giaddr[OS_INET_ADDRSTRLEN]
Definition: packet_decoder.h:222
char chaddr[MACSTR_LEN]
Definition: packet_decoder.h:223
uint8_t op
Definition: packet_decoder.h:208
DNS protocol schema definition.
Definition: packet_decoder.h:176
uint16_t tid
Definition: packet_decoder.h:178
uint16_t nqueries
Definition: packet_decoder.h:180
uint16_t nauth
Definition: packet_decoder.h:182
uint16_t flags
Definition: packet_decoder.h:179
char qname[MAX_QUESTION_LEN]
Definition: packet_decoder.h:184
uint16_t nother
Definition: packet_decoder.h:183
uint16_t nanswers
Definition: packet_decoder.h:181
Ethernet protocol schema definition.
Definition: packet_decoder.h:49
uint64_t timestamp
Definition: packet_decoder.h:50
uint32_t caplen
Definition: packet_decoder.h:52
uint16_t ether_type
Definition: packet_decoder.h:57
char ether_shost[MACSTR_LEN]
Definition: packet_decoder.h:56
char ifname[IF_NAMESIZE]
Definition: packet_decoder.h:54
char ether_dhost[MACSTR_LEN]
Definition: packet_decoder.h:55
uint32_t length
Definition: packet_decoder.h:53
ICMP4 protocol schema definition.
Definition: packet_decoder.h:152
uint8_t code
Definition: packet_decoder.h:155
uint32_t gateway
Definition: packet_decoder.h:157
uint16_t checksum
Definition: packet_decoder.h:156
uint8_t type
Definition: packet_decoder.h:154
ICMP6 protocol schema definition.
Definition: packet_decoder.h:164
uint8_t icmp6_type
Definition: packet_decoder.h:166
uint8_t icmp6_code
Definition: packet_decoder.h:167
uint32_t icmp6_un_data32
Definition: packet_decoder.h:169
uint16_t icmp6_cksum
Definition: packet_decoder.h:168
IP4 protocol schema definition.
Definition: packet_decoder.h:81
uint16_t ip_len
Definition: packet_decoder.h:89
uint8_t ip_v
Definition: packet_decoder.h:87
char ip_src[OS_INET_ADDRSTRLEN]
Definition: packet_decoder.h:83
uint8_t ip_tos
Definition: packet_decoder.h:88
uint16_t ip_off
Definition: packet_decoder.h:91
uint8_t ip_ttl
Definition: packet_decoder.h:92
uint16_t ip_sum
Definition: packet_decoder.h:94
uint8_t ip_p
Definition: packet_decoder.h:93
uint8_t ip_hl
Definition: packet_decoder.h:86
uint16_t ip_id
Definition: packet_decoder.h:90
char ip_dst[OS_INET_ADDRSTRLEN]
Definition: packet_decoder.h:84
IP6 protocol schema definition.
Definition: packet_decoder.h:101
uint8_t ip6_un1_nxt
Definition: packet_decoder.h:106
uint8_t ip6_un1_hlim
Definition: packet_decoder.h:107
uint8_t ip6_un2_vfc
Definition: packet_decoder.h:108
char ip6_src[OS_INET6_ADDRSTRLEN]
Definition: packet_decoder.h:109
char ip6_dst[OS_INET6_ADDRSTRLEN]
Definition: packet_decoder.h:110
uint32_t ip6_un1_flow
Definition: packet_decoder.h:104
uint16_t ip6_un1_plen
Definition: packet_decoder.h:105
mDNS protocol schema definition
Definition: packet_decoder.h:191
uint16_t flags
Definition: packet_decoder.h:194
uint16_t nother
Definition: packet_decoder.h:198
uint16_t tid
Definition: packet_decoder.h:193
uint16_t nauth
Definition: packet_decoder.h:197
uint16_t nanswers
Definition: packet_decoder.h:196
uint16_t nqueries
Definition: packet_decoder.h:195
char qname[MAX_QUESTION_LEN]
Definition: packet_decoder.h:199
TCP protocol schema definition.
Definition: packet_decoder.h:117
uint16_t ack
Definition: packet_decoder.h:129
uint16_t rst
Definition: packet_decoder.h:127
uint16_t window
Definition: packet_decoder.h:131
uint32_t seq
Definition: packet_decoder.h:121
uint16_t urg
Definition: packet_decoder.h:130
uint16_t doff
Definition: packet_decoder.h:124
uint16_t urg_ptr
Definition: packet_decoder.h:133
uint16_t res1
Definition: packet_decoder.h:123
uint16_t check_p
Definition: packet_decoder.h:132
uint16_t source
Definition: packet_decoder.h:119
uint32_t ack_seq
Definition: packet_decoder.h:122
uint16_t syn
Definition: packet_decoder.h:126
uint16_t fin
Definition: packet_decoder.h:125
uint16_t dest
Definition: packet_decoder.h:120
uint16_t psh
Definition: packet_decoder.h:128
Definition: packet_decoder.h:40
PACKET_TYPES type
Definition: packet_decoder.h:42
uint8_t * packet
Definition: packet_decoder.h:41
UDP protocol schema definition.
Definition: packet_decoder.h:140
uint16_t source
Definition: packet_decoder.h:142
uint16_t dest
Definition: packet_decoder.h:143
uint16_t check_p
Definition: packet_decoder.h:145
uint16_t len
Definition: packet_decoder.h:144