- ip_addr = ip_address(unicode(ip_addr))
- prefix_addr = ip_addr.packed
- mask_width = int(prefix)
- if ip_addr.version == 4:
- prefix_addr += 12 * b'\x00'
- traffic_type = getattr(
- SRv6PolicySteeringTypes, 'SR_STEER_IPV4').value
- else:
- traffic_type = getattr(
- SRv6PolicySteeringTypes, 'SR_STEER_IPV6').value
+ ip_addr = ip_address(ip_addr)
+ 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