1 /* Copyright (C) 2008 Board of Trustees, Leland Stanford Jr. University.
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to
5 * deal in the Software without restriction, including without limitation the
6 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 * sell copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 #define SWITCH_FLOW_H 1
31 /* Identification data for a flow. */
33 struct flow flow; /* Flow data (in network byte order). */
34 uint32_t wildcards; /* Wildcard fields (in host byte order). */
37 /* Maximum number of actions in a single flow entry. */
38 #define MAX_ACTIONS 16
41 struct sw_flow_key key;
43 uint32_t group_id; /* Flow group ID (for QoS). */
44 uint16_t max_idle; /* Idle time before discarding (seconds). */
45 time_t created; /* When the flow was created. */
46 time_t timeout; /* When the flow expires (if idle). */
47 uint64_t packet_count; /* Number of packets seen. */
48 uint64_t byte_count; /* Number of bytes seen. */
51 /* Actions (XXX probably most flows have only a single action). */
52 unsigned int n_actions;
53 struct ofp_action *actions;
56 int flow_matches(const struct sw_flow_key *, const struct sw_flow_key *);
57 int flow_del_matches(const struct sw_flow_key *, const struct sw_flow_key *,
59 struct sw_flow *flow_alloc(int n_actions);
60 void flow_free(struct sw_flow *);
61 void flow_deferred_free(struct sw_flow *);
62 void flow_extract_match(struct sw_flow_key* to, const struct ofp_match* from);
63 void flow_fill_match(struct ofp_match* to, const struct sw_flow_key* from);
65 void print_flow(const struct sw_flow_key *);
66 int flow_timeout(struct sw_flow *flow);
67 void flow_used(struct sw_flow *flow, struct buffer *buffer);
69 #endif /* switch-flow.h */