use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress in project netvirt by opendaylight.
the class ConntrackBasedSnatService method createOutboundTblEntry.
protected void createOutboundTblEntry(BigInteger dpnId, long routerId, String externalIp, int elanId, String extGwMacAddress, int addOrRemove) {
LOG.info("createOutboundTblEntry : dpId {} and routerId {}", dpnId, routerId);
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new NxMatchCtState(TRACKED_NEW_CT_STATE, TRACKED_NEW_CT_MASK));
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
List<ActionInfo> actionsInfos = new ArrayList<>();
if (addOrRemove == NwConstants.ADD_FLOW) {
actionsInfos.add(new ActionSetFieldEthernetSource(new MacAddress(extGwMacAddress)));
}
List<NxCtAction> ctActionsListCommit = new ArrayList<>();
int rangePresent = NxActionNatRangePresent.NXNATRANGEIPV4MIN.getIntValue();
int flags = NxActionNatFlags.NXNATFSRC.getIntValue();
NxCtAction nxCtActionCommit = new ActionNxConntrack.NxNat(0, flags, rangePresent, new IpPrefixOrAddress(externalIp.toCharArray()).getIpAddress(), null, 0, 0);
ctActionsListCommit.add(nxCtActionCommit);
int ctCommitFlag = 1;
ActionNxConntrack actionNxConntrackSubmit = new ActionNxConntrack(ctCommitFlag, 0, elanId, NwConstants.NAPT_PFIB_TABLE, ctActionsListCommit);
actionsInfos.add(actionNxConntrackSubmit);
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfos));
String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId);
syncFlow(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef, NatConstants.SNAT_NEW_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress in project netvirt by opendaylight.
the class NeutronvpnUtils method getSubnetIpPrefixes.
protected List<IpPrefixOrAddress> getSubnetIpPrefixes(Port port) {
List<Uuid> subnetIds = getSubnetIdsFromNetworkId(port.getNetworkId());
if (subnetIds == null) {
LOG.error("Failed to get Subnet Ids for the Network {}", port.getNetworkId());
return null;
}
List<IpPrefixOrAddress> subnetIpPrefixes = new ArrayList<>();
for (Uuid subnetId : subnetIds) {
Subnet subnet = getNeutronSubnet(subnetId);
if (subnet != null) {
subnetIpPrefixes.add(new IpPrefixOrAddress(subnet.getCidr()));
}
}
return subnetIpPrefixes;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress in project netvirt by opendaylight.
the class AclServiceUtilsTest method buildAAp.
private AllowedAddressPairs buildAAp(String addr) {
AllowedAddressPairsBuilder aapb = new AllowedAddressPairsBuilder();
aapb.setIpAddress(new IpPrefixOrAddress(addr.toCharArray()));
aapb.setMacAddress(new MacAddress("AA:BB:CC:DD:EE:FF"));
return aapb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress in project netvirt by opendaylight.
the class AclServiceUtils method buildBroadcastIpV4Matches.
public static List<MatchInfoBase> buildBroadcastIpV4Matches(String ipAddr) {
List<MatchInfoBase> matches = new ArrayList<>(2);
matches.add(new MatchEthernetDestination(new MacAddress(AclConstants.BROADCAST_MAC)));
matches.addAll(AclServiceUtils.buildIpMatches(new IpPrefixOrAddress(ipAddr.toCharArray()), MatchCriteria.MATCH_DESTINATION));
return matches;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress in project netvirt by opendaylight.
the class AclServiceUtils method buildIpMatches.
/**
* Builds the ip matches.
*
* @param ipPrefixOrAddress the ip prefix or address
* @param matchCriteria the source_ip or destination_ip used for the match
* @return the list
*/
public static List<MatchInfoBase> buildIpMatches(IpPrefixOrAddress ipPrefixOrAddress, MatchCriteria matchCriteria) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix();
if (ipPrefix != null) {
Ipv4Prefix ipv4Prefix = ipPrefix.getIpv4Prefix();
if (ipv4Prefix != null) {
flowMatches.add(MatchEthernetType.IPV4);
if (!ipv4Prefix.getValue().equals(AclConstants.IPV4_ALL_NETWORK)) {
flowMatches.add(matchCriteria == MatchCriteria.MATCH_SOURCE ? new MatchIpv4Source(ipv4Prefix) : new MatchIpv4Destination(ipv4Prefix));
}
} else {
flowMatches.add(MatchEthernetType.IPV6);
flowMatches.add(matchCriteria == MatchCriteria.MATCH_SOURCE ? new MatchIpv6Source(ipPrefix.getIpv6Prefix()) : new MatchIpv6Destination(ipPrefix.getIpv6Prefix()));
}
} else {
IpAddress ipAddress = ipPrefixOrAddress.getIpAddress();
if (ipAddress.getIpv4Address() != null) {
flowMatches.add(MatchEthernetType.IPV4);
flowMatches.add(matchCriteria == MatchCriteria.MATCH_SOURCE ? new MatchIpv4Source(ipAddress.getIpv4Address().getValue(), "32") : new MatchIpv4Destination(ipAddress.getIpv4Address().getValue(), "32"));
} else {
flowMatches.add(MatchEthernetType.IPV6);
flowMatches.add(matchCriteria == MatchCriteria.MATCH_SOURCE ? new MatchIpv6Source(ipAddress.getIpv6Address().getValue() + "/128") : new MatchIpv6Destination(ipAddress.getIpv6Address().getValue() + "/128"));
}
}
return flowMatches;
}
Aggregations