mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
ipfw: use function return value to fetch insn argument.
This is a prerequsite for splitting compile_rule() into smaller chunks. MFC after: 2 weeks
This commit is contained in:
parent
84b41342da
commit
2b5dd8b890
|
@ -1203,8 +1203,8 @@ static struct _s_x icmpcodes[] = {
|
|||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static void
|
||||
fill_reject_code(u_short *codep, char *str)
|
||||
static uint16_t
|
||||
get_reject_code(const char *str)
|
||||
{
|
||||
int val;
|
||||
char *s;
|
||||
|
@ -1214,8 +1214,7 @@ fill_reject_code(u_short *codep, char *str)
|
|||
val = match_token(icmpcodes, str);
|
||||
if (val < 0)
|
||||
errx(EX_DATAERR, "unknown ICMP unreachable code ``%s''", str);
|
||||
*codep = val;
|
||||
return;
|
||||
return (val);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -3965,23 +3964,20 @@ arg_or_targ(const char *arg, const char *action)
|
|||
return (arg1);
|
||||
}
|
||||
|
||||
static void
|
||||
fill_divert_port(ipfw_insn *cmd, char *arg, const char *action)
|
||||
static uint16_t
|
||||
get_divert_port(const char *arg, const char *action)
|
||||
{
|
||||
uint32_t arg1 = arg_or_targ_relaxed(arg, action);
|
||||
|
||||
if (arg1 != (uint32_t)(-1)) {
|
||||
cmd->arg1 = arg1;
|
||||
return;
|
||||
}
|
||||
if (arg1 != (uint32_t)(-1))
|
||||
return (arg1);
|
||||
|
||||
struct servent *s;
|
||||
setservent(1);
|
||||
s = getservbyname(arg, "divert");
|
||||
if (s != NULL)
|
||||
cmd->arg1 = ntohs(s->s_port);
|
||||
else
|
||||
if (s == NULL)
|
||||
errx(EX_DATAERR, "illegal divert/tee port");
|
||||
return (ntohs(s->s_port));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4143,7 +4139,7 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate)
|
|||
case TOK_UNREACH:
|
||||
action->opcode = O_REJECT;
|
||||
NEED1("missing reject code");
|
||||
fill_reject_code(&action->arg1, *av);
|
||||
action->arg1 = get_reject_code(*av);
|
||||
av++;
|
||||
if (action->arg1 == ICMP_UNREACH_NEEDFRAG && isdigit(**av)) {
|
||||
uint16_t mtu;
|
||||
|
@ -4161,7 +4157,7 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate)
|
|||
case TOK_UNREACH6:
|
||||
action->opcode = O_UNREACH6;
|
||||
NEED1("missing unreach code");
|
||||
fill_unreach6_code(&action->arg1, *av);
|
||||
action->arg1 = get_unreach6_code(*av);
|
||||
av++;
|
||||
break;
|
||||
|
||||
|
@ -4206,12 +4202,12 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate)
|
|||
break;
|
||||
case TOK_DIVERT:
|
||||
action->opcode = O_DIVERT;
|
||||
fill_divert_port(action, av[0], *(av - 1));
|
||||
action->arg1 = get_divert_port(av[0], *(av - 1));
|
||||
av++;
|
||||
break;
|
||||
case TOK_TEE:
|
||||
action->opcode = O_TEE;
|
||||
fill_divert_port(action, av[0], *(av - 1));
|
||||
action->arg1 = get_divert_port(av[0], *(av - 1));
|
||||
av++;
|
||||
break;
|
||||
case TOK_CALL:
|
||||
|
|
|
@ -448,7 +448,7 @@ struct _ipfw_insn *add_dstip6(struct _ipfw_insn *cmd, char *av, int cblen,
|
|||
struct tidx *tstate);
|
||||
|
||||
void fill_flow6(struct _ipfw_insn_u32 *cmd, char *av, int cblen);
|
||||
void fill_unreach6_code(u_short *codep, char *str);
|
||||
uint16_t get_unreach6_code(const char *str);
|
||||
void fill_icmp6types(struct _ipfw_insn_icmp6 *cmd, char *av, int cblen);
|
||||
int fill_ext6hdr(struct _ipfw_insn *cmd, char *av);
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ static struct _s_x icmp6codes[] = {
|
|||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
void
|
||||
fill_unreach6_code(u_short *codep, char *str)
|
||||
uint16_t
|
||||
get_unreach6_code(const char *str)
|
||||
{
|
||||
int val;
|
||||
char *s;
|
||||
|
@ -66,8 +66,7 @@ fill_unreach6_code(u_short *codep, char *str)
|
|||
val = match_token(icmp6codes, str);
|
||||
if (val < 0)
|
||||
errx(EX_DATAERR, "unknown ICMPv6 unreachable code ``%s''", str);
|
||||
*codep = val;
|
||||
return;
|
||||
return (val);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue