1 /*
2 * Copyright (c) 2014-2015 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2016 Research Organization for Information Science
4 * and Technology (RIST). All rights reserved.
5 * Copyright (c) 2017 Amazon.com, Inc. or its affiliates.
6 * All Rights reserved.
7 *
8 * Portions of this software copied from libfabric
9 * (https://github.com/ofiwg/libfabric)
10 *
11 * LICENSE_BEGIN
12 *
13 * BSD license:
14 *
15 * Redistribution and use in source and binary forms, with or
16 * without modification, are permitted provided that the following
17 * conditions are met:
18 *
19 * - Redistributions of source code must retain the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer.
22 *
23 * - Redistributions in binary form must reproduce the above
24 * copyright notice, this list of conditions and the following
25 * disclaimer in the documentation and/or other materials
26 * provided with the distribution.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
40 *
41 * LICENSE_END
42 *
43 *
44 */
45
46 #ifndef LIBNL_UTILS_H
47 #define LIBNL_UTILS_H
48
49 #include "libnl3_utils.h"
50
51 struct opal_reachable_netlink_sk {
52 NL_HANDLE *nlh;
53 uint32_t seq;
54 };
55
56 /* returns 0 if host is reachable, EHOSTUNREACH if the host
57 * is not reachable, non-zero in other errors.
58 *
59 * If the route to the destination is through a gateway, *has_gateway
60 * is set to 1. Otherwise, it is set to 0.
61 */
62 int opal_reachable_netlink_rt_lookup(uint32_t src_addr,
63 uint32_t dst_addr, int oif,
64 int *has_gateway);
65
66 #if OPAL_ENABLE_IPV6
67 /* returns 0 if host is reachable, EHOSTUNREACH if the host
68 * is not reachable, non-zero in other errors.
69 *
70 * If the route to the destination is through a gateway, *has_gateway
71 * is set to 1. Otherwise, it is set to 0.
72 */
73 int opal_reachable_netlink_rt_lookup6(struct in6_addr *src_addr,
74 struct in6_addr *dst_addr, int oif,
75 int *has_gateway);
76 #endif
77
78 #endif /* LIBNL_UTILS_H */