summaryrefslogtreecommitdiffstats
path: root/src/ipset.c
blob: 6d42b60d2fe9d33d249f823b17322dd499773637 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* Copyright 2000-2002 Joakim Axelsson (gozem@linux.nu)
 *                     Patrick Schaaf (bof@bof.de)
 * Copyright 2003-2010 Jozsef Kadlecsik (kadlec@netfilter.org)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#include <assert.h>			/* assert */
#include <stdio.h>			/* fprintf */
#include <stdlib.h>			/* exit */
#include <string.h>			/* strcmp */

#include <config.h>
#include <libipset/ipset.h>		/* ipset library */
#include <libipset/xlate.h>		/* translate to nftables */

int
main(int argc, char *argv[])
{
	struct ipset *ipset;
	int ret;

	/* Load set types */
	ipset_load_types();

	/* Initialize ipset library */
	ipset = ipset_init();
	if (ipset == NULL) {
		fprintf(stderr, "Cannot initialize ipset, aborting.");
		exit(1);
	}

	if (!strcmp(argv[0], "ipset-translate")) {
		ret = ipset_xlate_argv(ipset, argc, argv);
	} else {
		ret = ipset_parse_argv(ipset, argc, argv);
	}

	ipset_fini(ipset);

	return ret;
}