From c470de0111f58c52b7a9b6a9f56c951467298b03 Mon Sep 17 00:00:00 2001 From: MrMcX Date: Mon, 27 Dec 2021 14:50:16 +0100 Subject: [PATCH] =?UTF-8?q?=E2=80=9ECustomize=E2=80=9C=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Customize.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Customize.md diff --git a/Customize.md b/Customize.md new file mode 100644 index 0000000..d0d491f --- /dev/null +++ b/Customize.md @@ -0,0 +1,25 @@ +# How to customize the code +## Modify packet data for other protocols: +The protocols are handled in *pipeForward*. Inside its *for* loop, layers are handled from low to high. If a layer is not defined here, its contents will be forwarded without any modification. Currently it is expected that every single packet has an Ethernet layer. After the handling of the Ethernet frame in the block commented with "Handle Ethernet frame", higher protocols are implemented. If a protocol builds on another protocol, it is nested inside its *if* clause. + +Implemented protocols besides Ethernet are: + +* IPv4 + * DHCP + * ICMP + * TCP + * UDP + * NBNS/NBDS: *only binary filtering* +* IPv6: *is currently dropped* +* ARP + +## Extend use of binary filtering +Unsupported protocols can be modified using filtering for binary values. This is done using the *filterPayload* method. To use this in an additional protocol, *filterPayload* should be called from *pipeForward* where the respective protocol would be handled as shown below for the NBNS/NBDS protocols: + +``` +if (udpPacket.SrcPort == 137 && udpPacket.DstPort == 137) || (udpPacket.SrcPort == 138 && udpPacket.DstPort == 138) { + filterPayload(prefix, &udpPacket.Payload) +} +``` + +If additional values should be filtered, they need to be added as byte slices to *vmVals* and *netVals* in the *filterPayload* method, where *vmVals* contains the values which should be sent to the VM and *netVals* those which should be sent to the network.