Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "network.h"
#include "common.h"

int size_eth;
/* Initializes pcap */
pcap_t *initialize_network(char *iface, char *filter, int type)
{
Expand All @@ -31,6 +32,11 @@ pcap_t *initialize_network(char *iface, char *filter, int type)
fprintf(stderr, "ERROR: Failed to open device %s: %s\n", iface, errbuf);
return NULL;
}
size_eth = sizeof(struct sniff_ethernet);
#ifdef DLT_LINUX_SLL
if(pcap_datalink(handle) == DLT_LINUX_SLL)
size_eth += 2;
#endif
}

if (pcap_compile(handle, &fp, filter, 0, net) == -1)
Expand All @@ -57,7 +63,7 @@ char *process_packet(const u_char *packet, struct pcap_pkthdr *header)
u_char *tls_record = NULL;
u_char *tls_handshake = NULL;
short tls_record_size = 0;
int size_ip = 0, size_tcp = 0, size_eth = 0, offset = 0, payload_size = 0, cert_size = 0;
int size_ip = 0, size_tcp = 0, offset = 0, payload_size = 0, cert_size = 0;
const u_char *payload = NULL;
char *fingerprint = NULL;
unsigned char md[SHA_DIGEST_LENGTH] = { 0 };
Expand All @@ -68,7 +74,6 @@ char *process_packet(const u_char *packet, struct pcap_pkthdr *header)
}

//ethernet = (struct sniff_ethernet*)(packet);
size_eth = sizeof(struct sniff_ethernet);

ip = (struct sniff_ip*)(packet + size_eth);
size_ip = IP_HL(ip)*4;
Expand Down