4 * Copyright (C) 2012 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
12 #include "netinet/ipl.h"
13 #include <sys/ioctl.h>
15 void ipf_dotuning(fd, tuneargs, iocfn)
24 bzero((char *)&tu, sizeof(tu));
25 obj.ipfo_rev = IPFILTER_VERSION;
26 obj.ipfo_size = sizeof(tu);;
27 obj.ipfo_ptr = (void *)&tu;
28 obj.ipfo_type = IPFOBJ_TUNEABLE;
30 for (s = strtok(tuneargs, ","); s != NULL; s = strtok(NULL, ",")) {
31 if (!strcmp(s, "list")) {
33 if ((*iocfn)(fd, SIOCIPFGETNEXT, &obj) == -1) {
34 ipf_perror_fd(fd, iocfn,
35 "ioctl(SIOCIPFGETNEXT)");
38 if (tu.ipft_cookie == NULL)
41 tu.ipft_name[sizeof(tu.ipft_name) - 1] = '\0';
44 } else if ((t = strchr(s, '=')) != NULL) {
45 tu.ipft_cookie = NULL;
47 strncpy(tu.ipft_name, s, sizeof(tu.ipft_name));
48 if (sscanf(t, "%lu", &tu.ipft_vlong) == 1) {
49 if ((*iocfn)(fd, SIOCIPFSET, &obj) == -1) {
50 ipf_perror_fd(fd, iocfn,
55 fprintf(stderr, "invalid value '%s'\n", s);
59 tu.ipft_cookie = NULL;
60 strncpy(tu.ipft_name, s, sizeof(tu.ipft_name));
61 if ((*iocfn)(fd, SIOCIPFGET, &obj) == -1) {
62 ipf_perror_fd(fd, iocfn, "ioctl(SIOCIPFGET)");
65 if (tu.ipft_cookie == NULL) {
66 fprintf(stderr, "Null cookie for %s\n", s);
70 tu.ipft_name[sizeof(tu.ipft_name) - 1] = '\0';