示例#1
0
        /// <summary>
        /// Parse bytes into a packet
        /// </summary>
        /// <param name="LinkLayer">
        /// A <see cref="LinkLayers"/>
        /// </param>
        /// <param name="PacketData">
        /// A <see cref="System.Byte"/>
        /// </param>
        /// <returns>
        /// A <see cref="Packet"/>
        /// </returns>
        public static Packet ParsePacket(LinkLayers LinkLayer, byte[] PacketData)
        {
            Packet p;
            var    bas = new ByteArraySegment(PacketData);

            //log.DEBUGFormat("LinkLayer {0}", LinkLayer);

            switch (LinkLayer)
            {
            case LinkLayers.Ethernet:
                p = new EthernetPacket(bas);
                break;

            case LinkLayers.LinuxSLL:
                p = new LinuxSLLPacket(bas);
                break;

            case LinkLayers.Ppp:
                p = new PPPPacket(bas);
                break;

            case LinkLayers.Ieee80211:
                p = new Ieee80211MacFrame(bas);
                break;

            case LinkLayers.Ieee80211_Radio:
                p = new Ieee80211RadioPacket(bas);
                break;

            default:
                throw new System.NotImplementedException("LinkLayer of " + LinkLayer + " is not implemented");
            }

            return(p);
        }
示例#2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parent">
 /// A <see cref="Ieee80211MacFrame"/>
 /// </param>
 /// <param name="bas">
 /// A <see cref="ByteArraySegment"/>
 /// </param>
 public CTSOrACKFrame(Ieee80211MacFrame parent, ByteArraySegment bas)
 {
     this.parent   = parent;
     header        = new ByteArraySegment(bas);
     header.Length = FrameSize;
 }