/*
 esp_pcap.h

 Author: Liraz Siri <liraz@bigfoot.com>

 Copyright (c) 1998 Liraz Siri <liraz@bigfoot.com>, Ariel, Israel
                    All rights reserved.

 Created: Thu Sep 24 02:52:10 GMT 1998

 Code for handling raw network packets using the pcap API.
*/

#include <pcap.h>
#include "buffer.h"

#define MAX_FILTER_LEN 128
#define BPF_FILTER	"dst host %s"

/* Initialize another (valid) live pcap interface.  */
int esp_pcap_init(pcap_t *pd, unsigned long s_addr, unsigned long mask,
		      int itype, int local);

/* Return true if we have a valid initialized network interface. False
   otherwise */
int esp_pcap_interfaces_available(void);

/* FD_SET our interfaces and wait for a packet to arrive on any of 
   the them. */
void esp_pcap_wait_for_packets(fd_set *readfds);

/* process any incoming packets. Determine ala readfds on which interface
   our packet is coming from */
int esp_pcap_handlepacket(fd_set *readfds, Buffer *incoming);

/* Returns a nonzero IPPROTO protocol on success after we handled,
   filtered and finally ACCEPTED a packet. (breaking sweat) */
int esp_pcap_accepted_protocol(void);

/* Here we actually get our hands on a reallife raw ip packet stripped of
   all those protocol traumatic headers... */
void esp_pcap_handle_ippkt(const u_char *packet, u_int length);

/*-- Verify wether or not packet is a complete valid packet we can
     pass on for further processing --*/
int fragmented(const u_char *packet, u_int length);

/* Lookup the pcap_handler function to use for interface type of 'itype',
   we return NULL on failure */
pcap_handler esp_pcap_lookup(int itype);

/* Interface packet handlers, this really needs no further explanation */
void raw_handler(u_char *user, const struct pcap_pkthdr *h, const u_char *p);
void null_handler(u_char *user, const struct pcap_pkthdr *h, const u_char *p);
void fddi_handler(u_char *user, const struct pcap_pkthdr *h, const u_char *p);
void slip_handler(u_char *user, const struct pcap_pkthdr *h, const u_char *p);
void ppp_handler(u_char *user, const struct pcap_pkthdr *h, const u_char *p);
void ether_handler(u_char *user, const struct pcap_pkthdr *h, const u_char *p);
 
