Search in sources :

Example 1 with BGPUpdateMessageParser

use of org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser in project bgpcep by opendaylight.

the class BGPActivator method registerMessageParsers.

private static void registerMessageParsers(final List<AutoCloseable> regs, final BGPExtensionProviderContext context) {
    final BGPOpenMessageParser omp = new BGPOpenMessageParser(context.getParameterRegistry());
    regs.add(context.registerMessageParser(BGPOpenMessageParser.TYPE, omp));
    regs.add(context.registerMessageSerializer(Open.class, omp));
    final BGPUpdateMessageParser ump = new BGPUpdateMessageParser(context.getAttributeRegistry());
    regs.add(context.registerMessageParser(BGPUpdateMessageParser.TYPE, ump));
    regs.add(context.registerMessageSerializer(Update.class, ump));
    final BGPNotificationMessageParser nmp = new BGPNotificationMessageParser();
    regs.add(context.registerMessageParser(BGPNotificationMessageParser.TYPE, nmp));
    regs.add(context.registerMessageSerializer(Notify.class, nmp));
    final BGPKeepAliveMessageParser kamp = new BGPKeepAliveMessageParser();
    regs.add(context.registerMessageParser(BGPKeepAliveMessageParser.TYPE, kamp));
    regs.add(context.registerMessageSerializer(Keepalive.class, kamp));
    final AddressFamilyRegistry afiReg = context.getAddressFamilyRegistry();
    final SubsequentAddressFamilyRegistry safiReg = context.getSubsequentAddressFamilyRegistry();
    final BGPRouteRefreshMessageParser rrmp = new BGPRouteRefreshMessageParser(afiReg, safiReg);
    regs.add(context.registerMessageParser(BGPRouteRefreshMessageParser.TYPE, rrmp));
    regs.add(context.registerMessageSerializer(RouteRefresh.class, rrmp));
}
Also used : BGPOpenMessageParser(org.opendaylight.protocol.bgp.parser.impl.message.BGPOpenMessageParser) BGPNotificationMessageParser(org.opendaylight.protocol.bgp.parser.impl.message.BGPNotificationMessageParser) AddressFamilyRegistry(org.opendaylight.protocol.bgp.parser.spi.AddressFamilyRegistry) SubsequentAddressFamilyRegistry(org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry) BGPUpdateMessageParser(org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser) Notify(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Notify) BGPRouteRefreshMessageParser(org.opendaylight.protocol.bgp.parser.impl.message.BGPRouteRefreshMessageParser) SubsequentAddressFamilyRegistry(org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry) BGPKeepAliveMessageParser(org.opendaylight.protocol.bgp.parser.impl.message.BGPKeepAliveMessageParser) RouteRefresh(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.RouteRefresh) Keepalive(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Keepalive) Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Open)

Example 2 with BGPUpdateMessageParser

use of org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser in project bgpcep by opendaylight.

the class BGPParserTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    updateParser = new BGPUpdateMessageParser(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getAttributeRegistry());
    for (int i = 1; i <= COUNTER; i++) {
        final String name = "/up" + i + ".bin";
        try (final InputStream is = BGPParserTest.class.getResourceAsStream(name)) {
            if (is == null) {
                throw new IOException("Failed to get resource " + name);
            }
            final ByteArrayOutputStream bis = new ByteArrayOutputStream();
            final byte[] data = new byte[MAX_SIZE];
            int nRead = 0;
            while ((nRead = is.read(data, 0, data.length)) != -1) {
                bis.write(data, 0, nRead);
            }
            bis.flush();
            inputBytes.add(bis.toByteArray());
            is.close();
        }
    }
    updatesWithMultiplePath = HexDumpBGPFileParser.parseMessages(BGPParserTest.class.getResourceAsStream(multiPathHexFile));
    constraint = mock(PeerSpecificParserConstraint.class);
    mpSupport = mock(MultiPathSupport.class);
    Mockito.doReturn(Optional.of(mpSupport)).when(constraint).getPeerConstraint(Mockito.any());
    Mockito.doReturn(true).when(mpSupport).isTableTypeSupported(Mockito.any());
}
Also used : BGPUpdateMessageParser(org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser) PeerSpecificParserConstraint(org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint) InputStream(java.io.InputStream) MultiPathSupport(org.opendaylight.protocol.bgp.parser.spi.MultiPathSupport) IOException(java.io.IOException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PeerSpecificParserConstraint(org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint) BeforeClass(org.junit.BeforeClass)

Example 3 with BGPUpdateMessageParser

use of org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser in project bgpcep by opendaylight.

the class ParserTest method setUp.

@Before
public void setUp() throws Exception {
    updateParser = new BGPUpdateMessageParser(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getAttributeRegistry());
    for (int i = 1; i <= COUNTER; i++) {
        final String name = "/up" + i + ".bin";
        try (final InputStream is = ParserTest.class.getResourceAsStream(name)) {
            if (is == null) {
                throw new IOException("Failed to get resource " + name);
            }
            final ByteArrayOutputStream bis = new ByteArrayOutputStream();
            final byte[] data = new byte[MAX_SIZE];
            int nRead;
            while ((nRead = is.read(data, 0, data.length)) != -1) {
                bis.write(data, 0, nRead);
            }
            bis.flush();
            inputBytes.add(bis.toByteArray());
            is.close();
        }
    }
}
Also used : BGPUpdateMessageParser(org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser) InputStream(java.io.InputStream) IOException(java.io.IOException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Before(org.junit.Before)

Aggregations

BGPUpdateMessageParser (org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 BGPKeepAliveMessageParser (org.opendaylight.protocol.bgp.parser.impl.message.BGPKeepAliveMessageParser)1 BGPNotificationMessageParser (org.opendaylight.protocol.bgp.parser.impl.message.BGPNotificationMessageParser)1 BGPOpenMessageParser (org.opendaylight.protocol.bgp.parser.impl.message.BGPOpenMessageParser)1 BGPRouteRefreshMessageParser (org.opendaylight.protocol.bgp.parser.impl.message.BGPRouteRefreshMessageParser)1 AddressFamilyRegistry (org.opendaylight.protocol.bgp.parser.spi.AddressFamilyRegistry)1 MultiPathSupport (org.opendaylight.protocol.bgp.parser.spi.MultiPathSupport)1 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)1 SubsequentAddressFamilyRegistry (org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry)1 Keepalive (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Keepalive)1 Notify (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Notify)1 Open (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Open)1 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)1 RouteRefresh (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.RouteRefresh)1