@Override public boolean isV6() { return this.ethertype == EtherTypes.IPv6.shortValue(); }
/** * Construct a new action instance which represents OF 1.3 PUSH_VLAN. * * @param tag An {@link EtherTypes} instance. */ public PushVlan(EtherTypes tag) { this(tag.intValue()); }
public static String getEtherTypeName(short number) { return getEtherTypeInternal((int) number & 0xffff); }
public static short getEtherTypeNumberShort(String name) { if (name.matches(regexNumberString)) { return Short.valueOf(name); } for (EtherTypes type : EtherTypes.values()) { if (type.description.equalsIgnoreCase(name)) { return type.shortValue(); } } return 0; }
public static EtherTypes loadFromString(String string) { int intType = Integer.parseInt(string); for (EtherTypes type : EtherTypes.values()) { if (type.number == intType) { return type; } } return null; }
EtherTypes.getEtherTypeName(((Short) flow.getMatch() .getField(MatchType.DL_TYPE).getValue()))); } else {
private Ethernet createEthernet(byte[] sourceMAC, byte[] targetMAC, ARP arp, short vlan) { Ethernet ethernet = new Ethernet(); ethernet.setSourceMACAddress(sourceMAC); ethernet.setDestinationMACAddress(targetMAC); if (vlan == 0) { ethernet.setEtherType(EtherTypes.ARP.shortValue()); ethernet.setPayload(arp); } else { IEEE8021Q dot1q = new IEEE8021Q(); dot1q.setVid(vlan); dot1q.setEtherType(EtherTypes.ARP.shortValue()); dot1q.setPayload(arp); dot1q.setCfi((byte)0); dot1q.setPcp((byte)0); ethernet.setEtherType(EtherTypes.VLANTAGGED.shortValue()); ethernet.setPayload(dot1q); } return ethernet; }
/** * Construct a new action instance which represents OF 1.3 PUSH_VLAN. * * @param tag An ethernet type of a new VLAN tag. */ public PushVlan(int tag) { type = ActionType.PUSH_VLAN; this.tag = tag; if (tag != EtherTypes.VLANTAGGED.intValue() && tag != EtherTypes.QINQ.intValue()) { // pass a value which will tell fail and tell something about the // original wrong value checkValue(ActionType.SET_DL_TYPE, 0xBAD << 16 | tag); } }
public static String getEtherTypeName(byte number) { return getEtherTypeInternal((int) number & 0xff); }
private Status validateFlow(Flow flow) { Match m = flow.getMatch(); boolean isIPEthertypeSet = m.isPresent(MatchType.DL_TYPE) && (m.getField(MatchType.DL_TYPE).getValue().equals(EtherTypes.IPv4.shortValue()) || m .getField(MatchType.DL_TYPE).getValue().equals(EtherTypes.IPv6.shortValue())); // network address check if ((m.isPresent(MatchType.NW_SRC) || m.isPresent(MatchType.NW_DST)) && !isIPEthertypeSet) { return new Status(StatusCode.NOTACCEPTABLE, "The match on network source or destination address cannot be accepted if the match " + "on proper ethertype is missing"); } // transport protocol check if (m.isPresent(MatchType.NW_PROTO) && !isIPEthertypeSet) { return new Status(StatusCode.NOTACCEPTABLE, "The match on network protocol cannot be accepted if the match on proper ethertype is missing"); } // transport ports check if ((m.isPresent(MatchType.TP_SRC) || m.isPresent(MatchType.TP_DST)) && (!isIPEthertypeSet || m.isAny(MatchType.NW_PROTO))) { return new Status( StatusCode.NOTACCEPTABLE, "The match on transport source or destination port cannot be accepted if the match on network protocol and match on IP ethertype are missing"); } return new Status(StatusCode.SUCCESS); }
public SetDlType(EtherTypes dlType) { type = ActionType.SET_DL_TYPE; this.dlType = dlType.intValue(); checkValue(this.dlType); }
public static String getEtherTypeName(int number) { return getEtherTypeInternal(number); }
InetAddress ipMask = InetAddress.getByName("255.255.255.0"); InetAddress ipMask2 = InetAddress.getByName("255.240.0.0"); short ethertype = EtherTypes.IPv4.shortValue(); short vlan = (short) 27; byte vlanPr = 3;
private void runChecks() { checkValue(ActionType.SET_DL_TYPE, tag); checkValue(ActionType.SET_VLAN_PCP, pcp); checkValue(ActionType.SET_VLAN_CFI, cfi); checkValue(ActionType.SET_VLAN_ID, vlanId); checkValue(tci); // Run action specific check which cannot be run by parent if (tag != EtherTypes.VLANTAGGED.intValue() && tag != EtherTypes.QINQ.intValue() && tag != EtherTypes.OLDQINQ.intValue() && tag != EtherTypes.CISCOQINQ.intValue()) { // pass a value which will tell fail and tell something about the // original wrong value checkValue(ActionType.SET_DL_TYPE, 0xBAD << 16 | tag); } }
InetAddress ipMask = InetAddress.getByName("255.255.255.0"); InetAddress ipMask2 = InetAddress.getByName("255.0.0.0"); short ethertype = EtherTypes.IPv4.shortValue(); short vlan = (short) 27; byte vlanPr = 3;
public PushVlan(EtherTypes tag, int pcp, int cfi, int vlanId) { type = ActionType.PUSH_VLAN; this.tag = tag.intValue(); this.cfi = cfi; this.pcp = pcp; this.vlanId = vlanId; this.tci = createTci(); this.header = createHeader(); runChecks(); }
@Override public PacketResult receiveDataPacket(RawPacket inPkt) { /* * note that this assumes that the protocol plugin will do appropriate * filtering to ensure that this only receives packets for its * container. */ if (mode == BroadcastMode.DISABLED) { return PacketResult.IGNORED; } Packet decodedPkt = this.dataPacketService.decodeDataPacket(inPkt); if (decodedPkt instanceof Ethernet) { Ethernet eth = (Ethernet) decodedPkt; // TODO: should we offer an option to not handle ARP since the // ARPHandler already does that // ignore LLDP if (eth.getEtherType() != EtherTypes.LLDP.shortValue()) { if (eth.isBroadcast()) { broadcastPacket(inPkt); } else if (eth.isMulticast()) { // TODO: for now just treat multicast as broadcast broadcastPacket(inPkt); } } } return PacketResult.KEEP_PROCESSING; }