import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
-import org.opendaylight.protocol.bgp.parser.impl.message.update.PathAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.SimpleAttributeRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.AttributeRegistry;
import org.opendaylight.protocol.bgp.parser.spi.MessageParser;
import org.opendaylight.protocol.concepts.Ipv4Util;
import org.opendaylight.protocol.util.ByteArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Preconditions;
+
/**
* LENGTH fields, that denote the length of the fields with variable length, have fixed SIZE.
*
*/
public class BGPUpdateMessageParser implements MessageParser {
public static final int TYPE = 2;
- public static final BGPUpdateMessageParser PARSER = new BGPUpdateMessageParser();
+ public static final BGPUpdateMessageParser PARSER = new BGPUpdateMessageParser(SimpleAttributeRegistry.INSTANCE);
private static Logger logger = LoggerFactory.getLogger(BGPUpdateMessageParser.class);
*/
public static final int TOTAL_PATH_ATTR_LENGTH_SIZE = 2;
- // Constructors -------------------------------------------------------
- private BGPUpdateMessageParser() {
+ private final AttributeRegistry reg;
+ // Constructors -------------------------------------------------------
+ public BGPUpdateMessageParser(final AttributeRegistry reg) {
+ this.reg = Preconditions.checkNotNull(reg);
}
// Getters & setters --------------------------------------------------
try {
if (totalPathAttrLength > 0) {
- final PathAttributes pathAttributes = PathAttributeParser.parseAttribute(ByteArray.subByte(body, byteOffset,
+ final PathAttributes pathAttributes = reg.parseAttributes(ByteArray.subByte(body, byteOffset,
totalPathAttrLength));
byteOffset += totalPathAttrLength;
eventBuilder.setPathAttributes(pathAttributes);