actions: Bundle action parsing parameters into a structure.
[cascardo/ovs.git] / ovn / lib / actions.h
1 /*
2  * Copyright (c) 2015 Nicira, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef OVN_ACTIONS_H
18 #define OVN_ACTIONS_H 1
19
20 #include <stdint.h>
21 #include "compiler.h"
22
23 struct expr;
24 struct lexer;
25 struct ofpbuf;
26 struct shash;
27 struct simap;
28
29 struct action_params {
30     /* A table of "struct expr_symbol"s to support (as one would provide to
31      * expr_parse()). */
32     const struct shash *symtab;
33
34      /* 'ports' must be a map from strings (presumably names of ports) to
35       * integers (as one would provide to expr_to_matches()).  Strings used in
36       * the actions that are not in 'ports' are translated to zero. */
37     const struct simap *ports;
38
39     /* A map from a port name to its connection tracking zone. */
40     const struct simap *ct_zones;
41
42     /* OVN maps each logical flow table (ltable), one-to-one, onto a physical
43      * OpenFlow flow table (ptable).  A number of parameters describe this
44      * mapping and data related to flow tables:
45      *
46      *     - 'first_ptable' and 'n_tables' define the range of OpenFlow tables
47      *        to which the logical "next" action should be able to jump.
48      *        Logical table 0 maps to OpenFlow table 'first_ptable', logical
49      *        table 1 to 'first_ptable + 1', and so on.  If 'n_tables' is 0
50      *        then "next" is disallowed entirely.
51      *
52      *     - 'cur_ltable' is an offset from 'first_ptable' (e.g. 0 <=
53      *       cur_ltable < n_ptables) of the logical flow that contains the
54      *       actions.  If cur_ltable + 1 < n_tables, then this defines the
55      *       default table that "next" will jump to.
56      *
57      *     - 'output_ptable' should be the OpenFlow table to which the logical
58      *       "output" action will resubmit. */
59     uint8_t n_tables;           /* Number of flow tables. */
60     uint8_t first_ptable;       /* First OpenFlow table. */
61     uint8_t cur_ltable;         /* 0 <= cur_ltable < n_tables. */
62     uint8_t output_ptable;      /* OpenFlow table for 'output' to resubmit. */
63 };
64
65 char *actions_parse(struct lexer *, const struct action_params *,
66                     struct ofpbuf *ofpacts, struct expr **prereqsp)
67     OVS_WARN_UNUSED_RESULT;
68 char *actions_parse_string(const char *s, const struct action_params *,
69                            struct ofpbuf *ofpacts, struct expr **prereqsp)
70     OVS_WARN_UNUSED_RESULT;
71
72 #endif /* ovn/actions.h */