1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-30 00:00:11 +01:00
VILLASnode/server/include/if.h

75 lines
2.2 KiB
C

/** Interface related functions
*
* These functions are used to manage a network interface.
* Most of them make use of Linux-specific APIs.
*
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2014, Institute for Automation of Complex Power Systems, EONERC
* @file
*/
#ifndef _IF_H_
#define _IF_H_
#include <sys/types.h>
#include <net/if.h>
#define IF_NAME_MAX IFNAMSIZ /**< Maximum length of an interface name */
#define IF_IRQ_MAX 3 /**< Maxmimal number of IRQs of an interface */
/** Interface data structure */
struct interface {
/** The index used by the kernel to reference this interface */
int index;
/** How many nodes use this interface for outgoing packets */
int refcnt;
/** Human readable name of this interface */
char name[IF_NAME_MAX];
/** List of IRQs of the NIC */
char irqs[IF_IRQ_MAX];
/** Linked list pointer */
struct interface *next;
};
/** Get outgoing interface.
*
* Does a lookup in the kernel routing table to determine
* the interface which sends the data to a certain socket
* address.
*
* @param sa A destination address for outgoing packets.
* @return The interface index.
*/
int if_getegress(struct sockaddr_in *sa);
/** Get all IRQs for this interface.
*
* Only MSI IRQs are determined by looking at:
* /sys/class/net/{ifname}/device/msi_irqs/
*
* @param i A pointer to the interface structure
* @retval 0 Success. Everything went well.
* @retval <0 Error. Something went wrong.
*/
int if_getirqs(struct interface *i);
/** Change the SMP affinity of NIC interrupts.
*
* @param i A pointer to the interface structure
* @param affinity A mask specifying which cores should handle this interrupt.
* @retval 0 Success. Everything went well.
* @retval <0 Error. Something went wrong.
*/
int if_setaffinity(struct interface *i, int affinity);
/** Search the list of interfaces for a given index.
*
* @param index The interface index to search for
* @param interfaces A linked list of all interfaces
* @retval NULL if no interface with index was found.
* @retval >0 Success. A pointer to the interface.
*/
struct interface* if_lookup_index(int index, struct interface *interfaces);
#endif /* _IF_H_ */