| 3729 | } |
| 3730 | |
| 3731 | static ipfw_insn * |
| 3732 | add_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 | |
| 3762 | static ipfw_insn * |
| 3763 | add_dst(ipfw_insn *cmd, char *av, u_char proto, int cblen, struct tidx *tstate) |
no test coverage detected