예제 #1
0
        public static void WriteUDPHeader(CircularFrameBuffer cfb, UDPParser up, EthernetParserGenerator ep,
                                          IPv4ParserGenerator ip, byte ports)
        {
            Emu.Status  = 0xff0;
            ip.Protocol = 17;
            ip.AssembleHeader();
            //Emu.PktIn = ip.CalculateCheckSum();
            //ip.HeaderChecksum = ip.CalculateCheckSum();
            //ip.AssembleHeader();
            ep.WriteToBuffer(cfb.PushData);
            ip.WriteToBuffer(cfb.PushData, 0);

            InterfaceFunctions.SetDestInterface(ports, cfb.PushData);
            cfb.PushData.Tkeep = 0xFFFFFFFF;
            cfb.PushData.Tlast = false;
            Kiwi.Pause();

            cfb.Push(cfb.PushData, true);
            Emu.Status = 0xff1;
            cfb.ResetPeek();

            cfb.PushData.Reset();

            ip.WriteToBuffer(cfb.PushData, 1);

            up.WriteToBuffer(cfb.PushData, (byte)(16 + (ip.IHL - 5) * 32));
            cfb.PushData.Tkeep = 0x0000003FF;
            cfb.PushData.Tlast = true;
            Kiwi.Pause();
            cfb.Push(cfb.PushData);
            Emu.Status = 0xff2;
        }
예제 #2
0
        public static void WriteIPv4EthernetHeader(CircularFrameBuffer cfb, EthernetParserGenerator ep, IPv4ParserGenerator ip,
                                                   byte ports)
        {
            ip.AssembleHeader();
            ep.WriteToBuffer(cfb.PushData);
            ip.WriteToBuffer(cfb.PushData, 0);

            cfb.PushData.Tkeep = 0xFFFFFFFF;
            cfb.PushData.Tlast = false;

            InterfaceFunctions.SetDestInterface(ports, cfb.PushData);

            cfb.Push(cfb.PushData);

            cfb.PushData.Reset();

            ip.WriteToBuffer(cfb.PushData, 1);

            cfb.Push(cfb.PushData);
        }
예제 #3
0
        private static void SetPacketData()
        {
            up.SrcPort  = SRC_PORT;
            up.DestPort = DEST_PORT;
            up.Length   = UDP_LENGTH;

            ep.SrcMac    = SRC_ADDRESS;
            ep.DestMac   = DEST_ADDRESS;
            ep.Ethertype = EthernetParserGenerator.ETHERTYPE_IPV4;
            InterfaceFunctions.SetDestInterface(InterfaceFunctions.PORT_BROADCAST, ep);
            ip.Version        = 4;
            ip.IHL            = 5;
            ip.DSCP           = 0;
            ip.ECN            = 0;
            ip.TotalLength    = 0;
            ip.Identification = 0;
            ip.Flags          = 0;
            ip.FragmentOffset = 0;
            ip.TTL            = 255;
            ip.Protocol       = 0;
            ip.SrcIp          = SRC_IP;
            ip.DestIp         = DEST_IP;
            ip.HeaderChecksum = ip.CalculateCheckSum();
        }