]>
Commit | Line | Data |
---|---|---|
e9e2c950 RZ |
1 | /********************************************************************* |
2 | * Copyright 2017-2018 Network Device Education Foundation, Inc. ("NetDEF") | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License as published by the Free | |
6 | * Software Foundation; either version 2 of the License, or (at your option) | |
7 | * any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along | |
15 | * with this program; see the file COPYING; if not, write to the Free Software | |
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | * | |
18 | * bfdctl.h: all BFDd control socket protocol definitions. | |
19 | * | |
20 | * Authors | |
21 | * ------- | |
22 | * Rafael Zalamena <rzalamena@opensourcerouting.org> | |
23 | */ | |
24 | ||
25 | #ifndef _BFDCTRL_H_ | |
26 | #define _BFDCTRL_H_ | |
27 | ||
28 | #include <netinet/in.h> | |
29 | ||
30 | #include <stdbool.h> | |
31 | #include <stdint.h> | |
32 | ||
33 | /* | |
34 | * Auxiliary definitions | |
35 | */ | |
36 | struct sockaddr_any { | |
37 | union { | |
38 | struct sockaddr_in sa_sin; | |
39 | struct sockaddr_in6 sa_sin6; | |
40 | }; | |
41 | }; | |
42 | ||
43 | #ifndef MAXNAMELEN | |
44 | #define MAXNAMELEN 32 | |
45 | #endif | |
46 | ||
47 | #define BPC_DEF_DETECTMULTIPLIER 3 | |
48 | #define BPC_DEF_RECEIVEINTERVAL 300 /* milliseconds */ | |
49 | #define BPC_DEF_TRANSMITINTERVAL 300 /* milliseconds */ | |
50 | #define BPC_DEF_ECHOINTERVAL 50 /* milliseconds */ | |
51 | ||
52 | /* Peer status */ | |
53 | enum bfd_peer_status { | |
54 | BPS_SHUTDOWN = 0, /* == PTM_BFD_ADM_DOWN, "adm-down" */ | |
55 | BPS_DOWN = 1, /* == PTM_BFD_DOWN, "down" */ | |
56 | BPS_INIT = 2, /* == PTM_BFD_INIT, "init" */ | |
57 | BPS_UP = 3, /* == PTM_BFD_UP, "up" */ | |
58 | }; | |
59 | ||
60 | struct bfd_peer_cfg { | |
61 | bool bpc_mhop; | |
62 | bool bpc_ipv4; | |
63 | struct sockaddr_any bpc_peer; | |
64 | struct sockaddr_any bpc_local; | |
65 | ||
66 | bool bpc_has_label; | |
67 | char bpc_label[MAXNAMELEN]; | |
68 | ||
e9e2c950 RZ |
69 | bool bpc_has_localif; |
70 | char bpc_localif[MAXNAMELEN + 1]; | |
71 | ||
72 | bool bpc_has_vrfname; | |
73 | char bpc_vrfname[MAXNAMELEN + 1]; | |
74 | ||
75 | bool bpc_has_detectmultiplier; | |
76 | uint8_t bpc_detectmultiplier; | |
77 | ||
78 | bool bpc_has_recvinterval; | |
79 | uint64_t bpc_recvinterval; | |
80 | ||
81 | bool bpc_has_txinterval; | |
82 | uint64_t bpc_txinterval; | |
83 | ||
84 | bool bpc_has_echointerval; | |
85 | uint64_t bpc_echointerval; | |
86 | ||
87 | bool bpc_echo; | |
88 | bool bpc_createonly; | |
89 | bool bpc_shutdown; | |
90 | ||
9beff0bd PG |
91 | bool bpc_cbit; |
92 | ||
e9e2c950 RZ |
93 | /* Status information */ |
94 | enum bfd_peer_status bpc_bps; | |
95 | uint32_t bpc_id; | |
96 | uint32_t bpc_remoteid; | |
97 | uint8_t bpc_diag; | |
98 | uint8_t bpc_remotediag; | |
99 | uint8_t bpc_remote_detectmultiplier; | |
100 | uint64_t bpc_remote_recvinterval; | |
101 | uint64_t bpc_remote_txinterval; | |
102 | uint64_t bpc_remote_echointerval; | |
103 | uint64_t bpc_lastevent; | |
104 | }; | |
105 | ||
106 | ||
107 | /* | |
108 | * Protocol definitions | |
109 | */ | |
110 | enum bc_msg_version { | |
111 | BMV_VERSION_1 = 1, | |
112 | }; | |
113 | ||
114 | enum bc_msg_type { | |
115 | BMT_RESPONSE = 1, | |
116 | BMT_REQUEST_ADD = 2, | |
117 | BMT_REQUEST_DEL = 3, | |
118 | BMT_NOTIFY = 4, | |
119 | BMT_NOTIFY_ADD = 5, | |
120 | BMT_NOTIFY_DEL = 6, | |
121 | }; | |
122 | ||
123 | /* Notify flags to use with bcm_notify. */ | |
124 | #define BCM_NOTIFY_ALL ((uint64_t)-1) | |
125 | #define BCM_NOTIFY_PEER_STATE (1ULL << 0) | |
126 | #define BCM_NOTIFY_CONFIG (1ULL << 1) | |
127 | #define BCM_NOTIFY_NONE 0 | |
128 | ||
129 | /* Response 'status' definitions. */ | |
130 | #define BCM_RESPONSE_OK "ok" | |
131 | #define BCM_RESPONSE_ERROR "error" | |
132 | ||
133 | /* Notify operation. */ | |
134 | #define BCM_NOTIFY_PEER_STATUS "status" | |
135 | #define BCM_NOTIFY_CONFIG_ADD "add" | |
136 | #define BCM_NOTIFY_CONFIG_DELETE "delete" | |
137 | #define BCM_NOTIFY_CONFIG_UPDATE "update" | |
138 | ||
139 | /* Notification special ID. */ | |
140 | #define BCM_NOTIFY_ID 0 | |
141 | ||
142 | struct bfd_control_msg { | |
143 | /* Total length without the header. */ | |
144 | uint32_t bcm_length; | |
145 | /* | |
146 | * Message request/response id. | |
147 | * All requests will have a correspondent response with the | |
148 | * same id. | |
149 | */ | |
150 | uint16_t bcm_id; | |
151 | /* Message type. */ | |
152 | uint8_t bcm_type; | |
153 | /* Message version. */ | |
154 | uint8_t bcm_ver; | |
155 | /* Message payload. */ | |
156 | uint8_t bcm_data[0]; | |
157 | }; | |
158 | ||
159 | #endif |