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.pcep.impl;
10 import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
13 * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.1">Common Message Header</a>
15 public class PCEPMessageHeaderDecoder extends LengthFieldBasedFrameDecoder {
17 private static final int MAX_FRAME_SIZE = 65528; // min 4, max 4096
19 private static final int VERSION_FLAGS_SIZE = 1;
21 private static final int LENGTH_SIZE = 2; // the length field represents the length of the whole message including
24 private static final int MESSAGE_TYPE_SIZE = 1;
28 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
29 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
30 | Ver | Flags | Message-Type | Message-Length |
31 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
35 public PCEPMessageHeaderDecoder() {
36 super(MAX_FRAME_SIZE, VERSION_FLAGS_SIZE + MESSAGE_TYPE_SIZE, LENGTH_SIZE, -LENGTH_SIZE - MESSAGE_TYPE_SIZE - VERSION_FLAGS_SIZE, 0);