2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.bgp.rib.impl;
10 import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
13 * @see <a href="http://tools.ietf.org/html/rfc4271#section-4.1">BGP Message Header</a>
15 final class BGPMessageHeaderDecoder extends LengthFieldBasedFrameDecoder {
17 private static final int MARKER_SIZE = 16;
20 * the length field represents the length of the whole message including the header
22 private static final int LENGTH_SIZE = 2;
24 private static final int MAX_FRAME_SIZE = 4096;
26 private static final int EXTENDED_MAX_FRAME_SIZE = 65535;
31 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
32 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 private BGPMessageHeaderDecoder(final int maxFrameSize) {
48 super(maxFrameSize, MARKER_SIZE, LENGTH_SIZE, -MARKER_SIZE - LENGTH_SIZE, 0);
51 static BGPMessageHeaderDecoder getBGPMessageHeaderDecoder() {
52 return new BGPMessageHeaderDecoder(MAX_FRAME_SIZE);
55 static BGPMessageHeaderDecoder getExtendedBGPMessageHeaderDecoder() {
56 return new BGPMessageHeaderDecoder(EXTENDED_MAX_FRAME_SIZE);