blob: 172a4d6b2dcfc106624ab3b726764993a21273b6 [file] [log] [blame]
Neale Rannse2fe0972020-11-26 08:37:27 +00001/*
2 * Copyright (c) 2020 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
16/**
17 * @brief FIB Source Address selection
18 *
19 * Use the FIB for source address selection on an interface
20 */
21
22#ifndef __FIB_SAS_H__
23#define __FIB_SAS_H__
24
25#include <vnet/fib/fib_types.h>
26#include <vnet/ip/ip_types.h>
27
28/**
29 * @brief Get a Source address to use in a packet being sent out
30 * an interface
31 *
32 * @param sw_if_index The interface on which the packet is to be sent
33 * @param af The address family of the packet
34 * @param dst The destination of the packet (can be NULL in which case any
35 * of the available address will be returned)
36 * @param src OUT the source address to use
37 *
38 * @return True if an address is available False (and src is unset) otherwise
39 */
40extern bool fib_sas_get (u32 sw_if_index,
41 ip_address_family_t af,
42 const ip46_address_t *dst,
43 ip46_address_t *src);
44
45/**
46 * @brief Get an IPv4 Source address to use in a packet being sent out
47 * an interface
48 *
49 * @param sw_if_index The interface on which the packet is to be sent
50 * @param dst The destination of the packet (can be NULL in which case any
51 * of the available address will be returned)
52 * @param src OUT the source address to use
53 *
54 * @return True if an address is available False (and src is unset) otherwise
55 */
56extern bool fib_sas4_get (u32 sw_if_index,
57 const ip4_address_t *dst,
58 ip4_address_t *src);
59
60/**
61 * @brief Get an IPv6 Source address to use in a packet being sent out
62 * an interface
63 *
64 * @param sw_if_index The interface on which the packet is to be sent
65 * @param dst The destination of the packet (can be NULL in which case any
66 * of the available address will be returned)
67 * @param src OUT the source address to use
68 *
69 * @return True if an address is available False (and src is unset) otherwise
70 */
71extern bool fib_sas6_get (u32 sw_if_index,
72 const ip6_address_t *dst,
73 ip6_address_t *src);
74
75#endif