blob: 52f201c081bc85d0f7200ad7d4daa672ec3dfc0e [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
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 Sekeraff92efe2017-11-30 07:00:31 +010018#include <stdarg.h>
19#include <vppinfra/types.h>
20#include <vppinfra/format.h>
Damjan Marion81bb6fc2022-01-16 22:47:55 +010021#include <vnet/error.h>
Klement Sekeraff92efe2017-11-30 07:00:31 +010022
Damjan Marion81bb6fc2022-01-16 22:47:55 +010023#define foreach_vnet_api_error foreach_vnet_error
Dave Barach2c41a612019-10-07 12:04:31 -040024
Dave Barachba868bb2016-08-08 09:51:21 -040025typedef enum
26{
Ed Warnickecb9cada2015-12-08 15:45:58 -070027#define _(a,b,c) VNET_API_ERROR_##a = (b),
Dave Barachba868bb2016-08-08 09:51:21 -040028 foreach_vnet_api_error
Ed Warnickecb9cada2015-12-08 15:45:58 -070029#undef _
30 VNET_API_N_ERROR,
31} vnet_api_error_t;
32
Damjan Marion81bb6fc2022-01-16 22:47:55 +010033format_function_t format_vnet_api_errno;
34
35static_always_inline vnet_api_error_t
36vnet_api_error (clib_error_t *err)
Klement Sekeraff92efe2017-11-30 07:00:31 +010037{
Damjan Marionab4d9172023-01-31 20:14:13 +010038 if (err == 0)
39 return 0;
Damjan Marion81bb6fc2022-01-16 22:47:55 +010040 if (err->code >= 0)
41 return VNET_API_ERROR_BUG;
42 return err->code;
Klement Sekeraff92efe2017-11-30 07:00:31 +010043}
Klement Sekeraff92efe2017-11-30 07:00:31 +010044
Damjan Marionf6d3abd2023-03-08 13:28:51 +000045static_always_inline vnet_api_error_t
46vnet_get_api_error_and_free (clib_error_t *err)
47{
48 vnet_api_error_t rv = vnet_api_error (err);
49 clib_error_free (err);
50 return rv;
51}
52
Ed Warnickecb9cada2015-12-08 15:45:58 -070053#endif /* included_vnet_api_errno_h */
Dave Barachba868bb2016-08-08 09:51:21 -040054
55/*
56 * fd.io coding-style-patch-verification: ON
57 *
58 * Local Variables:
59 * eval: (c-set-style "gnu")
60 * End:
61 */