diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2008-03-11 18:23:16 +0000 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2008-03-11 18:23:16 +0000 |
commit | 5800abad4620cbd3885b2460ee0383ced0cf6e3f (patch) | |
tree | 7d01e48143e3ccca773587f05b2570e53468a3c7 /print.c | |
parent | 11eda6b97b594d58541897a06d98e97f13a9aa2b (diff) | |
download | wireshark-5800abad4620cbd3885b2460ee0383ced0cf6e3f.tar.gz |
From Francesco Fondelli (bug 2349):
Attached is a patch to export packets data as "C Arrays". I often have
the need to [re]send data captured with wireshark using a raw/pf_packet socket.
Output format is one char[] per packet, it looks like almost the same as
the one produced by "Follow TCP stream".
svn path=/trunk/; revision=24604
Diffstat (limited to 'print.c')
-rw-r--r-- | print.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -628,6 +628,45 @@ write_csv_finale(FILE *fh _U_) } +void +write_carrays_preamble(FILE *fh _U_) +{ + +} + +void +proto_tree_write_carrays(const guint8 *pd, guint32 len, guint32 num, FILE *fh) +{ + guint32 i = 0; + + if (!len) + return; + + fprintf(fh, "char pkt%u[] = {\n", num); + + for (i = 0; i < len; i++) { + + fprintf(fh, "0x%02x", *(pd + i)); + + if (i == (len - 1)) { + fprintf(fh, " };\n\n"); + break; + } + + if (!((i + 1) % 8)) { + fprintf(fh, ", \n"); + } else { + fprintf(fh, ", "); + } + } +} + +void +write_carrays_finale(FILE *fh _U_) +{ + +} + /* * Find the data source for a specified field, and return a pointer * to the data in it. Returns NULL if the data is out of bounds. |