]> git.proxmox.com Git - mirror_frr.git/blame - babeld/babel_interface.h
Merge pull request #5793 from ton31337/fix/formatting_show_bgp_summary_failed
[mirror_frr.git] / babeld / babel_interface.h
CommitLineData
ca10883e
DS
1/*
2Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20THE SOFTWARE.
21*/
22
23#ifndef BABEL_INTERFACE_H
24#define BABEL_INTERFACE_H
25
26#include <zebra.h>
27#include "zclient.h"
28#include "vty.h"
29#include "distribute.h"
30
31#define CONFIG_DEFAULT 0
32#define CONFIG_NO 1
33#define CONFIG_YES 2
34
0437e105 35/* babeld interface information */
ca10883e
DS
36struct babel_interface {
37 unsigned short flags; /* see below */
38 unsigned short cost;
39 int channel;
40 struct timeval hello_timeout;
41 struct timeval update_timeout;
42 struct timeval flush_timeout;
43 struct timeval update_flush_timeout;
44 unsigned char *ipv4;
45 int buffered;
46 int bufsize;
47 /* Relative position of the Hello message in the send buffer, or
48 (-1) if there is none. */
49 int buffered_hello;
50 char have_buffered_id;
51 char have_buffered_nh;
52 char have_buffered_prefix;
01b08f09 53 unsigned char buffered_id[8];
ca10883e
DS
54 unsigned char buffered_nh[4];
55 unsigned char buffered_prefix[16];
56 unsigned char *sendbuf;
57 struct buffered_update *buffered_updates;
58 int num_buffered_updates;
59 int update_bufsize;
60 time_t bucket_time;
61 unsigned int bucket;
62 time_t last_update_time;
63 unsigned short hello_seqno;
64 unsigned hello_interval;
65 unsigned update_interval;
66 /* A higher value means we forget old RTT samples faster. Must be
67 between 1 and 256, inclusive. */
68 unsigned int rtt_decay;
69 /* Parameters for computing the cost associated to RTT. */
70 unsigned int rtt_min;
71 unsigned int rtt_max;
72 unsigned int max_rtt_penalty;
73
74 /* For filter type slot. */
75 struct access_list *list[DISTRIBUTE_MAX]; /* Access-list. */
76 struct prefix_list *prefix[DISTRIBUTE_MAX]; /* Prefix-list. */
77};
78
79typedef struct babel_interface babel_interface_nfo;
80static inline babel_interface_nfo* babel_get_if_nfo(struct interface *ifp)
81{
82 return ((babel_interface_nfo*) ifp->info);
83}
84
85/* babel_interface_nfo flags */
86#define BABEL_IF_IS_UP (1 << 0)
87#define BABEL_IF_WIRED (1 << 1)
88#define BABEL_IF_SPLIT_HORIZON (1 << 2)
89#define BABEL_IF_LQ (1 << 3)
90#define BABEL_IF_FARAWAY (1 << 4)
91#define BABEL_IF_TIMESTAMPS (1 << 5)
92
93/* Only INTERFERING can appear on the wire. */
94#define BABEL_IF_CHANNEL_UNKNOWN 0
95#define BABEL_IF_CHANNEL_INTERFERING 255
96#define BABEL_IF_CHANNEL_NONINTERFERING -2
97
98static inline int
99if_up(struct interface *ifp)
100{
101 return (if_is_operative(ifp) &&
102 ifp->connected != NULL &&
103 (babel_get_if_nfo(ifp)->flags & BABEL_IF_IS_UP));
104}
105
ca10883e
DS
106struct buffered_update {
107 unsigned char id[8];
108 unsigned char prefix[16];
109 unsigned char plen;
110 unsigned char pad[3];
111};
112
ca10883e
DS
113/* init function */
114void babel_if_init(void);
115
116/* Callback functions for zebra client */
117int babel_interface_up (int, struct zclient *, zebra_size_t, vrf_id_t);
118int babel_interface_down (int, struct zclient *, zebra_size_t, vrf_id_t);
119int babel_interface_add (int, struct zclient *, zebra_size_t, vrf_id_t);
120int babel_interface_delete (int, struct zclient *, zebra_size_t, vrf_id_t);
121int babel_interface_address_add (int, struct zclient *, zebra_size_t, vrf_id_t);
122int babel_interface_address_delete (int, struct zclient *, zebra_size_t, vrf_id_t);
123
138c5a74
DS
124int babel_ifp_create(struct interface *ifp);
125int babel_ifp_up(struct interface *ifp);
126int babel_ifp_down(struct interface *ifp);
127int babel_ifp_destroy(struct interface *ifp);
128
ca10883e
DS
129unsigned jitter(babel_interface_nfo *, int);
130unsigned update_jitter(babel_interface_nfo *babel_ifp, int urgent);
131/* return "true" if "address" is one of our ipv6 addresses */
132int is_interface_ll_address(struct interface *ifp, const unsigned char *address);
133/* Send retraction to all, and reset all interfaces statistics. */
134void babel_interface_close_all(void);
135extern int babel_enable_if_config_write (struct vty *);
136
137
138#endif