summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_damp.h
blob: 19bdbc7af3c1dfa934f4fe58cfcaff051a6de9ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 * OSPF flap dampening by Manav Bhatia
 * Copyright (C) 2002 
 * 
 * This file is part of GNU Zebra.
 * 
 * GNU Zebra is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2, or (at your option) any
 * later version.
 * 
 * GNU Zebra is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with GNU Zebra; see the file COPYING.  If not, write to the Free
 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.  
 */

/*
 * Flap Damping (target e.g. link/route)
 */

#define HAVE_OSPF6_DAMP

typedef enum
{
  OFF,
  ON,
} onoff_t;

typedef enum
{
  event_none,
  event_up,
  event_down,
} damp_event_t;

/* Structure maintained per target basis */
struct ospf6_damp_info
{
  /* identifier to decide which target */
  u_short type;
  struct prefix name;

  /* do we damping this info */
  onoff_t damping;

  u_int penalty;
  u_int flap;
  time_t t_start;   /* First flap (down event) time */
  time_t t_updated; /* Last time the penalty was updated */

  /* index and double-link for reuse list */
  int                    index;
  struct ospf6_damp_info *next;
  struct ospf6_damp_info *prev;

  /* the last event that we are avoiding */
  int (*event) (void *target);
  void *target;
  damp_event_t event_type;
  damp_event_t target_status;
};

#define OSPF6_DAMP_TYPE_ROUTE      0
#define OSPF6_DAMP_TYPE_MAX        1

/* Global Configuration Parameters */
struct ospf6_damp_config
{
  /* is damping enabled ? */
  onoff_t enabled;

  /* configurable parameters */
  u_int half_life;
  u_int suppress;
  u_int reuse;
  u_int t_hold;                 /* Maximum hold down time */

  /* Non configurable parameters */
  u_int   delta_t;
  u_int   delta_reuse;
  u_int   default_penalty;
  u_int   ceiling;              /* Max value a penalty can attain */
  double  scale_factor;

  int     decay_array_size;     /* Calculated using config parameters */
  double *decay_array;          /* Storage for decay values */

  int  reuse_index_array_size;  /* Size of reuse index array */
  int *reuse_index_array;

  int  reuse_list_size;         /* Number of reuse lists */
  struct ospf6_damp_info **reuse_list_array;
};

int ospf6_damp_reuse_timer (struct thread *);
void ospf6_damp_event_up   (u_short type, struct prefix *name,
                           int (*exec_up)   (void *), void *target);
void ospf6_damp_event_down (u_short type, struct prefix *name,
                           int (*exec_down) (void *), void *target);

void ospf6_damp_config_write (struct vty *);
void ospf6_damp_init ();