Blame src/vma/netlink/netlink_compatibility.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
Packit Service aa3af4
#ifndef NETLINK_COMPATIBILITY_H_
Packit Service aa3af4
#define NETLINK_COMPATIBILITY_H_
Packit Service aa3af4
Packit Service aa3af4
#include <unistd.h>
Packit Service aa3af4
#include <asm/types.h>
Packit Service aa3af4
#include <sys/socket.h>
Packit Service aa3af4
#include <fcntl.h>
Packit Service aa3af4
#include "config.h"
Packit Service aa3af4
#include <netlink/netlink.h>
Packit Service aa3af4
#include <netlink/socket.h>
Packit Service aa3af4
#include <netlink/object-api.h>
Packit Service aa3af4
#include <netlink/route/rtnl.h>
Packit Service aa3af4
#include <netlink/route/route.h>
Packit Service aa3af4
#include "vma/infra/subject_observer.h"
Packit Service aa3af4
#include <map>
Packit Service aa3af4
using namespace std;
Packit Service aa3af4
Packit Service aa3af4
extern "C" void link_event_callback(nl_object* obj);
Packit Service aa3af4
extern "C" void neigh_event_callback(nl_object* obj);
Packit Service aa3af4
extern "C" void route_event_callback(nl_object* obj);
Packit Service aa3af4
Packit Service aa3af4
class netlink_wrapper;
Packit Service aa3af4
enum e_netlink_event_type
Packit Service aa3af4
{
Packit Service aa3af4
	nlgrpNEIGH = 0,
Packit Service aa3af4
	nlgrpLINK = 1,
Packit Service aa3af4
	nlgrpROUTE = 2,
Packit Service aa3af4
	/* TODO: not supported yet
Packit Service aa3af4
	nlgrpADDRESS=3,
Packit Service aa3af4
	nlgrpPREFIX=4,
Packit Service aa3af4
	*/
Packit Service aa3af4
};
Packit Service aa3af4
Packit Service aa3af4
#ifdef HAVE_LIBNL3
Packit Service aa3af4
Packit Service aa3af4
typedef struct nl_sock nl_socket_handle;
Packit Service aa3af4
#define rtnl_compatible_route_get_priority rtnl_route_get_priority
Packit Service aa3af4
Packit Service aa3af4
nl_sock* nl_socket_handle_alloc();
Packit Service aa3af4
void nl_socket_handle_free(struct nl_sock * sock);
Packit Service aa3af4
void neigh_callback(nl_cache* , nl_object* obj, int, void*);
Packit Service aa3af4
void link_callback(nl_cache* , nl_object* obj, int, void*);
Packit Service aa3af4
void route_callback(nl_cache* , nl_object* obj, int, void*);
Packit Service aa3af4
Packit Service aa3af4
#else //HAVE_LIBNL1
Packit Service aa3af4
Packit Service aa3af4
#define rtnl_compatible_route_get_priority rtnl_route_get_prio
Packit Service aa3af4
typedef struct nl_handle nl_socket_handle;
Packit Service aa3af4
Packit Service aa3af4
nl_handle* nl_socket_handle_alloc();
Packit Service aa3af4
void nl_socket_handle_free(struct nl_handle* handle);
Packit Service aa3af4
void neigh_callback(nl_cache* , nl_object* obj, int);
Packit Service aa3af4
void link_callback(nl_cache* , nl_object* obj, int);
Packit Service aa3af4
void route_callback(nl_cache* , nl_object* obj, int);
Packit Service aa3af4
Packit Service aa3af4
#endif
Packit Service aa3af4
Packit Service aa3af4
void nl_socket_handle_disable_seq_check(nl_socket_handle* handle);
Packit Service aa3af4
nl_cache_mngr* nl_cache_mngr_compatible_alloc(nl_socket_handle* handle, int protocol, int flags);
Packit Service aa3af4
int nl_cache_mngr_compatible_add(struct nl_cache_mngr*	mngr, const char* name, change_func_t cb, void*	data, struct nl_cache** result);
Packit Service aa3af4
in_addr_t nl_object_get_compatible_gateway(struct rtnl_route* nl_route_obj);
Packit Service aa3af4
int nl_object_get_compatible_oif(struct rtnl_route* nl_route_obj);
Packit Service aa3af4
int nl_object_get_compatible_metric(struct rtnl_route* nl_route_obj, int attr);
Packit Service aa3af4
Packit Service aa3af4
Packit Service aa3af4
#endif /* NETLINK_COMPATIBILITY_H_ */