70 lines
1.6 KiB
C#
70 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace skyscraper8.Skyscraper.Net.VirtualNetworks
|
|
{
|
|
[VirtualNetworkId(4)]
|
|
internal class AtmAdaptationLayer5NetworkIdentifier : VirtualNetworkIdentifier
|
|
{
|
|
private VirtualNetworkIdentifier wrapped;
|
|
private int identifier;
|
|
|
|
public AtmAdaptationLayer5NetworkIdentifier(VirtualNetworkIdentifier wrapped)
|
|
{
|
|
this.wrapped = wrapped;
|
|
this.identifier = new Random().Next();
|
|
}
|
|
|
|
|
|
public override string GetCaptureFilenamePrefix()
|
|
{
|
|
return String.Format("AAL5,{0}", wrapped.GetCaptureFilenamePrefix());
|
|
}
|
|
|
|
public override string GetHumanReadableName()
|
|
{
|
|
return String.Format("AAL5 on {0}", wrapped.GetHumanReadableName());
|
|
}
|
|
|
|
public override int GetIdentifier()
|
|
{
|
|
return identifier;
|
|
}
|
|
|
|
private static Dictionary<VirtualNetworkIdentifier, AtmAdaptationLayer5NetworkIdentifier> wraps;
|
|
public static VirtualNetworkIdentifier GetWrap(VirtualNetworkIdentifier network)
|
|
{
|
|
if (wraps == null)
|
|
{
|
|
wraps = new Dictionary<VirtualNetworkIdentifier, AtmAdaptationLayer5NetworkIdentifier>();
|
|
}
|
|
|
|
if (wraps.ContainsKey(network))
|
|
{
|
|
return wraps[network];
|
|
}
|
|
else
|
|
{
|
|
AtmAdaptationLayer5NetworkIdentifier child = new AtmAdaptationLayer5NetworkIdentifier(network);
|
|
wraps.Add(network, child);
|
|
return child;
|
|
}
|
|
}
|
|
|
|
public ushort? GetPid()
|
|
{
|
|
VirtualNetworkIdentifier virtualNetworkIdentifier = wrapped;
|
|
PidNetworkIdentifier pid = wrapped as PidNetworkIdentifier;
|
|
if (pid != null)
|
|
{
|
|
return pid.PID;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|