@Override public Optional<MatchBuilder> process(@Nonnull Icmpv4TypeCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final Icmpv4MatchBuilder icmpv4MatchBuilder = data.getIcmpv4MatchBuilder(); Icmpv4Type icmpv4Type = source.getIcmpv4Type(); Short type = icmpv4Type.getIcmpv4Type(); if (type != null) { icmpv4MatchBuilder.setIcmpv4Type(type); matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()); } return Optional.of(matchBuilder); } }
@Override public Optional<MatchBuilder> process(@Nonnull Icmpv4CodeCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final Icmpv4MatchBuilder icmpv4MatchBuilder = data.getIcmpv4MatchBuilder(); Icmpv4Code icmpv4Code = source.getIcmpv4Code(); Short v4code = icmpv4Code.getIcmpv4Code(); if (v4code != null) { icmpv4MatchBuilder.setIcmpv4Code(v4code); matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()); } return Optional.of(matchBuilder); } }
/** * Configure the condition represented by this instance into the given * MD-SAL flow match builder. * * @param builder A {@link MatchBuilder} instance. * @param ver An {@link IpVersion} instance which describes the * IP version. * @throws IllegalStateException * {@code ver} is not {@link IpVersion#Ipv4}. */ @Override public void setMatch(MatchBuilder builder, IpVersion ver) { checkIpVersion(ver); Icmpv4MatchBuilder imatch; if (icmpType == null) { imatch = null; } else { imatch = create((Icmpv4MatchBuilder)null).setIcmpv4Type(icmpType); } if (icmpCode != null) { imatch = create(imatch).setIcmpv4Code(icmpCode); } if (imatch != null) { builder.setIcmpv4Match(imatch.build()); } }
/** * Match ICMP code and type * * @param matchBuilder MatchBuilder Object * @param type short representing an ICMP type * @param code short representing an ICMP code * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createICMPv4Match(MatchBuilder matchBuilder, short type, short code) { // Build the IPv4 Match requied per OVS Syntax IpMatchBuilder ipmatch = new IpMatchBuilder(); ipmatch.setIpProtocol((short) 1); matchBuilder.setIpMatch(ipmatch.build()); // Build the ICMPv4 Match Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); if (type != ALL_ICMP) { icmpv4match.setIcmpv4Type(type); } if (code != ALL_ICMP) { icmpv4match.setIcmpv4Code(code); } matchBuilder.setIcmpv4Match(icmpv4match.build()); return matchBuilder; }
/** * Match ICMP code and type * * @param matchBuilder MatchBuilder Object without a match yet * @param type short representing an ICMP type * @param code short representing an ICMP code * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createICMPv4Match(MatchBuilder matchBuilder, short type, short code) { EthernetMatchBuilder eth = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(IPV4_LONG)); eth.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(eth.build()); // Build the IPv4 Match requied per OVS Syntax IpMatchBuilder ipmatch = new IpMatchBuilder(); ipmatch.setIpProtocol((short) 1); matchBuilder.setIpMatch(ipmatch.build()); // Build the ICMPv4 Match Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); icmpv4match.setIcmpv4Type(type); icmpv4match.setIcmpv4Code(code); matchBuilder.setIcmpv4Match(icmpv4match.build()); return matchBuilder; }
/** * @return */ private static MatchBuilder createICMPv4Match() { final MatchBuilder match = new MatchBuilder(); final EthernetMatchBuilder eth = new EthernetMatchBuilder(); final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x0800L)); eth.setEthernetType(ethTypeBuilder.build()); match.setEthernetMatch(eth.build()); final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version ipmatch.setIpProtocol((short) 1); match.setIpMatch(ipmatch.build()); final Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4 // match icmpv4match.setIcmpv4Type((short) 8); icmpv4match.setIcmpv4Code((short) 0); match.setIcmpv4Match(icmpv4match.build()); return match; }
/** * Match ICMP code and type * * @param matchBuilder MatchBuilder Object without a match yet * @param type short representing an ICMP type * @param code short representing an ICMP code * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createICMPv4Match(MatchBuilder matchBuilder, short type, short code) { EthernetMatchBuilder eth = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(IPV4_LONG)); eth.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(eth.build()); // Build the IPv4 Match requied per OVS Syntax IpMatchBuilder ipmatch = new IpMatchBuilder(); ipmatch.setIpProtocol((short) 1); matchBuilder.setIpMatch(ipmatch.build()); // Build the ICMPv4 Match Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); icmpv4match.setIcmpv4Type(type); icmpv4match.setIcmpv4Code(code); matchBuilder.setIcmpv4Match(icmpv4match.build()); return matchBuilder; }
matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());