本文整理汇总了Java中org.onosproject.net.flow.criteria.IPCriterion类的典型用法代码示例。如果您正苦于以下问题:Java IPCriterion类的具体用法?Java IPCriterion怎么用?Java IPCriterion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPCriterion类属于org.onosproject.net.flow.criteria包,在下文中一共展示了IPCriterion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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);
}
});
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
}