]> git.proxmox.com Git - mirror_frr.git/blame - ldpd/keepalive.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / ldpd / keepalive.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: ISC
8429abe0
RW
2/* $OpenBSD$ */
3
4/*
5 * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
8429abe0
RW
6 */
7
eac6e3f0 8#include <zebra.h>
8429abe0
RW
9
10#include "ldpd.h"
11#include "ldpe.h"
12#include "log.h"
eac6e3f0 13#include "ldp_debug.h"
8429abe0
RW
14
15void
16send_keepalive(struct nbr *nbr)
17{
18 struct ibuf *buf;
19 uint16_t size;
20
21 size = LDP_HDR_SIZE + LDP_MSG_SIZE;
22 if ((buf = ibuf_open(size)) == NULL)
23 fatal(__func__);
24
25 gen_ldp_hdr(buf, size);
26 size -= LDP_HDR_SIZE;
27 gen_msg_hdr(buf, MSG_TYPE_KEEPALIVE, size);
28
903a7226 29 debug_kalive_send("keepalive: lsr-id %pI4", &nbr->id);
eac6e3f0 30
8429abe0 31 evbuf_enqueue(&nbr->tcp->wbuf, buf);
0f7b5df9 32 nbr->stats.kalive_sent++;
8429abe0
RW
33}
34
35int
36recv_keepalive(struct nbr *nbr, char *buf, uint16_t len)
37{
38 struct ldp_msg msg;
39
40 memcpy(&msg, buf, sizeof(msg));
41 if (len != LDP_MSG_SIZE) {
42 session_shutdown(nbr, S_BAD_MSG_LEN, msg.id, msg.type);
43 return (-1);
44 }
45
903a7226 46 debug_kalive_recv("keepalive: lsr-id %pI4", &nbr->id);
eac6e3f0 47
8429abe0
RW
48 if (nbr->state != NBR_STA_OPER)
49 nbr_fsm(nbr, NBR_EVT_KEEPALIVE_RCVD);
50
51 return (0);
52}