ROFL-pipeline
v0.6.0dev
|
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_t * | get_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_t * | physical_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_t * | physical_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_t * | physical_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_t * | physical_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_t * | physical_switch_get_monitoring (void) |
Retrieves the monitoring state of the physicals witch. More... | |
switch_port_name_list_t * | physical_switch_get_all_port_names (void) |
Gets a list of port names of all (currently) available port names. More... | |
switch_port_snapshot_t * | physical_switch_get_port_snapshot (const char *name) |
Gets a snapshot of the current port state, if it exists. More... | |
dpid_list_t * | physical_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_t * | physical_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_t * | flood_meta_port |
Special meta port: FLOOD. More... | |
switch_port_t * | in_port_meta_port |
Special meta port: IN_PORT. More... | |
switch_port_t * | all_meta_port |
Special meta port: ALL. More... | |
Physical switch abstraction and API.
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:
System ports(net interfaces): the ports availableon the system. This interfaces may be physical ports, or virtual, depending on the system. The semantic of a virtual port is strictly bound to the system in which is running (take a look at switch_port.h for more details).
The discovery of the system ports is up to the library user. It must be done during initialization and before ANY logical switch has been added to the physical switch.
Logical switches instances: a logical switch instance is a runnable instance of a switch that uses one or more of the ports available in the phyisical system. In other words, a logical switch is what OF protocol defines as "datapath", but only concerning forwarding (excluding the OF endpoint).
Logical switches are of type of_switch, and may be created using the version specific init/destroy functions provided by the library. (e.g. of1x_init_switch). Immediately after, they must be added to the physical switch. Note that instances not added to the physical switch are completely meaningless(*).
Once added the ports can be attached to the logical switch, and eventually, in the case of the software switches, start to process packets using the call of_process_packet_pipeline.
A typical usage of the library in the case of a software switch (that is, it uses rofl-pipeline to process packets) would be:
Definition in file physical_switch.h.
typedef struct dpid_list dpid_list_t |
List of dpids (snapshots)
typedef struct physical_switch physical_switch_t |
Keeps the state of the physical switch (device), including ports and logical switch instances.
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.
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.