ROFL-hal  v0.6.0dev
driver.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 HAL_DRIVER_H
6 #define HAL_DRIVER_H
7 
8 #include <stdbool.h>
9 #include <rofl/datapath/pipeline/monitoring.h>
10 #include <rofl/datapath/pipeline/physical_switch.h>
11 #include <rofl/datapath/pipeline/switch_port.h>
12 #include <rofl/datapath/pipeline/openflow/of_switch.h>
13 #include <rofl/datapath/pipeline/openflow/openflow1x/pipeline/matching_algorithms/matching_algorithms.h>
14 
15 #include "hal.h"
16 #include "hal_utils.h"
17 #include "extensions/extensions.h"
18 
26 //driver_info_t char array lengths
27 #define DRIVER_CODE_NAME_MAX_LEN 16
28 #define DRIVER_VERSION_MAX_LEN 16
29 #define DRIVER_DESCRIPTION_MAX_LEN 2048*4
30 #define DRIVER_USAGE_MAX_LEN 2048*4
31 #define DRIVER_EXTRA_PARAMS_MAX_LEN 2048*4
32 
37 typedef struct{
41  char code_name[DRIVER_CODE_NAME_MAX_LEN];
45  char version[DRIVER_VERSION_MAX_LEN];
49  char description[DRIVER_DESCRIPTION_MAX_LEN];
53  char usage[DRIVER_USAGE_MAX_LEN];
57  char extra_params[DRIVER_EXTRA_PARAMS_MAX_LEN];
59 
60 //C++ extern C
61 HAL_BEGIN_DECLS
62 
63 //Init&destroy driver
72 hal_result_t hal_driver_init(hal_extension_ops_t* extensions, const char* extra_params);
73 
81 
88 
89 //Monitroing
90 
96 monitored_entity_t* hal_driver_get_chassis_info(void);
97 
110 bool hal_driver_switch_exists(uint64_t dpid);
111 
117 dpid_list_t* hal_driver_get_all_lsi_dpids(void);
118 
124 hal_result_t hal_driver_create_switch(char* name, uint64_t dpid, of_version_t of_version, unsigned int num_of_tables, int* ma_list);
125 
132 of_switch_snapshot_t* hal_driver_get_switch_snapshot_by_dpid(uint64_t dpid);
133 
140 
141 
146 bool hal_driver_port_exists(const char *name);
147 
154 switch_port_name_list_t* hal_driver_get_all_port_names(void);
155 
160 switch_port_snapshot_t* hal_driver_get_port_snapshot_by_name(const char *name);
161 
168 switch_port_snapshot_t* hal_driver_get_port_snapshot_by_num(uint64_t dpid, unsigned int port_num);
169 
170 
171 //Attachment
172 
181 hal_result_t hal_driver_attach_port_to_switch(uint64_t dpid, const char* name, unsigned int* port_num);
182 
194 hal_result_t hal_driver_connect_switches(uint64_t dpid_lsi1, unsigned int* port_num1, switch_port_snapshot_t** port1, uint64_t dpid_lsi2, unsigned int* port_num2, switch_port_snapshot_t** port2);
195 
196 
204 hal_result_t hal_driver_detach_port_from_switch(uint64_t dpid, const char* name);
205 
213 hal_result_t hal_driver_detach_port_from_switch_at_port_num(uint64_t dpid, const unsigned int port_num);
214 
215 //Port control
216 
223 hal_result_t hal_driver_bring_port_up(const char* name);
224 
231 hal_result_t hal_driver_bring_port_down(const char* name);
232 
240 hal_result_t hal_driver_bring_port_up_by_num(uint64_t dpid, unsigned int port_num);
241 
249 hal_result_t hal_driver_bring_port_down_by_num(uint64_t dpid, unsigned int port_num);
250 
251 
261 monitoring_snapshot_state_t* hal_driver_get_monitoring_snapshot(uint64_t rev);
262 
271 hal_result_t hal_driver_list_matching_algorithms(of_version_t of_version, const char * const** name_list, int *count);
272 
273 
274 //C++ extern C
275 HAL_END_DECLS
276 
277 /* OpenFlow related events */
279 // [+] Add more versions here...
280 
281 #endif /* HAL_DRIVER_H */
HAL_BEGIN_DECLS hal_result_t hal_driver_init(hal_extension_ops_t *extensions, const char *extra_params)
Initialises driver.
hal_result_t hal_driver_bring_port_up(const char *name)
Brings up a system's port.
of_switch_snapshot_t * hal_driver_get_switch_snapshot_by_dpid(uint64_t dpid)
Retrieves a snapshot of the current state of a switch port, if the port name is found.
hal_result_t hal_driver_attach_port_to_switch(uint64_t dpid, const char *name, unsigned int *port_num)
Attempts to attach a system's port to switch, at port_num if defined, otherwise in the first empty po...
hal_result_t hal_driver_detach_port_from_switch(uint64_t dpid, const char *name)
Detaches a port from the switch.
hal_result_t hal_driver_list_matching_algorithms(of_version_t of_version, const char *const **name_list, int *count)
get a list of available matching algorithms
Hardware Abstraction Layer (HAL) main header file.
monitoring_snapshot_state_t * hal_driver_get_monitoring_snapshot(uint64_t rev)
Retrieve a snapshot of the monitoring state.
hal_result_t hal_driver_connect_switches(uint64_t dpid_lsi1, unsigned int *port_num1, switch_port_snapshot_t **port1, uint64_t dpid_lsi2, unsigned int *port_num2, switch_port_snapshot_t **port2)
Attempts to connect two logical switches via a virtual port.
bool hal_driver_port_exists(const char *name)
Checks if a port with the specified name exists.
Driver information structure.
Definition: driver.h:37
void hal_driver_get_info(driver_info_t *info)
Get the information of the driver (code-name, version, usage...)
hal_result_t hal_driver_bring_port_down_by_num(uint64_t dpid, unsigned int port_num)
Brings down a port from a Logical Switch Instance.
Extensions ops HAL definition.
hal_result_t hal_driver_destroy_switch_by_dpid(uint64_t dpid)
Instructs the driver to destroy the switch with the specified dpid.
switch_port_snapshot_t * hal_driver_get_port_snapshot_by_num(uint64_t dpid, unsigned int port_num)
Retrieves a snapshot of the current state of the port of the Logical Switch Instance with dpid at por...
monitored_entity_t * hal_driver_get_chassis_info(void)
Get the chassis information in the form of a monitored entity.
switch_port_snapshot_t * hal_driver_get_port_snapshot_by_name(const char *name)
Retrieves a snapshot of the current state of a switch port, if the port name is found.
hal_result_t hal_driver_bring_port_down(const char *name)
Brings down a system's port.
dpid_list_t * hal_driver_get_all_lsi_dpids(void)
Retrieve the list of LSIs dpids.
hal_result_t hal_driver_destroy(void)
Destroy driver state.
switch_port_name_list_t * hal_driver_get_all_port_names(void)
Retrieve the list of names of the available ports of the platform.
enum hal_result hal_result_t
HAL return values.
hal_result_t hal_driver_create_switch(char *name, uint64_t dpid, of_version_t of_version, unsigned int num_of_tables, int *ma_list)
Instruct driver to create an OF logical switch.
hal_result_t hal_driver_bring_port_up_by_num(uint64_t dpid, unsigned int port_num)
Brings up a port from a Logical Switch Instance.
HAL driver OpenFlow specific management interface.
bool hal_driver_switch_exists(uint64_t dpid)
Switch management functions.
hal_result_t hal_driver_detach_port_from_switch_at_port_num(uint64_t dpid, const unsigned int port_num)
Detaches port_num of the logical switch identified with dpid.