2 * Copyright (C) 1993-2005 by Darren Reed.
3 * See the IPFILTER.LICENCE file for details on licencing.
7 #include "netinet/ipl.h"
10 void ipf_dotuning(fd
, tuneargs
, iocfn
)
19 bzero((char *)&tu
, sizeof(tu
));
20 obj
.ipfo_rev
= IPFILTER_VERSION
;
21 obj
.ipfo_size
= sizeof(tu
);;
22 obj
.ipfo_ptr
= (void *)&tu
;
23 obj
.ipfo_type
= IPFOBJ_TUNEABLE
;
25 for (s
= strtok(tuneargs
, ","); s
!= NULL
; s
= strtok(NULL
, ",")) {
26 if (!strcmp(s
, "list")) {
28 if ((*iocfn
)(fd
, SIOCIPFGETNEXT
, &obj
) == -1) {
29 perror("ioctl(SIOCIPFGETNEXT)");
32 if (tu
.ipft_cookie
== NULL
)
35 tu
.ipft_name
[sizeof(tu
.ipft_name
) - 1] = '\0';
38 } else if ((t
= strchr(s
, '=')) != NULL
) {
39 tu
.ipft_cookie
= NULL
;
41 strncpy(tu
.ipft_name
, s
, sizeof(tu
.ipft_name
));
42 if (sscanf(t
, "%lu", &tu
.ipft_vlong
) == 1) {
43 if ((*iocfn
)(fd
, SIOCIPFSET
, &obj
) == -1) {
44 perror("ioctl(SIOCIPFSET)");
48 fprintf(stderr
, "invalid value '%s'\n", s
);
52 tu
.ipft_cookie
= NULL
;
53 strncpy(tu
.ipft_name
, s
, sizeof(tu
.ipft_name
));
54 if ((*iocfn
)(fd
, SIOCIPFGET
, &obj
) == -1) {
55 perror("ioctl(SIOCIPFGET)");
58 if (tu
.ipft_cookie
== NULL
) {
59 fprintf(stderr
, "Null cookie for %s\n", s
);
63 tu
.ipft_name
[sizeof(tu
.ipft_name
) - 1] = '\0';