/** * Convert To yang object L3VpnIfs. * * @param vpnAcs set of VpnAc * @return L3VpnIf List of L3vpn interface */ public static L3VpnIfs convertToL3VpnIfs(HashSet<VpnAc> vpnAcs) { List<L3VpnIf> l3vpnIfList = new ArrayList<L3VpnIf>(); for (VpnAc vpnAc : vpnAcs) { L3VpnIfBuilder l3VpnIfBuilder = new L3VpnIfBuilder(); l3VpnIfBuilder.ifName(vpnAc.acName()); Ipv4Address ipv4Address = new Ipv4Address(vpnAc.ipAddress().split("/")[0]); l3VpnIfBuilder.ipv4Addr(ipv4Address); Ipv4Address subnetMask = new Ipv4Address(IpUtil.getMask(String.valueOf(vpnAc.subNetMask()))); l3VpnIfBuilder.subnetMask(subnetMask); l3vpnIfList.add(l3VpnIfBuilder.build()); } L3VpnIfs l3VpnIfs = new L3VpnIfsBuilder().l3VpnIf(l3vpnIfList).build(); return l3VpnIfs; }
/** * parse IPV4 ARPA domain to IP bytes. * * @param name an ARPA string. * @return ARPA. */ private static NetworkInBytes parseIpV4Arpa(String name) { LOGGER.debug("parseInAddrArpa, name:" + name); String arpa = StringUtils.removeEndIgnoreCase(name, CHAR_DOT + DomainUtil.IPV4_ARPA_SUFFIX); arpa = StringUtils.reverseDelimited(arpa, CHAR_DOT); String[] arpaLabels = StringUtils.split(arpa, CHAR_DOT); int mask = arpaLabels.length * 8; String[] ipLabels = new String[BYTE_SIZE_IPV4]; for (int i = 0; i < BYTE_SIZE_IPV4; i++) { if (i < arpaLabels.length) { ipLabels[i] = arpaLabels[i]; } else { ipLabels[i] = "0"; } } String networkStr = StringUtils.join(ipLabels, CHAR_DOT) + "/" + mask; return IpUtil.parseNetworkV4(networkStr); }