Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | #ifndef included_vnet_api_errno_h |
| 16 | #define included_vnet_api_errno_h |
| 17 | |
Klement Sekera | ff92efe | 2017-11-30 07:00:31 +0100 | [diff] [blame] | 18 | #include <stdarg.h> |
| 19 | #include <vppinfra/types.h> |
| 20 | #include <vppinfra/format.h> |
Damjan Marion | 81bb6fc | 2022-01-16 22:47:55 +0100 | [diff] [blame] | 21 | #include <vnet/error.h> |
Klement Sekera | ff92efe | 2017-11-30 07:00:31 +0100 | [diff] [blame] | 22 | |
Damjan Marion | 81bb6fc | 2022-01-16 22:47:55 +0100 | [diff] [blame] | 23 | #define foreach_vnet_api_error foreach_vnet_error |
Dave Barach | 2c41a61 | 2019-10-07 12:04:31 -0400 | [diff] [blame] | 24 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 25 | typedef enum |
| 26 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 27 | #define _(a,b,c) VNET_API_ERROR_##a = (b), |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 28 | foreach_vnet_api_error |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 29 | #undef _ |
| 30 | VNET_API_N_ERROR, |
| 31 | } vnet_api_error_t; |
| 32 | |
Damjan Marion | 81bb6fc | 2022-01-16 22:47:55 +0100 | [diff] [blame] | 33 | format_function_t format_vnet_api_errno; |
| 34 | |
| 35 | static_always_inline vnet_api_error_t |
| 36 | vnet_api_error (clib_error_t *err) |
Klement Sekera | ff92efe | 2017-11-30 07:00:31 +0100 | [diff] [blame] | 37 | { |
Damjan Marion | ab4d917 | 2023-01-31 20:14:13 +0100 | [diff] [blame^] | 38 | if (err == 0) |
| 39 | return 0; |
Damjan Marion | 81bb6fc | 2022-01-16 22:47:55 +0100 | [diff] [blame] | 40 | if (err->code >= 0) |
| 41 | return VNET_API_ERROR_BUG; |
| 42 | return err->code; |
Klement Sekera | ff92efe | 2017-11-30 07:00:31 +0100 | [diff] [blame] | 43 | } |
Klement Sekera | ff92efe | 2017-11-30 07:00:31 +0100 | [diff] [blame] | 44 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 45 | #endif /* included_vnet_api_errno_h */ |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 46 | |
| 47 | /* |
| 48 | * fd.io coding-style-patch-verification: ON |
| 49 | * |
| 50 | * Local Variables: |
| 51 | * eval: (c-set-style "gnu") |
| 52 | * End: |
| 53 | */ |