-
Notifications
You must be signed in to change notification settings - Fork 57
/
team_private.h
130 lines (116 loc) · 4.28 KB
/
team_private.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* team-private.h - Network team device driver library private header
* Copyright (C) 2011 Jiri Pirko <jpirko@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _TEAM_PRIVATE_H_
#define _TEAM_PRIVATE_H_
#include <stdarg.h>
#include <syslog.h>
#include <netlink/netlink.h>
#include <team.h>
#include <private/list.h>
#include "config.h"
#define TEAM_EXPORT __attribute__ ((visibility("default")))
/**
* SECTION: team_handler
* @short_description: libteam context
*/
struct team_handle {
int event_fd;
struct nl_sock * nl_sock;
unsigned int nl_sock_seq;
struct nl_sock * nl_sock_event;
bool msg_recv_started;
int family;
uint32_t ifindex;
struct team_ifinfo * ifinfo;
struct list_item port_list;
struct list_item ifinfo_list;
struct list_item option_list;
struct {
struct list_item list;
team_change_type_mask_t pending_type_mask;
} change_handler;
struct {
struct nl_sock * sock;
struct nl_sock * sock_event;
} nl_cli;
void (*log_fn)(struct team_handle *th, int priority,
const char *file, int line, const char *fn,
const char *format, va_list args);
int log_priority;
};
/**
* SECTION: logging
* @short_description: libteam logging facility
*/
void team_log(struct team_handle *th, int priority,
const char *file, int line, const char *fn,
const char *format, ...);
static inline void __attribute__((always_inline, format(printf, 2, 3)))
team_log_null(struct team_handle *th, const char *format, ...) {}
#define team_log_cond(th, prio, arg...) \
do { \
if (team_get_log_priority(th) >= prio) \
team_log(th, prio, __FILE__, __LINE__, \
__FUNCTION__, ## arg); \
} while (0)
#ifdef ENABLE_LOGGING
# ifdef ENABLE_DEBUG
# define dbg(th, arg...) team_log_cond(th, LOG_DEBUG, ## arg)
# else
# define dbg(th, arg...) team_log_null(th, ## arg)
# endif
# define info(th, arg...) team_log_cond(th, LOG_INFO, ## arg)
# define warn(th, arg...) team_log_cond(th, LOG_WARNING, ## arg)
# define err(th, arg...) team_log_cond(th, LOG_ERR, ## arg)
#else
# define dbg(th, arg...) team_log_null(th, ## arg)
# define info(th, arg...) team_log_null(th, ## arg)
# define warn(th, arg...) team_log_null(th, ## arg)
# define err(th, arg...) team_log_null(th, ## arg)
#endif
/**
* SECTION: function prototypes
* @short_description: prototypes for internal functions
*/
int get_port_list_handler(struct nl_msg *msg, void *arg);
int port_list_alloc(struct team_handle *th);
int port_list_init(struct team_handle *th);
void port_list_free(struct team_handle *th);
int ifinfo_event_handler(struct nl_msg *msg, void *arg);
int ifinfo_list_alloc(struct team_handle *th);
int ifinfo_list_init(struct team_handle *th);
void ifinfo_list_free(struct team_handle *th);
int ifinfo_link_with_port(struct team_handle *th, uint32_t ifindex,
struct team_port *port, struct team_ifinfo **p_ifinfo);
int ifinfo_link(struct team_handle *th, uint32_t ifindex,
struct team_ifinfo **p_ifinfo);
void ifinfo_unlink(struct team_ifinfo *ifinfo);
int get_options_handler(struct nl_msg *msg, void *arg);
int option_list_alloc(struct team_handle *th);
int option_list_init(struct team_handle *th);
void option_list_free(struct team_handle *th);
int nl2syserr(int nl_error);
int send_and_recv(struct team_handle *th, struct nl_msg *msg,
int (*valid_handler)(struct nl_msg *, void *),
void *valid_data);
void set_call_change_handlers(struct team_handle *th,
team_change_type_mask_t set_type_mask);
int check_call_change_handlers(struct team_handle *th,
team_change_type_mask_t call_type_mask);
#endif /* _TEAM_PRIVATE_H_ */