ROFL-pipeline  v0.6.0dev
physical_switch.c
1 #include "physical_switch.h"
2 
3 #include <assert.h>
4 #include "platform/lock.h"
5 #include "platform/memory.h"
6 #include "platform/likely.h"
7 #include "util/logging.h"
8 #include "openflow/of_switch.h"
9 #include "openflow/openflow1x/pipeline/matching_algorithms/matching_algorithms.h"
10 
11 static physical_switch_t* psw=NULL;
12 
13 //Meta port shortcuts
14 #define META_PORT_FLOOD_INDEX 0
15 #define META_PORT_IN_PORT_INDEX 1
16 #define META_PORT_ALL_INDEX 2
17 
21 
22 
23 //
24 // Physical switch mgmt
25 //
26 
27 //Generate the matching algorithm list for all OpenFlow versions
28 void __physical_switch_generate_matching_algorithm_list(){
29  __of1x_generate_matching_algorithm_list();
30  //Add more versions here...
31 }
32 
33 //Init
34 rofl_result_t physical_switch_init(){
35 
36  ROFL_PIPELINE_DEBUG("Initializing physical switch\n");
37 
38  //Allocate memory for the physical switch structure
40 
41  if( unlikely(psw==NULL) )
42  return ROFL_FAILURE;
43 
44  psw->mutex = platform_mutex_init(NULL);
45  if(!psw->mutex)
46  return ROFL_FAILURE;
47 
48  platform_memset(psw->logical_switches, 0, sizeof(psw->logical_switches));
49  psw->num_of_logical_switches = 0;
50 
51  platform_memset(psw->physical_ports, 0, sizeof(psw->physical_ports));
52  platform_memset(psw->tunnel_ports, 0, sizeof(psw->tunnel_ports));
53  platform_memset(psw->virtual_ports, 0, sizeof(psw->virtual_ports));
54  platform_memset(psw->meta_ports, 0, sizeof(psw->meta_ports));
55 
56  //Generate metaports
57  //Flood
58  psw->meta_ports[META_PORT_FLOOD_INDEX].type = PORT_TYPE_META_FLOOD;
59  strncpy(psw->meta_ports[META_PORT_FLOOD_INDEX].name, "Flood meta port", SWITCH_PORT_MAX_LEN_NAME);
60  //In port
61  psw->meta_ports[META_PORT_IN_PORT_INDEX].type = PORT_TYPE_META_IN_PORT;
62  strncpy(psw->meta_ports[META_PORT_IN_PORT_INDEX].name, "In port meta port", SWITCH_PORT_MAX_LEN_NAME);
63  //All
64  psw->meta_ports[META_PORT_ALL_INDEX].type = PORT_TYPE_META_ALL;
65  strncpy(psw->meta_ports[META_PORT_ALL_INDEX].name, "All meta port", SWITCH_PORT_MAX_LEN_NAME);
66 
67  //Set extern pointer
68  flood_meta_port = &psw->meta_ports[META_PORT_FLOOD_INDEX];
69  in_port_meta_port = &psw->meta_ports[META_PORT_IN_PORT_INDEX];
70  all_meta_port = &psw->meta_ports[META_PORT_ALL_INDEX];
71 
72  //Initialize monitoring data
73  if(__monitoring_init(&psw->monitoring) != ROFL_SUCCESS)
74  return ROFL_FAILURE;
75 
76  //Generate matching algorithm lists
77  __physical_switch_generate_matching_algorithm_list();
78 
79  return ROFL_SUCCESS;
80 }
81 
83  return psw;
84 }
85 //Only used in multi-process deployments (with shared memory)
86 void __set_physical_switch(physical_switch_t* sw){
87  //Set the physical switch pointer
88  psw = sw;
89 
90  //Reassign meta-ports in HEAP
91  flood_meta_port = &psw->meta_ports[META_PORT_FLOOD_INDEX];
92  in_port_meta_port = &psw->meta_ports[META_PORT_IN_PORT_INDEX];
93  all_meta_port = &psw->meta_ports[META_PORT_ALL_INDEX];
94 }
95 
96 //Destroy
98 
99  unsigned int i;
100 
101  ROFL_PIPELINE_DEBUG("Destroying physical switch\n");
102 
103  //Serialize
104  platform_mutex_lock(psw->mutex);
105 
106  //Destroy logical switches
107  for(i=0;i<PHYSICAL_SWITCH_MAX_LS;i++){
108  if(psw->logical_switches[i])
109  of_destroy_switch(psw->logical_switches[i]);
110  }
111 
112  //Destroying ports
113  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_PHY_PORTS;i++){
114  if( psw->physical_ports[i] != NULL ){
115  switch_port_destroy(psw->physical_ports[i]);
116  }
117  }
118  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_VIR_PORTS;i++){
119  if( psw->virtual_ports[i] != NULL ){
120  switch_port_destroy(psw->virtual_ports[i]);
121  }
122  }
123  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_TUN_PORTS;i++){
124  if( psw->tunnel_ports[i] != NULL ){
125  switch_port_destroy(psw->tunnel_ports[i]);
126  }
127  }
128 
129  //Destroy monitoring
130  __monitoring_destroy(&psw->monitoring);
131 
132  //Destroy mutex
133  platform_mutex_destroy(psw->mutex);
134 
135  //destroy physical switch
137 }
138 
139 //
140 // Port management routines
141 //
142 
143 //Get the port by its name
145 
146  unsigned int i;
147 
148  //Physical ports
149  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_PHY_PORTS;i++){
150  if( psw->physical_ports[i] != NULL && strncmp(psw->physical_ports[i]->name, name, SWITCH_PORT_MAX_LEN_NAME)==0 ){
151  return psw->physical_ports[i];
152  }
153  }
154 
155  //Virtual ports
156  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_VIR_PORTS;i++){
157  if( psw->virtual_ports[i] != NULL && strncmp(psw->virtual_ports[i]->name, name, SWITCH_PORT_MAX_LEN_NAME)==0 ){
158  return psw->virtual_ports[i];
159  }
160  }
161 
162  //Tunnel ports
163  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_TUN_PORTS;i++){
164  if( psw->tunnel_ports[i] != NULL && strncmp(psw->tunnel_ports[i]->name, name, SWITCH_PORT_MAX_LEN_NAME)==0 ){
165  return psw->tunnel_ports[i];
166  }
167  }
168 
169  return NULL;
170 }
171 
172 
173 //Get the reference to the physical ports
176  return psw->physical_ports;
177 }
178 //Get the reference to the virtual ports
181  return psw->virtual_ports;
182 }
183 //Get the reference to the physical ports
186  return psw->tunnel_ports;
187 }
188 
189 /*
190 * Get a port by port_num
191 */
192 switch_port_t* physical_switch_get_port_by_num(const uint64_t dpid, unsigned int port_num){
193 
194  of_switch_t* lsw;
195 
197 
198  if( unlikely(lsw==NULL) )
199  return NULL;
200 
201  //Check port range
202  if( port_num >= LOGICAL_SWITCH_MAX_LOG_PORTS || port_num == 0)
203  return NULL;
204 
205  if( lsw->logical_ports[port_num].attachment_state != LOGICAL_PORT_STATE_ATTACHED )
206  return NULL;
207 
208  return lsw->logical_ports[port_num].port;
209 }
210 
211 /*
212 * Attempts to add a port to the physical switch pool port
213 */
215 
216  unsigned int i, max;
217  switch_port_t** array = NULL;
218 
219 
220  if( unlikely(port==NULL) )
221  return ROFL_FAILURE;
222 
223  ROFL_PIPELINE_DEBUG("Trying to add port(%p) named %s to the physical switch\n", port, port->name);
224 
225  if(physical_switch_get_port_by_name(port->name)){
226  ROFL_PIPELINE_DEBUG("There is already a port named:%s in the physical switch\n",port->name);
227  return ROFL_FAILURE;
228  }
229 
230  //Serialize
231  platform_mutex_lock(psw->mutex);
232 
233  switch(port->type){
234 
235  case PORT_TYPE_PHYSICAL:
237  array = psw->physical_ports;
238  break;
239 
240  case PORT_TYPE_VIRTUAL:
242  array = psw->virtual_ports;
243  break;
244 
245  case PORT_TYPE_TUNNEL:
247  array = psw->tunnel_ports;
248  break;
249 
250  case PORT_TYPE_NF_NATIVE:
251  case PORT_TYPE_NF_SHMEM:
252  case PORT_TYPE_NF_EXTERNAL:
253  //IVANO - FIXME: I'm not sure about this
255  array = psw->physical_ports;
256  break;
257 
258  default:
259  //Invalid type
260  platform_mutex_unlock(psw->mutex);
261  return ROFL_FAILURE;
262  }
263 
264  //Look for the first empty slot
265  for(i=0;i<max;i++){
266  if(array[i] == NULL){
267  array[i] = port;
268  platform_mutex_unlock(psw->mutex);
269  return ROFL_SUCCESS;
270  }
271  }
272 
273  platform_mutex_unlock(psw->mutex);
274 
275  //No free slots left in the pool
276  ROFL_PIPELINE_DEBUG("Insertion failed of port(%p); no available slots\n",port);
277  return ROFL_FAILURE;
278 }
279 
280 /*
281 * Removes and destroys a port from the physical_switch pool referenced by its name
282 */
283 rofl_result_t physical_switch_remove_port(const char* name){
284 
285  unsigned int i;
286  switch_port_t* port;
287 
288  if( unlikely(name==NULL) )
289  return ROFL_FAILURE;
290 
291  //Serialize
292  platform_mutex_lock(psw->mutex);
293 
294  //Looking in the physical ports list
295  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_PHY_PORTS;i++){
296 
297  if( psw->physical_ports[i] != NULL && strncmp(psw->physical_ports[i]->name, name, SWITCH_PORT_MAX_LEN_NAME) == 0 ){
298  port = psw->physical_ports[i];
299  psw->physical_ports[i] = NULL;
300  platform_mutex_unlock(psw->mutex);
301  switch_port_destroy(port);
302  return ROFL_SUCCESS;
303  }
304  }
305 
306  //Looking in the virtual ports list
307  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_VIR_PORTS;i++){
308  if( psw->virtual_ports[i] != NULL && strncmp(psw->virtual_ports[i]->name, name, SWITCH_PORT_MAX_LEN_NAME) == 0 ){
309  port = psw->virtual_ports[i];
310  psw->virtual_ports[i] = NULL;
311  platform_mutex_unlock(psw->mutex);
312  switch_port_destroy(port);
313  return ROFL_SUCCESS;
314  }
315  }
316 
317  //Looking in the tunnel ports list
318  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_TUN_PORTS;i++){
319  if( psw->tunnel_ports[i] != NULL && strncmp(psw->tunnel_ports[i]->name, name, SWITCH_PORT_MAX_LEN_NAME) == 0 ){
320  port = psw->tunnel_ports[i];
321  psw->tunnel_ports[i] = NULL;
322  platform_mutex_unlock(psw->mutex);
323  switch_port_destroy(port);
324  return ROFL_SUCCESS;
325  }
326  }
327 
328  platform_mutex_unlock(psw->mutex);
329 
330  //Port not found
331  return ROFL_FAILURE;
332 
333 
334 }
335 
336 
337 
338 //
339 // Logical switch management
340 //
341 
342 /*
343 * Retrieves the list of logical switches within the logical switch
344 */
345 of_switch_t** physical_switch_get_logical_switches(unsigned int* max_switches){
346 
347  *max_switches = PHYSICAL_SWITCH_MAX_LS;
348 
349  return psw->logical_switches;
350 }
351 
352 
353 //Get logical switch
355  int i;
356 
357  for(i=0;i<PHYSICAL_SWITCH_MAX_LS;i++){
358  if( psw->logical_switches[i] && psw->logical_switches[i]->dpid == dpid )
359  return psw->logical_switches[i];
360  }
361 
362  return NULL;
363 }
364 
365 //Add/remove methods
367  int i;
368 
370  return ROFL_FAILURE;
371 
372  //Serialize
373  platform_mutex_lock(psw->mutex);
374 
375  // check bounds
376  if(psw->num_of_logical_switches == PHYSICAL_SWITCH_MAX_LS){
377  //Serialize
378  platform_mutex_unlock(psw->mutex);
379  return ROFL_FAILURE;
380  }
381 
382  //Look for an available slot
383  for(i=0;i<PHYSICAL_SWITCH_MAX_LS;i++){
384  if(!psw->logical_switches[i])
385  break;
386  }
387 
388  psw->logical_switches[i] = sw;
389  psw->num_of_logical_switches++;
390 
391  platform_mutex_unlock(psw->mutex);
392  return ROFL_SUCCESS;
393 }
394 
395 rofl_result_t physical_switch_remove_logical_switch_by_dpid(const uint64_t dpid){
396 
397  int i;
398  of_switch_t* sw;
399 
400  ROFL_PIPELINE_DEBUG("Removing logical switch with dpid: 0x%"PRIx64"\n",dpid);
401 
402  //Serialize
403  platform_mutex_lock(psw->mutex);
404 
406  platform_mutex_unlock(psw->mutex);
407  ROFL_PIPELINE_WARN("Logical switch not found\n");
408  return ROFL_FAILURE;
409  }
410 
411  for(i=0;i<PHYSICAL_SWITCH_MAX_LS;i++){
412  if(psw->logical_switches[i] && psw->logical_switches[i]->dpid == dpid){
413 
414  sw = psw->logical_switches[i];
415 
416  psw->logical_switches[i] = NULL;
417  psw->num_of_logical_switches--;
418 
419  //Free the rest to do stuff with the physical sw
420  platform_mutex_unlock(psw->mutex);
421 
422  //Destroy the switch
423  of_destroy_switch(sw);
424 
425  return ROFL_SUCCESS;
426  }
427  }
428 
429  //This statement can never be reached
430  platform_mutex_unlock(psw->mutex);
431  return ROFL_FAILURE;
432 }
433 
436 }
437 
438 //
439 // Logical switches port management
440 //
441 
442 
443 //Getters
445  return (of_switch_t*)port.attached_sw;
446 }
447 
448 //Attach
449 rofl_result_t physical_switch_attach_port_to_logical_switch(switch_port_t* port, of_switch_t* sw, unsigned int* port_num){
450 
451  rofl_result_t return_val;
452 
453  if( unlikely(sw==NULL) || unlikely(port==NULL) || unlikely(port->attached_sw!=NULL) )
454  return ROFL_FAILURE;
455 
456  //Serialize
457  platform_mutex_lock(psw->mutex);
458 
459  return_val = __of_attach_port_to_switch(sw, port, port_num);
460 
461  platform_mutex_unlock(psw->mutex);
462  return return_val;
463 
464 }
465 
467 
468  rofl_result_t return_val;
469 
470  if( unlikely(sw==NULL) || unlikely(port==NULL) || unlikely(port->attached_sw!=NULL) )
471  return ROFL_FAILURE;
472 
473  //Serialize
474  platform_mutex_lock(psw->mutex);
475 
476  return_val = __of_attach_port_to_switch_at_port_num(sw, port_num, port);
477 
478  platform_mutex_unlock(psw->mutex);
479  return return_val;
480 }
481 
482 
483 rofl_result_t physical_switch_detach_port_num_from_logical_switch(unsigned int port_num, of_switch_t* sw){
484  rofl_result_t return_val;
485 
486  if( unlikely(sw==NULL) )
487  return ROFL_FAILURE;
488 
489  //Serialize
490  platform_mutex_lock(psw->mutex);
491 
492  return_val = __of_detach_port_from_switch_by_port_num(sw, port_num);
493 
494  platform_mutex_unlock(psw->mutex);
495  return return_val;
496 
497 }
498 
500 
501  rofl_result_t return_val;
502 
503  if( unlikely(sw==NULL) || unlikely(port==NULL) )
504  return ROFL_FAILURE;
505 
506  //Serialize
507  platform_mutex_lock(psw->mutex);
508 
509  return_val = __of_detach_port_from_switch(sw, port);
510 
511  platform_mutex_unlock(psw->mutex);
512  return return_val;
513 
514 
515 }
516 
518 
519  rofl_result_t return_val;
520 
521  if( unlikely(sw==NULL) )
522  return ROFL_FAILURE;
523 
524  //Serialize
525  platform_mutex_lock(psw->mutex);
526 
527  return_val = __of_detach_all_ports_from_switch(sw);
528 
529  platform_mutex_unlock(psw->mutex);
530  return return_val;
531 
532 }
533 
534 
535 //
536 // Snapshots
537 //
538 
539 //List of ports
541 
543  __switch_port_name_t* names;
544  unsigned int num_of_ports, i;
545 
546  //Serialize
547  platform_mutex_lock(psw->mutex);
548 
549  //Determine the number of (currenly) exisitng ports
550  num_of_ports=0;
551  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_PHY_PORTS;i++){
552  if(psw->physical_ports[i])
553  num_of_ports++;
554  }
555  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_TUN_PORTS;i++){
556  if(psw->tunnel_ports[i])
557  num_of_ports++;
558  }
559  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_VIR_PORTS;i++){
560  if(psw->virtual_ports[i])
561  num_of_ports++;
562  }
563 
564  //Allocate memory
566  names = platform_malloc_shared(sizeof(__switch_port_name_t)*num_of_ports);
567 
568  if(!list || !names){
569  platform_mutex_unlock(psw->mutex);
570  if(list)
571  platform_free_shared(list);
572  if(names)
573  platform_free_shared(names);
574  return NULL;
575  }
576 
577  //Fill in
578  list->names = names;
579  list->num_of_ports = num_of_ports;
580 
581  num_of_ports=0;
582  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_PHY_PORTS;i++){
583  if(psw->physical_ports[i]){
584  memcpy(&list->names[num_of_ports], &psw->physical_ports[i]->name, SWITCH_PORT_MAX_LEN_NAME);
585  num_of_ports++;
586  }
587  }
588  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_TUN_PORTS;i++){
589  if(psw->tunnel_ports[i]){
590  memcpy(&list->names[num_of_ports], &psw->tunnel_ports[i]->name, SWITCH_PORT_MAX_LEN_NAME);
591  num_of_ports++;
592  }
593  }
594  for(i=0;i<PHYSICAL_SWITCH_MAX_NUM_VIR_PORTS;i++){
595  if(psw->virtual_ports[i]){
596  memcpy(&list->names[num_of_ports], &psw->virtual_ports[i]->name, SWITCH_PORT_MAX_LEN_NAME);
597  num_of_ports++;
598  }
599  }
600 
601  platform_mutex_unlock(psw->mutex);
602 
603  return list;
604 }
605 
606 //Get the port snapshot
608 
609  switch_port_t* port;
610  switch_port_snapshot_t* snapshot;
611 
612  if(!name)
613  return NULL;
614 
615  //Serialize
616  platform_mutex_lock(psw->mutex);
617 
619 
620  if(!port){
621  platform_mutex_unlock(psw->mutex);
622  return NULL;
623  }
624 
625  snapshot = __switch_port_get_snapshot(port);
626 
627  platform_mutex_unlock(psw->mutex);
628 
629  return snapshot;
630 }
631 
632 //LSIs
634 
635  int i,j;
636  dpid_list_t* list;
637 
638  list = platform_malloc_shared(sizeof(dpid_list_t));
639 
640  //Prevent management actions to screw the walk through the LSIs
641  platform_mutex_lock(psw->mutex);
642 
643  //Set the number of elements
644  list->num_of_lsis = psw->num_of_logical_switches;
645 
646  //Allocate the list space
647  list->dpids = platform_malloc_shared(sizeof(uint64_t)*list->num_of_lsis);
648 
649  if(!list->dpids){
650  platform_mutex_unlock(psw->mutex);
651  return NULL;
652  }
653 
654  //Fill it with 0s
655  platform_memset(list->dpids,0,sizeof(uint64_t)*list->num_of_lsis);
656  for(i=0,j=0;i<PHYSICAL_SWITCH_MAX_LS;i++){
657  if(psw->logical_switches[i]){
658  list->dpids[j] = psw->logical_switches[i]->dpid;
659  j++;
660  }
661  }
662 
663  platform_mutex_unlock(psw->mutex);
664 
665  return list;
666 }
667 
669  platform_free_shared(list->dpids);
670  platform_free_shared(list);
671 }
672 
674 
675  of_switch_t* sw;
676  of_switch_snapshot_t* to_return=NULL;
677 
678 
679  //Serialize
680  platform_mutex_lock(psw->mutex);
681 
682  //Try to find the switch
684 
685  if(sw)
686  to_return = __of_switch_get_snapshot(sw);
687 
688  platform_mutex_unlock(psw->mutex);
689 
690  return to_return;
691 }
#define PHYSICAL_SWITCH_MAX_NUM_VIR_PORTS
Maximum number of virtual ports.
OpenFlow-enabled switch abstraction (version-indepedent part).
Definition: of_switch.h:55
Defines the locking interface used by the library. The user of the library MUST provide an implementa...
Defines the memory management interface used by the library. The user of the library MUST provide an ...
void platform_mutex_lock(platform_mutex_t *mutex)
Locks the platform_mutex_t mutex.
rofl_result_t physical_switch_add_logical_switch(of_switch_t *sw)
Add a logical switch to the pool.
rofl_result_t physical_switch_init()
Initializes the physical switch.
rofl_result_t physical_switch_detach_all_ports_from_logical_switch(of_switch_t *sw)
Detaches all the ports from the logical switch.
void platform_mutex_unlock(platform_mutex_t *mutex)
Unlocks the platform_mutex_t mutex.
of_switch_t ** physical_switch_get_logical_switches(unsigned int *max_switches)
Retrieves the list of logical switches within the logical switch.
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 ove...
List of ports name (snapshots)
Definition: switch_port.h:232
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.
ROFL_BEGIN_DECLS platform_mutex_t * platform_mutex_init(void *params)
Allocates and initializes a mutex.
void dpid_list_destroy(dpid_list_t *list)
Destroy a previously generated list of dpids.
Physical switch abstraction and API.
void * platform_memset(void *src, int c, size_t length)
Sets 'c' to the whole chunk of memory.
switch_port_t ** physical_switch_get_virtual_ports(unsigned int *max_ports)
Get the reference to the virtual ports.
switch_port_t * all_meta_port
Special meta port: ALL.
#define PHYSICAL_SWITCH_MAX_NUM_PHY_PORTS
Maximum number of phyisical ports.
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 AN...
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.
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.
#define PHYSICAL_SWITCH_MAX_LS
Maximum number of logical switches that can be instantiated.
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.
Port abstraction.
Definition: switch_port.h:145
switch_port_t ** physical_switch_get_tunnel_ports(unsigned int *max_ports)
Get the reference to the physical ports.
switch_port_t * physical_switch_get_port_by_name(const char *name)
Retrieve a physical switch port by name.
List of dpids (snapshots)
rofl_result_t switch_port_destroy(switch_port_t *port)
Destroy a switch_port structure.
Definition: switch_port.c:66
switch_port_snapshot_t * physical_switch_get_port_snapshot(const char *name)
Gets a snapshot of the current port state, if it exists.
void platform_mutex_destroy(platform_mutex_t *mutex)
Destroys and deallocates a mutex previously inited by platform_mutex_init().
rofl_result_t physical_switch_detach_port_from_logical_switch(switch_port_t *port, of_switch_t *sw)
Detaches port from logical switch sw.
switch_port_t ** physical_switch_get_physical_ports(unsigned int *max_ports)
Get the reference to the physical ports.
physical_switch_t * get_physical_switch()
Get the reference to the (unique) physical switch.
Keeps the state of the physical switch (device), including ports and logical switch instances...
void * platform_malloc_shared(size_t length)
Allocates a chunk of dynamic memory of size length, which must be accessible (R/W) for all the thread...
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.
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...
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.
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
void physical_switch_destroy()
Destroys the physical switch state.
#define PHYSICAL_SWITCH_MAX_NUM_TUN_PORTS
Maximum number of tunnel ports.
dpid_list_t * physical_switch_get_all_lsi_dpids(void)
Get the list of existing LSI DPIDs.
ROFL_BEGIN_DECLS rofl_result_t __monitoring_init(monitoring_state_t *monitoring)
Initializes the monitoring state.
Definition: monitoring.c:207
void platform_free_shared(void *data)
Frees a chunk of dynamic memory previously allocated with platform_malloc_shared().
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.
switch_port_t * in_port_meta_port
Special meta port: IN_PORT.
switch_port_name_list_t * physical_switch_get_all_port_names(void)
Gets a list of port names of all (currently) available port names.
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.
switch_port_t * flood_meta_port
Special meta port: FLOOD.