@Override public String toString() { return type.toString(); }
/** * Throw and handle the invalid value exception * * @param value * @return void */ private void throwValueException(int value) { String error = "Invalid field value assignement. For type: " + type.getId() + " Expected: " + type.getRange() + ", Got: 0x" + Integer.toHexString(value); try { throw new Exception(error); } catch (Exception e) { logger.error(e.getMessage()); if (debug) { logger.error("", e); } } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((type == null) ? 0 : type.calculateConsistentHashCode()); return result; }
/** * Returns the id of this action * * @return String */ public String getId() { return type.getId(); }
/** * Checks if the passed value is in the valid range for this action * * @param value * @return boolean */ protected void checkValue(int value) { if (type.isValidTarget(value) == false) { isValid = false; throwValueException(value); } }
private boolean actionCompare(String name, ActionType type) { return name.equals(type.getId().toLowerCase()); }
/** * Checks if the passed value is in the valid range for the passed action * type This method is used for complex Action types which are * * @param value * @return boolean */ protected void checkValue(ActionType type, int value) { if (type.isValidTarget(value) == false) { isValid = false; throwValueException(value); } }
for (Class<? extends Action> action : actions) { if (action.isAssignableFrom(org.opendaylight.controller.sal.action.Drop.class)) { result.put(ActionType.DROP.toString(), "Drop"); } else if (action.isAssignableFrom(org.opendaylight.controller.sal.action.Loopback.class)) { result.put(ActionType.LOOPBACK.toString(), "Loopback"); } else if (action.isAssignableFrom(org.opendaylight.controller.sal.action.Flood.class)) { result.put(ActionType.FLOOD.toString(), "Flood"); } else if (action.isAssignableFrom(org.opendaylight.controller.sal.action.FloodAll.class)) { result.put(ActionType.FLOOD_ALL.toString(), "Flood All"); } else if (action.isAssignableFrom(org.opendaylight.controller.sal.action.Controller.class)) { result.put(ActionType.CONTROLLER.toString(), "Controller"); } else if (action.isAssignableFrom(org.opendaylight.controller.sal.action.SwPath.class)) { result.put(ActionType.SW_PATH.toString(), "Software Path"); } else if (action.isAssignableFrom(org.opendaylight.controller.sal.action.HwPath.class)) { result.put(ActionType.HW_PATH.toString(), "Hardware Path"); } else if (action.isAssignableFrom(org.opendaylight.controller.sal.action.Output.class)) { result.put(ActionType.OUTPUT.toString(), "Output"); } else if (action.isAssignableFrom(org.opendaylight.controller.sal.action.Enqueue.class)) { result.put(ActionType.ENQUEUE.toString(), "Enqueue"); } else if (action.isAssignableFrom(org.opendaylight.controller.sal.action.SetDlSrc.class)) { result.put(ActionType.SET_DL_SRC.toString(), "Set Datalayer Source Address"); } else if (action.isAssignableFrom(org.opendaylight.controller.sal.action.SetDlDst.class)) { result.put(ActionType.SET_DL_DST.toString(), "Set Datalayer Destination Address"); } else if (action.isAssignableFrom(org.opendaylight.controller.sal.action.SetVlanId.class)) { result.put(ActionType.SET_VLAN_ID.toString(), "Set VLAN ID"); } else if (action.isAssignableFrom(org.opendaylight.controller.sal.action.SetVlanPcp.class)) { result.put(ActionType.SET_VLAN_PCP.toString(), "Set VLAN Priority"); } else if (action.isAssignableFrom(org.opendaylight.controller.sal.action.SetVlanCfi.class)) { result.put(ActionType.SET_VLAN_CFI.toString(), "Set VLAN CFI");
sstr = Pattern.compile(ActionType.DROP.toString()).matcher(actiongrp); if (sstr.matches()) { actionList.add(new Drop()); sstr = Pattern.compile(ActionType.LOOPBACK.toString()).matcher(actiongrp); if (sstr.matches()) { actionList.add(new Loopback()); sstr = Pattern.compile(ActionType.FLOOD.toString()).matcher(actiongrp); if (sstr.matches()) { actionList.add(new Flood()); sstr = Pattern.compile(ActionType.FLOOD_ALL.toString()).matcher(actiongrp); if (sstr.matches()) { actionList.add(new FloodAll()); sstr = Pattern.compile(ActionType.SW_PATH.toString()).matcher(actiongrp); if (sstr.matches()) { actionList.add(new SwPath()); sstr = Pattern.compile(ActionType.HW_PATH.toString()).matcher(actiongrp); if (sstr.matches()) { actionList.add(new HwPath()); sstr = Pattern.compile(ActionType.CONTROLLER.toString()).matcher(actiongrp); if (sstr.matches()) { actionList.add(new Controller()); sstr = Pattern.compile(ActionType.SET_VLAN_ID.toString() + "=(.*)").matcher(actiongrp);
sstr = Pattern.compile(ActionType.SET_NW_SRC.toString() + "=(.*)").matcher(actiongrp); if (sstr.matches()) { if (!NetUtils.isIPv4AddressValid(sstr.group(1))) { sstr = Pattern.compile(ActionType.SET_NW_DST.toString() + "=(.*)").matcher(actiongrp); if (sstr.matches()) { if (!NetUtils.isIPv4AddressValid(sstr.group(1))) { sstr = Pattern.compile(ActionType.SET_VLAN_ID.toString() + "=(.*)").matcher(actiongrp); if (sstr.matches()) { if ((sstr.group(1) != null) && !isVlanIdValid(sstr.group(1))) { sstr = Pattern.compile(ActionType.SET_VLAN_PCP.toString() + "=(.*)").matcher(actiongrp); if (sstr.matches()) { if ((sstr.group(1) != null) && !isVlanPriorityValid(sstr.group(1))) { sstr = Pattern.compile(ActionType.SET_DL_SRC.toString() + "=(.*)").matcher(actiongrp); if (sstr.matches()) { if ((sstr.group(1) != null) && !isL2AddressValid(sstr.group(1))) { sstr = Pattern.compile(ActionType.SET_DL_DST.toString() + "=(.*)").matcher(actiongrp); if (sstr.matches()) { if ((sstr.group(1) != null) && !isL2AddressValid(sstr.group(1))) { sstr = Pattern.compile(ActionType.SET_NW_TOS.toString() + "=(.*)").matcher(actiongrp); if (sstr.matches()) { if ((sstr.group(1) != null) && !isTOSBitsValid(sstr.group(1))) { sstr = Pattern.compile(ActionType.SET_TP_SRC.toString() + "=(.*)").matcher(actiongrp);
actions.append(action.getType().toString()).append(" = ").append(ao.getPort().getNodeConnectorIdAsString()).append("<br>"); } else if (action instanceof SetVlanId) { SetVlanId av = (SetVlanId) action; String outVlanId = String.valueOf(av.getVlanId()); actions.append(action.getType().toString()).append(" = ").append(outVlanId).append("<br>"); } else if (action instanceof SetDlSrc) { SetDlSrc ads = (SetDlSrc) action; actions.append(action.getType().toString()).append(" = ").append(HexEncode.bytesToHexStringFormat(ads.getDlAddress())).append("<br>"); } else if (action instanceof SetDlDst) { SetDlDst add = (SetDlDst) action; actions.append(action.getType().toString()).append(" = ").append(HexEncode.bytesToHexStringFormat(add.getDlAddress())).append("<br>"); } else if (action instanceof SetNwSrc) { SetNwSrc ans = (SetNwSrc) action; actions.append(action.getType().toString()).append(" = ").append(ans.getAddressAsString()).append("<br>"); } else if (action instanceof SetNwDst) { SetNwDst and = (SetNwDst) action; actions.append(action.getType().toString()).append(" = ").append(and.getAddressAsString()).append("<br>"); } else if (action instanceof SetNwTos) { SetNwTos ant = (SetNwTos) action; actions.append(action.getType().toString()).append(" = ").append(ant.getNwTos()).append("<br>"); } else if (action instanceof SetTpSrc) { SetTpSrc ads = (SetTpSrc) action; actions.append(action.getType().toString()).append(" = ").append(ads.getPort()).append("<br>"); } else if (action instanceof SetTpDst) { SetTpDst atd = (SetTpDst) action; actions.append(action.getType().toString()).append(" = ").append(atd.getPort()).append("<br>"); } else if (action instanceof SetVlanPcp) { SetVlanPcp avp = (SetVlanPcp) action; actions.append(action.getType().toString()).append(" = ").append(avp.getPcp()).append("<br>");