@Test public void testDataFlowsets() throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bos); out.writeShort(9); out.writeShort(5); out.writeInt(289584773); out.writeInt(691368492); out.writeInt(168); out.writeInt(20); out.writeShort(0); out.writeShort(44); out.writeShort(256); out.writeShort(3); out.writeShort(4); out.writeShort(1); out.writeShort(7); out.writeShort(2); out.writeShort(23); out.writeShort(4); out.writeShort(257); out.writeShort(5); out.writeShort(8); out.writeShort(4); out.writeShort(500); out.writeShort(2); out.writeShort(82); out.writeShort(5); out.writeShort(62); out.writeShort(16); out.writeShort(80); out.writeShort(6); out.close(); out.writeShort(256); out.writeShort(20); out.writeByte(17); out.writeShort(23); out.writeInt(2857383); out.writeByte(10); out.writeShort(2551); out.writeInt(5137183); out.writeByte(0); out.writeByte(0); List<TSDRLogRecord> records = parseRecords(bos.toByteArray()); assertEquals(2, records.size()); Map<String, String> attrs = toMap(records.get(0).getRecordAttributes()); assertEquals(Long.valueOf(691368492L * 1000), records.get(0).getTimeStamp()); assertEquals(NetflowV9PacketParser.FLOW_SET_LOG_TEXT, records.get(0).getRecordFullText()); assertEquals("9", attrs.remove("version")); assertEquals("289584773", attrs.remove("sys_uptime")); assertEquals("168", attrs.remove("package_sequence")); assertEquals("20", attrs.remove("source_id")); assertEquals("17", attrs.remove("PROTOCOL")); assertEquals("23", attrs.remove("L4_SRC_PORT")); assertEquals("2857383", attrs.remove("OUT_BYTES")); assertEmpty(attrs); attrs = toMap(records.get(1).getRecordAttributes()); assertEquals(Long.valueOf(691368492L * 1000), records.get(1).getTimeStamp()); assertEquals(NetflowV9PacketParser.FLOW_SET_LOG_TEXT, records.get(1).getRecordFullText()); assertEquals("9", attrs.remove("version")); assertEquals("289584773", attrs.remove("sys_uptime")); assertEquals("168", attrs.remove("package_sequence")); assertEquals("20", attrs.remove("source_id")); assertEquals("10", attrs.remove("PROTOCOL")); assertEquals("2551", attrs.remove("L4_SRC_PORT")); assertEquals("5137183", attrs.remove("OUT_BYTES")); assertEmpty(attrs); bos = new ByteArrayOutputStream(); out = new DataOutputStream(bos); out.writeShort(9); out.writeShort(5); out.writeInt(289584780); out.writeInt(691368500); out.writeInt(168); out.writeInt(20); out.writeShort(257); out.writeShort(38); out.writeInt(0xa0000020); out.writeShort(99); out.writeBytes("FE1/0"); out.write(new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}); out.write(new byte[]{0xa, 0xb, 0xc, 0xd, 0x12, 0x4}); out.writeByte(0); records = parseRecords(bos.toByteArray()); assertEquals(1, records.size()); attrs = toMap(records.get(0).getRecordAttributes()); assertEquals(Long.valueOf(691368500L * 1000), records.get(0).getTimeStamp()); assertEquals(NetflowV9PacketParser.FLOW_SET_LOG_TEXT, records.get(0).getRecordFullText()); assertEquals("9", attrs.remove("version")); assertEquals("289584780", attrs.remove("sys_uptime")); assertEquals("168", attrs.remove("package_sequence")); assertEquals("20", attrs.remove("source_id")); assertEquals("160.0.0.32", attrs.remove("IPV4_SRC_ADDR")); assertEquals("99", attrs.remove("500")); assertEquals("FE1/0", attrs.remove("IF_NAME")); assertEquals("1:203:405:607:809:a0b:c0d:e0f", attrs.remove("IPV6_NEXT_HOP")); assertEquals("0a:0b:0c:0d:12:04", attrs.remove("IN_DST_MAC")); assertEmpty(attrs); }
@Override public void parseRecords() { while (recordCounter < totalRecordCount && !endOfData()) { final OptionalInt possibleCount = parseNextRecords(); if (!possibleCount.isPresent()) { return; } recordCounter += possibleCount.getAsInt(); } missingTemplateCache.checkTemplates(); }
NetflowV9PacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { while (recordCounter < totalRecordCount && !endOfData()) { final OptionalInt possibleCount = parseNextRecords(); if (!possibleCount.isPresent()) { return; } recordCounter += possibleCount.getAsInt(); } missingTemplateCache.checkTemplates(); } }
NetflowV9PacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { while (recordCounter < totalRecordCount && !endOfData()) { final OptionalInt possibleCount = parseNextRecords(); if (!possibleCount.isPresent()) { return; } recordCounter += possibleCount.getAsInt(); } missingTemplateCache.checkTemplates(); } NetflowV9PacketParser(byte[] data, int initialPosition, String sourceIP, FlowsetTemplateCache flowsetTemplateCache,
            OptionsTemplateCache optionsTemplateCache, MissingTemplateCache missingTemplateCache,
            TSDRLogRecordBuilder recordBuilder, Consumer<TSDRLogRecordBuilder> callback); private  NetflowV9PacketParser(NetflowV9PacketParser other, int fromPosition, int bytesToCopy); }
NetflowV9PacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { while (recordCounter < totalRecordCount && !endOfData()) { final OptionalInt possibleCount = parseNextRecords(); if (!possibleCount.isPresent()) { return; } recordCounter += possibleCount.getAsInt(); } missingTemplateCache.checkTemplates(); } NetflowV9PacketParser(byte[] data, int initialPosition, String sourceIP, FlowsetTemplateCache flowsetTemplateCache,
            OptionsTemplateCache optionsTemplateCache, MissingTemplateCache missingTemplateCache,
            TSDRLogRecordBuilder recordBuilder, Consumer<TSDRLogRecordBuilder> callback); private  NetflowV9PacketParser(NetflowV9PacketParser other, int fromPosition, int bytesToCopy); @Override void parseRecords(); }
NetflowV9PacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { while (recordCounter < totalRecordCount && !endOfData()) { final OptionalInt possibleCount = parseNextRecords(); if (!possibleCount.isPresent()) { return; } recordCounter += possibleCount.getAsInt(); } missingTemplateCache.checkTemplates(); } NetflowV9PacketParser(byte[] data, int initialPosition, String sourceIP, FlowsetTemplateCache flowsetTemplateCache,
            OptionsTemplateCache optionsTemplateCache, MissingTemplateCache missingTemplateCache,
            TSDRLogRecordBuilder recordBuilder, Consumer<TSDRLogRecordBuilder> callback); private  NetflowV9PacketParser(NetflowV9PacketParser other, int fromPosition, int bytesToCopy); @Override void parseRecords();  }