]> git.proxmox.com Git - mirror_frr.git/blob - babeld/babel_interface.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / babeld / babel_interface.h
1 // SPDX-License-Identifier: MIT
2 /*
3 Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
4 */
5
6 #ifndef BABEL_INTERFACE_H
7 #define BABEL_INTERFACE_H
8
9 #include <zebra.h>
10 #include "zclient.h"
11 #include "vty.h"
12 #include "distribute.h"
13
14 #define CONFIG_DEFAULT 0
15 #define CONFIG_NO 1
16 #define CONFIG_YES 2
17
18 /* babeld interface information */
19 struct babel_interface {
20 unsigned short flags; /* see below */
21 unsigned short cost;
22 int channel;
23 struct timeval hello_timeout;
24 struct timeval update_timeout;
25 struct timeval flush_timeout;
26 struct timeval update_flush_timeout;
27 unsigned char *ipv4;
28 int buffered;
29 int bufsize;
30 /* Relative position of the Hello message in the send buffer, or
31 (-1) if there is none. */
32 int buffered_hello;
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;
42 int update_bufsize;
43 time_t bucket_time;
44 unsigned int bucket;
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. */
53 unsigned int rtt_min;
54 unsigned int rtt_max;
55 unsigned int max_rtt_penalty;
56
57 /* For filter type slot. */
58 struct access_list *list[DISTRIBUTE_MAX]; /* Access-list. */
59 struct prefix_list *prefix[DISTRIBUTE_MAX]; /* Prefix-list. */
60 };
61
62 typedef struct babel_interface babel_interface_nfo;
63 static inline babel_interface_nfo* babel_get_if_nfo(struct interface *ifp)
64 {
65 return ((babel_interface_nfo*) ifp->info);
66 }
67
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)
75
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
80
81 static inline int
82 if_up(struct interface *ifp)
83 {
84 return (if_is_operative(ifp) &&
85 ifp->connected != NULL &&
86 CHECK_FLAG(babel_get_if_nfo(ifp)->flags, BABEL_IF_IS_UP));
87 }
88
89 struct buffered_update {
90 unsigned char id[8];
91 unsigned char prefix[16];
92 unsigned char plen;
93 unsigned char pad[3];
94 };
95
96 /* init function */
97 void babel_if_init(void);
98
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);
106
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);
111
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 *);
119
120
121 #endif