- prefix_addr = ip_addr.packed
- mask_width = int(prefix)
- if ip_addr.version == 4:
- prefix_addr += 12 * b"\0"
- traffic_type = getattr(
- SRv6PolicySteeringTypes, u"SR_STEER_IPV4"
- ).value
- else:
- traffic_type = getattr(
- SRv6PolicySteeringTypes, u"SR_STEER_IPV6"
- ).value
+ prefix = IPUtil.create_prefix_object(ip_addr, int(prefix))
+ traffic_type = getattr(
+ SRv6PolicySteeringTypes, u"SR_STEER_IPV4"
+ ).value if ip_addr.version == 4 else getattr(
+ SRv6PolicySteeringTypes, u"SR_STEER_IPV6"
+ ).value