]>
git.proxmox.com Git - mirror_frr.git/blob - ldpd/keepalive.c
4 * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 #include "ldp_debug.h"
27 send_keepalive(struct nbr
*nbr
)
32 size
= LDP_HDR_SIZE
+ LDP_MSG_SIZE
;
33 if ((buf
= ibuf_open(size
)) == NULL
)
36 gen_ldp_hdr(buf
, size
);
38 gen_msg_hdr(buf
, MSG_TYPE_KEEPALIVE
, size
);
40 debug_kalive_send("keepalive: lsr-id %s", inet_ntoa(nbr
->id
));
42 evbuf_enqueue(&nbr
->tcp
->wbuf
, buf
);
43 nbr
->stats
.kalive_sent
++;
47 recv_keepalive(struct nbr
*nbr
, char *buf
, uint16_t len
)
51 memcpy(&msg
, buf
, sizeof(msg
));
52 if (len
!= LDP_MSG_SIZE
) {
53 session_shutdown(nbr
, S_BAD_MSG_LEN
, msg
.id
, msg
.type
);
57 debug_kalive_recv("keepalive: lsr-id %s", inet_ntoa(nbr
->id
));
59 if (nbr
->state
!= NBR_STA_OPER
)
60 nbr_fsm(nbr
, NBR_EVT_KEEPALIVE_RCVD
);