ROFL-pipeline  v0.6.0dev
of_switch.c
1 #include "of_switch.h"
2 #include "../common/datapacket.h"
3 
4 //OpenFlow specific switch implementations
7 //Add more here...
8 
9 #include "openflow1x/pipeline/matching_algorithms/matching_algorithms.h"
10 
11 //Version strings
12 const char* of_version_str[__OF_VERSION_MAX] = {"INVALID", "1.0", "1.1", "1.2", "1.3"};
13 
14 //Wrapping destroy
15 rofl_result_t of_destroy_switch(const of_switch_t* sw){
16 
17  switch(sw->of_ver){
18  case OF_VERSION_10:
19  case OF_VERSION_12:
20  case OF_VERSION_13:
21  return __of1x_destroy_switch(((of1x_switch_t*)sw));
22  default:
23  return ROFL_FAILURE;
24  }
25 }
26 
27 rofl_result_t of_reconfigure_switch(of_switch_t* sw, of_version_t version){
28 
29  if(version == OF_VERSION_10 || version == OF_VERSION_12 || version == OF_VERSION_13){
30  return __of1x_reconfigure_switch((of1x_switch_t*)sw, version);
31  }else{
32  //Add other pipeline versions here..
33  }
34 
35  return ROFL_FAILURE;
36 }
37 
38 
39 //Wrapping of timers processing
41 
42  switch(sw->of_ver){
43  case OF_VERSION_10:
44  case OF_VERSION_12:
45  case OF_VERSION_13:
46  __of1x_process_pipeline_tables_timeout_expirations(&((of1x_switch_t*)sw)->pipeline);
47  break;
48  default:
49  //return ROFL_FAILURE;
50  break;
51  }
52 }
53 
54 
55 rofl_result_t __of_attach_port_to_switch_at_port_num(of_switch_t* sw, unsigned int port_num, switch_port_t* port){
56  switch(sw->of_ver){
57  case OF_VERSION_10:
58  case OF_VERSION_12:
59  case OF_VERSION_13:
60  return __of1x_attach_port_to_switch_at_port_num((of1x_switch_t*)sw, port_num, port);
61  default:
62  return ROFL_FAILURE;
63  }
64 }
65 
66 rofl_result_t __of_attach_port_to_switch(of_switch_t* sw, switch_port_t* port, unsigned int* port_num){
67  switch(sw->of_ver){
68  case OF_VERSION_10:
69  case OF_VERSION_12:
70  case OF_VERSION_13:
71  return __of1x_attach_port_to_switch((of1x_switch_t*)sw,port, port_num);
72  default:
73  return ROFL_FAILURE;
74  }
75 }
76 
77 rofl_result_t __of_detach_port_from_switch_by_port_num(of_switch_t* sw, unsigned int port_num){
78  switch(sw->of_ver){
79  case OF_VERSION_10:
80  case OF_VERSION_12:
81  case OF_VERSION_13:
82  return __of1x_detach_port_from_switch_by_port_num((of1x_switch_t*)sw, port_num);
83  default:
84  return ROFL_FAILURE;
85  }
86 }
87 
88 rofl_result_t __of_detach_port_from_switch(of_switch_t* sw, switch_port_t* port){
89  switch(sw->of_ver){
90  case OF_VERSION_10:
91  case OF_VERSION_12:
92  case OF_VERSION_13:
93  return __of1x_detach_port_from_switch((of1x_switch_t*)sw, port);
94  default:
95  return ROFL_FAILURE;
96  }
97 }
98 
99 rofl_result_t __of_detach_all_ports_from_switch(of_switch_t* sw){
100  switch(sw->of_ver){
101  case OF_VERSION_10:
102  case OF_VERSION_12:
103  case OF_VERSION_13:
104  return __of1x_detach_all_ports_from_switch((of1x_switch_t*)sw);
105  default:
106  return ROFL_FAILURE;
107  }
108 }
109 
110 rofl_result_t of_get_switch_matching_algorithms(of_version_t of_version, const char * const** name_list, int *count){
111 
112  switch (of_version) {
113  case OF_VERSION_10:
114  case OF_VERSION_12:
115  case OF_VERSION_13:
116  {
117  static const char * names[] = OF1X_MATCHING_ALGORITHM_NAMES;
118 
119  *count = of1x_matching_algorithm_count;
120  *name_list = names;
121  return ROFL_SUCCESS;
122  }
123  default:
124  return ROFL_FAILURE;
125  }
126 }
127 
128 
129 of_switch_snapshot_t* __of_switch_get_snapshot(of_switch_t* sw){
130  switch (sw->of_ver){
131  case OF_VERSION_10:
132  case OF_VERSION_12:
133  case OF_VERSION_13:
134  return (of_switch_snapshot_t*)__of1x_switch_get_snapshot((of1x_switch_t*)sw);
135  default:
136  return NULL;
137  }
138 }
140  switch (snapshot->of_ver){
141  case OF_VERSION_10:
142  case OF_VERSION_12:
143  case OF_VERSION_13:
144  __of1x_switch_destroy_snapshot((of1x_switch_snapshot_t*)snapshot);
145  default:
146  break;
147  }
148 }
OpenFlow-enabled switch abstraction (version-indepedent part).
Definition: of_switch.h:55
OpenFlow v1.0, 1.2 and 1.3.2 pipeline abstraction.
OpenFlow-enabled v1.0, 1.2 and 1.3.2 switch abstraction.
Definition: of1x_switch.h:28
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
Port abstraction.
Definition: switch_port.h:145
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
OpenFlow v1.0, 1.2 and 1.3.2 logical switch abstraction.
OpenFlow logical switch meta-abstraction.
rofl_result_t of_destroy_switch(const of_switch_t *sw)
Destroys an OpenFlow logical switch.
Definition: of_switch.c:15