libbgp  0.6
A C++ BGP Library.
bgp-keepalive-message.cc
Go to the documentation of this file.
1 
11 #include "bgp-keepalive-message.h"
12 #include "bgp-errcode.h"
13 #include <unistd.h>
14 
15 namespace libbgp {
16 
22 BgpKeepaliveMessage::BgpKeepaliveMessage(__attribute__((unused)) BgpLogHandler *loggger) : BgpMessage(logger) {
23  type = KEEPALIVE;
24 }
25 
26 ssize_t BgpKeepaliveMessage::parse(__attribute__((unused)) const uint8_t *from, size_t msg_sz) {
27  if (msg_sz != 0) {
28  size_t err_len = msg_sz + 19;
29  setError(E_HEADER, E_LENGTH, (uint8_t *) &err_len, 1);
30  return -1; // KEEPALIVE can't have message body
31  }
32 
33  return 0;
34 }
35 
36 ssize_t BgpKeepaliveMessage::write(__attribute__((unused)) uint8_t *to, __attribute__((unused)) size_t msg_sz) const {
37  return 0;
38 }
39 
40 ssize_t BgpKeepaliveMessage::doPrint(size_t indent, uint8_t **to, size_t *buf_sz) const {
41  return _print(indent, to, buf_sz, "KeepaliveMessage { }\n");
42 }
43 
44 }
BgpKeepaliveMessage(BgpLogHandler *logger)
Construct a new Bgp Keepalive Message:: Bgp Keepalive Message object.
ssize_t write(uint8_t *to, size_t buf_sz) const
Serialize a BGP message body.
static ssize_t _print(size_t indent, uint8_t **to, size_t *buf_left, const char *format,...)
Print helper.
ssize_t doPrint(size_t indent, uint8_t **to, size_t *buf_sz) const
Print implementation.
The BgpMessage base class.
Definition: bgp-message.h:35
void setError(uint8_t err, uint8_t suberr, const uint8_t *data, size_t data_len)
Set the error information.
Definition: serializable.cc:61
Definition: bgp-afi.h:14
The BgpLogHandler class.
The BGP keepalive message.
BGP error codes.
ssize_t parse(const uint8_t *from, size_t msg_sz)
Deserialize a BGP message body.