#ifndef __driver_ip_h
#define __driver_ip_h

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <netdb.h>
#include <errno.h>

#include <sys/socket.h>
#include <net/ethernet.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <netinet/ip_icmp.h>
#include <netinet/icmp6.h>

#define HAVE_SNPRINTF
#include <pcap.h>
#include <pcap-int.h>
#include <sll.h>

#define closesocket(s) close(s)

#define MAX_PACKET_SIZE 1024
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define NO_USEFUL_L4_FOUND -1
#define PCAP_NETMASK_UNKNOWN 0xffffffff
#define PORT 12349

typedef int SOCKET;
SOCKET exporterSocket;

/* icmphdr from <netinet/ip_icmp.h> has an union problem */
struct icmphdr_fake {
	u_int8_t type;
	u_int8_t code;
	u_int16_t checksum;
	u_int16_t union1_size;
	u_int32_t gateway;
	u_int16_t union2_size;
};

void process_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *packet);
void send_headers(const u_char *packet, short hsize);
void create_exporter_socket(int *sock);

#endif
