trafgen: Get packet from proto_hdr if possible
[netsniff-ng-new.git] / trafgen_dev.h
blob686a577778cc5b428729d4b06c1ac90609d913d0
1 #ifndef TRAFGEN_DEV_H
2 #define TRAFGEN_DEV_H
4 #include <stdbool.h>
5 #include <inttypes.h>
7 #include "pcap_io.h"
9 enum dev_io_mode_t {
10 DEV_IO_IN = 1 << 0,
11 DEV_IO_OUT = 1 << 1,
14 struct dev_io_ops;
16 struct dev_io {
17 int fd;
18 char *name;
19 char *trans;
20 int ifindex;
21 int dev_type;
22 uint32_t link_type;
23 uint32_t pcap_magic;
24 bool is_initialized;
25 enum pcap_mode pcap_mode;
27 const struct pcap_file_ops *pcap_ops;
28 const struct dev_io_ops *ops;
31 struct dev_io_ops {
32 int(*open) (struct dev_io *dev, const char *name, enum dev_io_mode_t mode);
33 int(*write) (struct dev_io *dev, const uint8_t *buf, size_t len);
34 int(*read) (struct dev_io *dev, uint8_t *buf, size_t len, struct timespec *tstamp);
35 int(*set_link_type) (struct dev_io *dev, int link_type);
36 void(*close) (struct dev_io *dev);
39 extern struct dev_io *dev_io_open(const char *name, enum dev_io_mode_t mode);
40 extern int dev_io_write(struct dev_io *dev, const uint8_t *buf, size_t len);
41 extern int dev_io_read(struct dev_io *dev, uint8_t *buf, size_t len,
42 struct timespec *tstamp);
43 extern int dev_io_ifindex_get(struct dev_io *dev);
44 extern int dev_io_fd_get(struct dev_io *dev);
45 extern const char *dev_io_name_get(struct dev_io *dev);
46 extern int dev_io_link_type_set(struct dev_io *dev, int link_type);
47 extern bool dev_io_is_netdev(struct dev_io *dev);
48 extern bool dev_io_is_pcap(struct dev_io *dev);
49 extern void dev_io_close(struct dev_io *dev);
51 #endif /* TRAFGEN_DEV_H */