1 package org.opendaylight.protocol.bgp.parser.impl.message;
3 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
4 import org.opendaylight.protocol.bgp.parser.spi.MessageParser;
5 import org.opendaylight.protocol.bgp.parser.spi.MessageSerializer;
6 import org.opendaylight.protocol.bgp.parser.spi.MessageUtil;
7 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Keepalive;
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.KeepaliveBuilder;
9 import org.opendaylight.yangtools.yang.binding.Notification;
11 import com.google.common.base.Preconditions;
13 public class BGPKeepAliveMessageParser implements MessageParser, MessageSerializer {
14 public static final int TYPE = 4;
15 public static final MessageParser PARSER;
16 public static final MessageSerializer SERIALIZER;
18 private static final Keepalive msg = new KeepaliveBuilder().build();
19 private static final byte[] bytes = MessageUtil.formatMessage(TYPE, new byte[0]);
23 final BGPKeepAliveMessageParser p = new BGPKeepAliveMessageParser();
28 private BGPKeepAliveMessageParser() {
33 public Keepalive parseMessageBody(final byte[] body, final int messageLength) throws BGPDocumentedException {
34 if (body.length != 0) {
35 throw BGPDocumentedException.badMessageLength("Message length field not within valid range.", messageLength);
42 public byte[] serializeMessage(final Notification message) {
43 Preconditions.checkArgument(message instanceof Keepalive);