X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vnet%2Fvnet%2Funix%2Fpcap2pg.c;h=217a61f4cb47d6398c90e8dc009d7fb070eaa709;hb=07203afe6fc5f1573135189329e41f125da1f558;hp=10b47c976dce8b832d506f5f7b06ef326aa0425a;hpb=c068179a6c8ce57428f4f8dda19fb2de6027fe8f;p=vpp.git diff --git a/vnet/vnet/unix/pcap2pg.c b/vnet/vnet/unix/pcap2pg.c index 10b47c976dc..217a61f4cb4 100644 --- a/vnet/vnet/unix/pcap2pg.c +++ b/vnet/vnet/unix/pcap2pg.c @@ -14,14 +14,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +/** + * @file + * @brief Functions to convert PCAP file format to VPP PG (Packet Generator) + * + */ #include #include #include pcap_main_t pcap_main; -static char * pg_fmt = +/** + * @brief char * to seed a PG file + */ +static char * pg_fmt = "packet-generator new {\n" " name s%d\n" " limit 1\n" @@ -29,16 +36,32 @@ static char * pg_fmt = " node ethernet-input\n"; +/** + * @brief Packet Generator Stream boilerplate + * + * @param *ofp - FILE + * @param i - int + * @param *pkt - u8 + */ void stream_boilerplate (FILE *ofp, int i, u8 * pkt) { fformat(ofp, pg_fmt, i, vec_len(pkt), vec_len(pkt)); } +/** + * @brief Conversion of PCAP file to PG file format + * + * @param *pm - pcap_main_t + * @param *ofp - FILE + * + * @return rc - int + * + */ int pcap2pg (pcap_main_t * pm, FILE *ofp) { int i, j; u8 *pkt; - + for (i = 0; i < vec_len (pm->packets_read); i++) { int offset; @@ -51,13 +74,13 @@ int pcap2pg (pcap_main_t * pm, FILE *ofp) stream_boilerplate (ofp, i, pkt); fformat (ofp, " data {\n"); - + ethertype = clib_net_to_host_u16 (h->type); - /* + /** * In vnet terms, packet generator interfaces are not ethernets. * They don't have vlan tables. - * This dance transforms captured 802.1q VLAN packets into + * This transforms captured 802.1q VLAN packets into * regular Ethernet packets. */ if (ethertype == 0x8100 /* 802.1q vlan */) @@ -69,7 +92,7 @@ int pcap2pg (pcap_main_t * pm, FILE *ofp) else offset = 14; - fformat (ofp, + fformat (ofp, " 0x%04x: %02x%02x.%02x%02x.%02x%02x" " -> %02x%02x.%02x%02x.%02x%02x\n", ethertype, @@ -97,6 +120,10 @@ int pcap2pg (pcap_main_t * pm, FILE *ofp) return 0; } +/** + * @brief pcap2pg. + * usage: pcap2pg -i [-o ] + */ int main (int argc, char **argv) { unformat_input_t input;