<commit_before>package se.sics.cooja.plugins.analyzers;

import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.File;

public class PcapExporter {

    DataOutputStream out;
    
    public PcapExporter() throws IOException {
    }
    
    public void openPcap(File pcapFile) throws IOException {
    	if ( out != null ) {
    		closePcap();
    	}
    	if ( pcapFile == null ) {
            pcapFile = new File("radiolog-" + System.currentTimeMillis() + ".pcap");
    	}
    	out = new DataOutputStream(new FileOutputStream(pcapFile));
        /* pcap header */
        out.writeInt(0xa1b2c3d4);
        out.writeShort(0x0002);
        out.writeShort(0x0004);
        out.writeInt(0);
        out.writeInt(0);
        out.writeInt(4096);
        out.writeInt(195); /* 195 for LINKTYPE_IEEE802_15_4 */
        out.flush();
        System.out.println("Opened pcap file " + pcapFile);
    }
    public void closePcap() throws IOException {
        out.close();
        out = null;
    }

    public void exportPacketData(byte[] data) throws IOException {
        if (out == null) {
            openPcap(null);
        }
        try {
            /* pcap packet header */
            out.writeInt((int) System.currentTimeMillis() / 1000);
            out.writeInt((int) ((System.currentTimeMillis() % 1000) * 1000));
            out.writeInt(data.length);
            out.writeInt(data.length+2);
            /* and the data */
            out.write(data);<commit_msg>undo COOJA FCS fix<commit_after>package se.sics.cooja.plugins.analyzers;

import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.File;

public class PcapExporter {

    DataOutputStream out;
    
    public PcapExporter() throws IOException {
    }
    
    public void openPcap(File pcapFile) throws IOException {
    	if ( out != null ) {
    		closePcap();
    	}
    	if ( pcapFile == null ) {
            pcapFile = new File("radiolog-" + System.currentTimeMillis() + ".pcap");
    	}
    	out = new DataOutputStream(new FileOutputStream(pcapFile));
        /* pcap header */
        out.writeInt(0xa1b2c3d4);
        out.writeShort(0x0002);
        out.writeShort(0x0004);
        out.writeInt(0);
        out.writeInt(0);
        out.writeInt(4096);
        out.writeInt(195); /* 195 for LINKTYPE_IEEE802_15_4 */
        out.flush();
        System.out.println("Opened pcap file " + pcapFile);
    }
    public void closePcap() throws IOException {
        out.close();
        out = null;
    }

    public void exportPacketData(byte[] data) throws IOException {
        if (out == null) {
            openPcap(null);
        }
        try {
            /* pcap packet header */
            out.writeInt((int) System.currentTimeMillis() / 1000);
            out.writeInt((int) ((System.currentTimeMillis() % 1000) * 1000));
            out.writeInt(data.length);
            out.writeInt(data.length);
            /* and the data */
            out.write(data);
{'fraction_non_alphanumeric': 0.12179689971527997, 'fraction_numerical': 0.028788358114520723, 'mean_word_length': 2.219959266802444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1463602', 'n_tokens_mistral': 1036, 'n_tokens_neox': 976, 'n_words': 196}