Initial commit of PSE and CDU
Change-Id: Ibcd57f7dac5ea7be54f7b8b37634baeba161b233
diff --git a/client_data_usage/cdu_init.c b/client_data_usage/cdu_init.c
new file mode 100644
index 0000000..f5106ad
--- /dev/null
+++ b/client_data_usage/cdu_init.c
@@ -0,0 +1,90 @@
+/* cdu_init.c
+ *
+ * This file defines client data usage module init.
+ *
+ * Author: Cradlepoint Technology, Inc. <source@cradlepoint.com>
+ * Adrian Sitterle <asitterle@cradlepoint.com>
+ *
+ * Copyright (C) 2019 Cradlepoint Technology, Inc.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/jhash.h>
+#include <net/netfilter/nf_conntrack.h>
+#include <net/netfilter/nf_conntrack_core.h>
+#include <net/netfilter/nf_conntrack_acct.h>
+
+#include "cdu_types.h"
+#include "cdu_db.h"
+#include "cdu_nf_events.h"
+#include "cdu_xt_target.h"
+#include "cdu_seq_file.h"
+
+
+int __init usage_init_module(void)
+{
+ int ret;
+
+ CDU_DEBUG("Initializing module.\n");
+
+ /* initialize usage_hash database */
+ cdu_db_init();
+
+ /* initialize proc file interface */
+ if (cdu_seq_file_init())
+ goto err_seq;
+
+ /* initialize netfilter eventing triggered at beginning and end of a flow */
+ ret = cdu_nf_events_register();
+ if (ret)
+ goto err_nf;
+
+ /* initialize xt table callbacks, used to determine direction of ct */
+ ret = cdu_xt_target_register();
+ if (ret)
+ goto err_xt;
+
+ CDU_INFO("Client data usage module loaded.\n");
+ return 0;
+
+err_xt:
+ cdu_xt_target_unregister();
+err_nf:
+ cdu_nf_events_unregister();
+err_seq:
+ cdu_seq_file_uninit();
+
+ cdu_db_uninit();
+
+ CDU_INFO("Client data usage module init failed. %d\n", ret);
+ return ret;
+
+}
+
+void __exit usage_exit_module(void)
+{
+ cdu_xt_target_unregister();
+ cdu_nf_events_unregister();
+ cdu_seq_file_uninit();
+ cdu_db_uninit();
+ CDU_INFO("Client data usage module unloaded.\n");
+}
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Cradlepoint, Inc");
+MODULE_DESCRIPTION("Client usage statistics");
+
+module_init(usage_init_module);
+module_exit(usage_exit_module);