8140019622341187c0b392dd123a2a28cdf87764
[controller.git] / opendaylight / samples / simpleforwarding / src / main / java / org / opendaylight / controller / samples / simpleforwarding / IBroadcastHandler.java
1 /*
2  * Copyright (c) 2013 IBM and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.samples.simpleforwarding;
10
11 import org.opendaylight.controller.sal.core.NodeConnector;
12 import org.opendaylight.controller.sal.packet.RawPacket;
13 import org.opendaylight.controller.topologymanager.ITopologyManager;
14
15 /**
16  * Provides support for flooding/broadcasting of packets.
17  */
18 public interface IBroadcastHandler {
19
20     /**
21      * The mode to select which ports to broadcast a given packet. See the
22      * individual modes for the expected behavior.
23      */
24     static enum BroadcastMode {
25         /**
26          * Turn off broadcast handling and ignore all received data packets.
27          */
28         DISABLED,
29
30         /**
31          * sends broadcast packets out ports where there are known hosts as
32          * discovered by {@link ITopologyManager#getNodeConnectorWithHost}.
33          */
34         BROADCAST_TO_HOSTS,
35
36         /**
37          * sends broadcast packets out all non-internal links as discovered by
38          * {@link ITopologyManager#isInternal}. Also ignores ports which have
39          * {@link NodeConnector#getType} of "SW" indicating OFPP_LOCAL.
40          */
41         BROADCAST_TO_NONINTERNAL,
42
43         /**
44          * sends broadcast packets out the ports specified by an external
45          * implementation of {@link IBroadcastPortSelector}.
46          */
47         EXTERNAL_QUERY
48     };
49
50     /**
51      * Set the {@link BroadcastMode} for this {@link IBroadcastHandler}.
52      * @param m
53      */
54     void setMode(BroadcastMode m);
55
56     /**
57      * Safely flood/broadcast a {@link RawPacket} received on a given
58      * {@link NodeConnector}.
59      *
60      * @param pkt
61      *            The packet to flood/broadcast
62      * @return <tt>true</tt> if the broadcast is successful, <tt>false</tt>
63      *         otherwise
64      */
65     boolean broadcastPacket(RawPacket pkt);
66 }