]> git.proxmox.com Git - mirror_frr.git/blame - ldpd/keepalive.c
lib: use traditional yacc empty statement
[mirror_frr.git] / ldpd / keepalive.c
CommitLineData
8429abe0
RW
1/* $OpenBSD$ */
2
3/*
4 * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
5 *
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.
9 *
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.
17 */
18
eac6e3f0 19#include <zebra.h>
8429abe0
RW
20
21#include "ldpd.h"
22#include "ldpe.h"
23#include "log.h"
eac6e3f0 24#include "ldp_debug.h"
8429abe0
RW
25
26void
27send_keepalive(struct nbr *nbr)
28{
29 struct ibuf *buf;
30 uint16_t size;
31
32 size = LDP_HDR_SIZE + LDP_MSG_SIZE;
33 if ((buf = ibuf_open(size)) == NULL)
34 fatal(__func__);
35
36 gen_ldp_hdr(buf, size);
37 size -= LDP_HDR_SIZE;
38 gen_msg_hdr(buf, MSG_TYPE_KEEPALIVE, size);
39
eac6e3f0
RW
40 debug_kalive_send("keepalive: lsr-id %s", inet_ntoa(nbr->id));
41
8429abe0
RW
42 evbuf_enqueue(&nbr->tcp->wbuf, buf);
43}
44
45int
46recv_keepalive(struct nbr *nbr, char *buf, uint16_t len)
47{
48 struct ldp_msg msg;
49
50 memcpy(&msg, buf, sizeof(msg));
51 if (len != LDP_MSG_SIZE) {
52 session_shutdown(nbr, S_BAD_MSG_LEN, msg.id, msg.type);
53 return (-1);
54 }
55
eac6e3f0
RW
56 debug_kalive_recv("keepalive: lsr-id %s", inet_ntoa(nbr->id));
57
8429abe0
RW
58 if (nbr->state != NBR_STA_OPER)
59 nbr_fsm(nbr, NBR_EVT_KEEPALIVE_RCVD);
60
61 return (0);
62}