ROFL-pipeline  v0.6.0dev
of_switch.h
Go to the documentation of this file.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef __OF_SWITCH_H__
6 #define __OF_SWITCH_H__
7 
8 #include <inttypes.h>
9 #include "rofl.h"
10 #include "../switch_port.h"
11 
24 typedef enum{
25  OF_VERSION_10 = 0x01,
26  OF_VERSION_11 = 0x02,
27  OF_VERSION_12 = 0x03,
28  OF_VERSION_13 = 0x04,
29  //Add more here...
30 }of_version_t;
31 
32 #define __OF_VERSION_MAX (OF_VERSION_13+1)
33 
34 //String for nice dumping
35 extern const char* of_version_str[__OF_VERSION_MAX];
36 
37 #ifndef LOGICAL_SWITCH_MAX_LOG_PORTS
38  #define LOGICAL_SWITCH_MAX_LOG_PORTS 512 // 511, 0 slot NEVER used (has to be less than OF1X_PORT_MAX)
39 #endif
40 
41 //Max length of the LSI name
42 #define LOGICAL_SWITCH_MAX_LEN_NAME 32
43 
44 //Platform dependent opaque state
45 typedef void of_switch_platform_state_t;
46 
47 //Fwd decl
48 struct datapacket;
49 struct of_switch;
50 
55 typedef struct of_switch{
56 
57  //Make sure ALL ofXX_switch_t contain this three fields
58  //at the VERY beginning
59 
60  /* This part is common and MUST be at the very beginning */
61  of_version_t of_ver;
62  uint64_t dpid;
63  char name[LOGICAL_SWITCH_MAX_LEN_NAME];
64  unsigned int max_ports;
65  unsigned int num_of_ports;
66 
67  //Switch logical ports
68  logical_switch_port_t logical_ports[LOGICAL_SWITCH_MAX_LOG_PORTS];
69 
75  of_switch_platform_state_t* platform_state;
76  /* End of common part */
77 
78  //Version specific content...
80 
85 
86 typedef int of_packet_in_reason_t;
87 
88 //C++ extern C
89 ROFL_BEGIN_DECLS
90 
91 //Wrapping destroy
107 rofl_result_t of_destroy_switch(const of_switch_t* sw);
108 
109 
115 rofl_result_t of_reconfigure_switch(of_switch_t* sw, of_version_t version);
116 
117 //Wrapping timers
132 
133 //Wrapping port management
134 rofl_result_t __of_attach_port_to_switch_at_port_num(of_switch_t* sw, unsigned int port_num, switch_port_t* port);
135 rofl_result_t __of_attach_port_to_switch(of_switch_t* sw, switch_port_t* port, unsigned int* port_num);
136 rofl_result_t __of_detach_port_from_switch_by_port_num(of_switch_t* sw, unsigned int port_num);
137 rofl_result_t __of_detach_port_from_switch(of_switch_t* sw, switch_port_t* port);
138 rofl_result_t __of_detach_all_ports_from_switch(of_switch_t* sw);
139 
145 rofl_result_t of_get_switch_matching_algorithms(of_version_t of_version, const char * const** name_list, int *count);
146 
147 //
148 // Snapshots
149 //
150 
151 //Creates a snapshot of the running of LSI
152 of_switch_snapshot_t* __of_switch_get_snapshot(of_switch_t* sw);
153 
159 
160 //C++ extern C
161 ROFL_END_DECLS
162 
163 #endif //OF_SWITCH
OpenFlow-enabled switch abstraction (version-indepedent part).
Definition: of_switch.h:55
rofl_result_t of_reconfigure_switch(of_switch_t *sw, of_version_t version)
Reconfigures the pipeline to behave as an OF specific version pipeline.
Definition: of_switch.c:27
void of_switch_destroy_snapshot(of_switch_snapshot_t *snapshot)
Destroy a previously generated snapshot.
Definition: of_switch.c:139
of_switch_t of_switch_snapshot_t
Switch snapshot.
Definition: of_switch.h:84
of_switch_platform_state_t * platform_state
Platform agnostic state.
Definition: of_switch.h:75
Port abstraction.
Definition: switch_port.h:145
struct of_switch of_switch_t
OpenFlow-enabled switch abstraction (version-indepedent part).
void of_process_pipeline_tables_timeout_expirations(const of_switch_t *sw)
Processes flow entry expirations in all the pipeline tables of the switch.
Definition: of_switch.c:40
rofl_result_t of_get_switch_matching_algorithms(of_version_t of_version, const char *const **name_list, int *count)
Retrieves the list of available matching algorithms available for OF version of_version.
Definition: of_switch.c:110
Data packet abstraction.
Definition: datapacket.h:49
ROFL_BEGIN_DECLS rofl_result_t of_destroy_switch(const of_switch_t *sw)
Destroys an OpenFlow logical switch.
Definition: of_switch.c:15