@Test @Parameters(method = "getOneSwitchOnePortFlowParameters") public void findFlowRelatedDataForOneSwitchOnePortFlowTest( int inVlan, int srcVlan, int dstVlan, List<Integer> vlansInPacket, boolean source) { createFlow(FLOW_ID, srcVlan, dstVlan, null, true, true); LldpInfoData data = createLldpInfoDataData(SWITCH_ID_1, vlansInPacket, PORT_NUMBER_1); FlowRelatedData flowRelatedData = packetService.findFlowRelatedDataForOneSwitchFlow(data); assertEquals(FLOW_ID, flowRelatedData.getFlowId()); assertEquals(inVlan, flowRelatedData.getOriginalVlan()); assertEquals(source, flowRelatedData.getSource()); }
@VisibleForTesting FlowRelatedData findFlowRelatedDataForOneSwitchFlow(ConnectedDevicePacketBase data) { int outputVlan = data.getVlans().isEmpty() ? 0 : data.getVlans().get(0); int customerVlan = data.getVlans().size() > 1 ? data.getVlans().get(1) : 0; Flow flow = getFlowBySwitchIdInPortAndOutVlan( data.getSwitchId(), data.getPortNumber(), outputVlan, getPacketName(data)); if (flow == null) { return null; } if (!flow.isOneSwitchFlow()) { log.warn("Found NOT one switch flow {} by SwitchId {}, port number {}, vlan {} from {} packet", flow.getFlowId(), data.getSwitchId(), data.getPortNumber(), outputVlan, getPacketName(data)); return null; } if (flow.getSrcPort() == flow.getDestPort()) { return getOneSwitchOnePortFlowRelatedData(flow, outputVlan, customerVlan, data); } if (data.getPortNumber() == flow.getSrcPort()) { if (flow.getSrcVlan() == FULL_PORT_VLAN) { if (flow.getDestVlan() == FULL_PORT_VLAN) { return new FlowRelatedData(outputVlan, flow.getFlowId(), true); } else { return new FlowRelatedData(customerVlan, flow.getFlowId(), true); } } else { return new FlowRelatedData(flow.getSrcVlan(), flow.getFlowId(), true); } } else if (data.getPortNumber() == flow.getDestPort()) { if (flow.getDestVlan() == FULL_PORT_VLAN) { if (flow.getSrcVlan() == FULL_PORT_VLAN) { return new FlowRelatedData(outputVlan, flow.getFlowId(), false); } else { return new FlowRelatedData(customerVlan, flow.getFlowId(), false); } } else { return new FlowRelatedData(flow.getDestVlan(), flow.getFlowId(), false); } } log.warn("Got LLDP packet from one switch flow {} with non-src/non-dst vlan {}. SwitchId {}, " + "port number {}", flow.getFlowId(), outputVlan, data.getSwitchId(), data.getPortNumber()); return null; }
PacketService { @VisibleForTesting FlowRelatedData findFlowRelatedDataForOneSwitchFlow(ConnectedDevicePacketBase data) { int outputVlan = data.getVlans().isEmpty() ? 0 : data.getVlans().get(0); int customerVlan = data.getVlans().size() > 1 ? data.getVlans().get(1) : 0; Flow flow = getFlowBySwitchIdInPortAndOutVlan( data.getSwitchId(), data.getPortNumber(), outputVlan, getPacketName(data)); if (flow == null) { return null; } if (!flow.isOneSwitchFlow()) { log.warn("Found NOT one switch flow {} by SwitchId {}, port number {}, vlan {} from {} packet", flow.getFlowId(), data.getSwitchId(), data.getPortNumber(), outputVlan, getPacketName(data)); return null; } if (flow.getSrcPort() == flow.getDestPort()) { return getOneSwitchOnePortFlowRelatedData(flow, outputVlan, customerVlan, data); } if (data.getPortNumber() == flow.getSrcPort()) { if (flow.getSrcVlan() == FULL_PORT_VLAN) { if (flow.getDestVlan() == FULL_PORT_VLAN) { return new FlowRelatedData(outputVlan, flow.getFlowId(), true); } else { return new FlowRelatedData(customerVlan, flow.getFlowId(), true); } } else { return new FlowRelatedData(flow.getSrcVlan(), flow.getFlowId(), true); } } else if (data.getPortNumber() == flow.getDestPort()) { if (flow.getDestVlan() == FULL_PORT_VLAN) { if (flow.getSrcVlan() == FULL_PORT_VLAN) { return new FlowRelatedData(outputVlan, flow.getFlowId(), false); } else { return new FlowRelatedData(customerVlan, flow.getFlowId(), false); } } else { return new FlowRelatedData(flow.getDestVlan(), flow.getFlowId(), false); } } log.warn("Got LLDP packet from one switch flow {} with non-src/non-dst vlan {}. SwitchId {}, " + "port number {}", flow.getFlowId(), outputVlan, data.getSwitchId(), data.getPortNumber()); return null; } }
PacketService { @VisibleForTesting FlowRelatedData findFlowRelatedDataForOneSwitchFlow(ConnectedDevicePacketBase data) { int outputVlan = data.getVlans().isEmpty() ? 0 : data.getVlans().get(0); int customerVlan = data.getVlans().size() > 1 ? data.getVlans().get(1) : 0; Flow flow = getFlowBySwitchIdInPortAndOutVlan( data.getSwitchId(), data.getPortNumber(), outputVlan, getPacketName(data)); if (flow == null) { return null; } if (!flow.isOneSwitchFlow()) { log.warn("Found NOT one switch flow {} by SwitchId {}, port number {}, vlan {} from {} packet", flow.getFlowId(), data.getSwitchId(), data.getPortNumber(), outputVlan, getPacketName(data)); return null; } if (flow.getSrcPort() == flow.getDestPort()) { return getOneSwitchOnePortFlowRelatedData(flow, outputVlan, customerVlan, data); } if (data.getPortNumber() == flow.getSrcPort()) { if (flow.getSrcVlan() == FULL_PORT_VLAN) { if (flow.getDestVlan() == FULL_PORT_VLAN) { return new FlowRelatedData(outputVlan, flow.getFlowId(), true); } else { return new FlowRelatedData(customerVlan, flow.getFlowId(), true); } } else { return new FlowRelatedData(flow.getSrcVlan(), flow.getFlowId(), true); } } else if (data.getPortNumber() == flow.getDestPort()) { if (flow.getDestVlan() == FULL_PORT_VLAN) { if (flow.getSrcVlan() == FULL_PORT_VLAN) { return new FlowRelatedData(outputVlan, flow.getFlowId(), false); } else { return new FlowRelatedData(customerVlan, flow.getFlowId(), false); } } else { return new FlowRelatedData(flow.getDestVlan(), flow.getFlowId(), false); } } log.warn("Got LLDP packet from one switch flow {} with non-src/non-dst vlan {}. SwitchId {}, " + "port number {}", flow.getFlowId(), outputVlan, data.getSwitchId(), data.getPortNumber()); return null; } PacketService(PersistenceManager persistenceManager); }
PacketService { @VisibleForTesting FlowRelatedData findFlowRelatedDataForOneSwitchFlow(ConnectedDevicePacketBase data) { int outputVlan = data.getVlans().isEmpty() ? 0 : data.getVlans().get(0); int customerVlan = data.getVlans().size() > 1 ? data.getVlans().get(1) : 0; Flow flow = getFlowBySwitchIdInPortAndOutVlan( data.getSwitchId(), data.getPortNumber(), outputVlan, getPacketName(data)); if (flow == null) { return null; } if (!flow.isOneSwitchFlow()) { log.warn("Found NOT one switch flow {} by SwitchId {}, port number {}, vlan {} from {} packet", flow.getFlowId(), data.getSwitchId(), data.getPortNumber(), outputVlan, getPacketName(data)); return null; } if (flow.getSrcPort() == flow.getDestPort()) { return getOneSwitchOnePortFlowRelatedData(flow, outputVlan, customerVlan, data); } if (data.getPortNumber() == flow.getSrcPort()) { if (flow.getSrcVlan() == FULL_PORT_VLAN) { if (flow.getDestVlan() == FULL_PORT_VLAN) { return new FlowRelatedData(outputVlan, flow.getFlowId(), true); } else { return new FlowRelatedData(customerVlan, flow.getFlowId(), true); } } else { return new FlowRelatedData(flow.getSrcVlan(), flow.getFlowId(), true); } } else if (data.getPortNumber() == flow.getDestPort()) { if (flow.getDestVlan() == FULL_PORT_VLAN) { if (flow.getSrcVlan() == FULL_PORT_VLAN) { return new FlowRelatedData(outputVlan, flow.getFlowId(), false); } else { return new FlowRelatedData(customerVlan, flow.getFlowId(), false); } } else { return new FlowRelatedData(flow.getDestVlan(), flow.getFlowId(), false); } } log.warn("Got LLDP packet from one switch flow {} with non-src/non-dst vlan {}. SwitchId {}, " + "port number {}", flow.getFlowId(), outputVlan, data.getSwitchId(), data.getPortNumber()); return null; } PacketService(PersistenceManager persistenceManager); void handleLldpData(LldpInfoData data); void handleArpData(ArpInfoData data); }
PacketService { @VisibleForTesting FlowRelatedData findFlowRelatedDataForOneSwitchFlow(ConnectedDevicePacketBase data) { int outputVlan = data.getVlans().isEmpty() ? 0 : data.getVlans().get(0); int customerVlan = data.getVlans().size() > 1 ? data.getVlans().get(1) : 0; Flow flow = getFlowBySwitchIdInPortAndOutVlan( data.getSwitchId(), data.getPortNumber(), outputVlan, getPacketName(data)); if (flow == null) { return null; } if (!flow.isOneSwitchFlow()) { log.warn("Found NOT one switch flow {} by SwitchId {}, port number {}, vlan {} from {} packet", flow.getFlowId(), data.getSwitchId(), data.getPortNumber(), outputVlan, getPacketName(data)); return null; } if (flow.getSrcPort() == flow.getDestPort()) { return getOneSwitchOnePortFlowRelatedData(flow, outputVlan, customerVlan, data); } if (data.getPortNumber() == flow.getSrcPort()) { if (flow.getSrcVlan() == FULL_PORT_VLAN) { if (flow.getDestVlan() == FULL_PORT_VLAN) { return new FlowRelatedData(outputVlan, flow.getFlowId(), true); } else { return new FlowRelatedData(customerVlan, flow.getFlowId(), true); } } else { return new FlowRelatedData(flow.getSrcVlan(), flow.getFlowId(), true); } } else if (data.getPortNumber() == flow.getDestPort()) { if (flow.getDestVlan() == FULL_PORT_VLAN) { if (flow.getSrcVlan() == FULL_PORT_VLAN) { return new FlowRelatedData(outputVlan, flow.getFlowId(), false); } else { return new FlowRelatedData(customerVlan, flow.getFlowId(), false); } } else { return new FlowRelatedData(flow.getDestVlan(), flow.getFlowId(), false); } } log.warn("Got LLDP packet from one switch flow {} with non-src/non-dst vlan {}. SwitchId {}, " + "port number {}", flow.getFlowId(), outputVlan, data.getSwitchId(), data.getPortNumber()); return null; } PacketService(PersistenceManager persistenceManager); void handleLldpData(LldpInfoData data); void handleArpData(ArpInfoData data); static final int FULL_PORT_VLAN; }