From 5f101e656a24271726d1e9cd672631b6033c36c1 Mon Sep 17 00:00:00 2001
From: Gerlof Langeveld <gerlof.langeveld@atoptool.nl>
Date: Sat, 25 Mar 2017 12:40:23 +0100
Subject: [PATCH] Preparations to move atop to github

---
 netatop.h                                    | 48 +++++++++++++++++++++++++++-
 netatopd.h                                   | 13 +++++++-
 atop.specsystemd => rpmspec/atop.specsystemd |  0
 atop.specsysv => rpmspec/atop.specsysv       |  0
 4 files changed, 59 insertions(+), 2 deletions(-)
 mode change 120000 => 100644 netatop.h
 mode change 120000 => 100644 netatopd.h
 rename atop.specsystemd => rpmspec/atop.specsystemd (100%)
 rename atop.specsysv => rpmspec/atop.specsysv (100%)

diff --git a/netatop.h b/netatop.h
deleted file mode 120000
index 5a2a89f..0000000
--- a/netatop.h
+++ /dev/null
@@ -1 +0,0 @@
-../Netatop/netatop.h
\ No newline at end of file
diff --git a/netatop.h b/netatop.h
new file mode 100644
index 0000000..a14e6fa
--- /dev/null
+++ b/netatop.h
@@ -0,0 +1,47 @@
+#define	COMLEN	16
+
+struct taskcount {
+	unsigned long long	tcpsndpacks;
+	unsigned long long	tcpsndbytes;
+	unsigned long long	tcprcvpacks;
+	unsigned long long	tcprcvbytes;
+
+	unsigned long long	udpsndpacks;
+	unsigned long long	udpsndbytes;
+	unsigned long long	udprcvpacks;
+	unsigned long long	udprcvbytes;
+
+	/* space for future extensions */
+};
+
+struct netpertask {
+	pid_t			id;	// tgid or tid (depending on command)
+	unsigned long		btime;
+	char			command[COMLEN];
+
+	struct taskcount	tc;
+};
+
+
+/*
+** getsocktop commands
+*/
+#define NETATOP_BASE_CTL   	15661
+
+// just probe if the netatop module is active
+#define NETATOP_PROBE		(NETATOP_BASE_CTL)
+
+// force garbage collection to make finished processes available
+#define NETATOP_FORCE_GC	(NETATOP_BASE_CTL+1)
+
+// wait until all finished processes are read (blocks until done)
+#define NETATOP_EMPTY_EXIT	(NETATOP_BASE_CTL+2)
+
+// get info for finished process (blocks until available)
+#define NETATOP_GETCNT_EXIT	(NETATOP_BASE_CTL+3)
+
+// get counters for thread group (i.e. process):  input is 'id' (pid)
+#define NETATOP_GETCNT_TGID	(NETATOP_BASE_CTL+4)
+
+// get counters for thread:  input is 'id' (tid)
+#define NETATOP_GETCNT_PID 	(NETATOP_BASE_CTL+5)
diff --git a/netatopd.h b/netatopd.h
deleted file mode 120000
index 3145fa2..0000000
--- a/netatopd.h
+++ /dev/null
@@ -1 +0,0 @@
-../Netatop/netatopd.h
\ No newline at end of file
diff --git a/netatopd.h b/netatopd.h
new file mode 100644
index 0000000..c1ba8e0
--- /dev/null
+++ b/netatopd.h
@@ -0,0 +1,12 @@
+#define SEMAKEY         1541961
+
+#define NETEXITFILE     "/var/run/netatop.log"
+#define MYMAGIC         (unsigned int) 0xfeedb0b0
+
+struct naheader {
+        u_int32_t	magic;	// magic number MYMAGIC
+        u_int32_t	curseq;	// sequence number of last netpertask
+        u_int16_t	hdrlen;	// length of this header
+        u_int16_t	ntplen;	// length of netpertask structure
+        pid_t    	mypid;	// PID of netatopd itself
+};
diff --git a/atop.specsystemd b/rpmspec/atop.specsystemd
similarity index 100%
rename from atop.specsystemd
rename to rpmspec/atop.specsystemd
diff --git a/atop.specsysv b/rpmspec/atop.specsysv
similarity index 100%
rename from atop.specsysv
rename to rpmspec/atop.specsysv
