]>
git.proxmox.com Git - mirror_frr.git/blob - bfdd/event.c
654928b9b3759a7bd745dbe3aa7cd25935023328
1 /*********************************************************************
2 * Copyright 2017-2018 Network Device Education Foundation, Inc. ("NetDEF")
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along
15 * with this program; see the file COPYING; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * event.c: implements the BFD loop event handlers.
22 * Rafael Zalamena <rzalamena@opensourcerouting.org>
29 void tv_normalize(struct timeval
*tv
);
31 void tv_normalize(struct timeval
*tv
)
33 /* Remove seconds part from microseconds. */
34 tv
->tv_sec
= tv
->tv_usec
/ 1000000;
35 tv
->tv_usec
= tv
->tv_usec
% 1000000;
38 void bfd_recvtimer_update(struct bfd_session
*bs
)
40 struct timeval tv
= {.tv_sec
= 0, .tv_usec
= bs
->detect_TO
};
42 /* Remove previous schedule if any. */
43 bfd_recvtimer_delete(bs
);
45 /* Don't add event if peer is deactivated. */
46 if (CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
) ||
52 thread_add_timer_tv(master
, bfd_recvtimer_cb
, bs
, &tv
,
56 void bfd_echo_recvtimer_update(struct bfd_session
*bs
)
58 struct timeval tv
= {.tv_sec
= 0, .tv_usec
= bs
->echo_detect_TO
};
60 /* Remove previous schedule if any. */
61 bfd_echo_recvtimer_delete(bs
);
63 /* Don't add event if peer is deactivated. */
64 if (CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
) ||
70 thread_add_timer_tv(master
, bfd_echo_recvtimer_cb
, bs
, &tv
,
71 &bs
->echo_recvtimer_ev
);
74 void bfd_xmttimer_update(struct bfd_session
*bs
, uint64_t jitter
)
76 struct timeval tv
= {.tv_sec
= 0, .tv_usec
= jitter
};
78 /* Remove previous schedule if any. */
79 bfd_xmttimer_delete(bs
);
81 /* Don't add event if peer is deactivated. */
82 if (CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
) ||
88 thread_add_timer_tv(master
, bfd_xmt_cb
, bs
, &tv
, &bs
->xmttimer_ev
);
91 void bfd_echo_xmttimer_update(struct bfd_session
*bs
, uint64_t jitter
)
93 struct timeval tv
= {.tv_sec
= 0, .tv_usec
= jitter
};
95 /* Remove previous schedule if any. */
96 bfd_echo_xmttimer_delete(bs
);
98 /* Don't add event if peer is deactivated. */
99 if (CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
) ||
105 thread_add_timer_tv(master
, bfd_echo_xmt_cb
, bs
, &tv
,
106 &bs
->echo_xmttimer_ev
);
109 void bfd_recvtimer_delete(struct bfd_session
*bs
)
111 THREAD_OFF(bs
->recvtimer_ev
);
114 void bfd_echo_recvtimer_delete(struct bfd_session
*bs
)
116 THREAD_OFF(bs
->echo_recvtimer_ev
);
119 void bfd_xmttimer_delete(struct bfd_session
*bs
)
121 THREAD_OFF(bs
->xmttimer_ev
);
124 void bfd_echo_xmttimer_delete(struct bfd_session
*bs
)
126 THREAD_OFF(bs
->echo_xmttimer_ev
);