2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow;
11 import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.applyActionIns;
12 import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.instructions;
13 import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.nxOutputRegAction;
15 import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.OfContext;
16 import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.OfWriter;
17 import org.opendaylight.groupbasedpolicy.resolver.PolicyInfo;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg7;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * Manage the table that assigns source endpoint group, bridge domain, and
27 * router domain to registers to be used by other tables.
29 public class ExternalMapper extends FlowTable {
31 protected static final Logger LOG = LoggerFactory.getLogger(ExternalMapper.class);
33 public static short TABLE_ID;
35 public ExternalMapper(OfContext ctx, short tableId) {
41 public short getTableId() {
46 public void sync(NodeId nodeId, PolicyInfo policyInfo, OfWriter ofWriter) throws Exception {
48 if (ctx.getSwitchManager().getExternalPorts(nodeId) == null) {
49 LOG.trace("No external ports found for node: {}", nodeId);
53 ofWriter.writeFlow(nodeId, TABLE_ID, dropFlow(Integer.valueOf(1), null, TABLE_ID));
56 * Default Egress flow. Other methods may write to this table to augment egress
57 * functionality, such as bypassing/utilising the NAT table, or ServiceFunctionChaining
59 ofWriter.writeFlow(nodeId, TABLE_ID, defaultFlow());
63 private Flow defaultFlow() {
64 FlowId flowid = FlowIdUtils.newFlowId(TABLE_ID, "defaultExternalFlow", null);
65 Flow flow = base().setPriority(100)
67 .setInstructions(instructions(applyActionIns(nxOutputRegAction(NxmNxReg7.class))))