Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


added network server files
[palacios.git] / misc / network_servers / vtl / if.h
1 #ifndef __IF_H
2 #define __IF_H 1
3
4 #include "util.h"
5 #include "debug.h"
6 #include "raw_ethernet_packet.h"
7
8
9
10 #ifdef linux
11 #include <libnet.h>
12 #define LIBNET_ERRORBUF_SIZE 256
13 #elif defined(WIN32)
14 #define WPCAP
15 #endif
16
17 #include <pcap.h>
18
19 #ifdef WIN32
20 #include <Packet32.h>
21 #endif
22
23
24 typedef struct iface {
25   string *name;
26
27   pcap_t * pcap_interface;
28
29   char mode;
30
31 #ifdef linux
32   int pcap_fd;
33
34   libnet_t * net_interface;
35 #elif defined(WIN32)
36   HANDLE pcap_event;
37 #endif
38
39 } iface_t;
40
41 #define IF_PACKET 1
42 #define IF_BREAK 2
43 #define IF_CONT 3
44
45
46 #define IF_RD 0x1
47 #define IF_WR 0x2
48 #define IF_RW 0x3
49
50
51 iface_t * if_connect(string if_name, char mode = IF_RW);
52 int if_setup_filter(iface_t * iface, string bpf_str);
53
54 #ifdef linux
55 int if_get_fd(iface_t * iface);
56 #elif WIN32
57 HANDLE if_get_event(iface_t * iface);
58 #endif
59
60 int if_loop(iface_t * iface, RawEthernetPacket * pkt);
61 void pkt_handler(u_char * pkt, const struct pcap_pkthdr * pkt_header, const u_char * pkt_data);
62
63 int if_write_pkt(iface_t * iface, RawEthernetPacket * pkt);
64 int if_read_pkt(iface_t * iface, RawEthernetPacket * pkt);
65
66
67 #endif // !__IF_H