-
Notifications
You must be signed in to change notification settings - Fork 5
/
bfdctl.h
163 lines (134 loc) · 3.77 KB
/
bfdctl.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*********************************************************************
* Copyright 2017-2018 Network Device Education Foundation, Inc. ("NetDEF")
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* bfdctl.h: all BFDd control socket protocol definitions.
*
* Authors
* -------
* Rafael Zalamena <[email protected]>
*/
#ifndef _BFDCTRL_H_
#define _BFDCTRL_H_
#include <netinet/in.h>
#include <stdbool.h>
#include <stdint.h>
/*
* Auxiliary definitions
*/
struct sockaddr_any {
union {
struct sockaddr_in sa_sin;
struct sockaddr_in6 sa_sin6;
};
};
#ifndef MAXNAMELEN
#define MAXNAMELEN 32
#endif
#define BPC_DEF_DETECTMULTIPLIER 3
#define BPC_DEF_RECEIVEINTERVAL 300 /* milliseconds */
#define BPC_DEF_TRANSMITINTERVAL 300 /* milliseconds */
#define BPC_DEF_ECHOINTERVAL 50 /* milliseconds */
/* Peer status */
enum bfd_peer_status {
BPS_SHUTDOWN = 0, /* == PTM_BFD_ADM_DOWN, "adm-down" */
BPS_DOWN = 1, /* == PTM_BFD_DOWN, "down" */
BPS_INIT = 2, /* == PTM_BFD_INIT, "init" */
BPS_UP = 3, /* == PTM_BFD_UP, "up" */
};
struct bfd_peer_cfg {
bool bpc_mhop;
bool bpc_ipv4;
struct sockaddr_any bpc_peer;
struct sockaddr_any bpc_local;
bool bpc_has_label;
char bpc_label[MAXNAMELEN];
bool bpc_has_vxlan;
unsigned int bpc_vxlan;
bool bpc_has_localif;
char bpc_localif[MAXNAMELEN + 1];
bool bpc_has_vrfname;
char bpc_vrfname[MAXNAMELEN + 1];
bool bpc_has_detectmultiplier;
uint8_t bpc_detectmultiplier;
bool bpc_has_recvinterval;
uint64_t bpc_recvinterval;
bool bpc_has_txinterval;
uint64_t bpc_txinterval;
bool bpc_has_echointerval;
uint64_t bpc_echointerval;
bool bpc_echo;
bool bpc_createonly;
bool bpc_shutdown;
/* Status information */
enum bfd_peer_status bpc_bps;
uint32_t bpc_id;
uint32_t bpc_remoteid;
uint8_t bpc_diag;
uint8_t bpc_remotediag;
uint8_t bpc_remote_detectmultiplier;
uint64_t bpc_remote_recvinterval;
uint64_t bpc_remote_txinterval;
uint64_t bpc_remote_echointerval;
uint64_t bpc_lastevent;
};
/*
* Protocol definitions
*/
#define BFD_CONTROL_SOCK_PATH "/var/run/bfdd.sock"
enum bc_msg_version {
BMV_VERSION_1 = 1,
};
enum bc_msg_type {
BMT_RESPONSE = 1,
BMT_REQUEST_ADD = 2,
BMT_REQUEST_DEL = 3,
BMT_NOTIFY = 4,
BMT_NOTIFY_ADD = 5,
BMT_NOTIFY_DEL = 6,
};
/* Notify flags to use with bcm_notify. */
#define BCM_NOTIFY_ALL ((uint64_t)-1)
#define BCM_NOTIFY_PEER_STATE (1ULL << 0)
#define BCM_NOTIFY_CONFIG (1ULL << 1)
#define BCM_NOTIFY_NONE 0
/* Response 'status' definitions. */
#define BCM_RESPONSE_OK "ok"
#define BCM_RESPONSE_ERROR "error"
/* Notify operation. */
#define BCM_NOTIFY_PEER_STATUS "status"
#define BCM_NOTIFY_CONFIG_ADD "add"
#define BCM_NOTIFY_CONFIG_DELETE "delete"
#define BCM_NOTIFY_CONFIG_UPDATE "update"
/* Notification special ID. */
#define BCM_NOTIFY_ID 0
struct bfd_control_msg {
/* Total length without the header. */
uint32_t bcm_length;
/*
* Message request/response id.
* All requests will have a correspondent response with the
* same id.
*/
uint16_t bcm_id;
/* Message type. */
uint8_t bcm_type;
/* Message version. */
uint8_t bcm_ver;
/* Message payload. */
uint8_t bcm_data[0];
};
#endif