BUG-54 : switched channel pipeline to be protocol specific.
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / BGPMessageHeaderDecoder.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.bgp.rib.impl;
9
10 import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
11
12 /**
13  * @see <a href="http://tools.ietf.org/html/rfc4271#section-4.1">BGP Message Header</a>
14  */
15 public final class BGPMessageHeaderDecoder extends LengthFieldBasedFrameDecoder {
16
17         private static final int MAX_FRAME_SIZE = 4096; // min 19, max 4096
18
19         private static final int MARKER_SIZE = 16;
20
21         private static final int LENGTH_SIZE = 2; // the length field represents the length of the whole message including
22                                                                                                 // the header
23
24         /*
25                 
26          0                   1                   2                   3
27           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
28           +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29           |                                                               |
30           +                                                               +
31           |                                                               |
32           +                                                               +
33           |                           Marker                              |
34           +                                                               +
35           |                                                               |
36           +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37           |          Length               |      Type     |
38           +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39           
40          */
41
42         public BGPMessageHeaderDecoder() {
43                 super(MAX_FRAME_SIZE, MARKER_SIZE, LENGTH_SIZE, -MARKER_SIZE - LENGTH_SIZE, 0);
44         }
45 }