BUG-7976: Race between peer removal and routes update
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / BGPMessageHeaderDecoder.java
index e4144ba9ef308f6955958d7b8d3e5a2dc66913fb..b22e3fbb7b0c9aa77f34cb0d59912a5a7cb7631e 100644 (file)
@@ -14,32 +14,47 @@ import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
  */
 public final class BGPMessageHeaderDecoder extends LengthFieldBasedFrameDecoder {
 
-       private static final int MAX_FRAME_SIZE = 4096; // min 19, max 4096
-
-       private static final int MARKER_SIZE = 16;
-
-       private static final int LENGTH_SIZE = 2; // the length field represents the length of the whole message including
-                                                                                               // the header
-
-       /*
-               
-        0                   1                   2                   3
-         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
-         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-         |                                                               |
-         +                                                               +
-         |                                                               |
-         +                                                               +
-         |                           Marker                              |
-         +                                                               +
-         |                                                               |
-         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-         |          Length               |      Type     |
-         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-         
-        */
-
-       public BGPMessageHeaderDecoder() {
-               super(MAX_FRAME_SIZE, MARKER_SIZE, LENGTH_SIZE, -MARKER_SIZE - LENGTH_SIZE, 0);
-       }
+    private static final int MARKER_SIZE = 16;
+
+    /*
+     * the length field represents the length of the whole message including the header
+     */
+    private static final int LENGTH_SIZE = 2;
+
+    private static final int MAX_FRAME_SIZE = 4096;
+
+    private static final int EXTENDED_MAX_FRAME_SIZE = 65535;
+
+    /*
+
+     0                   1                   2                   3
+      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
+      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+      |                                                               |
+      |                                                               |
+      |                                                               |
+      |                                                               |
+      |                           Marker                              |
+      |                                                               |
+      |                                                               |
+      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+      |          Length               |      Type     |
+      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+     */
+
+
+    private BGPMessageHeaderDecoder(final int maxFrameSize) {
+        super(maxFrameSize, MARKER_SIZE, LENGTH_SIZE, -MARKER_SIZE - LENGTH_SIZE, 0);
+    }
+
+    public static BGPMessageHeaderDecoder getBGPMessageHeaderDecoder() {
+        return new BGPMessageHeaderDecoder(MAX_FRAME_SIZE);
+    }
+
+    public static BGPMessageHeaderDecoder getExtendedBGPMessageHeaderDecoder() {
+        return new BGPMessageHeaderDecoder(EXTENDED_MAX_FRAME_SIZE);
+    }
+
+
 }