예제 #1
0
파일: dns.c 프로젝트: iitis/flowcalc
struct client *create_client(mmatic *mm)
{
	struct client *client;
	client = mmatic_zalloc(mm, sizeof *client);
	client->servers = thash_create_intkey(mmatic_free, mm);
	return client;
}
예제 #2
0
파일: ndpi.c 프로젝트: vpereira/flowcalc
bool init(struct lfc *lfc, void **pdata)
{
    mmatic *mm;
    struct ndpi *ndpi;
    IPOQUE_PROTOCOL_BITMASK all;

    mm = mmatic_create();
    ndpi = mmatic_zalloc(mm, sizeof *ndpi);
    ndpi->mm = mm;
    ndpi->ids = thash_create_intkey(NULL, mm); // TODO: null ffn?

    ndpi->ipq = ipoque_init_detection_module(1000, ma, db); // TODO: 1000?
    if (!ndpi->ipq) {
        dbg(0, "ipoque_init_detection_module() failed\n");
        return false;
    }

    IPOQUE_BITMASK_SET_ALL(all);
    ipoque_set_protocol_detection_bitmask2(ndpi->ipq, &all);

    *pdata = ndpi;

    printf("%%%% ndpi 0.1 - nDPI\n");
    printf("@attribute ndpi_proto string\n");

    return true;
}
예제 #3
0
int main(int argc, char *argv[])
{
	mmatic *mm;

	/*
	 * initialization
	 */
	mm = mmatic_create();
	fd = mmatic_zalloc(mm, sizeof *fd);
	fd->mm = mm;
	fd->cache = thash_create_intkey(mmatic_free, mm);
	fd->out_files = thash_create_strkey(trace_destroy_output, mm);

	/* catch SIGINT */
	signal(SIGINT, sigint);

	/* read options */
	if (parse_argv(argc, argv))
		return 1;

	/* file-system init */
	{
		if (streq(fd->arff_file, "-")) {
			fd->afh = stdin;
		} else {
			fd->afh = fopen(fd->arff_file, "r");
			if (!fd->afh) {
				cleanup();
				die("Reading input ARFF file '%s' failed: %s\n", fd->arff_file, strerror(errno));
			}
		}

		if (pjf_mkdir(fd->dir) != 0) {
			cleanup();
			die("Creating output directory '%s' failed\n", fd->dir);
		}
	}

	fd->lfc = lfc_init();
	lfc_register(fd->lfc, "flowdump", sizeof(struct flow), pkt, NULL, fd);

	if (!lfc_run(fd->lfc, fd->pcap_file, fd->filter)) {
		cleanup();
		die("Reading file '%s' failed\n", fd->pcap_file);
	}

	cleanup();
	return 0;
}