MCPcopy Create free account
hub / github.com/F-Stack/f-stack / add_dst

Function add_dst

tools/ipfw/ipfw2.c:3762–3791  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3760}
3761
3762static ipfw_insn *
3763add_dst(ipfw_insn *cmd, char *av, u_char proto, int cblen, struct tidx *tstate)
3764{
3765 struct in6_addr a;
3766 char *host, *ch, buf[INET6_ADDRSTRLEN];
3767 ipfw_insn *ret = NULL;
3768 size_t len;
3769
3770 /* Copy first address in set if needed */
3771 if ((ch = strpbrk(av, "/,")) != NULL) {
3772 len = ch - av;
3773 strlcpy(buf, av, sizeof(buf));
3774 if (len < sizeof(buf))
3775 buf[len] = '\0';
3776 host = buf;
3777 } else
3778 host = av;
3779
3780 if (proto == IPPROTO_IPV6 || strcmp(av, "me6") == 0 ||
3781 inet_pton(AF_INET6_LINUX, host, &a) == 1)
3782 ret = add_dstip6(cmd, av, cblen, tstate);
3783 /* XXX: should check for IPv4, not !IPv6 */
3784 if (ret == NULL && (proto == IPPROTO_IP || strcmp(av, "me") == 0 ||
3785 inet_pton(AF_INET6_LINUX, host, &a) != 1))
3786 ret = add_dstip(cmd, av, cblen, tstate);
3787 if (ret == NULL && strcmp(av, "any") != 0)
3788 ret = cmd;
3789
3790 return ret;
3791}
3792
3793/*
3794 * Parse arguments and assemble the microinstructions which make up a rule.

Callers 1

compile_ruleFunction · 0.85

Calls 6

strpbrkFunction · 0.85
strcmpFunction · 0.85
inet_ptonFunction · 0.85
add_dstip6Function · 0.85
add_dstipFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected