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

Function add_src

tools/ipfw/ipfw2.c:3731–3760  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3729}
3730
3731static ipfw_insn *
3732add_src(ipfw_insn *cmd, char *av, u_char proto, int cblen, struct tidx *tstate)
3733{
3734 struct in6_addr a;
3735 char *host, *ch, buf[INET6_ADDRSTRLEN];
3736 ipfw_insn *ret = NULL;
3737 size_t len;
3738
3739 /* Copy first address in set if needed */
3740 if ((ch = strpbrk(av, "/,")) != NULL) {
3741 len = ch - av;
3742 strlcpy(buf, av, sizeof(buf));
3743 if (len < sizeof(buf))
3744 buf[len] = '\0';
3745 host = buf;
3746 } else
3747 host = av;
3748
3749 if (proto == IPPROTO_IPV6 || strcmp(av, "me6") == 0 ||
3750 inet_pton(AF_INET6_LINUX, host, &a) == 1)
3751 ret = add_srcip6(cmd, av, cblen, tstate);
3752 /* XXX: should check for IPv4, not !IPv6 */
3753 if (ret == NULL && (proto == IPPROTO_IP || strcmp(av, "me") == 0 ||
3754 inet_pton(AF_INET6_LINUX, host, &a) != 1))
3755 ret = add_srcip(cmd, av, cblen, tstate);
3756 if (ret == NULL && strcmp(av, "any") != 0)
3757 ret = cmd;
3758
3759 return ret;
3760}
3761
3762static ipfw_insn *
3763add_dst(ipfw_insn *cmd, char *av, u_char proto, int cblen, struct tidx *tstate)

Callers 1

compile_ruleFunction · 0.85

Calls 6

strpbrkFunction · 0.85
strcmpFunction · 0.85
inet_ptonFunction · 0.85
add_srcip6Function · 0.85
add_srcipFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected