]> git.proxmox.com Git - mirror_frr.git/blob - bfdd/bfdctl.h
Merge pull request #13578 from opensourcerouting/fix/ripd_argv_find
[mirror_frr.git] / bfdd / bfdctl.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*********************************************************************
3 * Copyright 2017-2018 Network Device Education Foundation, Inc. ("NetDEF")
4 *
5 * bfdctl.h: all BFDd control socket protocol definitions.
6 *
7 * Authors
8 * -------
9 * Rafael Zalamena <rzalamena@opensourcerouting.org>
10 */
11
12 #ifndef _BFDCTRL_H_
13 #define _BFDCTRL_H_
14
15 #include <netinet/in.h>
16
17 #include <stdbool.h>
18 #include <stdint.h>
19
20 /*
21 * Auxiliary definitions
22 */
23 struct sockaddr_any {
24 union {
25 struct sockaddr_in sa_sin;
26 struct sockaddr_in6 sa_sin6;
27 };
28 };
29
30 #ifndef MAXNAMELEN
31 #define MAXNAMELEN 32
32 #endif
33
34 #define BPC_DEF_DETECTMULTIPLIER 3
35 #define BPC_DEF_RECEIVEINTERVAL 300 /* milliseconds */
36 #define BPC_DEF_TRANSMITINTERVAL 300 /* milliseconds */
37 #define BPC_DEF_ECHORECEIVEINTERVAL 50 /* milliseconds */
38 #define BPC_DEF_ECHOTRANSMITINTERVAL 50 /* milliseconds */
39
40 /* Peer status */
41 enum bfd_peer_status {
42 BPS_SHUTDOWN = 0, /* == PTM_BFD_ADM_DOWN, "adm-down" */
43 BPS_DOWN = 1, /* == PTM_BFD_DOWN, "down" */
44 BPS_INIT = 2, /* == PTM_BFD_INIT, "init" */
45 BPS_UP = 3, /* == PTM_BFD_UP, "up" */
46 };
47
48 struct bfd_peer_cfg {
49 bool bpc_mhop;
50 bool bpc_ipv4;
51 struct sockaddr_any bpc_peer;
52 struct sockaddr_any bpc_local;
53
54 bool bpc_has_label;
55 char bpc_label[MAXNAMELEN];
56
57 bool bpc_has_localif;
58 char bpc_localif[MAXNAMELEN + 1];
59
60 bool bpc_has_vrfname;
61 char bpc_vrfname[MAXNAMELEN + 1];
62
63 bool bpc_has_detectmultiplier;
64 uint8_t bpc_detectmultiplier;
65
66 bool bpc_has_recvinterval;
67 uint64_t bpc_recvinterval;
68
69 bool bpc_has_txinterval;
70 uint64_t bpc_txinterval;
71
72 bool bpc_has_echorecvinterval;
73 uint64_t bpc_echorecvinterval;
74
75 bool bpc_has_echotxinterval;
76 uint64_t bpc_echotxinterval;
77
78 bool bpc_has_minimum_ttl;
79 uint8_t bpc_minimum_ttl;
80
81 bool bpc_echo;
82 bool bpc_createonly;
83 bool bpc_shutdown;
84
85 bool bpc_cbit;
86 bool bpc_passive;
87
88 bool bpc_has_profile;
89 char bpc_profile[64];
90
91 /* Status information */
92 enum bfd_peer_status bpc_bps;
93 uint32_t bpc_id;
94 uint32_t bpc_remoteid;
95 uint8_t bpc_diag;
96 uint8_t bpc_remotediag;
97 uint8_t bpc_remote_detectmultiplier;
98 uint64_t bpc_remote_recvinterval;
99 uint64_t bpc_remote_txinterval;
100 uint64_t bpc_remote_echointerval;
101 uint64_t bpc_lastevent;
102 };
103
104
105 /*
106 * Protocol definitions
107 */
108 enum bc_msg_version {
109 BMV_VERSION_1 = 1,
110 };
111
112 enum bc_msg_type {
113 BMT_RESPONSE = 1,
114 BMT_REQUEST_ADD = 2,
115 BMT_REQUEST_DEL = 3,
116 BMT_NOTIFY = 4,
117 BMT_NOTIFY_ADD = 5,
118 BMT_NOTIFY_DEL = 6,
119 };
120
121 /* Notify flags to use with bcm_notify. */
122 #define BCM_NOTIFY_ALL ((uint64_t)-1)
123 #define BCM_NOTIFY_PEER_STATE (1ULL << 0)
124 #define BCM_NOTIFY_CONFIG (1ULL << 1)
125 #define BCM_NOTIFY_NONE 0
126
127 /* Response 'status' definitions. */
128 #define BCM_RESPONSE_OK "ok"
129 #define BCM_RESPONSE_ERROR "error"
130
131 /* Notify operation. */
132 #define BCM_NOTIFY_PEER_STATUS "status"
133 #define BCM_NOTIFY_CONFIG_ADD "add"
134 #define BCM_NOTIFY_CONFIG_DELETE "delete"
135 #define BCM_NOTIFY_CONFIG_UPDATE "update"
136
137 /* Notification special ID. */
138 #define BCM_NOTIFY_ID 0
139
140 struct bfd_control_msg {
141 /* Total length without the header. */
142 uint32_t bcm_length;
143 /*
144 * Message request/response id.
145 * All requests will have a correspondent response with the
146 * same id.
147 */
148 uint16_t bcm_id;
149 /* Message type. */
150 uint8_t bcm_type;
151 /* Message version. */
152 uint8_t bcm_ver;
153 /* Message payload. */
154 uint8_t bcm_data[0];
155 };
156
157 #endif