Jon Schipp
unread,May 1, 2013, 4:41:01 PM5/1/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to netsn...@googlegroups.com
Here's a little sed one liner I came up with to work on an exported
Wireshark C array of packet bytes.
$ sed 's/.*{$/{/g;/0x/s/^/
/;s/;//;s/\/\*.*\*\///;s/\(0x[a-z0-9]\{2\}\) /\1,/' < C_array.txt |
trafgen --in - --out eth0
Before:
/* Frame (66 bytes) */
static const unsigned char pkt20[66] = {
0xc4, 0x2c, 0x03, 0x0d, 0x36, 0x1a, 0x3c, 0x07, /* .,..6.<. */
0x54, 0x75, 0xd1, 0x40, 0x08, 0x00, 0x45, 0x00, /* Tu.@..E. */
0x00, 0x34, 0xfe, 0xfa, 0x40, 0x00, 0x40, 0x06, /* .4..@.@. */
0x00, 0x00, 0xc0, 0xa8, 0x01, 0x40, 0xc0, 0xa8, /* .....@.. */
0x01, 0x07, 0xc0, 0x2d, 0x02, 0x24, 0xa9, 0x52, /* ...-.$.R */
0xaf, 0x48, 0x30, 0xb2, 0xa0, 0x40, 0x80, 0x10, /* .H0..@.. */
0x1f, 0xf7, 0x83, 0xbe, 0x00, 0x00, 0x01, 0x01, /* ........ */
0x08, 0x0a, 0x12, 0xa2, 0x9c, 0x8e, 0x3e, 0x0a, /* ......>. */
0x57, 0xff /* W. */
};
After:
{
0xc4, 0x2c, 0x03, 0x0d, 0x36, 0x1a, 0x3c, 0x07,
0x54, 0x75, 0xd1, 0x40, 0x08, 0x00, 0x45, 0x00,
0x00, 0x34, 0xfe, 0xfa, 0x40, 0x00, 0x40, 0x06,
0x00, 0x00, 0xc0, 0xa8, 0x01, 0x40, 0xc0, 0xa8,
0x01, 0x07, 0xc0, 0x2d, 0x02, 0x24, 0xa9, 0x52,
0xaf, 0x48, 0x30, 0xb2, 0xa0, 0x40, 0x80, 0x10,
0x1f, 0xf7, 0x83, 0xbe, 0x00, 0x00, 0x01, 0x01,
0x08, 0x0a, 0x12, 0xa2, 0x9c, 0x8e, 0x3e, 0x0a,
0x57, 0xff,
}
Trafgen doesn't like the comments at the end, so I had to get rid of them.
This may be useful to someone so I thought I'd share.