////////////////////////////////////////////////////////////////////// These are little helper functions for the main rules evaluator.
| 40 | // These are little helper functions for the main rules evaluator. |
| 41 | // |
| 42 | static bool |
| 43 | check_value(TSHttpTxn txnp, swoc::IPRange const &range) |
| 44 | { |
| 45 | const sockaddr *client_ip = TSHttpTxnClientAddrGet(txnp); |
| 46 | if (!client_ip) { |
| 47 | return false; |
| 48 | } |
| 49 | |
| 50 | if (range.empty()) { // this means "match any address". |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | swoc::IPEndpoint client_addr{client_ip}; |
| 55 | |
| 56 | swoc::bwprint(ts::bw_dbg, "cfg_ip {::c}, client_ip {}", range, client_addr); |
| 57 | Dbg(Bg_dbg_ctl, "%s", ts::bw_dbg.c_str()); |
| 58 | |
| 59 | if (client_addr.family() == range.family()) { |
| 60 | return (range.is_ip4() && range.ip4().contains(swoc::IP4Addr(client_addr.ip4()))) || |
| 61 | (range.is_ip6() && range.ip6().contains(swoc::IP6Addr(client_addr.ip6()))); |
| 62 | } |
| 63 | |
| 64 | return false; // Different family, no match. |
| 65 | } |
| 66 | |
| 67 | static bool |
| 68 | check_value(TSHttpTxn txnp, BgFetchRule::size_cmp_type const &cmp) |
no test coverage detected