- first_action += f"const uint32_t srcip = ip->saddr & MASK4({high_byte});\n"
- first_action += f"void *rate_map = &v4_src_rate_{v4persrcratelimitcnt};\n"
- v4persrcratelimitcnt += 1
+ first_action += f"const uint32_t srcip = ip->saddr & MASK4({mid_byte});\n"
+ first_action += f"void *rate_map = &v4_src_rate_{len(v4persrcratelimits)};\n"
+ first_action += f"struct persrc_rate4_ptr rate_ptr = get_v4_persrc_ratelimit(srcip, rate_map, {(high_byte + 1) * 4096}, time_masked);\n"
+ first_action += f"struct persrc_rate4_entry *rate = rate_ptr.rate;\n"
+ v4persrcratelimits.append((high_byte + 1) * 4096)
+ elif mid_byte <= 64:
+ first_action += f"const uint64_t srcip = BE128BEHIGH64(ip6->saddr & MASK6({mid_byte}));\n"
+ first_action += f"void *rate_map = &v5_src_rate_{len(v5persrcratelimits)};\n"
+ first_action += f"struct persrc_rate5_ptr rate_ptr = get_v5_persrc_ratelimit(srcip, rate_map, {(high_byte + 1) * 4096}, time_masked);\n"
+ first_action += f"struct persrc_rate5_entry *rate = rate_ptr.rate;\n"
+ v5persrcratelimits.append((high_byte + 1) * 4096)