/** * Constructs a new ethertype. * * @param ethType The actual ethertype * @param type it's textual representation * @param deserializer a parser for this ethertype */ EtherType(int ethType, String type, Deserializer<?> deserializer) { this.etherType = new EthType(ethType); this.type = type; this.deserializer = deserializer; }
/** * Returns Ethernet type. * * @return ethernet type * @throws IllegalArgumentException if the JSON is invalid */ private EthType getEthType() { String ethTypeStr = nullIsIllegal(json.get(InstructionCodec.ETHERNET_TYPE), InstructionCodec.ETHERNET_TYPE + InstructionCodec.MISSING_MEMBER_MESSAGE).asText(); Matcher matcher = ETHTYPE_PATTERN.matcher(ethTypeStr); if (!matcher.matches()) { throw new IllegalArgumentException("ETHERNET_TYPE must be a four digit hex string starting with 0x"); } short ethernetType = (short) Integer.parseInt(matcher.group(1), 16); return new EthType(ethernetType); }
case POP_MPLS: OFActionPopMpls popMpls = (OFActionPopMpls) act; builder.popMpls(new EthType(popMpls.getEthertype().getValue())); break; case PUSH_MPLS: