Bug 773: SimpleForwardingImpl hits NPE when .frm member is null and new host is...
[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.packet.RawPacket;
12
13
14 /**
15  * Provides support for flooding/broadcasting of packets.
16  */
17 public interface IBroadcastHandler {
18
19     /**
20      * The mode to select which ports to broadcast a given packet. See the
21      * individual modes for the expected behavior.
22      */
23     static enum BroadcastMode {
24         /**
25          * Turn off broadcast handling and ignore all received data packets.
26          */
27         DISABLED,
28
29         /**
30          * sends broadcast packets out ports where there are known hosts as
31          * discovered by {@link ITopologyManager#getNodeConnectorWithHost}.
32          */
33         BROADCAST_TO_HOSTS,
34
35         /**
36          * sends broadcast packets out all non-internal links as discovered by
37          * {@link ITopologyManager#isInternal}. Also ignores ports which have
38          * {@link NodeConnector#getType} of "SW" indicating OFPP_LOCAL.
39          */
40         BROADCAST_TO_NONINTERNAL,
41
42         /**
43          * sends broadcast packets out the ports specified by an external
44          * implementation of {@link IBroadcastPortSelector}.
45          */
46         EXTERNAL_QUERY
47     };
48
49     /**
50      * Set the {@link BroadcastMode} for this {@link IBroadcastHandler}.
51      * @param m
52      */
53     void setMode(BroadcastMode m);
54
55     /**
56      * Safely flood/broadcast a {@link RawPacket} received on a given
57      * {@link NodeConnector}.
58      *
59      * @param pkt
60      *            The packet to flood/broadcast
61      * @return <tt>true</tt> if the broadcast is successful, <tt>false</tt>
62      *         otherwise
63      */
64     boolean broadcastPacket(RawPacket pkt);
65 }