ROFL-pipeline  v0.6.0dev
Data Structures | Macros | Typedefs | Functions | Variables
physical_switch.h File Reference

Physical switch abstraction and API. More...

#include <stdlib.h>
#include <string.h>
#include "rofl.h"
#include "openflow/of_switch.h"
#include "switch_port.h"
#include "monitoring.h"
#include "platform/lock.h"

Go to the source code of this file.

Data Structures

struct  physical_switch
 Keeps the state of the physical switch (device), including ports and logical switch instances. More...
 
struct  dpid_list
 List of dpids (snapshots) More...
 

Macros

#define PHYSICAL_SWITCH_MAX_LS   64
 Maximum number of logical switches that can be instantiated. More...
 
#define PHYSICAL_SWITCH_MAX_NUM_PHY_PORTS   1024
 Maximum number of phyisical ports. More...
 
#define PHYSICAL_SWITCH_MAX_NUM_VIR_PORTS   256
 Maximum number of virtual ports. More...
 
#define PHYSICAL_SWITCH_MAX_NUM_TUN_PORTS   32
 Maximum number of tunnel ports. More...
 
#define PHYSICAL_SWITCH_MAX_NUM_META_PORTS   8
 

Typedefs

typedef void platform_physical_switch_state_t
 
typedef struct physical_switch physical_switch_t
 Keeps the state of the physical switch (device), including ports and logical switch instances. More...
 
typedef struct dpid_list dpid_list_t
 List of dpids (snapshots) More...
 

Functions

ROFL_BEGIN_DECLS rofl_result_t physical_switch_init (void)
 Initializes the physical switch. More...
 
physical_switch_tget_physical_switch (void)
 Get the reference to the (unique) physical switch. More...
 
void __set_physical_switch (physical_switch_t *sw)
 
void physical_switch_destroy (void)
 Destroys the physical switch state. More...
 
of_switch_t ** physical_switch_get_logical_switches (unsigned int *max_switches)
 Retrieves the list of logical switches within the logical switch. More...
 
rofl_result_t physical_switch_add_logical_switch (of_switch_t *sw)
 Add a logical switch to the pool. More...
 
rofl_result_t physical_switch_remove_logical_switch_by_dpid (const uint64_t dpid)
 Attemps to remove AND destroy a previously added logical switch from the pool by dpid. More...
 
rofl_result_t physical_switch_remove_logical_switch (of_switch_t *sw)
 Attemps to remove AND destroy a previously added logical switch from the pool. More...
 
of_switch_tphysical_switch_get_logical_switch_by_dpid (const uint64_t dpid)
 Attemps to retrieve a logical switch from the pool by its dpid. More...
 
of_switch_tphysical_switch_get_logical_switch_attached_to_port (const switch_port_t port)
 Attemps to retrieve the logical switch attached to the port. More...
 
switch_port_tphysical_switch_get_port_by_name (const char *name)
 Retrieve a physical switch port by name. More...
 
switch_port_t ** physical_switch_get_physical_ports (unsigned int *max_ports)
 Get the reference to the physical ports. More...
 
switch_port_t ** physical_switch_get_virtual_ports (unsigned int *max_ports)
 Get the reference to the virtual ports. More...
 
switch_port_t ** physical_switch_get_tunnel_ports (unsigned int *max_ports)
 Get the reference to the physical ports. More...
 
rofl_result_t physical_switch_add_port (switch_port_t *port)
 Adds a port to the physical_switch pool portAttempts to add a port to the physical switch pool port. More...
 
rofl_result_t physical_switch_remove_port (const char *name)
 Removes and destroys a port from the physical_switch pool referenced by its nameAttempts to remove AND destroy a port referenced by name. More...
 
switch_port_tphysical_switch_get_port_by_num (const uint64_t dpid, unsigned int port_num)
 Retrieve a port attached to logical switch with dpid at port num. More...
 
rofl_result_t get_logical_switch_ports (of_switch_t *sw, logical_switch_port_t **ports, unsigned int *num_of_ports, unsigned int *logical_sw_max_ports)
 Retrieve the physical port list. More...
 
rofl_result_t physical_switch_attach_port_to_logical_switch (switch_port_t *port, of_switch_t *sw, unsigned int *port_num)
 Attaches port to logical switch. More...
 
rofl_result_t physical_switch_attach_port_to_logical_switch_at_port_num (switch_port_t *port, of_switch_t *sw, unsigned int port_num)
 Attaches port to logical switch at port number port_num. More...
 
rofl_result_t physical_switch_detach_port_num_from_logical_switch (unsigned int port_num, of_switch_t *sw)
 Detaches port located at port_num from logical switch sw. More...
 
rofl_result_t physical_switch_detach_port_from_logical_switch (switch_port_t *port, of_switch_t *sw)
 Detaches port from logical switch sw. More...
 
rofl_result_t physical_switch_detach_all_ports_from_logical_switch (of_switch_t *sw)
 Detaches all the ports from the logical switch. More...
 
static monitoring_state_tphysical_switch_get_monitoring (void)
 Retrieves the monitoring state of the physicals witch. More...
 
switch_port_name_list_tphysical_switch_get_all_port_names (void)
 Gets a list of port names of all (currently) available port names. More...
 
switch_port_snapshot_tphysical_switch_get_port_snapshot (const char *name)
 Gets a snapshot of the current port state, if it exists. More...
 
dpid_list_tphysical_switch_get_all_lsi_dpids (void)
 Get the list of existing LSI DPIDs. More...
 
void dpid_list_destroy (dpid_list_t *list)
 Destroy a previously generated list of dpids. More...
 
of_switch_snapshot_tphysical_switch_get_logical_switch_snapshot (const uint64_t dpid)
 Generates a snapshot of the current running state of a LSI, which can be safely read and iterated over time. More...
 
void __physical_switch_generate_matching_algorithm_list (void)
 

Variables

switch_port_tflood_meta_port
 Special meta port: FLOOD. More...
 
switch_port_tin_port_meta_port
 Special meta port: IN_PORT. More...
 
switch_port_tall_meta_port
 Special meta port: ALL. More...
 

Detailed Description

Physical switch abstraction and API.

Author
Marc Sune<marc.sune (at) bisdn.de>

The physical switch is the abstraction that contains the state of a forwarding device (e.g. a physical switch, or a server).

The physical switch stores fundamentally information about:

A typical usage of the library in the case of a software switch (that is, it uses rofl-pipeline to process packets) would be:

physical_switch_init(); //This must be always the first
//Here the user MUST fill in the available ports
//E.g. interfaces
for i in num of interfaces:
switch_port_t* port = switch_port_init("eth0", true, PORT_TYPE_PHYSICAL, LOGICAL_PORT_STATE_FREE);
//Add it to the physical switch
//Now we create one or more Logical switch instances
dpid = 0x100;
//Note from this point on if any port is attached
//The switch will start to process packets so
//processing threads may be launched depending on the
//system.
//Also note I/O system for receiving and sending packets
//must be ready at least immediately after the attachment
//Now we attach a port
port = physical_switch_get_port("eth0");
//Switch should receive packets and process them

Definition in file physical_switch.h.

Typedef Documentation

typedef struct dpid_list dpid_list_t

List of dpids (snapshots)

Keeps the state of the physical switch (device), including ports and logical switch instances.

Function Documentation

dpid_list_t* physical_switch_get_all_lsi_dpids ( void  )

Get the list of existing LSI DPIDs.

List should be deleted using dpid_list_destroy()

Definition at line 633 of file physical_switch.c.

Variable Documentation

switch_port_t* all_meta_port

Special meta port: ALL.

Definition at line 20 of file physical_switch.c.

switch_port_t* flood_meta_port

Special meta port: FLOOD.

Definition at line 18 of file physical_switch.c.

switch_port_t* in_port_meta_port

Special meta port: IN_PORT.

Definition at line 19 of file physical_switch.c.