mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-22 17:02:58 +02:00
The connections.cgi file has been rewritten to read the needed information directly from the kernel. Byte counters have been added which show how much data has been transmitted over one connection in each direction.
32 lines
710 B
C
32 lines
710 B
C
/* IPFire helper program - getconntracktable
|
|
*
|
|
* This program is distributed under the terms of the GNU General Public
|
|
* Licence. See the file COPYING for details.
|
|
*
|
|
* The kernel's connection tracking table is not readable by
|
|
* non-root users. So this helper will just read and output it.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "setuid.h"
|
|
|
|
int main(void) {
|
|
if (!(initsetuid()))
|
|
exit(1);
|
|
|
|
FILE *fp = fopen("/proc/net/nf_conntrack", "r");
|
|
if (fp == NULL) {
|
|
exit(1);
|
|
}
|
|
|
|
/* Read content line by line and write it to stdout. */
|
|
char linebuf[STRING_SIZE];
|
|
while (fgets(linebuf, STRING_SIZE, fp)) {
|
|
printf("%s", linebuf);
|
|
}
|
|
|
|
fclose(fp);
|
|
return 0;
|
|
}
|