ROFL-pipeline  v0.6.0dev
of1x_flow_entry.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 __OF1X_FLOW_ENTRY_H__
6 #define __OF1X_FLOW_ENTRY_H__
7 
8 #include <stdlib.h>
9 #include <string.h>
10 
11 #include "rofl.h"
12 #include "../../../common/ternary_fields.h"
13 #include "of1x_match.h"
14 #include "of1x_instruction.h"
15 #include "of1x_timers.h"
16 #include "of1x_statistics.h"
17 #include "of1x_utils.h"
18 
27 //Fwd declarations
28 struct of1x_pipeline;
29 struct of1x_flow_table;
30 struct of1x_timers_info;
31 struct of1x_group_table;
32 
38  NOT_STRICT = 0,
39  STRICT
41 
47  OF1X_FLOW_REMOVE_IDLE_TIMEOUT=0, /* Flow idle time exceeded idle_timeout. */
48  OF1X_FLOW_REMOVE_HARD_TIMEOUT=1, /* Time exceeded hard_timeout. */
49  OF1X_FLOW_REMOVE_DELETE=2, /* Evicted by a DELETE flow mod. */
50  OF1X_FLOW_REMOVE_GROUP_DELETE=3, /* Group was removed. */
51 
52  OF1X_FLOW_REMOVE_NO_REASON = 0xFF /* No reason -> do not notify */
54 
60 
61 //Used to pre-append priority, to emulate OF1.0 behaviour ONLY
62 #define OF10_NON_WILDCARDED_PRIORITY_FLAG 0x10000
63 
64 //Do not check cookie value
65 #define OF1X_DO_NOT_CHECK_COOKIE 0xffffffffffffffffULL
66 
71 typedef struct of1x_flow_entry{
72 
73  //Entry priority(lowest 16 bit is the OF priority)
74  //17th bit is only set to 1/0 for OF1.0 (is wildcarded or not)
75  uint32_t priority;
76 
77  //Previous entry
78  struct of1x_flow_entry* prev;
79 
80  //Next entry
81  struct of1x_flow_entry* next;
82 
83  //Table in which rule is inserted (for fast safety checkings)
84  struct of1x_flow_table* table;
85 
86  //Matches
87  of1x_match_group_t matches;
88 
89  //Instructions
90  of1x_instruction_group_t inst_grp;
91 
92  //Cookie
93  uint64_t cookie;
94  uint64_t cookie_mask;
95 
96  //Notify when removed
97  bool notify_removal;
98 
99  //Timers
100  struct of1x_timers_info timer_info;
101 
102  //Opaque flags bitmap
103  //This is necessary for OF1.3 and beyond, since
104  //the insertion flags need to kept for future
105  //flow_stats request... none-sense
106  uint32_t flags;
107 
108  //statistics
109  of1x_stats_flow_t stats;
110 
111  //RWlock
112  platform_rwlock_t* rwlock;
113 
114  //Platform agnostic pointer
115  of1x_flow_entry_platform_state_t* platform_state;
117 
118 //C++ extern C
119 ROFL_BEGIN_DECLS
120 
125 of1x_flow_entry_t* of1x_init_flow_entry(bool notify_removal);
126 
127 //This should never be used from outside the library
128 rofl_result_t __of1x_destroy_flow_entry_with_reason(of1x_flow_entry_t* entry, of1x_flow_remove_reason_t reason);
129 
134 rofl_result_t of1x_destroy_flow_entry(of1x_flow_entry_t* entry);
135 
136 //Add match
141 rofl_result_t of1x_add_match_to_entry(of1x_flow_entry_t* entry, of1x_match_t* match);
142 
143 //Update entry
144 rofl_result_t __of1x_update_flow_entry(of1x_flow_entry_t* entry_to_update, of1x_flow_entry_t* mod, bool reset_counts);
145 
146 //Fast validation against OF version
147 rofl_result_t __of1x_validate_flow_entry(of1x_flow_entry_t* entry, struct of1x_pipeline* pipeline, unsigned int table_id);
148 
149 //Flow comparison
150 bool __of1x_flow_entry_check_equal(of1x_flow_entry_t*const original, of1x_flow_entry_t*const entry, uint32_t out_port, uint32_t out_group, bool check_cookie);
151 bool __of1x_flow_entry_check_overlap(of1x_flow_entry_t*const original, of1x_flow_entry_t*const entry, bool check_priority, bool check_cookie, uint32_t out_port, uint32_t out_group);
152 bool __of1x_flow_entry_check_contained(of1x_flow_entry_t*const original, of1x_flow_entry_t*const subentry, bool check_priority, bool check_cookie, uint32_t out_port, uint32_t out_group, bool reverse_out_check);
153 
154 //Dump flow
161 void of1x_dump_flow_entry(of1x_flow_entry_t* entry, bool raw_nbo);
162 
163 //C++ extern C
164 ROFL_END_DECLS
165 
166 #endif //OF1X_FLOW_ENTRY
ROFL_BEGIN_DECLS of1x_flow_entry_t * of1x_init_flow_entry(bool notify_removal)
Create an empty flow entry.
OpenFlow v1.0, 1.2 and 1.3.2 flow entry structure.
enum of1x_flow_remove_reason of1x_flow_remove_reason_t
Flow remove reasons (enum ofp_flow_removed_reason)
void of1x_flow_entry_platform_state_t
Platform dependent opaque state.
OpenFlow v1.X instructions.
void of1x_dump_flow_entry(of1x_flow_entry_t *entry, bool raw_nbo)
Dumps the flow entry for debugging purposes.
OpenFlow v1.0, 1.2 and 1.3.2 flow table abstraction.
of1x_flow_removal_strictness
Flow removal operations strictness.
bool __of1x_flow_entry_check_contained(of1x_flow_entry_t *const original, of1x_flow_entry_t *const subentry, bool check_priority, bool check_cookie, uint32_t out_port, uint32_t out_group, bool reverse_out_check)
Checks whether an entry is contained in the other.
struct of1x_flow_entry of1x_flow_entry_t
OpenFlow v1.0, 1.2 and 1.3.2 flow entry structure.
bool __of1x_flow_entry_check_overlap(of1x_flow_entry_t *const original, of1x_flow_entry_t *const entry, bool check_priority, bool check_cookie, uint32_t out_port, uint32_t out_group)
Checks whether two entries overlap overlapping.
OpenFlow v1.0, 1.2 and 1.3.2 timers subsystem.
of1x_flow_remove_reason
Flow remove reasons (enum ofp_flow_removed_reason)
rofl_result_t of1x_add_match_to_entry(of1x_flow_entry_t *entry, of1x_match_t *match)
Adds a match to the flow_entry.
OpenFlow v1.0, 1.2 and 1.3.2 matches.
rofl_result_t of1x_destroy_flow_entry(of1x_flow_entry_t *entry)
Destroy the flow entry, including stats, instructions and actions.
enum of1x_flow_removal_strictness of1x_flow_removal_strictness_t
Flow removal operations strictness.
OpenFlow v1.0, 1.2 and 1.3.2 pipeline abstraction data structure.
Definition: of1x_pipeline.h:50
bool __of1x_flow_entry_check_equal(of1x_flow_entry_t *const original, of1x_flow_entry_t *const entry, uint32_t out_port, uint32_t out_group, bool check_cookie)
Checks if entry is identical to another one out_port and out_grouap are ALWAYS checked against origin...
OpenFlow v1.0, 1.2 and 1.3.2 statistics subsystem.
rofl_result_t __of1x_validate_flow_entry(of1x_flow_entry_t *entry, struct of1x_pipeline *pipeline, unsigned int table_id)
Check if the entry(matches, actions and instructions is valid for insertion)