2015-09-14 18:05:03 +02:00
|
|
|
/* Netlink related functions.
|
2015-08-22 17:42:02 +02:00
|
|
|
*
|
2022-03-15 09:18:01 -04:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
2022-03-15 09:28:57 -04:00
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
2022-07-04 18:20:03 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-08-22 17:42:02 +02:00
|
|
|
*/
|
|
|
|
|
2017-02-16 09:04:12 -03:00
|
|
|
#pragma once
|
2015-08-22 17:42:02 +02:00
|
|
|
|
2020-09-13 11:01:20 +02:00
|
|
|
#include <sys/socket.h>
|
|
|
|
|
2015-08-22 17:42:02 +02:00
|
|
|
#include <netlink/netlink.h>
|
|
|
|
#include <netlink/route/link.h>
|
2023-09-07 11:46:39 +02:00
|
|
|
#include <netlink/route/route.h>
|
2015-08-22 17:42:02 +02:00
|
|
|
|
2020-09-13 11:01:20 +02:00
|
|
|
namespace villas {
|
|
|
|
namespace kernel {
|
|
|
|
namespace nl {
|
|
|
|
|
2015-09-14 18:05:03 +02:00
|
|
|
/* Get index of outgoing interface for given destination address.
|
2015-08-22 17:42:02 +02:00
|
|
|
*
|
2015-09-14 18:05:03 +02:00
|
|
|
* @retval >=0 Interface index of outgoing interface.
|
|
|
|
* @retval <0 Error. Something went wrong.
|
2015-08-22 17:42:02 +02:00
|
|
|
*/
|
2020-09-13 11:01:20 +02:00
|
|
|
int get_egress(struct nl_addr *addr);
|
|
|
|
|
|
|
|
/* Lookup routing tables to get the interface on which packets for a certain destination
|
|
|
|
* will leave the system.
|
|
|
|
*
|
|
|
|
* @param[in] sa The destination address for outgoing packets.
|
|
|
|
* @param[out] link The egress interface.
|
|
|
|
* @retval 0 Success. Everything went well.
|
|
|
|
* @retval <0 Error. Something went wrong.
|
|
|
|
*/
|
2023-09-07 11:46:39 +02:00
|
|
|
struct rtnl_link *get_egress_link(struct sockaddr *sa);
|
2015-08-22 17:42:02 +02:00
|
|
|
|
2015-09-14 18:05:03 +02:00
|
|
|
// Get or create global netlink socket.
|
2023-09-07 11:46:39 +02:00
|
|
|
struct nl_sock *init();
|
2015-08-22 17:42:02 +02:00
|
|
|
|
2015-09-14 18:05:03 +02:00
|
|
|
// Close and free global netlink socket.
|
2020-09-13 11:01:20 +02:00
|
|
|
void shutdown();
|
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace nl
|
|
|
|
} // namespace kernel
|
|
|
|
} // namespace villas
|