summaryrefslogtreecommitdiff
path: root/trafgen_l3.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2018-03-08 18:10:37 +0100
committerTobias Klauser <tklauser@distanz.ch>2018-03-08 18:12:59 +0100
commit65ba0860baa53670e79211edbd047a8080ec1f8a (patch)
tree7f22147fe08c1f102d63ffd8797fc6bb798cbaa0 /trafgen_l3.c
parent1e1c5f955291544815713b0af6370214b574c0ed (diff)
trafgen: support dumping IPv6 protocol header command
Support dissecting IPv6 headers into the îp6' trafgen protocol header command. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_l3.c')
-rw-r--r--trafgen_l3.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/trafgen_l3.c b/trafgen_l3.c
index a3f711d..9d0d930 100644
--- a/trafgen_l3.c
+++ b/trafgen_l3.c
@@ -212,6 +212,20 @@ static void ipv6_set_next_proto(struct proto_hdr *hdr, enum proto_id pid)
proto_hdr_field_set_default_u8(hdr, IP6_NEXT_HDR, ip_proto);
}
+static enum proto_id ipv6_get_next_proto(struct proto_hdr *hdr)
+{
+ switch (proto_hdr_field_get_u8(hdr, IP6_NEXT_HDR)) {
+ case IPPROTO_ICMPV6:
+ return PROTO_IP4;
+ case IPPROTO_UDP:
+ return PROTO_UDP;
+ case IPPROTO_TCP:
+ return PROTO_TCP;
+ default:
+ return __PROTO_MAX;
+ }
+}
+
static const struct proto_ops ipv6_proto_ops = {
.id = PROTO_IP6,
.layer = PROTO_L3,
@@ -219,6 +233,7 @@ static const struct proto_ops ipv6_proto_ops = {
.field_changed = ipv6_field_changed,
.packet_finish = ipv6_packet_finish,
.set_next_proto = ipv6_set_next_proto,
+ .get_next_proto = ipv6_get_next_proto,
};
void protos_l3_init(void)