4 * Copyright (C) 2003-2005 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * Id: ipf_dotuning.c,v 1.2.4.3 2006/06/16 17:21:02 darrenr Exp
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 perror("ioctl(SIOCIPFGETNEXT)");
37 if (tu
.ipft_cookie
== NULL
)
40 tu
.ipft_name
[sizeof(tu
.ipft_name
) - 1] = '\0';
43 } else if ((t
= strchr(s
, '=')) != NULL
) {
44 tu
.ipft_cookie
= NULL
;
46 strncpy(tu
.ipft_name
, s
, sizeof(tu
.ipft_name
));
47 if (sscanf(t
, "%lu", &tu
.ipft_vlong
) == 1) {
48 if ((*iocfn
)(fd
, SIOCIPFSET
, &obj
) == -1) {
49 perror("ioctl(SIOCIPFSET)");
53 fprintf(stderr
, "invalid value '%s'\n", s
);
57 tu
.ipft_cookie
= NULL
;
58 strncpy(tu
.ipft_name
, s
, sizeof(tu
.ipft_name
));
59 if ((*iocfn
)(fd
, SIOCIPFGET
, &obj
) == -1) {
60 perror("ioctl(SIOCIPFGET)");
63 if (tu
.ipft_cookie
== NULL
) {
64 fprintf(stderr
, "Null cookie for %s\n", s
);
68 tu
.ipft_name
[sizeof(tu
.ipft_name
) - 1] = '\0';