summaryrefslogtreecommitdiff
path: root/trafgen_proto.c
diff options
context:
space:
mode:
Diffstat (limited to 'trafgen_proto.c')
-rw-r--r--trafgen_proto.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/trafgen_proto.c b/trafgen_proto.c
index d976c14..96fd6da 100644
--- a/trafgen_proto.c
+++ b/trafgen_proto.c
@@ -409,6 +409,19 @@ void protos_init(const char *dev)
protos_l4_init();
}
+void proto_packet_update(uint32_t idx)
+{
+ struct packet *pkt = packet_get(idx);
+ ssize_t i;
+
+ for (i = pkt->headers_count - 1; i >= 0; i--) {
+ struct proto_hdr *hdr = pkt->headers[i];
+
+ if (hdr->ops->packet_update)
+ hdr->ops->packet_update(hdr);
+ }
+}
+
void proto_packet_finish(void)
{
struct proto_hdr **headers = current_packet()->headers;
@@ -424,3 +437,22 @@ void proto_packet_finish(void)
ops->packet_finish(hdr);
}
}
+
+void proto_field_func_add(struct proto_hdr *hdr, uint32_t fid,
+ struct proto_field_func *func)
+{
+ struct proto_field *field = proto_field_by_id(hdr, fid);
+
+ bug_on(!func);
+
+ field->func.update_field = func->update_field;
+}
+
+void proto_field_dyn_apply(struct proto_field *field)
+{
+ if (field->func.update_field)
+ field->func.update_field(field);
+
+ if (field->hdr->ops->field_changed)
+ field->hdr->ops->field_changed(field);
+}