Allow for IP_FW_ADD to be used in getsockopt(2) incarnation as

well, in which case return the rule number back into userland.

PR:		bin/18351
Reviewed by:	archie, luigi
This commit is contained in:
Ruslan Ermilov 2000-10-12 07:59:14 +00:00
parent 67467625e2
commit bc95ac80b2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=67003
3 changed files with 7 additions and 4 deletions

View File

@ -2131,11 +2131,11 @@ badviacombo:
rule.fw_loghighest = rule.fw_logamount;
}
done:
i = sizeof(rule);
if (getsockopt(s, IPPROTO_IP, IP_FW_ADD, &rule, &i) == -1)
err(EX_UNAVAILABLE, "getsockopt(%s)", "IP_FW_ADD");
if (!do_quiet)
show_ipfw(&rule, 10, 10);
i = setsockopt(s, IPPROTO_IP, IP_FW_ADD, &rule, sizeof rule);
if (i)
err(EX_UNAVAILABLE, "setsockopt(%s)", "IP_FW_ADD");
}
static void

View File

@ -1512,7 +1512,7 @@ add_entry(struct ip_fw_head *chainptr, struct ip_fw *frwl)
}
if (nbr < IPFW_DEFAULT_RULE - 100)
nbr += 100;
ftmp->fw_number = nbr;
ftmp->fw_number = frwl->fw_number = nbr;
}
/* Got a valid number; now insert it, keeping the list ordered */
@ -1928,6 +1928,8 @@ ip_fw_ctl(struct sockopt *sopt)
error = EINVAL;
} else {
error = add_entry(&ip_fw_chain, &frwl);
if (!error && sopt->sopt_dir == SOPT_GET)
error = sooptcopyout(sopt, &frwl, sizeof frwl);
}
break;

View File

@ -259,6 +259,7 @@ rip_ctloutput(so, sopt)
error = sooptcopyout(sopt, &optval, sizeof optval);
break;
case IP_FW_ADD:
case IP_FW_GET:
if (ip_fw_ctl_ptr == 0)
error = ENOPROTOOPT;