diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2017-07-29 12:46:08 +0300 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2017-08-10 09:03:37 +0200 |
commit | 19348cec323373d84674c1d2cf34315cbf47c80d (patch) | |
tree | 3dd13803e6f9b2e84ff85b90b17a9cbc97bc93ea /trafgen_dev.h | |
parent | d55874b960a8663cc86284fad4d0472ff37b7a7e (diff) |
trafgen: dev_io: Change read/write to specify struct packet *
Refactor dev_io_ops read & write to specify struct packet *,
it may simplify a bit a caller logic. And it allow to keep
required members within one struct packet object.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_dev.h')
-rw-r--r-- | trafgen_dev.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/trafgen_dev.h b/trafgen_dev.h index 686a577..6708eb8 100644 --- a/trafgen_dev.h +++ b/trafgen_dev.h @@ -12,6 +12,7 @@ enum dev_io_mode_t { }; struct dev_io_ops; +struct packet; struct dev_io { int fd; @@ -23,6 +24,8 @@ struct dev_io { uint32_t pcap_magic; bool is_initialized; enum pcap_mode pcap_mode; + size_t buf_len; + uint8_t *buf; const struct pcap_file_ops *pcap_ops; const struct dev_io_ops *ops; @@ -30,16 +33,15 @@ struct dev_io { struct dev_io_ops { int(*open) (struct dev_io *dev, const char *name, enum dev_io_mode_t mode); - int(*write) (struct dev_io *dev, const uint8_t *buf, size_t len); - int(*read) (struct dev_io *dev, uint8_t *buf, size_t len, struct timespec *tstamp); + int(*write) (struct dev_io *dev, const struct packet *pkt); + struct packet *(*read) (struct dev_io *dev); int(*set_link_type) (struct dev_io *dev, int link_type); void(*close) (struct dev_io *dev); }; extern struct dev_io *dev_io_open(const char *name, enum dev_io_mode_t mode); -extern int dev_io_write(struct dev_io *dev, const uint8_t *buf, size_t len); -extern int dev_io_read(struct dev_io *dev, uint8_t *buf, size_t len, - struct timespec *tstamp); +extern int dev_io_write(struct dev_io *dev, const struct packet *pkt); +extern struct packet *dev_io_read(struct dev_io *dev); extern int dev_io_ifindex_get(struct dev_io *dev); extern int dev_io_fd_get(struct dev_io *dev); extern const char *dev_io_name_get(struct dev_io *dev); |