diff options
author | Damjan Marion <damarion@cisco.com> | 2016-07-04 21:04:40 +0200 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2016-07-06 22:38:28 +0000 |
commit | 3d9c86e9f70892c82c11530e0db7db78b7e6ce21 (patch) | |
tree | 72a715d0d0665392d3a70feb4c47219809bc9993 /vnet/vnet/pg/output.c | |
parent | 64f450da8f375e000f139fe1c8f7071dac37af29 (diff) |
Add support for capturing packets on packet generator interfaces
This patch introduces following changes:
- 4 predefined pg/stream[0-3] interfaces are removed
- Interface naming is changed form pg/streamX to pgX where X can be
any u32 value
- one pgX interface can handle multiple streams
- keyword "source pgX" is added to "packet-generator add" command, X is 0
by default
- new cli "packet-generator capture" is introduced
- new cli "create packet-generator interface pgX"
Change-Id: I768d075b9d4a34f0b5073debdc5dd4a0880c682c
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'vnet/vnet/pg/output.c')
-rw-r--r-- | vnet/vnet/pg/output.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/vnet/vnet/pg/output.c b/vnet/vnet/pg/output.c index cc098da21c6..5ce3f903508 100644 --- a/vnet/vnet/pg/output.c +++ b/vnet/vnet/pg/output.c @@ -38,15 +38,35 @@ */ #include <vlib/vlib.h> +#include <vnet/vnet.h> #include <vnet/pg/pg.h> +#include <vnet/ethernet/ethernet.h> uword pg_output (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { + pg_main_t * pg = &pg_main; u32 * buffers = vlib_frame_args (frame); uword n_buffers = frame->n_vectors; - vlib_buffer_free_no_next (vm, buffers, n_buffers); + uword n_left = n_buffers; + vnet_interface_output_runtime_t * rd = (void *) node->runtime_data; + pg_interface_t * pif = pool_elt_at_index (pg->interfaces, rd->dev_instance); + + if (pif->pcap_file_name != 0) + { + while (n_left > 0) + { + n_left--; + u32 bi0 = buffers[0]; + buffers++; + + pcap_add_buffer (&pif->pcap_main, vm, bi0, ETHERNET_MAX_PACKET_BYTES); + } + pcap_write (&pif->pcap_main); + } + + vlib_buffer_free_no_next (vm, vlib_frame_args (frame), n_buffers); return n_buffers; } |