Package org.krakenapps.pcap.decoder.ip

Examples of org.krakenapps.pcap.decoder.ip.IpDecoder


    @Override
    public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException {
        super.initialize(split, context);
        tupleQueue = new ArrayList<Tuple>();

        IpDecoder ipDecoder = new IpDecoder();
        UdpProcessor udpProcessor = new UdpProcessor() {
            @Override
            public void process(UdpPacket p) {
                try {
                    Buffer buf = p.getData();
                    byte[] data = new byte[buf.readableBytes()];
                    buf.gets(data);
                    dns = new Message(data);
                    valid = true;
                } catch (IOException e) {
                    e.printStackTrace();
                    clear();
                }
            }
        };

        UdpDecoder udpDecoder = new UdpDecoder(new UdpPortProtocolMapper()) {
            @Override
            public void process(Ipv4Packet packet) {
                super.process(packet);
            }
        };

        udpDecoder.registerUdpProcessor(udpProcessor);
        eth.register(EthernetType.IPV4, ipDecoder);
        ipDecoder.register(InternetProtocol.UDP, udpDecoder);
    }
View Full Code Here


    @Override
    public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException {
        taskAttemptContext = context;
        super.initialize(split, context);

        IpDecoder ipDecoder = new IpDecoder() {
            @Override
            public void process(EthernetFrame frame) {
                packetTuple.setIpv4PacketFields(Ipv4Packet.parse(frame.dup().getData()));
                super.process(frame);
            }
        };

        TcpDecoder tcpDecoder = new TcpDecoder(new TcpPortProtocolMapper()) {
            @Override
            public void process(Ipv4Packet packet) {
                try {
                    packetTuple.setTcpFields(TcpPacket.parse(packet));
                } catch (BufferUnderflowException e) {
                    System.err.println("Ignoring error in setTcpFields: " + e);
                }
            }
        };

        UdpProcessor udpProcessor = new UdpProcessor() {
            @Override
            public void process(UdpPacket p) {
                packetTuple.setUdpFields(p);
            }
        };

        UdpDecoder udpDecoder = new UdpDecoder(new UdpPortProtocolMapper()) {
            @Override
            public void process(Ipv4Packet packet) {
                // nothing really
                super.process(packet);
            }
        };

        udpDecoder.registerUdpProcessor(udpProcessor);

        eth.register(EthernetType.IPV4, ipDecoder);
        ipDecoder.register(InternetProtocol.TCP, tcpDecoder);
        ipDecoder.register(InternetProtocol.UDP, udpDecoder);
    }
View Full Code Here

    @Override
    public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException {
        super.initialize(split, context);

        IpDecoder ipDecoder = new IpDecoder() {

            @Override
            public void process(EthernetFrame frame) {
                ipPacket = Ipv4Packet.parse(frame.getBuffer());
                ipData = copyData(ipPacket.getData());
                super.process(frame);
            }
        };

        TcpDecoder tcpDecoder = new TcpDecoder(new TcpPortProtocolMapper()) {
            @Override
            public void process(Ipv4Packet packet) {
                tcpPacket = TcpPacket.parse(packet);
                tcpData = copyData(tcpPacket.getData());
            }
        };

        UdpProcessor udpProcessor = new UdpProcessor() {
            @Override
            public void process(UdpPacket p) {
                udpPacket = p;
                udpData = copyData(p.getData());
            }
        };

        UdpDecoder udpDecoder = new UdpDecoder(new UdpPortProtocolMapper()) {
            @Override
            public void process(Ipv4Packet packet) {
                // nothing really
                super.process(packet);
            }
        };

        udpDecoder.registerUdpProcessor(udpProcessor);

        eth.register(EthernetType.IPV4, ipDecoder);
        ipDecoder.register(InternetProtocol.TCP, tcpDecoder);
        ipDecoder.register(InternetProtocol.UDP, udpDecoder);

        byteKey = new UnsignedByte[n];
        for (int i = 0; i < n; i++)
            byteKey[i] = new UnsignedByte(0);
    }
View Full Code Here

    @Override
    public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException {
        super.initialize(split, context);
        tupleQueue = new ArrayList<Tuple>();

        IpDecoder ipDecoder = new IpDecoder();
        UdpProcessor udpProcessor = new UdpProcessor() {
            @Override
            public void process(UdpPacket p) {
                try {
                    Buffer buf = p.getData();
                    byte[] data = new byte[buf.readableBytes()];
                    buf.gets(data);
                    dns = new Message(data);
                    valid = true;
                } catch (IOException e) {
                    e.printStackTrace();
                    clear();
                }
            }
        };

        UdpDecoder udpDecoder = new UdpDecoder(new UdpPortProtocolMapper()) {
            @Override
            public void process(Ipv4Packet packet) {
                super.process(packet);
                srcIP = packet.getSourceAddress().getHostAddress();
                dstIP = packet.getDestinationAddress().getHostAddress();
            }
        };

        udpDecoder.registerUdpProcessor(udpProcessor);
        eth.register(EthernetType.IPV4, ipDecoder);
        ipDecoder.register(InternetProtocol.UDP, udpDecoder);
    }
View Full Code Here

TOP

Related Classes of org.krakenapps.pcap.decoder.ip.IpDecoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.