Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 1 | :: # Copyright 2013, Big Switch Networks, Inc. |
| 2 | :: # |
| 3 | :: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with |
| 4 | :: # the following special exception: |
| 5 | :: # |
| 6 | :: # LOXI Exception |
| 7 | :: # |
| 8 | :: # As a special exception to the terms of the EPL, you may distribute libraries |
| 9 | :: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided |
| 10 | :: # that copyright and licensing notices generated by LoxiGen are not altered or removed |
| 11 | :: # from the LoxiGen Libraries and the notice provided below is (i) included in |
| 12 | :: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any |
| 13 | :: # documentation for the LoxiGen Libraries, if distributed in binary form. |
| 14 | :: # |
| 15 | :: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler." |
| 16 | :: # |
| 17 | :: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain |
| 18 | :: # a copy of the EPL at: |
| 19 | :: # |
| 20 | :: # http://www.eclipse.org/legal/epl-v10.html |
| 21 | :: # |
| 22 | :: # Unless required by applicable law or agreed to in writing, software |
| 23 | :: # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 24 | :: # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 25 | :: # EPL for the specific language governing permissions and limitations |
| 26 | :: # under the EPL. |
| 27 | :: |
Rich Lane | d983aa5 | 2013-06-13 11:48:37 -0700 | [diff] [blame] | 28 | :: include('_copyright.c') |
Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 29 | |
| 30 | /**************************************************************** |
| 31 | * File: of_utils.h |
| 32 | * |
| 33 | * Some utilities provided based on LOCI code generation |
| 34 | * |
| 35 | ****************************************************************/ |
| 36 | |
| 37 | #include <loci/of_utils.h> |
Rich Lane | a8b5463 | 2014-02-19 11:17:47 -0800 | [diff] [blame] | 38 | #include <stdio.h> |
| 39 | #include <stdlib.h> |
Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 40 | |
| 41 | |
| 42 | /** |
| 43 | * Check if the given port is used as an output for any entry on the list |
| 44 | * @param actions The list of actions being checked |
| 45 | * @param outport The port being sought |
| 46 | * @returns Boolean, true if entry has an output action to outport |
| 47 | * |
| 48 | * @fixme VERSION Currently only OF 1.0 supported |
| 49 | * @fixme Check for error return in accessor |
| 50 | * |
| 51 | * If outport is "wildcard", the test should be ignored, so return true |
| 52 | */ |
| 53 | |
| 54 | int |
| 55 | of_action_list_has_out_port(of_list_action_t *actions, of_port_no_t outport) |
| 56 | { |
| 57 | of_action_t elt; |
| 58 | of_action_output_t *output; |
| 59 | int loop_rv; |
| 60 | of_port_no_t port_no; |
| 61 | int rv = 0; |
| 62 | |
| 63 | if (outport == OF_PORT_DEST_WILDCARD) { /* Same as OFPP_ANY */ |
| 64 | return 1; |
| 65 | } |
| 66 | |
| 67 | output = &elt.output; |
| 68 | OF_LIST_ACTION_ITER(actions, &elt, loop_rv) { |
| 69 | if (output->object_id == OF_ACTION_OUTPUT) { |
| 70 | of_action_output_port_get(output, &port_no); |
| 71 | if (port_no == outport) { |
| 72 | rv = 1; |
| 73 | break; |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | return rv; |
| 79 | } |
| 80 | |
Rich Lane | a8b5463 | 2014-02-19 11:17:47 -0800 | [diff] [blame] | 81 | void |
| 82 | loci_assert_fail(const char *msg, const char *file, unsigned int line) |
| 83 | { |
| 84 | fprintf(stderr, "\\nASSERT %s. %s:%d\\n", msg, file, line); |
| 85 | abort(); |
| 86 | } |