本文整理汇总了Java中org.onosproject.net.flow.criteria.IPCriterion类的典型用法代码示例。如果您正苦于以下问题:Java IPCriterion类的具体用法?Java IPCriterion怎么用?Java IPCriterion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPCriterion类属于org.onosproject.net.flow.criteria包,在下文中一共展示了IPCriterion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: processIpv4UnicastRule
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
private void processIpv4UnicastRule(IPCriterion ipDstCriterion, ForwardingObjective fwd,
PipelinerTranslationResult.Builder resultBuilder) {
checkNotNull(ipDstCriterion, "IP dst criterion should not be null");
if (fwd.nextId() == null) {
log.warn("Forwarding objective for IPv4 unicast should contains next id");
resultBuilder.setError(ObjectiveError.BADPARAMS);
return;
}
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchIPDst(ipDstCriterion.ip())
.build();
TrafficTreatment treatment = buildSetNextIdTreatment(fwd.nextId());
FlowRule flowRule = DefaultFlowRule.builder()
.withSelector(selector)
.withTreatment(treatment)
.fromApp(fwd.appId())
.withPriority(fwd.priority())
.makePermanent()
.forDevice(deviceId)
.forTable(FabricConstants.TBL_UNICAST_V4_ID)
.build();
resultBuilder.addFlowRule(flowRule);
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:26,代码来源:FabricForwardingPipeliner.java
示例2: getHosts
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
/**
* Gets the hosts for the given initial packet.
*
* @param trace the trace we are building
* @return set of the hosts we are trying to reach
*/
private Set<Host> getHosts(StaticPacketTrace trace) {
IPCriterion ipv4Criterion = ((IPCriterion) trace.getInitialPacket()
.getCriterion(Criterion.Type.IPV4_DST));
IPCriterion ipv6Criterion = ((IPCriterion) trace.getInitialPacket()
.getCriterion(Criterion.Type.IPV6_DST));
Set<Host> hosts = new HashSet<>();
if (ipv4Criterion != null) {
hosts.addAll(hostService.getHostsByIp(ipv4Criterion.ip().address()));
}
if (ipv6Criterion != null) {
hosts.addAll(hostService.getHostsByIp(ipv6Criterion.ip().address()));
}
EthCriterion ethCriterion = ((EthCriterion) trace.getInitialPacket()
.getCriterion(Criterion.Type.ETH_DST));
if (ethCriterion != null) {
hosts.addAll(hostService.getHostsByMac(ethCriterion.mac()));
}
return hosts;
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:26,代码来源:TroubleshootManager.java
示例3: match
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
/**
* Matches the packet with the given flow entry.
*
* @param packet the packet to match
* @param flowEntry the flow entry to match the packet against
* @return true if the packet matches the flow.
*/
private boolean match(TrafficSelector packet, FlowEntry flowEntry) {
//TODO handle MAC matching
return flowEntry.selector().criteria().stream().allMatch(criterion -> {
Criterion.Type type = criterion.type();
//If the criterion has IP we need to do LPM to establish matching.
if (type.equals(Criterion.Type.IPV4_SRC) || type.equals(Criterion.Type.IPV4_DST) ||
type.equals(Criterion.Type.IPV6_SRC) || type.equals(Criterion.Type.IPV6_DST)) {
IPCriterion ipCriterion = (IPCriterion) criterion;
IPCriterion matchCriterion = (IPCriterion) packet.getCriterion(ipCriterion.type());
//if the packet does not have an IPv4 or IPv6 criterion we return false
if (matchCriterion == null) {
return false;
}
try {
Subnet subnet = Subnet.createInstance(ipCriterion.ip().toString());
return subnet.isInSubnet(matchCriterion.ip().address().toInetAddress());
} catch (UnknownHostException e) {
return false;
}
//we check that the packet contains the criterion provided by the flow rule.
} else {
return packet.criteria().contains(criterion);
}
});
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:33,代码来源:TroubleshootManager.java
示例4: readIpDstFromSelector
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
protected static IpPrefix readIpDstFromSelector(TrafficSelector selector) {
if (selector == null) {
return null;
}
Criterion criterion = selector.getCriterion(Criterion.Type.IPV4_DST);
return (criterion == null) ? null : ((IPCriterion) criterion).ip();
}
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:Ofdpa2Pipeline.java
示例5: Filter
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
public Filter(PortCriterion p, EthCriterion e, VlanIdCriterion v,
Collection<IPCriterion> ips) {
this.eth = e;
this.port = p;
this.vlan = v;
this.ips = ips;
}
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:PicaPipeline.java
示例6: processIpTraffic
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
@Override
protected Collection<FlowRule> processIpTraffic(ForwardingObjective fwd, FlowRule.Builder rule) {
IPCriterion ipSrc = (IPCriterion) fwd.selector()
.getCriterion(Criterion.Type.IPV4_SRC);
if (ipSrc != null) {
log.warn("Driver does not currently handle matching Src IP");
fail(fwd, ObjectiveError.UNSUPPORTED);
return Collections.emptySet();
}
IPCriterion ipDst = (IPCriterion) fwd.selector()
.getCriterion(Criterion.Type.IPV4_DST);
if (ipDst != null) {
log.error("Driver handles Dst IP matching as specific forwarding "
+ "objective, not versatile");
fail(fwd, ObjectiveError.UNSUPPORTED);
return Collections.emptySet();
}
IPProtocolCriterion ipProto = (IPProtocolCriterion) fwd.selector()
.getCriterion(Criterion.Type.IP_PROTO);
if (ipProto != null && ipProto.protocol() == IPv4.PROTOCOL_TCP) {
log.warn("Driver automatically punts all packets reaching the "
+ "LOCAL table to the controller");
pass(fwd);
return Collections.emptySet();
}
return Collections.emptySet();
}
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:OvsCorsaPipeline.java
示例7: processIpFilter
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
@Override
protected FlowRule.Builder processIpFilter(FilteringObjective filt, IPCriterion ip, PortCriterion port) {
log.debug("adding rule for IP: {}", ip.ip());
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchIPDst(ip.ip());
treatment.transition(LOCAL_TABLE);
return DefaultFlowRule.builder()
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(HIGHEST_PRIORITY)
.makePermanent()
.forTable(FIB_TABLE);
}
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:OvsCorsaPipeline.java
示例8: processIpFilter
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
@Override
protected Builder processIpFilter(FilteringObjective filt, IPCriterion ip, PortCriterion port) {
log.debug("adding rule for IP: {}", ip.ip());
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchIPDst(ip.ip());
treatment.transition(LOCAL_TABLE);
return DefaultFlowRule.builder()
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(HIGHEST_PRIORITY)
.makePermanent()
.forTable(FIB_TABLE);
}
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:CorsaPipelineV3.java
示例9: processIpTraffic
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
@Override
protected Collection<FlowRule> processIpTraffic(ForwardingObjective fwd, Builder rule) {
IPCriterion ipSrc = (IPCriterion) fwd.selector()
.getCriterion(Criterion.Type.IPV4_SRC);
if (ipSrc != null) {
log.warn("Driver does not currently handle matching Src IP");
fail(fwd, ObjectiveError.UNSUPPORTED);
return ImmutableSet.of();
}
IPCriterion ipDst = (IPCriterion) fwd.selector()
.getCriterion(Criterion.Type.IPV4_DST);
if (ipDst != null) {
log.error("Driver handles Dst IP matching as specific forwarding "
+ "objective, not versatile");
fail(fwd, ObjectiveError.UNSUPPORTED);
return ImmutableSet.of();
}
IPProtocolCriterion ipProto = (IPProtocolCriterion) fwd.selector()
.getCriterion(Criterion.Type.IP_PROTO);
if (ipProto != null && ipProto.protocol() == IPv4.PROTOCOL_TCP) {
log.warn("Driver automatically punts all packets reaching the "
+ "LOCAL table to the controller");
pass(fwd);
return ImmutableSet.of();
}
return ImmutableSet.of();
}
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:CorsaPipelineV39.java
示例10: matchCriterion
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
/**
* Matches an IP address criterion object.
*
* @param criterion criterion to match
* @return true if the JSON matches the criterion, false otherwise.
*/
private boolean matchCriterion(IPCriterion criterion) {
final String ip = criterion.ip().toString();
final String jsonIp = jsonCriterion.get("ip").textValue();
if (!ip.equals(jsonIp)) {
description.appendText("ip was " + jsonIp);
return false;
}
return true;
}
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:CriterionJsonMatcher.java
示例11: getDstIpFromSelector
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
private IpPrefix getDstIpFromSelector(FlowRule flowRule) {
Criterion criterion = flowRule.selector().getCriterion(IPV4_DST);
if (criterion != null && criterion instanceof IPCriterion) {
IPCriterion ip = (IPCriterion) criterion;
return ip.ip();
} else {
return null;
}
}
开发者ID:opencord,项目名称:vtn,代码行数:10,代码来源:DefaultInstanceHandler.java
示例12: matchAddIPV4
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
private boolean matchAddIPV4(TsLoopPacket pkt,
Criterion criterion,
TsReturn<Boolean> isBigger) {
if (pkt.headerExists(criterion.type())) {
IpPrefix ipFlow = ((IPCriterion) criterion).ip();
IpPrefix ipPkt =
((IPCriterion) pkt.getHeader(criterion.type())).ip();
// attention - the order below is important
if (ipFlow.equals(ipPkt)) {
// shoot
} else if (ipFlow.contains(ipPkt)) {
// shoot, pkt is more exact than flowEntry
} else if (ipPkt.contains(ipFlow)) {
// pkt should be changed to be more exact
pkt.setHeader(criterion);
isBigger.setValue(true);
} else {
// match fail
return false;
}
} else {
// attention the order of criteria in "for" loop
pkt.setHeader(criterion);
isBigger.setValue(true);
}
return true;
}
开发者ID:MaoJianwei,项目名称:ONOS_Network_Troubleshooting_System,代码行数:35,代码来源:DefaultCheckLoop.java
示例13: matchAddIPV4
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
private boolean matchAddIPV4(TsFindBhPacket pkt, Criterion criterion) {
if (pkt.existHeader(criterion.type())) {
IpPrefix ipFlow = ((IPCriterion) criterion).ip();
IpPrefix ipPkt = ((IPCriterion) pkt.getHeader(criterion.type())).ip();
return ipFlow.equals(ipPkt) || ipFlow.contains(ipPkt);
} else {
return false;
}
}
开发者ID:MaoJianwei,项目名称:ONOS_Network_Troubleshooting_System,代码行数:10,代码来源:NetworkTsFindBlackHole.java
示例14: matchAddIPV4
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
/**
* before invoking me, must check prerequisite.
*/
private boolean matchAddIPV4(TsLoopPacket pkt, Criterion criterion, TsReturn<Boolean> isBigger) {
if (pkt.existHeader(criterion.type())) {
IpPrefix ipFlow = ((IPCriterion) criterion).ip();
IpPrefix ipPkt = ((IPCriterion) pkt.getHeader(criterion.type())).ip();
// attention - the order below is important
if (ipFlow.equals(ipPkt)) {
// shoot
} else if (ipFlow.contains(ipPkt)) {
// shoot, pkt is more exact than flowEntry
} else if (ipPkt.contains(ipFlow)) {
// pkt should be changed to be more exact
pkt.setHeader(criterion);
isBigger.setValue(true);
} else {
// match fail
return false;
}
} else {
// Done - no need - check prerequisite - attention the order of criteria in "for" loop
pkt.setHeader(criterion);
isBigger.setValue(true);
}
return true;
}
开发者ID:MaoJianwei,项目名称:ONOS_Network_Troubleshooting_System,代码行数:35,代码来源:NetworkTsCheckLoop.java
示例15: matchAddIPV4
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
/**
* .
* @param pkt :.
* @param criterion :.
* @return .
*/
private boolean matchAddIPV4(TsFindBhPacket pkt, Criterion criterion) {
if (pkt.existHeader(criterion.type())) {
IpPrefix ipFlow = ((IPCriterion) criterion).ip();
IpPrefix ipPkt = ((IPCriterion) pkt.getHeader(criterion.type())).ip();
return ipFlow.equals(ipPkt) || ipFlow.contains(ipPkt);
} else {
return false;
}
}
开发者ID:MaoJianwei,项目名称:ONOS_Network_Troubleshooting_System,代码行数:16,代码来源:NetworkTsFindBlackHole.java
示例16: matchAddIPV4
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
/**
* before invoking me, must check prerequisite.
* @param pkt :.
* @param criterion :.
* @param isBigger :.
* @return .
*/
private boolean matchAddIPV4(TsLoopPacket pkt, Criterion criterion, TsReturn<Boolean> isBigger) {
if (pkt.existHeader(criterion.type())) {
IpPrefix ipFlow = ((IPCriterion) criterion).ip();
IpPrefix ipPkt = ((IPCriterion) pkt.getHeader(criterion.type())).ip();
// attention - the order below is important
if (ipFlow.equals(ipPkt)) {
// shoot
} else if (ipFlow.contains(ipPkt)) {
// shoot, pkt is more exact than flowEntry
} else if (ipPkt.contains(ipFlow)) {
// pkt should be changed to be more exact
pkt.setHeader(criterion);
isBigger.setValue(true);
} else {
// match fail
return false;
}
} else {
// Done - no need - check prerequisite - attention the order of criteria in "for" loop
pkt.setHeader(criterion);
isBigger.setValue(true);
}
return true;
}
开发者ID:MaoJianwei,项目名称:ONOS_Network_Troubleshooting_System,代码行数:39,代码来源:NetworkTsCheckLoop.java
示例17: buildIpv6Selector
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
/**
* Helper method to build Ipv6 selector using the selector provided by
* a forwarding objective.
*
* @param builderToUpdate the builder to update
* @param fwd the selector to read
* @return 0 if the update ends correctly. -1 if the matches
* are not yet supported
*/
protected int buildIpv6Selector(TrafficSelector.Builder builderToUpdate,
ForwardingObjective fwd) {
TrafficSelector selector = fwd.selector();
IpPrefix ipv6Dst = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV6_DST)).ip();
if (ipv6Dst.isMulticast()) {
if (ipv6Dst.prefixLength() != IpAddress.INET6_BIT_LENGTH) {
log.warn("Multicast specific forwarding objective can only be /128");
fail(fwd, ObjectiveError.BADPARAMS);
return -1;
}
VlanId assignedVlan = readVlanFromSelector(fwd.meta());
if (assignedVlan == null) {
log.warn("VLAN ID required by multicast specific fwd obj is missing. Abort.");
fail(fwd, ObjectiveError.BADPARAMS);
return -1;
}
if (requireVlanExtensions()) {
OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(assignedVlan);
builderToUpdate.extension(ofdpaMatchVlanVid, deviceId);
} else {
builderToUpdate.matchVlanId(assignedVlan);
}
builderToUpdate.matchEthType(Ethernet.TYPE_IPV6).matchIPv6Dst(ipv6Dst);
log.debug("processing IPv6 multicast specific forwarding objective {} -> next:{}"
+ " in dev:{}", fwd.id(), fwd.nextId(), deviceId);
} else {
if (ipv6Dst.prefixLength() != 0) {
builderToUpdate.matchIPv6Dst(ipv6Dst);
}
builderToUpdate.matchEthType(Ethernet.TYPE_IPV6);
log.debug("processing IPv6 unicast specific forwarding objective {} -> next:{}"
+ " in dev:{}", fwd.id(), fwd.nextId(), deviceId);
}
return 0;
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:47,代码来源:Ofdpa2Pipeline.java
示例18: readIpDstFromSelector
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
static IpPrefix readIpDstFromSelector(TrafficSelector selector) {
if (selector == null) {
return null;
}
Criterion criterion = selector.getCriterion(Criterion.Type.IPV4_DST);
return (criterion == null) ? null : ((IPCriterion) criterion).ip();
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:8,代码来源:Ofdpa2Pipeline.java
示例19: getStaticRoute
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
/**
* Helper method to convert FlowRule into an abstraction of static route
* {@link StaticRoute}.
*
* @param devId the device id
* @param criteria the IP destination criteria
* @param output the output instruction
* @return optional of Static Route
*/
private Optional<StaticRoute> getStaticRoute(DeviceId devId,
IPCriterion criteria,
OutputInstruction output,
int priority) {
DeviceService deviceService = this.handler().get(DeviceService.class);
Collection<Port> ports = deviceService.getPorts(devId);
Optional<Port> port = ports.stream().filter(x -> x.number().equals(output.port())).findAny();
if (!port.isPresent()) {
log.error("The port {} does not exist in the device",
output.port());
return Optional.empty();
}
//Find if the route refers to a local interface.
Optional<Port> local = deviceService.getPorts(devId).stream().filter(this::isIp)
.filter(p -> criteria.ip().getIp4Prefix().contains(
Ip4Address.valueOf(p.annotations().value(IP_STRING)))).findAny();
if (local.isPresent()) {
return Optional.of(new StaticRoute(criteria.ip().getIp4Prefix(),
criteria.ip().getIp4Prefix().address(), true, priority));
}
Optional<Ip4Address> nextHop = findIpDst(devId, port.get());
if (nextHop.isPresent()) {
return Optional.of(
new StaticRoute(criteria.ip().getIp4Prefix(), nextHop.get(), false, priority));
} else {
log.error("The destination interface has not an IP {}", port.get());
return Optional.empty();
}
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:44,代码来源:FlowRuleJuniperImpl.java
示例20: testIpCriterion
import org.onosproject.net.flow.criteria.IPCriterion; //导入依赖的package包/类
@Test
public void testIpCriterion() throws Exception {
IpPrefix prefix1 = IpPrefix.valueOf(random.nextInt(), random.nextInt(32));
int bitWidth = prefix1.address().toOctets().length * 8;
IPCriterion criterion = (IPCriterion) Criteria.matchIPDst(prefix1);
PiLpmFieldMatch lpmMatch = (PiLpmFieldMatch) translateCriterion(criterion, fieldId, LPM, bitWidth);
assertThat(lpmMatch.value().asArray(), is(criterion.ip().address().toOctets()));
assertThat(lpmMatch.prefixLength(), is(criterion.ip().prefixLength()));
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:13,代码来源:PiCriterionTranslatorsTest.java
注:本文中的org.onosproject.net.flow.criteria.IPCriterion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论