net.floodlightcontroller.core.util
Class AppCookie

java.lang.Object
  extended by net.floodlightcontroller.core.util.AppCookie

public class AppCookie
extends java.lang.Object

A static utility class to register flow cookiue AppIds and generating flow cookies for a particular App` An "app" is a module or piece of code that can install flows in a switch. E.g., Forwarding and StaticFlowPusher are apps. An App is identified by a 12 bit integer, the id. Furthermore, an App has a name. The id value must be unique but the same name can be registered for multiple numeric ids. TODO: should we enforce unique names This class is thread-safe. The 64 bit OpenFlow cookie field used in the following way

  • Bit 63 -- 52 (12 bit): the AppId
  • Bit 51 -- 32 (20 bit): currently unused. Set to 0.
  • Bit 31 -- 0 (32 bit): user data FIXME: The class should be a singleton. The registration method should return an instance of class. This instance should then be used to generate flow cookies. Ideally, we would also represent a flow cookie as a class instance.

    Author:
    capveg

    Constructor Summary
    AppCookie()
               
     
    Method Summary
    static int extractApp(long cookie)
              Extract the application id from a flow cookie.
    static int extractUser(long cookie)
               
    static java.lang.String getAppName(int application)
              Retrieves the application name registered for the given application id or null if the application has not been registered
    static boolean isDestIpRewriteFlagSet(long cookie)
               
    static boolean isDestMacRewriteFlagSet(long cookie)
               
    static boolean isRewriteFlagSet(long cookie)
               
    static boolean isSrcIpRewriteFlagSet(long cookie)
               
    static boolean isSrcMacRewriteFlagSet(long cookie)
               
    static long makeCookie(int application, int user)
              Encapsulate an application ID and a user block of stuff into a cookie
    static void registerApp(int application, java.lang.String appName)
              A lame attempt to prevent duplicate application ID.
    static long setDestIpRewriteFlag(long cookie)
               
    static long setDestMacRewriteFlag(long cookie)
               
    static long setSrcIpRewriteFlag(long cookie)
               
    static long setSrcMacRewriteFlag(long cookie)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    AppCookie

    public AppCookie()
    Method Detail

    makeCookie

    public static long makeCookie(int application,
                                  int user)
    Encapsulate an application ID and a user block of stuff into a cookie

    Parameters:
    application - An ID to identify the application
    user - Some application specific data
    Returns:
    a cookie for use in OFFlowMod.setCookie()
    Throws:
    java.lang.IllegalStateException - if the application has not been registered

    extractApp

    public static int extractApp(long cookie)
    Extract the application id from a flow cookie. Does not check whether the application id is registered

    Parameters:
    cookie -
    Returns:

    extractUser

    public static int extractUser(long cookie)

    isRewriteFlagSet

    public static boolean isRewriteFlagSet(long cookie)

    isSrcMacRewriteFlagSet

    public static boolean isSrcMacRewriteFlagSet(long cookie)

    isDestMacRewriteFlagSet

    public static boolean isDestMacRewriteFlagSet(long cookie)

    isSrcIpRewriteFlagSet

    public static boolean isSrcIpRewriteFlagSet(long cookie)

    isDestIpRewriteFlagSet

    public static boolean isDestIpRewriteFlagSet(long cookie)

    setSrcMacRewriteFlag

    public static long setSrcMacRewriteFlag(long cookie)

    setDestMacRewriteFlag

    public static long setDestMacRewriteFlag(long cookie)

    setSrcIpRewriteFlag

    public static long setSrcIpRewriteFlag(long cookie)

    setDestIpRewriteFlag

    public static long setDestIpRewriteFlag(long cookie)

    registerApp

    public static void registerApp(int application,
                                   java.lang.String appName)
                            throws AppIDException
    A lame attempt to prevent duplicate application ID. TODO: Once bigdb is merged, we should expose appID->appName map via REST API so CLI doesn't need a separate copy of the map.

    Parameters:
    application -
    appName -
    Throws:
    AppIDInUseException
    AppIDException

    getAppName

    public static java.lang.String getAppName(int application)
    Retrieves the application name registered for the given application id or null if the application has not been registered

    Parameters:
    application -
    Returns: