]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/misc-progs/qosctrl.c
1 /* This file is part of the IPFire Firewall.
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
12 #include <sys/types.h>
15 #include "libsmooth.h"
17 #define QOS_SH "/var/ipfire/qos/bin/qos.sh"
19 int main(int argc
, char *argv
[]) {
20 struct keyvalue
* kv
= NULL
;
28 fprintf(stderr
, "\nNo argument given.\n\nqosctrl (start|stop|restart|status|generate)\n\n");
32 if (strcmp(argv
[1], "generate") == 0) {
34 if (!readkeyvalues(kv
, CONFIG_ROOT
"/qos/settings")) {
35 fprintf(stderr
, "Cannot read QoS settings\n");
40 char enabled
[STRING_SIZE
];
41 if (!findkey(kv
, "ENABLED", enabled
))
42 strcpy(enabled
, "off");
44 if (strcmp(enabled
, "on") == 0)
45 safe_system("/usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > " QOS_SH
);
50 if ((fd
= open(QOS_SH
, O_RDONLY
)) != -1) {
53 // If there is no qos.sh do nothing.
57 safe_system("chmod 755 " QOS_SH
" &>/dev/null");
58 if (strcmp(argv
[1], "start") == 0) {
59 safe_system(QOS_SH
" start");
60 } else if (strcmp(argv
[1], "stop") == 0) {
61 safe_system(QOS_SH
" clear");
62 } else if (strcmp(argv
[1], "status") == 0) {
63 safe_system(QOS_SH
" status");
64 } else if (strcmp(argv
[1], "restart") == 0) {
65 safe_system(QOS_SH
" restart");
67 if (strcmp(argv
[1], "generate") == 0) {exit(0);}
68 fprintf(stderr
, "\nBad argument given.\n\nqosctrl (start|stop|restart|status|generate)\n\n");