diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2016-07-26 22:35:08 +0300 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2016-08-02 17:24:43 +0200 |
commit | 820e85f9f29513860092a02599efa529c00a1089 (patch) | |
tree | 864ad7a68b1985ba4dd390170091458aa904ed73 /trafgen_parser.y | |
parent | 59e69bf9106e6f085f90cb33ac7241e3ded41767 (diff) |
trafgen: proto: Move proto headers into packet
Until now headers were used only for packet creation at compile time,
which does not allow to handle dynamic field updates at runtime. To
support dynamic updates, it is necessary to keep the proto_hdr entries
around after packet compilation so we can reference the header fields to
dynamically update.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
[tk: Adjust patch description, simplify code]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_parser.y')
-rw-r--r-- | trafgen_parser.y | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/trafgen_parser.y b/trafgen_parser.y index a286e6b..035d9c1 100644 --- a/trafgen_parser.y +++ b/trafgen_parser.y @@ -1004,11 +1004,21 @@ static void dump_conf(void) void cleanup_packets(void) { - size_t i; + size_t i, j; for (i = 0; i < plen; ++i) { - if (packets[i].len > 0) - xfree(packets[i].payload); + struct packet *pkt = &packets[i]; + + if (pkt->len > 0) + xfree(pkt->payload); + + for (j = 0; j < pkt->headers_count; j++) { + struct proto_hdr *hdr = pkt->headers[j]; + + if (hdr->fields) + xfree(hdr->fields); + xfree(hdr); + } } free(packets); |