24 BgpNotificationMessage::BgpNotificationMessage(__attribute__((unused)) BgpLogHandler *loggger) : BgpMessage(logger) {
30 BgpNotificationMessage::~BgpNotificationMessage() {
31 if (data_len > 0) free(data);
42 BgpNotificationMessage::BgpNotificationMessage(__attribute__((unused)) BgpLogHandler *loggger, uint8_t errcode, uint8_t subcode,
const uint8_t *data, uint16_t data_len) :
BgpMessage(logger) {
44 this->errcode = errcode;
45 this->subcode = subcode;
46 this->data_len = data_len;
48 this->data = (uint8_t *) malloc(data_len);
49 memcpy(this->data, data, data_len);
55 setError(E_HEADER, E_LENGTH, NULL, 0);
59 const uint8_t *buffer = from;
61 errcode = getValue<uint8_t>(&buffer);
62 subcode = getValue<uint8_t>(&buffer);
65 setError(E_HEADER, E_LENGTH, NULL, 0);
73 if (buf_sz < (
size_t) (data_len + 2))
return -1;
76 putValue<uint8_t>(&buffer, errcode);
77 putValue<uint8_t>(&buffer, subcode);
78 memcpy(buffer, data, data_len);
86 written +=
_print(indent, to, buf_sz,
"NotificationMessage {\n");
98 written +=
_print(indent, to, buf_sz,
"Error { %s }\n", err_msg);
99 written +=
_print(indent, to, buf_sz,
"SubError { %s }\n", err_sub_msg);
102 written +=
_print(indent, to, buf_sz,
"}\n");
ssize_t doPrint(size_t indent, uint8_t **to, size_t *buf_sz) const
Print implementation.
const char * bgp_error_code_str[7]
Error strings for BGP error codes.
BgpMessage(BgpLogHandler *logger)
Construct a new Bgp Message object.
static ssize_t _print(size_t indent, uint8_t **to, size_t *buf_left, const char *format,...)
Print helper.
ssize_t write(uint8_t *to, size_t buf_sz) const
Serialize a BGP message body.
ssize_t parse(const uint8_t *from, size_t msg_sz)
Deserialize a BGP message body.
const char * bgp_fsm_error_str[4]
Error strings for BGP FSM error subcodes.
const char * bgp_cease_error_str[9]
Error strings for BGP cease error subcodes.
void setError(uint8_t err, uint8_t suberr, const uint8_t *data, size_t data_len)
Set the error information.
Buffer operation helpers.
const char * bgp_open_error_subcode_str[8]
Error strings for BGP open message error subcodes.
const char * bgp_update_error_str[12]
Error strings for BGP update message error subcodes.
The BGP notification message.
const char * bgp_header_error_subcode_str[4]
Error strings for BGP header error subcodes.