1 // SPDX-License-Identifier: MIT
3 Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
6 #ifndef BABEL_INTERFACE_H
7 #define BABEL_INTERFACE_H
12 #include "distribute.h"
14 #define CONFIG_DEFAULT 0
18 /* babeld interface information */
19 struct babel_interface
{
20 unsigned short flags
; /* see below */
23 struct timeval hello_timeout
;
24 struct timeval update_timeout
;
25 struct timeval flush_timeout
;
26 struct timeval update_flush_timeout
;
30 /* Relative position of the Hello message in the send buffer, or
31 (-1) if there is none. */
33 char have_buffered_id
;
34 char have_buffered_nh
;
35 char have_buffered_prefix
;
36 unsigned char buffered_id
[8];
37 unsigned char buffered_nh
[4];
38 unsigned char buffered_prefix
[16];
39 unsigned char *sendbuf
;
40 struct buffered_update
*buffered_updates
;
41 int num_buffered_updates
;
45 time_t last_update_time
;
46 unsigned short hello_seqno
;
47 unsigned hello_interval
;
48 unsigned update_interval
;
49 /* A higher value means we forget old RTT samples faster. Must be
50 between 1 and 256, inclusive. */
51 unsigned int rtt_decay
;
52 /* Parameters for computing the cost associated to RTT. */
55 unsigned int max_rtt_penalty
;
57 /* For filter type slot. */
58 struct access_list
*list
[DISTRIBUTE_MAX
]; /* Access-list. */
59 struct prefix_list
*prefix
[DISTRIBUTE_MAX
]; /* Prefix-list. */
62 typedef struct babel_interface babel_interface_nfo
;
63 static inline babel_interface_nfo
* babel_get_if_nfo(struct interface
*ifp
)
65 return ((babel_interface_nfo
*) ifp
->info
);
68 /* babel_interface_nfo flags */
69 #define BABEL_IF_IS_UP (1 << 0)
70 #define BABEL_IF_WIRED (1 << 1)
71 #define BABEL_IF_SPLIT_HORIZON (1 << 2)
72 #define BABEL_IF_LQ (1 << 3)
73 #define BABEL_IF_FARAWAY (1 << 4)
74 #define BABEL_IF_TIMESTAMPS (1 << 5)
76 /* Only INTERFERING can appear on the wire. */
77 #define BABEL_IF_CHANNEL_UNKNOWN 0
78 #define BABEL_IF_CHANNEL_INTERFERING 255
79 #define BABEL_IF_CHANNEL_NONINTERFERING -2
82 if_up(struct interface
*ifp
)
84 return (if_is_operative(ifp
) &&
85 ifp
->connected
!= NULL
&&
86 CHECK_FLAG(babel_get_if_nfo(ifp
)->flags
, BABEL_IF_IS_UP
));
89 struct buffered_update
{
91 unsigned char prefix
[16];
97 void babel_if_init(void);
99 /* Callback functions for zebra client */
100 int babel_interface_up (int, struct zclient
*, zebra_size_t
, vrf_id_t
);
101 int babel_interface_down (int, struct zclient
*, zebra_size_t
, vrf_id_t
);
102 int babel_interface_add (int, struct zclient
*, zebra_size_t
, vrf_id_t
);
103 int babel_interface_delete (int, struct zclient
*, zebra_size_t
, vrf_id_t
);
104 int babel_interface_address_add (int, struct zclient
*, zebra_size_t
, vrf_id_t
);
105 int babel_interface_address_delete (int, struct zclient
*, zebra_size_t
, vrf_id_t
);
107 int babel_ifp_create(struct interface
*ifp
);
108 int babel_ifp_up(struct interface
*ifp
);
109 int babel_ifp_down(struct interface
*ifp
);
110 int babel_ifp_destroy(struct interface
*ifp
);
112 unsigned jitter(babel_interface_nfo
*, int);
113 unsigned update_jitter(babel_interface_nfo
*babel_ifp
, int urgent
);
114 /* return "true" if "address" is one of our ipv6 addresses */
115 int is_interface_ll_address(struct interface
*ifp
, const unsigned char *address
);
116 /* Send retraction to all, and reset all interfaces statistics. */
117 void babel_interface_close_all(void);
118 extern int babel_enable_if_config_write (struct vty
*);