Blame src/vma/netlink/link_info.h

Packit Service aa3af4
/*
Packit Service aa3af4
 * Copyright (c) 2001-2020 Mellanox Technologies, Ltd. All rights reserved.
Packit Service aa3af4
 *
Packit Service aa3af4
 * This software is available to you under a choice of one of two
Packit Service aa3af4
 * licenses.  You may choose to be licensed under the terms of the GNU
Packit Service aa3af4
 * General Public License (GPL) Version 2, available from the file
Packit Service aa3af4
 * COPYING in the main directory of this source tree, or the
Packit Service aa3af4
 * BSD license below:
Packit Service aa3af4
 *
Packit Service aa3af4
 *     Redistribution and use in source and binary forms, with or
Packit Service aa3af4
 *     without modification, are permitted provided that the following
Packit Service aa3af4
 *     conditions are met:
Packit Service aa3af4
 *
Packit Service aa3af4
 *      - Redistributions of source code must retain the above
Packit Service aa3af4
 *        copyright notice, this list of conditions and the following
Packit Service aa3af4
 *        disclaimer.
Packit Service aa3af4
 *
Packit Service aa3af4
 *      - Redistributions in binary form must reproduce the above
Packit Service aa3af4
 *        copyright notice, this list of conditions and the following
Packit Service aa3af4
 *        disclaimer in the documentation and/or other materials
Packit Service aa3af4
 *        provided with the distribution.
Packit Service aa3af4
 *
Packit Service aa3af4
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit Service aa3af4
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit Service aa3af4
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Packit Service aa3af4
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
Packit Service aa3af4
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
Packit Service aa3af4
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit Service aa3af4
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit Service aa3af4
 * SOFTWARE.
Packit Service aa3af4
 */
Packit Service aa3af4
Packit Service aa3af4
Packit Service aa3af4
#ifndef NETLINK_LINK_INFO_H_
Packit Service aa3af4
#define NETLINK_LINK_INFO_H_
Packit Service aa3af4
Packit Service aa3af4
#include <netlink/route/link.h>
Packit Service aa3af4
#include <iostream>
Packit Service aa3af4
Packit Service aa3af4
class netlink_link_info
Packit Service aa3af4
{
Packit Service aa3af4
public:
Packit Service aa3af4
	netlink_link_info(struct rtnl_link* link);
Packit Service aa3af4
	virtual ~netlink_link_info()
Packit Service aa3af4
	{
Packit Service aa3af4
	}
Packit Service aa3af4
Packit Service aa3af4
	// fill all attributes using the provided netlink original link
Packit Service aa3af4
	void fill(struct rtnl_link* link);
Packit Service aa3af4
Packit Service aa3af4
Packit Service aa3af4
//	// Hardware type (eg. ARPHRD_ETHER or ARPHRD_VOID)
Packit Service aa3af4
//	uint32_t arptype;
Packit Service aa3af4
Packit Service aa3af4
	// the link layer broadcast address string
Packit Service aa3af4
	std::string broadcast_str;
Packit Service aa3af4
Packit Service aa3af4
	// Address family or AF_UNSPEC if not specified.
Packit Service aa3af4
	int addr_family;
Packit Service aa3af4
Packit Service aa3af4
	/* return link flags:
Packit Service aa3af4
	 * IFF_UP 			Link is up (administratively)
Packit Service aa3af4
	 * IFF_RUNNING 		Link is up and carrier is OK (RFC2863 OPER_UP)
Packit Service aa3af4
	 * IFF_LOWER_UP 	Link layer is operational
Packit Service aa3af4
	 * IFF_DORMANT		Driver signals dormant
Packit Service aa3af4
	 * IFF_BROADCAST	Link supports broadcasting
Packit Service aa3af4
	 * IFF_MULTICAST	Link supports multicasting
Packit Service aa3af4
	 * IFF_ALLMULTI		Link supports multicast routing
Packit Service aa3af4
	 * IFF_DEBUG		Tell driver to do debugging (currently unused)
Packit Service aa3af4
	 * IFF_LOOPBACK		Link loopback network
Packit Service aa3af4
	 * IFF_POINTOPOINT	Point-to-point link
Packit Service aa3af4
	 * IFF_NOARP		ARP is not supported
Packit Service aa3af4
	 * IFF_PROMISC		Status of promiscious mode
Packit Service aa3af4
	 * IFF_MASTER		Master of a load balancer (bonding)
Packit Service aa3af4
	 * IFF_SLAVE		Slave to a master link
Packit Service aa3af4
	 * IFF_PORTSEL		Driver supports setting media type (only used by ARM ethernet)
Packit Service aa3af4
	 * IFF_AUTOMEDIA	Link selects port automatically (only used by ARM ethernet)
Packit Service aa3af4
	 * IFF_ECHO			Echo sent packets (testing feature, CAN only)
Packit Service aa3af4
	 * IFF_DYNAMIC		Unused (BSD compatibility)
Packit Service aa3af4
	 * IFF_NOTRAILERS	Unused (BSD compatibility)
Packit Service aa3af4
	 *
Packit Service aa3af4
	 */
Packit Service aa3af4
	uint32_t flags;
Packit Service aa3af4
Packit Service aa3af4
	// the interface index of the link
Packit Service aa3af4
	int ifindex;
Packit Service aa3af4
Packit Service aa3af4
//	/* the link mode
Packit Service aa3af4
//	 * IF_LINK_MODE_DEFAULT Default link mode
Packit Service aa3af4
//	 * IF_LINK_MODE_DORMANT Limit upward transition to dormant
Packit Service aa3af4
//	 */
Packit Service aa3af4
//	uint8_t mode;
Packit Service aa3af4
Packit Service aa3af4
	// interface index of master link or 0 if not specified
Packit Service aa3af4
	int master_ifindex;
Packit Service aa3af4
Packit Service aa3af4
	/* the maximum transmission unit
Packit Service aa3af4
	 * specifies the maximum packet size a network device can transmit or receive
Packit Service aa3af4
	 * 	 */
Packit Service aa3af4
	uint32_t mtu;
Packit Service aa3af4
Packit Service aa3af4
	/* a unique,human readable description of the link.
Packit Service aa3af4
	 * by default, links are named based on their type and then enumerated,
Packit Service aa3af4
	 * e.g. eth0, eth1, ethn but they may be renamed at any time
Packit Service aa3af4
	 *  */
Packit Service aa3af4
	std::string name;
Packit Service aa3af4
Packit Service aa3af4
	/* extended information on the link status (from: RFC 2863 operational status linux/if.h)
Packit Service aa3af4
	 * 		Unknown state 		IF_OPER_UNKNOWN
Packit Service aa3af4
	 * 		Link not present 	IF_OPER_NOTPRESENT
Packit Service aa3af4
	 * 		Link down			IF_OPER_DOWN
Packit Service aa3af4
	 * 		L1 down				IF_OPER_LOWERLAYERDOWN
Packit Service aa3af4
	 * 		Testing				IF_OPER_TESTING
Packit Service aa3af4
	 * 		Dormant				IF_OPER_DORMANT
Packit Service aa3af4
	 * 		Link up 			IF_OPER_UP
Packit Service aa3af4
	 *
Packit Service aa3af4
	 */
Packit Service aa3af4
	uint8_t operstate;
Packit Service aa3af4
Packit Service aa3af4
	// transmission queue length
Packit Service aa3af4
	uint32_t txqlen;
Packit Service aa3af4
Packit Service aa3af4
	const std::string get_operstate2str() const;
Packit Service aa3af4
Packit Service aa3af4
};
Packit Service aa3af4
Packit Service aa3af4
#endif /* NETLINK_LINK_INFO_H_ */