0

I need to make a tool that modifies the VLanTaggedFrame.VLanIdentifier in a packet. The problem is, my packets may have multiple vlan tags.

realistically it’s between 1~3 tags but I want to make a recursive procedure and not make a chain of if statements.

I need some way to extract every VLanTaggedFrame layer (into a list or array) without knowing how many there are (as long as x.EtherType == EthernetType.VLanTaggedFrame , but where x is constantly changing stack of layers).

Any idea how I can do this?

My main direction was taking the packet.ethernet.vlantaggedframe.payload, but it’s of Datagram type and there seem to be no ‘<em>payload’ in datagram type object, so I can’t do x = x.payload recursively.

any help will be appreciated :)

4

1 回答 1

0

像这样的东西怎么样:

EthernetBaseDatagram vlanParent = packet.Ethernet;
List<ILayer> vlanLayers = new List<ILayer>();
while (vlanParent.EtherType == EthernetType.VLanTaggedFrame)
{
    VLanTaggedFrameDatagram vlan = vlanParent.VLanTaggedFrame;
    vlanLayers.Add(vlan.ExtractLayer());
    vlanParent = vlan;
}
于 2014-03-14T10:36:22.800 回答