diff options
| -rw-r--r-- | conf/packet_io/packet_io.toml | 20 | ||||
| -rw-r--r-- | conf/stellar/stellar.toml (renamed from conf/stellar/stellar.conf) | 0 | ||||
| -rw-r--r-- | src/app.toml | 20 | ||||
| -rw-r--r-- | src/packet_io/packet_io_internal.cpp | 2 | ||||
| -rw-r--r-- | src/packet_io/packet_io_internal.h | 2 | ||||
| -rw-r--r-- | src/packet_io/pcap_file_mode/pio_pcap_file.cpp | 18 | ||||
| -rw-r--r-- | src/packet_io/pcap_file_mode/pio_pcap_file.h | 2 |
7 files changed, 39 insertions, 25 deletions
diff --git a/conf/packet_io/packet_io.toml b/conf/packet_io/packet_io.toml new file mode 100644 index 0000000..61016aa --- /dev/null +++ b/conf/packet_io/packet_io.toml @@ -0,0 +1,20 @@ +[PACKET_IO] +# example1: +# RUN_MODE="PCAP_LIVE_MODE" +# WORKER_THREAD_NUM=10 # Prompt pcap how many threads to start to receive packets +# INTERFACE=["eth0", "eth1"] +# SNAP_LEN=65535 # default 65535 +# PROMISC=1 # 0(disable) 1(enable), if enable nic promisc mode, default 0(disable) +# BPF_FILTER="port 80 and udp" # default null + +# example2: +# RUN_MODE="MARSIO_MODE" +# WORKER_THREAD_NUM=10 # Prompt marsio how many threads to start to receive packets +# INTERFACE=["eth0", "eth1"] + +# example3: +RUN_MODE="PCAP_FILE_MODE" +WORKER_THREAD_NUM=2 # Prompt pcap how many threads to start to receive packets +PCAP_FILE_PATH="./src/packet_io/test/pcap_sample" # if single file, specify dir+filename; if pcapfile directory, specify dir +DELETE_WHEN_DONE=0 # 0(false) 1(true), default 0, if delete it when the pcapfile is processed +BPF_FILTER="port 443 and tcp" # default null
\ No newline at end of file diff --git a/conf/stellar/stellar.conf b/conf/stellar/stellar.toml index e69de29..e69de29 100644 --- a/conf/stellar/stellar.conf +++ b/conf/stellar/stellar.toml diff --git a/src/app.toml b/src/app.toml deleted file mode 100644 index 39d5536..0000000 --- a/src/app.toml +++ /dev/null @@ -1,20 +0,0 @@ -[PACKET_IO] -# example1: -# RUN_MODE="PCAP_LIVE_MODE" -# WORKER_THREAD_NUM=10 # Prompt pcap how many threads to start to receive packets -# INTERFACE=["eth0", "eth1"] -# SNAP_LEN=65535 # default 65535 -# PROMISC=1 # 0(disable) 1(enable), if enable nic promisc mode, default 0(disable) -# BPF_FILTER="port 80 and udp" # default null - -# example2: -# RUN_MODE="MARSIO_MODE" -# WORKER_THREAD_NUM=10 # Prompt marsio how many threads to start to receive packets -# INTERFACE=["eth0", "eth1"] - -# example3: -RUN_MODE="PCAP_FILE_MODE" -WORKER_THREAD_NUM=2 # Prompt pcap how many threads to start to receive packets -PCAP_FILE_PATH="/home/liuwentan/project/stellar/stellar/src/packet_io/test/pcap_sample" # if single file, specify dir+filename; if pcapfile directory, specify dir -DELETE_WHEN_DONE=0 # 0(false) 1(true), default 0, if delete it when the pcapfile is processed -BPF_FILTER="port 443 and tcp" # default null
\ No newline at end of file diff --git a/src/packet_io/packet_io_internal.cpp b/src/packet_io/packet_io_internal.cpp index a115424..fab858c 100644 --- a/src/packet_io/packet_io_internal.cpp +++ b/src/packet_io/packet_io_internal.cpp @@ -29,7 +29,7 @@ struct pio_device_operations pio_device_ops_array[PACKET_IO_RUN_MODE_MAX] = .open = pio_pcap_file_device_open, .close = pio_pcap_file_device_close, .recv = pio_pcap_file_device_receive, - .send = nullptr, + .send = pio_pcap_file_device_send, .pkt_free = pio_pcap_file_device_pkt_free, .buff_ctrlzone = pio_pcap_file_device_buff_ctrlzone, .buff_mtod = pio_pcap_file_device_buff_mtod, diff --git a/src/packet_io/packet_io_internal.h b/src/packet_io/packet_io_internal.h index e52dd7c..9fdef43 100644 --- a/src/packet_io/packet_io_internal.h +++ b/src/packet_io/packet_io_internal.h @@ -116,8 +116,6 @@ struct pio_pcap_config { /* delete after the pcap file is processed */ int should_delete; - //time_t delay; - /* snapshot length */ int snaplen; diff --git a/src/packet_io/pcap_file_mode/pio_pcap_file.cpp b/src/packet_io/pcap_file_mode/pio_pcap_file.cpp index 296000f..bc16d96 100644 --- a/src/packet_io/pcap_file_mode/pio_pcap_file.cpp +++ b/src/packet_io/pcap_file_mode/pio_pcap_file.cpp @@ -849,11 +849,25 @@ ssize_t pio_pcap_file_device_receive(struct packet_io_device *pdev, uint32_t rxq return res; } +ssize_t pio_pcap_file_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct stellar_packet **pkts, size_t nr_pkts) +{ + struct pio_pcap_file_device_context *pfile_dev_ctx = pdev->entity.pcap_file_dev_ctx; + if (nullptr == pfile_dev_ctx) { + log_error(ST_ERR_PIO_PCAP_FILE_DEVICE, "invalid pcap_file_dev_ctx pointer."); + return -1; + } + + for (size_t i = 0; i < nr_pkts; i++) { + FREE(pkts[i]); + } + + return 0; +} + void pio_pcap_file_device_pkt_free(__unused struct packet_io_device *pdev, __unused uint32_t qid, struct stellar_packet **pkts, size_t nr_pkts) { for (size_t i = 0; i < nr_pkts; i++) { - struct pio_packet *p = (struct pio_packet *)pkts[i]; - FREE(p); + FREE(pkts[i]); } } diff --git a/src/packet_io/pcap_file_mode/pio_pcap_file.h b/src/packet_io/pcap_file_mode/pio_pcap_file.h index 9bc5e15..c8f0042 100644 --- a/src/packet_io/pcap_file_mode/pio_pcap_file.h +++ b/src/packet_io/pcap_file_mode/pio_pcap_file.h @@ -133,6 +133,8 @@ ssize_t pio_pcap_file_device_close(struct packet_io_device *pdev); ssize_t pio_pcap_file_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct stellar_packet **pkts, size_t nr_pkts); +ssize_t pio_pcap_file_device_send(struct packet_io_device *pdev, uint32_t rxq_id, struct stellar_packet **pkts, size_t nr_pkts); + void pio_pcap_file_device_pkt_free(struct packet_io_device *pdev, uint32_t qid, struct stellar_packet **pkts, size_t nr_pkts); char *pio_pcap_file_device_buff_ctrlzone(struct stellar_packet *p, size_t *ctrlzone_len); |
