hs-test: clean up Makefile for compatibility with ci-management
[vpp.git] / src / vnet / api_errno.h
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
18 #include <stdarg.h>
19 #include <vppinfra/types.h>
20 #include <vppinfra/format.h>
21 #include <vnet/error.h>
22
23 #define foreach_vnet_api_error foreach_vnet_error
24
25 typedef enum
26 {
27 #define _(a,b,c) VNET_API_ERROR_##a = (b),
28   foreach_vnet_api_error
29 #undef _
30     VNET_API_N_ERROR,
31 } vnet_api_error_t;
32
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)
37 {
38   if (err == 0)
39     return 0;
40   if (err->code >= 0)
41     return VNET_API_ERROR_BUG;
42   return err->code;
43 }
44
45 static_always_inline vnet_api_error_t
46 vnet_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
53 #endif /* included_vnet_api_errno_h */
54
55 /*
56  * fd.io coding-style-patch-verification: ON
57  *
58  * Local Variables:
59  * eval: (c-set-style "gnu")
60  * End:
61  */