<artifactId>topology-api-config</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-api-cfg</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-netty</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-netty-cfg</artifactId>
- <version>${project.version}</version>
- </dependency>
</dependencies>
</dependencyManagement>
<artifactId>bgp-rib-spi</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.tcpmd5</groupId>
<artifactId>tcpmd5-api</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.tcpmd5</groupId>
<artifactId>tcpmd5-netty</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bgp-parser-impl</artifactId>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-netty</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.tcpmd5</groupId>
<artifactId>tcpmd5-jni</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.tcpmd5</groupId>
<artifactId>tcpmd5-jni</artifactId>
<type>test-jar</type>
<scope>test</scope>
import io.netty.util.concurrent.Future;
import java.net.InetSocketAddress;
import java.util.List;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
import org.opendaylight.controller.config.api.JmxAttributeValidationException;
import org.opendaylight.protocol.bgp.rib.impl.BGPPeer;
import org.opendaylight.protocol.bgp.rib.impl.StrictBGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
+import org.opendaylight.tcpmd5.api.KeyMapping;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.BgpParameters;
import java.net.InetSocketAddress;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-import org.opendaylight.bgpcep.tcpmd5.netty.MD5ChannelFactory;
-import org.opendaylight.bgpcep.tcpmd5.netty.MD5ChannelOption;
-import org.opendaylight.bgpcep.tcpmd5.netty.MD5ServerChannelFactory;
import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
import org.opendaylight.protocol.framework.AbstractDispatcher;
import org.opendaylight.protocol.framework.ReconnectStrategy;
import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
+import org.opendaylight.tcpmd5.api.KeyMapping;
+import org.opendaylight.tcpmd5.netty.MD5ChannelFactory;
+import org.opendaylight.tcpmd5.netty.MD5ChannelOption;
+import org.opendaylight.tcpmd5.netty.MD5ServerChannelFactory;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
import io.netty.util.concurrent.Future;
import java.net.InetSocketAddress;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
import org.opendaylight.protocol.bgp.parser.BGPSession;
import org.opendaylight.protocol.framework.ReconnectStrategy;
import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
+import org.opendaylight.tcpmd5.api.KeyMapping;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
import io.netty.channel.ChannelFuture;
import java.net.InetSocketAddress;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
+import org.opendaylight.tcpmd5.api.KeyMapping;
/**
* Dispatcher class for creating BGP server.
import javax.management.InstanceAlreadyExistsException;
import javax.management.ObjectName;
import org.junit.Test;
-import org.opendaylight.bgpcep.tcpmd5.jni.NativeTestSupport;
import org.opendaylight.controller.config.api.IdentityAttributeRef;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.CommitStatus;
import org.opendaylight.controller.config.yang.tcpmd5.jni.cfg.NativeKeyAccessFactoryModuleFactory;
import org.opendaylight.controller.config.yang.tcpmd5.netty.cfg.MD5ClientChannelFactoryModuleFactory;
import org.opendaylight.controller.config.yang.tcpmd5.netty.cfg.MD5ClientChannelFactoryModuleMXBean;
+import org.opendaylight.tcpmd5.jni.NativeTestSupport;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
<controller.config.version>0.2.5-SNAPSHOT</controller.config.version>
<controller.framework.version>0.5.0-SNAPSHOT</controller.framework.version>
<controller.mdsal.version>1.1-SNAPSHOT</controller.mdsal.version>
+
+ <!-- TCP-MD5 artifacts -->
+ <tcpmd5.version>1.0.0-SNAPSHOT</tcpmd5.version>
</properties>
<dependencyManagement>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
- </dependency>
+ </dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.tcpmd5</groupId>
+ <artifactId>tcpmd5-api</artifactId>
+ <version>${tcpmd5.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.tcpmd5</groupId>
+ <artifactId>tcpmd5-netty</artifactId>
+ <version>${tcpmd5.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.tcpmd5</groupId>
<artifactId>tcpmd5-jni</artifactId>
- <version>${project.version}</version>
+ <version>${tcpmd5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.tcpmd5</groupId>
<artifactId>tcpmd5-jni</artifactId>
- <version>${project.version}</version>
+ <version>${tcpmd5.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
ret.add(mavenBundle("org.opendaylight.yangtools.model", "ietf-topology").versionAsInProject());
ret.add(mavenBundle("org.opendaylight.yangtools.model", "yang-ext").versionAsInProject());
+ ret.add(mavenBundle("org.opendaylight.tcpmd5", "tcpmd5-api").versionAsInProject());
+ ret.add(mavenBundle("org.opendaylight.tcpmd5", "tcpmd5-netty").versionAsInProject());
+
ret.add(mavenBundle("org.javassist", "javassist").versionAsInProject());
ret.add(mavenBundle("org.opendaylight.controller", "config-api").versionAsInProject());
ret.add(mavenBundle("org.opendaylight.controller", "netty-config-api").versionAsInProject());
@Override
protected Collection<String> prerequisiteBundles() {
return Lists.newArrayList("concepts", "bgp-concepts", "bgp-linkstate", "bgp-parser-api", "bgp-parser-impl", "bgp-parser-spi",
- "bgp-rib-api", "bgp-rib-spi", "bgp-util", "rsvp-api", "tcpmd5-api", "tcpmd5-netty", "util");
+ "bgp-rib-api", "bgp-rib-spi", "bgp-util", "rsvp-api", "util");
}
@Override
@Override
protected Collection<String> prerequisiteBundles() {
return Lists.newArrayList("concepts", "bgp-concepts", "bgp-linkstate", "bgp-parser-api", "bgp-parser-impl", "bgp-parser-spi",
- "bgp-rib-api", "bgp-rib-impl", "bgp-rib-spi", "bgp-util", "rsvp-api", "tcpmd5-api", "tcpmd5-netty", "util");
+ "bgp-rib-api", "bgp-rib-impl", "bgp-rib-spi", "bgp-util", "rsvp-api", "util");
}
@Override
public final class PcepApiBundleTest extends AbstractBundleTest {
@Override
protected Collection<String> prerequisiteBundles() {
- return Lists.newArrayList("concepts", "rsvp-api", "tcpmd5-api", "util");
+ return Lists.newArrayList("concepts", "rsvp-api", "util");
}
@Override
protected Collection<String> prerequisiteBundles() {
return Lists.newArrayList("concepts", "pcep-api", "pcep-spi", "pcep-ietf-stateful02", "pcep-ietf-stateful07",
"pcep-topology-api", "pcep-tunnel-api", "rsvp-api", "programming-api", "programming-topology-api", "topology-api",
- "topology-tunnel-api", "programming-tunnel-api", "tcpmd5-api", "tcpmd5-netty", "util");
+ "topology-tunnel-api", "programming-tunnel-api", "util");
}
@Override
public final class PcepSpiBundleTest extends AbstractBundleTest {
@Override
protected Collection<String> prerequisiteBundles() {
- return Lists.newArrayList("concepts", "pcep-api", "rsvp-api", "tcpmd5-api", "util");
+ return Lists.newArrayList("concepts", "pcep-api", "rsvp-api", "util");
}
@Override
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
import org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext;
import org.opendaylight.protocol.bgp.util.HexDumpBGPFileParser;
import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
+import org.opendaylight.tcpmd5.api.KeyMapping;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.LinkstateAddressFamily;
mavenBundle("org.opendaylight.bgpcep", "pcep-spi").versionAsInProject(), //
mavenBundle("org.opendaylight.bgpcep", "pcep-ietf-stateful02").versionAsInProject(), //
mavenBundle("org.opendaylight.bgpcep", "pcep-ietf-stateful07").versionAsInProject(), //
- mavenBundle("org.opendaylight.bgpcep", "tcpmd5-api").versionAsInProject(), //
- mavenBundle("org.opendaylight.bgpcep", "tcpmd5-netty").versionAsInProject(), //
+ mavenBundle("org.opendaylight.tcpmd5", "tcpmd5-api").versionAsInProject(), //
+ mavenBundle("org.opendaylight.tcpmd5", "tcpmd5-netty").versionAsInProject(), //
mavenBundle("org.opendaylight.bgpcep", "topology-api").versionAsInProject(), //
mavenBundle("org.opendaylight.bgpcep", "topology-tunnel-api").versionAsInProject(), //
mavenBundle("org.opendaylight.bgpcep", "programming-topology-api").versionAsInProject(), //
<artifactId>rsvp-api</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.tcpmd5</groupId>
<artifactId>tcpmd5-api</artifactId>
</dependency>
<dependency>
import java.net.InetSocketAddress;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
import org.opendaylight.protocol.framework.SessionListenerFactory;
+import org.opendaylight.tcpmd5.api.KeyMapping;
/**
* Dispatcher class for creating servers and clients.
<groupId>${project.groupId}</groupId>
<artifactId>pcep-impl</artifactId>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-netty</artifactId>
- </dependency>
<!--
FIXME: this is in support of the generated code. This should not
<groupId>${project.groupId}</groupId>
<artifactId>pcep-impl</artifactId>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-netty</artifactId>
- </dependency>
<!--
FIXME: this is in support of the generated code. This should not
<artifactId>util</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.tcpmd5</groupId>
<artifactId>tcpmd5-netty</artifactId>
</dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>netty-config-api</artifactId>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-netty</artifactId>
- </dependency>
<!-- Test dependencies -->
<dependency>
import java.net.InetSocketAddress;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-import org.opendaylight.bgpcep.tcpmd5.netty.MD5ChannelFactory;
-import org.opendaylight.bgpcep.tcpmd5.netty.MD5ChannelOption;
-import org.opendaylight.bgpcep.tcpmd5.netty.MD5ServerChannelFactory;
import org.opendaylight.protocol.framework.AbstractDispatcher;
import org.opendaylight.protocol.framework.SessionListenerFactory;
import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
import org.opendaylight.protocol.pcep.PCEPDispatcher;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.protocol.pcep.spi.MessageRegistry;
+import org.opendaylight.tcpmd5.api.KeyMapping;
+import org.opendaylight.tcpmd5.netty.MD5ChannelFactory;
+import org.opendaylight.tcpmd5.netty.MD5ChannelOption;
+import org.opendaylight.tcpmd5.netty.MD5ServerChannelFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
<artifactId>topology-tunnel-api</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-api-cfg</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-netty</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-netty-cfg</artifactId>
- <version>${project.version}</version>
- </dependency>
-
</dependencies>
</dependencyManagement>
</project>
<artifactId>topology-api</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.tcpmd5</groupId>
<artifactId>tcpmd5-api</artifactId>
</dependency>
<dependency>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.tcpmd5</groupId>
<artifactId>tcpmd5-jni</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-jni</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>org.opendaylight.tcpmd5</groupId>
+ <artifactId>tcpmd5-jni</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
import java.util.concurrent.ExecutionException;
import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
import org.opendaylight.bgpcep.topology.DefaultTopologyReference;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
import org.opendaylight.protocol.pcep.PCEPDispatcher;
+import org.opendaylight.tcpmd5.api.KeyMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.rev140113.NetworkTopologyContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.NetworkTopologyPcepProgrammingService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.NetworkTopologyPcepService;
import java.net.InetSocketAddress;
import java.util.concurrent.ExecutionException;
import org.opendaylight.bgpcep.pcep.topology.provider.PCEPTopologyProvider;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
import org.opendaylight.controller.config.api.JmxAttributeValidationException;
import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleMXBean;
+import org.opendaylight.tcpmd5.api.KeyMapping;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import javax.management.InstanceAlreadyExistsException;
import javax.management.ObjectName;
import org.junit.Test;
-import org.opendaylight.bgpcep.tcpmd5.jni.NativeTestSupport;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.CommitStatus;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.opendaylight.controller.config.yang.tcpmd5.jni.cfg.NativeKeyAccessFactoryModuleFactory;
import org.opendaylight.controller.config.yang.tcpmd5.netty.cfg.MD5ServerChannelFactoryModuleFactory;
import org.opendaylight.controller.config.yang.tcpmd5.netty.cfg.MD5ServerChannelFactoryModuleMXBean;
+import org.opendaylight.tcpmd5.jni.NativeTestSupport;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.tcpmd5.cfg.rev140427.Rfc2385Key;
<artifactId>sal-binding-config</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.tcpmd5</groupId>
<artifactId>tcpmd5-netty</artifactId>
</dependency>
<module>programming</module>
<module>rsvp</module>
<module>topology</module>
- <module>tcp-md5</module>
<!-- Integration tests -->
<module>integration-tests</module>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2013 Robert Varga. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<projectDescription>
- <name>tcpmd5-parent</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.m2e.core.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.m2e.core.maven2Nature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2014 Robert Varga. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<projectDescription>
- <name>tcpmd5-api</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.m2e.core.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.m2e.core.maven2Nature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
- Copyright (c) 2013 Robert Varga. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>tcpmd5-parent</artifactId>
- <version>0.3.1-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>tcpmd5-api</artifactId>
- <description>RFC2385-enable sockets API</description>
- <packaging>bundle</packaging>
- <name>${project.artifactId}</name>
- <prerequisites>
- <maven>3.0.4</maven>
- </prerequisites>
-
- <dependencies>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-api</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5;
-
-import com.google.common.base.Preconditions;
-
-import java.nio.channels.Channel;
-
-/**
- * Dummy KeyAccessFactory. This factory does not support any channels and it does not give out any KeyAccess objects.
- */
-public final class DummyKeyAccessFactory implements KeyAccessFactory {
- private static final DummyKeyAccessFactory INSTANCE = new DummyKeyAccessFactory();
-
- private DummyKeyAccessFactory() {
-
- }
-
- /**
- * Get a DummyKeyAccessFactory instance.
- *
- * @return A singleton instance.
- */
- public static DummyKeyAccessFactory getInstance() {
- return INSTANCE;
- }
-
- @Override
- public KeyAccess getKeyAccess(final Channel channel) {
- Preconditions.checkNotNull(channel);
- return null;
- }
-
- @Override
- public boolean canHandleChannelClass(final Class<? extends Channel> clazz) {
- Preconditions.checkNotNull(clazz);
- return false;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5;
-
-import java.io.IOException;
-
-import javax.annotation.Nonnull;
-
-/**
- * Interface for accessing key information attached to an object.
- */
-public interface KeyAccess {
- /**
- * Retrieve the key mapping.
- *
- * @return The key mapping currently attached.
- * @throws IOException when the retrieve operation fails.
- */
- @Nonnull
- KeyMapping getKeys() throws IOException;
-
- /**
- * Attach key mappings.
- *
- * @param keys Mappings which should
- * @throws IOException when the set operation fails.
- * @throws IllegalArgumentException if a key length is zero or it exceeds platform-supported length (usually 80
- * bytes).
- */
- void setKeys(@Nonnull KeyMapping keys) throws IOException;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5;
-
-import java.nio.channels.Channel;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-/**
- * Interface exposed by classes which can create KeyAccess instances for individual channels.
- */
-public interface KeyAccessFactory {
- /**
- * Obtain a KeyAccess instance for a channel.
- *
- * @param channel Channel instance, may not be null
- * @return a KeyAccess instance, or null if the channel is not supported by this factory.
- * @throws NullPointerException if channel is null
- */
- @Nullable
- KeyAccess getKeyAccess(@Nonnull Channel channel);
-
- /**
- * Check whether a particular channel class is supported by this factory.
- *
- * @param clazz Channel class, may not be null
- * @return true if the class is supported, i.e. getKeyAccess() can be expected to succeed.
- * @throws NullPointerException if clazz is null
- */
- boolean canHandleChannelClass(@Nonnull Class<? extends Channel> clazz);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5;
-
-import java.net.InetAddress;
-import java.util.HashMap;
-import java.util.Map;
-
-public final class KeyMapping extends HashMap<InetAddress, byte[]> {
- private static final long serialVersionUID = 1L;
-
- public KeyMapping() {
- super();
- }
-
- public KeyMapping(final int initialCapacity, final float loadFactor) {
- super(initialCapacity, loadFactor);
- }
-
- public KeyMapping(final int initialCapacity) {
- super(initialCapacity);
- }
-
- public KeyMapping(final Map<? extends InetAddress, ? extends byte[]> m) {
- super(m);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5;
-
-import java.net.SocketOption;
-
-/**
- * Utility class holding the singleton socket options used by the TCP-MD5 support library.
- */
-public final class MD5SocketOptions {
- /**
- * TCP MD5 Signature option, as defined in RFC 2385.
- */
- public static final SocketOption<KeyMapping> TCP_MD5SIG = new SocketOption<KeyMapping>() {
- @Override
- public String name() {
- return "TCP_MD5SIG";
- }
-
- @Override
- public Class<KeyMapping> type() {
- return KeyMapping.class;
- }
- };
-
- private MD5SocketOptions() {
- throw new UnsupportedOperationException("Utility class cannot be instatiated");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-/**
- * Common TCP MD5 key access and manipulation API.
- */
-package org.opendaylight.bgpcep.tcpmd5;
\ No newline at end of file
+++ /dev/null
-// vi: set smarttab et sw=4 tabstop=4:
-module odl-tcpmd5-cfg {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:cfg";
- prefix "tcpmd5";
-
- import config { prefix config; revision-date 2013-04-05; }
-
- organization "Cisco Systems, Inc.";
-
- contact "Robert Varga <rovarga@cisco.com>";
-
- description
- "This module contains the base YANG definitions for
- TCP MD5 Signature option.
-
- Copyright (c)2014 Cisco Systems, Inc. All rights reserved.;
-
- This program and the accompanying materials are made available
- under the terms of the Eclipse Public License v1.0 which
- accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html";
-
- revision "2014-04-27" {
- description
- "Initial revision";
- }
-
- identity key-access-factory {
- description
- "Service representing a way for accessing key informtion.";
-
- base "config:service-type";
- config:java-class "org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory";
- }
-
- typedef rfc2385-key {
- type string {
- length 1..80;
- }
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-
-import java.io.IOException;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class DummyKeyAccessFactoryTest {
- private ServerSocketChannel ssc;
- private KeyAccessFactory kaf;
- private SocketChannel sc;
-
- @Before
- public void setup() throws IOException {
- kaf = DummyKeyAccessFactory.getInstance();
- sc = SocketChannel.open();
- ssc = ServerSocketChannel.open();
- }
-
- @After
- public void tearDown() throws IOException {
- sc.close();
- ssc.close();
- }
-
- @Test
- public void testCanHandleChannelClass() {
- assertFalse(kaf.canHandleChannelClass(sc.getClass()));
- assertFalse(kaf.canHandleChannelClass(ssc.getClass()));
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullCanHandleChannelClass() {
- assertFalse(kaf.canHandleChannelClass(null));
- }
-
- @Test
- public void testGetKeyAccess() {
- assertNull(kaf.getKeyAccess(sc));
- assertNull(kaf.getKeyAccess(ssc));
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullGetKeyAccess() {
- assertNull(kaf.getKeyAccess(null));
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class MD5SocketOptionsTest {
-
- @Test
- public void testMd5SigName() {
- assertEquals("TCP_MD5SIG", MD5SocketOptions.TCP_MD5SIG.name());
- }
-
- @Test
- public void testMd5SigType() {
- assertEquals(KeyMapping.class, MD5SocketOptions.TCP_MD5SIG.type());
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>tcpmd5-controller-config</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.m2e.core.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.m2e.core.maven2Nature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
- Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
- <scm>
- <connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
- <url>https://wiki.opendaylight.org/view/BGP_LS_PCEP:Main</url>
- <tag>HEAD</tag>
- </scm>
- <parent>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>tcpmd5-parent</artifactId>
- <version>0.3.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>tcpmd5-controller-config</artifactId>
- <description>Controller Configuration files for BGP protocol</description>
- <packaging>jar</packaging>
- <name>${project.artifactId}</name>
- <prerequisites>
- <maven>3.0.4</maven>
- </prerequisites>
-
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<snapshot>
- <required-capabilities>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:cfg?module=odl-tcpmd5-cfg&revision=2014-04-27</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:jni:cfg?module=odl-tcpmd5-jni-cfg&revision=2014-04-27</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:netty:cfg?module=odl-tcpmd5-netty-cfg&revision=2014-04-27</capability>
- </required-capabilities>
-
- <configuration>
- <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <!--
- Uncomment this block to enable TCP MD5 Signature support
-
- <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:jni:cfg">prefix:native-key-access-factory</type>
- <name>global-key-access-factory</name>
- </module>
-
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:netty:cfg">prefix:md5-client-channel-factory</type>
- <name>md5-client-channel-factory</name>
-
- <key-access-factory>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:cfg">prefix:key-access-factory</type>
- <name>global-key-access-factory</name>
- </key-access-factory>
- </module>
-
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:netty:cfg">prefix:md5-server-channel-factory-impl</type>
- <name>md5-server-channel-factory</name>
-
- <server-key-access-factory>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:cfg">prefix:key-access-factory</type>
- <name>global-key-access-factory</name>
- </server-key-access-factory>
- </module>
- </modules>
-
- <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <service>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:cfg">prefix:key-access-factory</type>
- <instance>
- <name>global-key-access-factory</name>
- <provider>/modules/module[type='native-key-access-factory'][name='global-key-access-factory']</provider>
- </instance>
- </service>
-
- <service>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:netty:cfg">prefix:md5-channel-factory</type>
- <instance>
- <name>md5-client-channel-factory</name>
- <provider>/modules/module[type='md5-client-channel-factory'][name='md5-client-channel-factory']</provider>
- </instance>
- </service>
-
- <service>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:netty:cfg">prefix:md5-server-channel-factory</type>
- <instance>
- <name>md5-server-channel-factory</name>
- <provider>/modules/module[type='md5-server-channel-factory-impl'][name='md5-server-channel-factory']</provider>
- </instance>
- </service>
- </services>
- -->
- </data>
- </configuration>
-</snapshot>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2013 Robert Varga. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<projectDescription>
- <name>tcpmd5-jni</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.m2e.core.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.m2e.core.maven2Nature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
- Copyright (c) 2013 Robert Varga. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>tcpmd5-parent</artifactId>
- <version>0.3.1-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>tcpmd5-jni</artifactId>
- <description>Native support for RFC2385-enabled TCP sockets</description>
- <packaging>bundle</packaging>
- <name>${project.artifactId}</name>
-
- <prerequisites>
- <maven>3.0.4</maven>
- </prerequisites>
-
- <properties>
- <nar.groupId>com.github.maven-nar</nar.groupId>
- <nar.version>3.1.0</nar.version>
- <copy.version>0.2.5</copy.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-api</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-api</artifactId>
- </dependency>
-
- <!-- Testing dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- <Include-Resource>
- libtcpmd5-jni.so=target/nar/tcpmd5-jni-${project.version}-amd64-Linux-gpp-jni/lib/amd64-Linux-gpp/jni/libtcpmd5-jni-${project.version}.so,
- META-INF/yang=target/classes/META-INF/yang,
- META-INF/services=target/classes/META-INF/services
- </Include-Resource>
- </instructions>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>com.github.goldin</groupId>
- <artifactId>copy-maven-plugin</artifactId>
- <version>0.2.5</version>
- <executions>
- <execution>
- <id>copy-native</id>
- <phase>process-classes</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <resources>
- <resource>
- <targetPath>${project.build.outputDirectory}</targetPath>
- <file>${project.build.directory}/nar/tcpmd5-jni-${project.version}-amd64-Linux-gpp-jni/lib/amd64-Linux-gpp/jni/libtcpmd5-jni-${project.version}.so</file>
- <destFileName>libtcpmd5-jni.so</destFileName>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <!-- Let eclipse know about the generated sources -->
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>target/nar/nar-generated</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>${nar.groupId}</groupId>
- <artifactId>nar-maven-plugin</artifactId>
- <version>${nar.version}</version>
- <extensions>true</extensions>
- <configuration>
- <c/>
- <libraries>
- <library>
- <type>jni</type>
- <narSystemPackage>org.opendaylight.bgpcep.tcpmd5.jni</narSystemPackage>
- <linkCPP>false</linkCPP>
- </library>
- </libraries>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>nar-validate</goal>
- <goal>nar-download</goal>
- <goal>nar-unpack</goal>
- <goal>nar-assembly</goal>
- <goal>nar-system-generate</goal>
- <goal>nar-resources</goal>
- <goal>nar-javah</goal>
- <goal>nar-compile</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
-
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>${nar.groupId}</groupId>
- <artifactId>nar-maven-plugin</artifactId>
- <versionRange>${nar.version}</versionRange>
- <goals>
- <goal>nar-assembly</goal>
- <goal>nar-compile</goal>
- <goal>nar-download</goal>
- <goal>nar-gnu-configure</goal>
- <goal>nar-gnu-make</goal>
- <goal>nar-gnu-process</goal>
- <goal>nar-gnu-resources</goal>
- <goal>nar-javah</goal>
- <goal>nar-process-libraries</goal>
- <goal>nar-resources</goal>
- <goal>nar-system-generate</goal>
- <goal>nar-testCompile</goal>
- <goal>nar-testDownload</goal>
- <goal>nar-testUnpack</goal>
- <goal>nar-unpack</goal>
- <goal>nar-validate</goal>
- <goal>nar-vcproj</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <execute/>
- </action>
- </pluginExecution>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>com.github.goldin</groupId>
- <artifactId>copy-maven-plugin</artifactId>
- <versionRange>${copy.version}</versionRange>
- <goals>
- <goal>copy</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <execute/>
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-#include <org_opendaylight_bgpcep_tcpmd5_jni_NarSystem.h>
-#include <org_opendaylight_bgpcep_tcpmd5_jni_NativeKeyAccess.h>
-
-#include <errno.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <linux/tcp.h>
-
-struct handler {
- jclass clazz;
- jfieldID field;
-};
-
-static struct handler *handlers = NULL;
-static unsigned handler_count = 0;
-static jclass illegal_argument = NULL;
-static jclass illegal_state = NULL;
-static jclass io = NULL;
-
-static void __attribute__ ((format (printf, 3, 4))) jni_exception(JNIEnv *env, jclass clazz, const char *fmt, ...)
-{
- char buf[1024] = "";
- va_list ap;
-
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
-
- (*env)->ThrowNew(env, clazz, buf);
-}
-
-#define ILLEGAL_ARGUMENT(...) jni_exception(env, illegal_argument, __VA_ARGS__)
-#define ILLEGAL_STATE(...) jni_exception(env, illegal_state, __VA_ARGS__)
-#define IO(...) jni_exception(env, io, __VA_ARGS__)
-
-static void __attribute__ ((format (printf, 3, 4))) log_message(JNIEnv *env, jobject logger, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
-}
-
-#define ERROR(...) log_message(env, logger, __VA_ARGS__)
-#define WARN(...) log_message(env, logger, __VA_ARGS__)
-
-static const struct handler *add_handler(JNIEnv *env, jobject logger, const char *name, const char *field, const char *sig)
-{
- // Find the class
- const jclass clazz = (*env)->FindClass(env, name);
- if (clazz == NULL) {
- goto out;
- }
-
- // Find the field
- const jfieldID fid = (*env)->GetFieldID(env, clazz, field, sig);
- if (fid == NULL) {
- goto out_clazz;
- }
-
- // Reallocate the array
- struct handler *r = realloc(handlers, (handler_count + 1) * sizeof(struct handler));
- if (r == NULL) {
- ERROR("Failed to allocate handler: %s", strerror(errno));
- goto out_clazz;
- }
- handlers = r;
-
- // Fill the array
- struct handler *ret = handlers + handler_count;
- ret->clazz = (*env)->NewGlobalRef(env, clazz);
- ret->field = fid;
-
- if (ret->clazz == NULL) {
- goto out_clazz;
- }
-
- handler_count += 1;
- (*env)->DeleteLocalRef(env, clazz);
- return ret;
-
-out_clazz:
- (*env)->DeleteLocalRef(env, clazz);
-out:
- (*env)->ExceptionDescribe(env);
- (*env)->ExceptionClear(env);
- return NULL;
-}
-
-static const struct handler *find_handler(JNIEnv *env, jclass clazz)
-{
- if (clazz != NULL) {
- unsigned i;
-
- for (i = 0; i < handler_count; ++i) {
- const struct handler *h = handlers + i;
- if ((*env)->IsAssignableFrom(env, clazz, h->clazz) == JNI_TRUE) {
- return h;
- }
- }
- }
-
- return NULL;
-}
-
-static jclass resolve_class(JNIEnv *env, const char *what, jclass *where)
-{
- if (*where == NULL) {
- jclass clazz = (*env)->FindClass(env, what);
- if (clazz == NULL) {
- return NULL;
- }
-
- jclass ref = (*env)->NewGlobalRef(env, clazz);
- (*env)->DeleteLocalRef(env, clazz);
- if (ref == NULL) {
- return NULL;
- }
-
- *where = ref;
- return ref;
- } else {
- return *where;
- }
-}
-
-static void native_error(JNIEnv *env, const char *what, int err)
-{
- char buf[256] = "";
- strerror_r(err, buf, sizeof(buf));
- IO("Native operation %s failed: %s", what, buf);
-}
-
-static int resolve_exceptions(JNIEnv *env)
-{
- // First resolve Exception classes, these are mandatory
- if (resolve_class(env, "java/lang/IllegalStateException", &illegal_state) == NULL) {
- fprintf(stderr, "Failed to resolve java.lang.IllegalStateException\n");
- return 1;
- }
- if (resolve_class(env, "java/lang/IllegalArgumentException", &illegal_argument) == NULL) {
- fprintf(stderr, "Failed to resolve java.lang.IllegalArgumentException\n");
- return 1;
- }
- if (resolve_class(env, "java/io/IOException", &io) == NULL) {
- fprintf(stderr, "Failed to resolve java.io.IOException\n");
- return 1;
- }
-
- return 0;
-}
-
-static jobject resolve_logging(JNIEnv *env, jclass clazz)
-{
- jclass lf = (*env)->FindClass(env, "org/slf4j/LoggerFactory");
- if (lf != NULL) {
- jmethodID mid = (*env)->GetStaticMethodID(env, lf, "getLogger", "(Ljava/lang/Class;)Lorg/slf4j/Logger;");
- if (mid != NULL) {
- return (*env)->CallStaticObjectMethod(env, lf, mid, clazz);
- }
- }
-
- return NULL;
-}
-
-static jint sanity_check(JNIEnv *env, jobject logger)
-{
- struct tcp_md5sig md5sig = {
- .tcpm_addr = {
- .ss_family = AF_INET,
- },
- };
-
- // Sanity-check maximum key size against the structure
- if (TCP_MD5SIG_MAXKEYLEN > sizeof(md5sig.tcpm_key)) {
- ERROR("Structure key size %zu is less than %d", sizeof(md5sig.tcpm_key), TCP_MD5SIG_MAXKEYLEN);
- return -1;
- }
-
- // Now run a quick check to see if we can really the getsockopt/setsockopt calls are
- // supported.
- const int fd = socket(AF_INET, SOCK_STREAM, 0);
- if (fd == -1) {
- ERROR("Failed to open a socket for sanity tests: %s", strerror(errno));
- return -1;
- }
-
- // Attempt to set a new key with maximum size
- md5sig.tcpm_keylen = TCP_MD5SIG_MAXKEYLEN;
- if (setsockopt(fd, IPPROTO_TCP, TCP_MD5SIG, &md5sig, sizeof(md5sig)) != 0) {
- ERROR("Failed to set TCP_MD5SIG option: %s", strerror(errno));
- close(fd);
- return -1;
- }
-
- // Attempt to remove the key
- md5sig.tcpm_keylen = 0;
- if (setsockopt(fd, IPPROTO_TCP, TCP_MD5SIG, &md5sig, sizeof(md5sig)) != 0) {
- ERROR("Failed to clear TCP_MD5SIG option: %s", strerror(errno));
- close(fd);
- return -1;
- }
-
- // All done
- close(fd);
- return 0;
-}
-
-/*
- * Class: org_opendaylight_bgpcep_tcpmd5_jni_NarSystem
- * Method: runUnitTestsNative
- * Signature: ()I
- */
-jint Java_org_opendaylight_bgpcep_tcpmd5_jni_NarSystem_runUnitTestsNative(JNIEnv *env, jobject obj)
-{
- if (resolve_exceptions(env)) {
- return 0;
- }
-
- jobject logger = resolve_logging(env, (*env)->GetObjectClass(env, obj));
- if (sanity_check(env, logger)) {
- return 0;
- }
-
- int ret = 0;
- if (add_handler(env, logger, "sun/nio/ch/ServerSocketChannelImpl", "fdVal", "I")) {
- ++ret;
- }
- if (add_handler(env, logger, "sun/nio/ch/SocketChannelImpl", "fdVal", "I")) {
- ++ret;
- }
-
- return ret;
-}
-
-/*
- * Class: org_opendaylight_bgpcep_tcpmd5_jni_NativeKeyAccess
- * Method: isClassSupported0
- * Signature: (Ljava/lang/Class;)Z
- */
-jboolean Java_org_opendaylight_bgpcep_tcpmd5_jni_NativeKeyAccess_isClassSupported0(JNIEnv *env, jclass clazz, jclass arg)
-{
- const struct handler *h = find_handler(env, arg);
- return h == NULL ? JNI_FALSE : JNI_TRUE;
-}
-
-/*
- * Class: org_opendaylight_bgpcep_tcpmd5_jni_NativeKeyAccess
- * Method: setChannelKey0
- * Signature: (Ljava/nio/channels/Channel;[B)V
- */
-void Java_org_opendaylight_bgpcep_tcpmd5_jni_NativeKeyAccess_setChannelKey0(JNIEnv *env, jclass clazz, jobject channel, jbyteArray address, jbyteArray key)
-{
- if (address == NULL) {
- ILLEGAL_ARGUMENT("Address may not be null");
- return;
- }
- if (channel == NULL) {
- ILLEGAL_ARGUMENT("Channel may not be null");
- return;
- }
-
- const jsize addrlen = (*env)->GetArrayLength(env, address);
- if (addrlen != 4 && addrlen != 16) {
- ILLEGAL_ARGUMENT("Unsupported address length %d", addrlen);
- return;
- }
-
- jsize keylen = 0;
- if (key != NULL) {
- keylen = (*env)->GetArrayLength(env, key);
- if (keylen <= 0) {
- ILLEGAL_ARGUMENT("Negative array length %d encountered", keylen);
- return;
- }
- if (keylen > TCP_MD5SIG_MAXKEYLEN) {
- ILLEGAL_ARGUMENT("Key length %d exceeds platform limit %d", keylen, TCP_MD5SIG_MAXKEYLEN);
- return;
- }
- }
-
- struct tcp_md5sig md5sig;
- memset(&md5sig, 0, sizeof(md5sig));
- md5sig.tcpm_keylen = (uint16_t) keylen;
-
- /*
- * TCP_MD5SIG_MAXKEYLEN may not be an accurate check of key field
- * length. Check the field size before accessing it.
- */
- if (keylen > sizeof(md5sig.tcpm_key)) {
- ILLEGAL_ARGUMENT("Key length %d exceeds native buffer limit %zu", keylen, sizeof(md5sig.tcpm_key));
- return;
- }
-
- if (keylen != 0) {
- (*env)->GetByteArrayRegion(env, key, 0, keylen, (void *) &md5sig.tcpm_key);
- if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
- return;
- }
- }
-
- const struct handler *h = find_handler(env, (*env)->GetObjectClass(env, channel));
- if (h == NULL) {
- ILLEGAL_STATE("Failed to find handler");
- return;
- }
-
- const jint fd = (*env)->GetIntField(env, channel, h->field);
- if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
- return;
- }
-
- struct sockaddr_storage ss;
- memset(&ss, 0, sizeof(ss));
-
- socklen_t ssl = sizeof(ss);
- if (getsockname(fd, (struct sockaddr *)&ss, &ssl) == -1) {
- native_error(env, "getsockname", errno);
- return;
- }
-
- /*
- * Fill out the address.
- */
- md5sig.tcpm_addr.ss_family = ss.ss_family;
- void *dest = NULL;
-
- switch (ss.ss_family) {
- case AF_INET:
- switch (addrlen) {
- case 4:
- // IPv4 dest in IPv4 socket
- dest = &((struct sockaddr_in *)&md5sig.tcpm_addr)->sin_addr;
- break;
- case 16:
- // IPv6 dest in IPv4 socket
- ILLEGAL_ARGUMENT("Invalid IPv6 address for IPv4 socket");
- return;
- default:
- // Ugh?
- ILLEGAL_STATE("Unexpected address length %d", addrlen);
- return;
- }
- break;
- case AF_INET6:
- switch (addrlen) {
- case 4:
- {
- // IPv4 dest in IPv4 socket, we need to create a mapped address.
- struct in6_addr *a = &((struct sockaddr_in6 *)&md5sig.tcpm_addr)->sin6_addr;
-
- a->s6_addr[10] = 0xFF;
- a->s6_addr[11] = 0xFF;
- dest = a->s6_addr + 12;
- break;
- }
- case 16:
- // IPv6 dest in IPv6 socket
- dest = &((struct sockaddr_in6 *)&md5sig.tcpm_addr)->sin6_addr;
- return;
- default:
- ILLEGAL_STATE("Unexpected address length %d", addrlen);
- return;
- }
- break;
- default:
- ILLEGAL_STATE("Unexpected address family %d", ss.ss_family);
- return;
- }
-
- (*env)->GetByteArrayRegion(env, address, 0, addrlen, dest);
- if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
- return;
- }
-
- if (setsockopt(fd, IPPROTO_TCP, TCP_MD5SIG, &md5sig, sizeof(md5sig)) == -1) {
- native_error(env, "setsockopt", errno);
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.jni;
-
-import com.google.common.base.Preconditions;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.nio.channels.Channel;
-import java.util.Arrays;
-import java.util.Map.Entry;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccess;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of KeyAccess using Java Native Interface plugin to talk directly to the underlying operating system.
- */
-final class NativeKeyAccess implements KeyAccess {
- private static final Logger LOG = LoggerFactory.getLogger(NativeKeyAccess.class);
-
- private static native void setChannelKey0(Channel channel, byte[] address, byte[] key) throws IOException;
-
- static native boolean isClassSupported0(Class<?> channel);
-
- private KeyMapping currentKeys = new KeyMapping();
- private final Channel channel;
-
- NativeKeyAccess(final Channel channel) {
- this.channel = Preconditions.checkNotNull(channel);
- }
-
- @Override
- public void setKeys(final KeyMapping keys) throws IOException {
- for (Entry<InetAddress, byte[]> e : keys.entrySet()) {
- Preconditions.checkArgument(e.getKey() != null, "Null address is not allowed");
- Preconditions.checkArgument(e.getValue() != null, "Key for address %s is null", e.getKey());
- Preconditions.checkArgument(e.getValue().length != 0, "Key for address %s is empty", e.getKey());
- }
-
- synchronized (this) {
- // Walk current keys and delete any that are not in the new map
- for (Entry<InetAddress, byte[]> e : currentKeys.entrySet()) {
- if (!keys.containsKey(e.getKey())) {
- LOG.debug("Channel {} removing key for address {}", channel, e.getKey());
- setChannelKey0(channel, e.getKey().getAddress(), null);
- }
- }
-
- for (Entry<InetAddress, byte[]> e : keys.entrySet()) {
- final byte[] currentValue = currentKeys.get(e.getKey());
- if (!Arrays.equals(currentValue, e.getValue())) {
- LOG.debug("Channel {} adding key for address {}", channel, e.getKey());
- setChannelKey0(channel, e.getKey().getAddress(), e.getValue());
- }
- }
-
- this.currentKeys = new KeyMapping(keys);
- LOG.debug("Channel {} key mapping update completed", channel);
- }
- }
-
- @Override
- public synchronized KeyMapping getKeys() {
- return currentKeys;
- }
-}
+++ /dev/null
-/*
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.jni;
-
-import com.google.common.base.Preconditions;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.channels.Channel;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.nio.file.attribute.PosixFilePermission;
-import java.nio.file.attribute.PosixFilePermissions;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccess;
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class NativeKeyAccessFactory implements KeyAccessFactory {
- private static final Logger LOG = LoggerFactory.getLogger(NativeKeyAccessFactory.class);
- private static final String LIBNAME = "libtcpmd5-jni.so";
- private static NativeKeyAccessFactory INSTANCE = null;
-
- private final Map<Channel, KeyAccess> channels = new WeakHashMap<>();
-
- private NativeKeyAccessFactory() {
-
- }
-
- /**
- * Get the singleton instance.
- *
- * @return Singleton service instance.
- * @throws NativeSupportUnavailableException if run-time does not support the functions needed to instantiate an
- * operational factory.
- */
- public static NativeKeyAccessFactory getInstance() throws NativeSupportUnavailableException {
- if (INSTANCE != null) {
- return INSTANCE;
- }
-
- synchronized (NativeKeyAccessFactory.class) {
- if (INSTANCE == null) {
- try {
- loadLibrary();
- } catch (IOException | RuntimeException e) {
- throw new NativeSupportUnavailableException("Failed to load library", e);
- }
-
- int rt = NarSystem.runUnitTests();
- if (rt == 0) {
- throw new NativeSupportUnavailableException("Run-time does not support required functionality");
- }
-
- LOG.debug("Run-time found {} supported channel classes", rt);
- INSTANCE = new NativeKeyAccessFactory();
- }
- return INSTANCE;
- }
- }
-
- @Override
- public KeyAccess getKeyAccess(final Channel channel) {
- if (!NativeKeyAccess.isClassSupported0(channel.getClass())) {
- LOG.debug("No support available for class {}", channel.getClass());
- return null;
- }
-
- synchronized (channels) {
- KeyAccess e = channels.get(channel);
- if (e == null) {
- e = new NativeKeyAccess(channel);
- channels.put(channel, e);
- }
-
- return e;
- }
- }
-
- @Override
- public boolean canHandleChannelClass(final Class<? extends Channel> clazz) {
- if (!NativeKeyAccess.isClassSupported0(Preconditions.checkNotNull(clazz))) {
- LOG.debug("No support available for class {}", clazz);
- return false;
- }
-
- return true;
- }
-
- private static void loadLibrary() throws IOException {
- final InputStream is = NativeKeyAccessFactory.class.getResourceAsStream('/' + LIBNAME);
- if (is == null) {
- throw new IOException(String.format("Failed to open library resource %s", LIBNAME));
- }
-
- try {
- final Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-x---");
- final Path p = Files.createTempFile(LIBNAME, null, PosixFilePermissions.asFileAttribute(perms));
-
- try {
- LOG.debug("Copying {} to {}", is, p);
-
- Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING);
-
- Runtime.getRuntime().load(p.toString());
- LOG.info("Library {} loaded", p);
- } finally {
- try {
- Files.deleteIfExists(p);
- } catch (IOException e) {
- LOG.warn("Failed to remove temporary file {}", p, e);
- }
- }
- } finally {
- try {
- is.close();
- } catch (IOException e) {
- LOG.warn("Failed to close library input stream", e);
- }
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.jni;
-
-import java.io.IOException;
-
-/**
- * Exception thrown when the runtime platform or underlying operating system cannot support native key access.
- */
-public final class NativeSupportUnavailableException extends IOException {
- private static final long serialVersionUID = 1L;
-
- public NativeSupportUnavailableException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public NativeSupportUnavailableException(final String message) {
- super(message);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.tcpmd5.jni.cfg;
-
-import java.nio.channels.Channel;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccess;
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.jni.NativeKeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.jni.NativeSupportUnavailableException;
-
-/**
- * Service representing a way for accessing key informtion.
- */
-public class NativeKeyAccessFactoryModule extends
- org.opendaylight.controller.config.yang.tcpmd5.jni.cfg.AbstractNativeKeyAccessFactoryModule {
- private KeyAccessFactory kaf;
-
- public NativeKeyAccessFactoryModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public NativeKeyAccessFactoryModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
- final org.opendaylight.controller.config.yang.tcpmd5.jni.cfg.NativeKeyAccessFactoryModule oldModule,
- final java.lang.AutoCloseable oldInstance) {
- super(identifier, dependencyResolver, oldModule, oldInstance);
- }
-
- @Override
- public void customValidation() {
- try {
- kaf = NativeKeyAccessFactory.getInstance();
- } catch (NativeSupportUnavailableException e) {
- throw new UnsupportedOperationException("Native support is not available", e);
- }
- }
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- final KeyAccessFactory kaf = this.kaf;
-
- final class CloseableNativeKeyAccessFactory implements AutoCloseable, KeyAccessFactory {
- @Override
- public KeyAccess getKeyAccess(final Channel channel) {
- return kaf.getKeyAccess(channel);
- }
-
- @Override
- public boolean canHandleChannelClass(final Class<? extends Channel> clazz) {
- return kaf.canHandleChannelClass(clazz);
- }
-
- @Override
- public void close() {
- // Nothing to do
- }
- }
-
- return new CloseableNativeKeyAccessFactory();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.tcpmd5.jni.cfg;
-
-public class NativeKeyAccessFactoryModuleFactory extends
- org.opendaylight.controller.config.yang.tcpmd5.jni.cfg.AbstractNativeKeyAccessFactoryModuleFactory {
-
-}
+++ /dev/null
-// vi: set smarttab et sw=4 tabstop=4:
-module odl-tcpmd5-jni-cfg {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:jni:cfg";
- prefix "jni";
-
- import config { prefix config; revision-date 2013-04-05; }
- import odl-tcpmd5-cfg { prefix tcpmd5; revision-date 2014-04-27; }
-
- organization "Cisco Systems, Inc.";
-
- contact "Robert Varga <rovarga@cisco.com>";
-
- description
- "This module contains the base YANG definitions for
- TCP MD5 Signature option.
-
- Copyright (c)2014 Cisco Systems, Inc. All rights reserved.;
-
- This program and the accompanying materials are made available
- under the terms of the Eclipse Public License v1.0 which
- accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html";
-
- revision "2014-04-27" {
- description
- "Initial revision";
- }
-
- identity native-key-access-factory {
- description
- "Service representing a way for accessing key informtion.";
-
- base config:module-type;
- config:provided-service tcpmd5:key-access-factory;
- config:java-name-prefix NativeKeyAccessFactory;
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case native-key-access-factory {
- when "/config:modules/config:module/config:type = 'native-key-access-factory'";
- }
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.jni;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.nio.channels.Channel;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-import java.util.Collections;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.bgpcep.tcpmd5.KeyAccess;
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class BasicNativeKeyAccessTest {
- private static final Logger LOG = LoggerFactory.getLogger(BasicNativeKeyAccessTest.class);
- private static final byte[] KEY1 = new byte[] { 1 };
- private static final byte[] KEY2 = new byte[] { 2, 3 };
-
- private KeyAccessFactory factory;
- private Channel channel;
-
- private void testKeyManipulation(final Channel c) throws IOException {
- assertTrue(factory.canHandleChannelClass(c.getClass()));
-
- final KeyAccess ka = factory.getKeyAccess(c);
- assertEquals(Collections.emptyMap(), ka.getKeys());
-
- final KeyMapping key1 = new KeyMapping();
- key1.put(InetAddress.getLocalHost(), KEY1);
- LOG.debug("Setting key {}", KEY1);
- ka.setKeys(key1);
- assertEquals(key1, ka.getKeys());
-
- final KeyMapping key2 = new KeyMapping();
- key2.put(InetAddress.getLocalHost(), KEY2);
- LOG.debug("Setting key {}", KEY2);
- ka.setKeys(key2);
- assertEquals(key2, ka.getKeys());
-
- LOG.debug("Deleting keys");
- ka.setKeys(new KeyMapping());
- assertEquals(Collections.emptyMap(), ka.getKeys());
- }
-
- @Before
- public void setup() throws IOException {
- factory = NativeKeyAccessFactory.getInstance();
- channel = SocketChannel.open();
- }
-
- @After
- public void teardown() throws IOException {
- channel.close();
- }
-
- @Test
- public void testSocket() throws IOException {
- testKeyManipulation(channel);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullChannel() {
- factory.getKeyAccess(null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullClass() {
- factory.canHandleChannelClass(null);
- }
-
- @Test
- public void testServerSocket() throws IOException {
- try (final ServerSocketChannel ssc = ServerSocketChannel.open()) {
- testKeyManipulation(ssc);
- }
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testShortKey() throws IOException {
- final KeyAccess ka = factory.getKeyAccess(channel);
-
- final KeyMapping map = new KeyMapping();
- map.put(InetAddress.getLocalHost(), new byte[0]);
- ka.setKeys(map);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testLongKey() throws IOException {
- final KeyAccess ka = factory.getKeyAccess(channel);
- final KeyMapping map = new KeyMapping();
- map.put(InetAddress.getLocalHost(), new byte[81]);
- ka.setKeys(map);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.jni;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.SocketTimeoutException;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.bgpcep.tcpmd5.KeyAccess;
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ConnectivityNativeKeyAccessTest {
- private static final Logger LOG = LoggerFactory.getLogger(ConnectivityNativeKeyAccessTest.class);
- private static final byte[] KEY1 = new byte[] { 1 };
- private static final byte[] KEY2 = new byte[] { 2, 3 };
-
- private KeyAccessFactory factory;
- private Thread serverThread;
- private InetAddress address;
- private int port;
- private AtomicReference<SocketChannel> serverClient;
-
- @Before
- public void setup() throws IOException {
- factory = NativeKeyAccessFactory.getInstance();
- address = InetAddress.getLoopbackAddress();
- serverClient = new AtomicReference<>();
-
- final ServerSocketChannel sc = ServerSocketChannel.open();
- LOG.debug("Instatiated server {}", sc);
-
- final KeyAccess ka = factory.getKeyAccess(sc);
- final KeyMapping map = new KeyMapping();
- map.put(address, KEY1);
- ka.setKeys(map);
- LOG.debug("Server got key {}", KEY1);
-
- sc.bind(new InetSocketAddress(address, 0));
- port = ((InetSocketAddress) sc.getLocalAddress()).getPort();
- LOG.debug("Server bound to port {}", port);
-
- serverThread = new Thread(new Runnable() {
- @Override
- public void run() {
- LOG.debug("Server thread started");
- try {
- SocketChannel s = sc.accept();
- LOG.debug("Accepted channel {}", s);
- serverClient.set(s);
- } catch (IOException e) {
- LOG.debug("Failed to accept connection", e);
- }
- }
- });
- serverThread.start();
- }
-
- @After
- public void teardown() throws InterruptedException {
- serverThread.interrupt();
- serverThread.join();
- }
-
- @Test(timeout = 2000)
- public void testMatchingKey() throws IOException {
- try (final SocketChannel c = SocketChannel.open()) {
- final KeyAccess ka = factory.getKeyAccess(c);
- final KeyMapping map = new KeyMapping();
- map.put(address, KEY1);
- ka.setKeys(map);
-
- c.connect(new InetSocketAddress(address, port));
- assertTrue(c.isConnected());
- }
- }
-
- @Test(timeout = 5000, expected = SocketTimeoutException.class)
- public void testMisatchedKey() throws IOException {
- try (final SocketChannel c = SocketChannel.open()) {
- final KeyAccess ka = factory.getKeyAccess(c);
- final KeyMapping map = new KeyMapping();
- map.put(address, KEY2);
- ka.setKeys(map);
-
- c.socket().connect(new InetSocketAddress(address, port), 2000);
- assertFalse(c.isConnected());
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.bgpcep.tcpmd5.jni;
-
-import org.junit.Assume;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NativeTestSupport {
- private static final Logger LOG = LoggerFactory.getLogger(NativeTestSupport.class);
-
- public static void assumeSupportedPlatform() {
- try {
- NativeKeyAccessFactory.getInstance();
- }catch (NativeSupportUnavailableException e) {
- LOG.info("Skipping test, this platform is not supported");
- Assume.assumeNoException(e);
- }
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2013 Robert Varga. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<projectDescription>
- <name>tcpmd5-netty</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.m2e.core.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.m2e.core.maven2Nature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
- Copyright (c) 2013 Robert Varga. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>tcpmd5-parent</artifactId>
- <version>0.3.1-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>tcpmd5-netty</artifactId>
- <description>RFC2385-enable sockets for Netty</description>
- <packaging>bundle</packaging>
- <name>${project.artifactId}</name>
- <prerequisites>
- <maven>3.0.4</maven>
- </prerequisites>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-api</artifactId>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-transport</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>netty-config-api</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2014 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.netty;
-
-import io.netty.buffer.ByteBufAllocator;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.MessageSizeEstimator;
-import io.netty.channel.RecvByteBufAllocator;
-import io.netty.channel.socket.DefaultServerSocketChannelConfig;
-
-import java.util.Map;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-
-public class DefaultMD5ServerSocketChannelConfig extends DefaultServerSocketChannelConfig implements MD5ServerSocketChannelConfig {
- private final NettyKeyAccess keyAccess;
-
- public DefaultMD5ServerSocketChannelConfig(final MD5NioServerSocketChannel channel, final KeyAccessFactory keyAccessFactory) {
- super(channel, channel.javaChannel().socket());
- this.keyAccess = NettyKeyAccess.create(keyAccessFactory, channel.javaChannel());
- }
-
- @Override
- public KeyMapping getMD5SignatureKeys() {
- return keyAccess.getKeys();
- }
-
- @Override
- public MD5ServerSocketChannelConfig setMD5SignatureKeys(final KeyMapping keys) {
- keyAccess.setKeys(keys);
- return this;
- }
-
- @Override
- public MD5ServerSocketChannelConfig setBacklog(final int backlog) {
- super.setBacklog(backlog);
- return this;
- }
-
- @Override
- public MD5ServerSocketChannelConfig setReuseAddress(final boolean reuseAddress) {
- super.setReuseAddress(reuseAddress);
- return this;
- }
-
- @Override
- public MD5ServerSocketChannelConfig setReceiveBufferSize(final int receiveBufferSize) {
- super.setReceiveBufferSize(receiveBufferSize);
- return this;
- }
-
- @Override
- public MD5ServerSocketChannelConfig setPerformancePreferences(final int connectionTime, final int latency, final int bandwidth) {
- super.setPerformancePreferences(connectionTime, latency, bandwidth);
- return this;
- }
-
- @Override
- public MD5ServerSocketChannelConfig setConnectTimeoutMillis(final int connectTimeoutMillis) {
- super.setConnectTimeoutMillis(connectTimeoutMillis);
- return this;
- }
-
- @Override
- public MD5ServerSocketChannelConfig setMaxMessagesPerRead(final int maxMessagesPerRead) {
- super.setMaxMessagesPerRead(maxMessagesPerRead);
- return this;
- }
-
- @Override
- public MD5ServerSocketChannelConfig setWriteSpinCount(final int writeSpinCount) {
- super.setWriteSpinCount(writeSpinCount);
- return this;
- }
-
- @Override
- public MD5ServerSocketChannelConfig setAllocator(final ByteBufAllocator allocator) {
- super.setAllocator(allocator);
- return this;
- }
-
- @Override
- public MD5ServerSocketChannelConfig setRecvByteBufAllocator(final RecvByteBufAllocator allocator) {
- super.setRecvByteBufAllocator(allocator);
- return this;
- }
-
- @Override
- public MD5ServerSocketChannelConfig setAutoRead(final boolean autoRead) {
- super.setAutoRead(autoRead);
- return this;
- }
-
- @Override
- public MD5ServerSocketChannelConfig setMessageSizeEstimator(final MessageSizeEstimator estimator) {
- super.setMessageSizeEstimator(estimator);
- return this;
- }
-
- @Override
- public Map<ChannelOption<?>, Object> getOptions() {
- final Map<ChannelOption<?>, Object> opts = super.getOptions();
- final KeyMapping keys = keyAccess.getKeys();
- if (keys != null) {
- opts.put(MD5ChannelOption.TCP_MD5SIG, keys);
- }
-
- return opts;
- }
-
- @Override
- public boolean setOptions(final Map<ChannelOption<?>, ?> options) {
- boolean setAllOptions = true;
- if (options.containsKey(MD5ChannelOption.TCP_MD5SIG)) {
- setAllOptions = setOption(MD5ChannelOption.TCP_MD5SIG, (KeyMapping) options.get(MD5ChannelOption.TCP_MD5SIG));
- }
-
- return super.setOptions(options) && setAllOptions;
- }
-
- @Override
- public <T> T getOption(final ChannelOption<T> option) {
- if (option == MD5ChannelOption.TCP_MD5SIG) {
- @SuppressWarnings("unchecked")
- final T ret = (T) keyAccess.getKeys();
- return ret;
- }
-
- return super.getOption(option);
- }
-
- @Override
- public <T> boolean setOption(final ChannelOption<T> option, final T value) {
- if (option == MD5ChannelOption.TCP_MD5SIG) {
- keyAccess.setKeys((KeyMapping) value);
- return true;
- }
-
- return super.setOption(option, value);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.netty;
-
-import io.netty.buffer.ByteBufAllocator;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.MessageSizeEstimator;
-import io.netty.channel.RecvByteBufAllocator;
-import io.netty.channel.socket.DefaultSocketChannelConfig;
-
-import java.util.Map;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-
-public class DefaultMD5SocketChannelConfig extends DefaultSocketChannelConfig implements MD5SocketChannelConfig {
- private final NettyKeyAccess keyAccess;
-
- public DefaultMD5SocketChannelConfig(final MD5NioSocketChannel channel, final KeyAccessFactory keyAccessFactory) {
- super(channel, channel.javaChannel().socket());
- this.keyAccess = NettyKeyAccess.create(keyAccessFactory, channel.javaChannel());
- }
-
- @Override
- public KeyMapping getMD5SignatureKeys() {
- return keyAccess.getKeys();
- }
-
- @Override
- public MD5SocketChannelConfig setMD5SignatureKeys(final KeyMapping keys) {
- keyAccess.setKeys(keys);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setTcpNoDelay(final boolean tcpNoDelay) {
- super.setTcpNoDelay(tcpNoDelay);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setSoLinger(final int soLinger) {
- super.setSoLinger(soLinger);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setSendBufferSize(final int sendBufferSize) {
- super.setSendBufferSize(sendBufferSize);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setReceiveBufferSize(final int receiveBufferSize) {
- super.setReceiveBufferSize(receiveBufferSize);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setKeepAlive(final boolean keepAlive) {
- super.setKeepAlive(keepAlive);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setTrafficClass(final int trafficClass) {
- super.setTrafficClass(trafficClass);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setReuseAddress(final boolean reuseAddress) {
- super.setReuseAddress(reuseAddress);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setPerformancePreferences(final int connectionTime, final int latency, final int bandwidth) {
- super.setPerformancePreferences(connectionTime, latency, bandwidth);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setAllowHalfClosure(final boolean allowHalfClosure) {
- super.setAllowHalfClosure(allowHalfClosure);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setConnectTimeoutMillis(final int connectTimeoutMillis) {
- super.setConnectTimeoutMillis(connectTimeoutMillis);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setMaxMessagesPerRead(final int maxMessagesPerRead) {
- super.setMaxMessagesPerRead(maxMessagesPerRead);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setWriteSpinCount(final int writeSpinCount) {
- super.setWriteSpinCount(writeSpinCount);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setAllocator(final ByteBufAllocator allocator) {
- super.setAllocator(allocator);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setRecvByteBufAllocator(final RecvByteBufAllocator allocator) {
- super.setRecvByteBufAllocator(allocator);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setAutoRead(final boolean autoRead) {
- super.setAutoRead(autoRead);
- return this;
- }
-
- @Override
- public MD5SocketChannelConfig setMessageSizeEstimator(final MessageSizeEstimator estimator) {
- super.setMessageSizeEstimator(estimator);
- return this;
- }
-
- @Override
- public Map<ChannelOption<?>, Object> getOptions() {
- final Map<ChannelOption<?>, Object> opts = super.getOptions();
- final KeyMapping keys = keyAccess.getKeys();
- if (keys != null) {
- opts.put(MD5ChannelOption.TCP_MD5SIG, keys);
- }
-
- return opts;
- }
-
- @Override
- public boolean setOptions(final Map<ChannelOption<?>, ?> options) {
- boolean setAllOptions = true;
- if (options.containsKey(MD5ChannelOption.TCP_MD5SIG)) {
- setAllOptions = setOption(MD5ChannelOption.TCP_MD5SIG, (KeyMapping) options.get(MD5ChannelOption.TCP_MD5SIG));
- }
-
- return super.setOptions(options) && setAllOptions;
- }
-
- @Override
- public <T> T getOption(final ChannelOption<T> option) {
- if (option == MD5ChannelOption.TCP_MD5SIG) {
- @SuppressWarnings("unchecked")
- final T ret = (T) keyAccess.getKeys();
- return ret;
- }
-
- return super.getOption(option);
- }
-
- @Override
- public <T> boolean setOption(final ChannelOption<T> option, final T value) {
- if (option == MD5ChannelOption.TCP_MD5SIG) {
- keyAccess.setKeys((KeyMapping) value);
- return true;
- }
-
- return super.setOption(option, value);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.netty;
-
-import io.netty.bootstrap.ChannelFactory;
-import io.netty.channel.Channel;
-
-public interface MD5ChannelFactory<C extends Channel> extends ChannelFactory<C> {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.netty;
-
-import io.netty.channel.ChannelOption;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-
-/**
- * TCP MD5 Signature {@link ChannelOption}.
- */
-public final class MD5ChannelOption extends ChannelOption<KeyMapping> {
- /**
- * Singleton instance of TCP MD5 Signature ChannelOption.
- */
- public static final MD5ChannelOption TCP_MD5SIG = new MD5ChannelOption("TCP_MD5SIG");
-
- @SuppressWarnings("deprecation")
- private MD5ChannelOption(final String name) {
- super(name);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.netty;
-
-import com.google.common.base.Preconditions;
-
-import io.netty.channel.ChannelException;
-import io.netty.channel.ChannelMetadata;
-import io.netty.channel.ChannelOutboundBuffer;
-import io.netty.channel.nio.AbstractNioMessageChannel;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-import java.util.List;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-
-/**
- * {@link io.netty.channel.socket.nio.NioServerSocketChannel} enabled with support for TCP MD5 Signature option.
- */
-public class MD5NioServerSocketChannel extends AbstractNioMessageChannel implements io.netty.channel.socket.ServerSocketChannel {
- private static final ChannelMetadata METADATA = new ChannelMetadata(false);
-
- private final MD5ServerSocketChannelConfig config;
- private final KeyAccessFactory keyAccessFactory;
-
- private static ServerSocketChannel newChannel() {
- try {
- return ServerSocketChannel.open();
- } catch (IOException e) {
- throw new ChannelException("Failed to instantiate channel", e);
- }
- }
-
- private MD5NioServerSocketChannel(final ServerSocketChannel channel, final KeyAccessFactory keyAccessFactory) {
- super(null, channel, SelectionKey.OP_ACCEPT);
- this.config = new DefaultMD5ServerSocketChannelConfig(this, keyAccessFactory);
- this.keyAccessFactory = Preconditions.checkNotNull(keyAccessFactory);
- }
-
- public MD5NioServerSocketChannel(final KeyAccessFactory keyAccessFactory) {
- this(newChannel(), keyAccessFactory);
- }
-
- @Override
- public MD5ServerSocketChannelConfig config() {
- return this.config;
- }
-
- @Override
- public InetSocketAddress localAddress() {
- return (InetSocketAddress) super.localAddress();
- }
-
- @Override
- public ChannelMetadata metadata() {
- return METADATA;
- }
-
- @Override
- public boolean isActive() {
- return javaChannel().socket().isBound();
- }
-
- @Override
- public InetSocketAddress remoteAddress() {
- return null;
- }
-
- @Override
- protected ServerSocketChannel javaChannel() {
- return (ServerSocketChannel) super.javaChannel();
- }
-
- @Override
- protected SocketAddress localAddress0() {
- return javaChannel().socket().getLocalSocketAddress();
- }
-
- @Override
- protected void doBind(final SocketAddress localAddress) throws IOException {
- javaChannel().socket().bind(localAddress, config.getBacklog());
- }
-
- @Override
- protected void doClose() throws IOException {
- javaChannel().close();
- }
-
- @Override
- protected int doReadMessages(final List<Object> buf) throws IOException {
- final SocketChannel jc = javaChannel().accept();
- if (jc == null) {
- return 0;
- }
-
- final MD5NioSocketChannel ch = new MD5NioSocketChannel(this, jc, keyAccessFactory);
- buf.add(ch);
- return 1;
- }
-
- @Override
- protected boolean doWriteMessage(final Object msg, final ChannelOutboundBuffer in) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected boolean doConnect(final SocketAddress remoteAddress, final SocketAddress localAddress) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void doFinishConnect() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected SocketAddress remoteAddress0() {
- return null;
- }
-
- @Override
- protected void doDisconnect() {
- throw new UnsupportedOperationException();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.netty;
-
-import com.google.common.base.Preconditions;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-
-public class MD5NioServerSocketChannelFactory implements MD5ServerChannelFactory<MD5NioServerSocketChannel> {
- private final KeyAccessFactory keyAccessFactory;
-
- public MD5NioServerSocketChannelFactory(final KeyAccessFactory keyAccessFactory) {
- this.keyAccessFactory = Preconditions.checkNotNull(keyAccessFactory);
- }
-
- @Override
- public MD5NioServerSocketChannel newChannel() {
- return new MD5NioServerSocketChannel(keyAccessFactory);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.netty;
-
-import com.google.common.base.Preconditions;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelException;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelMetadata;
-import io.netty.channel.ChannelPromise;
-import io.netty.channel.EventLoop;
-import io.netty.channel.FileRegion;
-import io.netty.channel.nio.AbstractNioByteChannel;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.SocketChannel;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-
-/**
- * {@link io.netty.channel.socket.nio.NioSocketChannel} enabled with support for TCP MD5 Signature option.
- */
-public class MD5NioSocketChannel extends AbstractNioByteChannel implements io.netty.channel.socket.SocketChannel {
- private static final ChannelMetadata METADATA = new ChannelMetadata(false);
-
- private final MD5SocketChannelConfig config;
-
- private static SocketChannel newChannel() {
- try {
- return SocketChannel.open();
- } catch (IOException e) {
- throw new ChannelException("Failed to instantiate channel", e);
- }
- }
-
- MD5NioSocketChannel(final MD5NioServerSocketChannel parent, final SocketChannel channel, final KeyAccessFactory factory) {
- super(parent, channel);
- this.config = new DefaultMD5SocketChannelConfig(this, factory);
- }
-
- public MD5NioSocketChannel(final KeyAccessFactory keyAccessFactory) {
- this(null, newChannel(), keyAccessFactory);
- }
-
- @Override
- public MD5SocketChannelConfig config() {
- return this.config;
- }
-
- @Override
- protected SocketChannel javaChannel() {
- return (SocketChannel) super.javaChannel();
- }
-
- @Override
- public boolean isActive() {
- final SocketChannel ch = javaChannel();
- return ch.isOpen() && ch.isConnected();
- }
-
- @Override
- public ChannelMetadata metadata() {
- return METADATA;
- }
-
- @Override
- public MD5NioServerSocketChannel parent() {
- return (MD5NioServerSocketChannel) super.parent();
- }
-
- @Override
- public InetSocketAddress localAddress() {
- return (InetSocketAddress) super.localAddress();
- }
-
- @Override
- public InetSocketAddress remoteAddress() {
- return (InetSocketAddress) super.remoteAddress();
- }
-
- @Override
- public boolean isInputShutdown() {
- return super.isInputShutdown();
- }
-
- @Override
- public boolean isOutputShutdown() {
- return javaChannel().socket().isOutputShutdown() || !isActive();
- }
-
- @Override
- public ChannelFuture shutdownOutput() {
- return shutdownOutput(newPromise());
- }
-
- @Override
- public ChannelFuture shutdownOutput(final ChannelPromise future) {
- EventLoop loop = eventLoop();
- if (loop.inEventLoop()) {
- try {
- javaChannel().socket().shutdownOutput();
- future.setSuccess();
- } catch (Exception e) {
- future.setFailure(e);
- }
- } else {
- loop.execute(new Runnable() {
- @Override
- public void run() {
- shutdownOutput(future);
- }
- });
- }
- return future;
- }
-
- @Override
- protected long doWriteFileRegion(final FileRegion region) throws IOException {
- return region.transferTo(javaChannel(), region.transfered());
- }
-
- @Override
- protected int doReadBytes(final ByteBuf buf) throws IOException {
- return buf.writeBytes(javaChannel(), buf.writableBytes());
- }
-
- @Override
- protected int doWriteBytes(final ByteBuf buf) throws IOException {
- return buf.readBytes(javaChannel(), buf.readableBytes());
- }
-
- @Override
- protected boolean doConnect(final SocketAddress remoteAddress, final SocketAddress localAddress) throws IOException {
- if (localAddress != null) {
- javaChannel().socket().bind(localAddress);
- }
-
- boolean success = false;
- try {
- boolean connected = javaChannel().connect(remoteAddress);
- if (!connected) {
- selectionKey().interestOps(SelectionKey.OP_CONNECT);
- }
- success = true;
- return connected;
- } finally {
- if (!success) {
- doClose();
- }
- }
- }
-
- @Override
- protected void doFinishConnect() throws IOException {
- Preconditions.checkState(javaChannel().finishConnect(), "finishConnect() failed");
- }
-
- @Override
- protected SocketAddress localAddress0() {
- return javaChannel().socket().getLocalSocketAddress();
- }
-
- @Override
- protected SocketAddress remoteAddress0() {
- return javaChannel().socket().getRemoteSocketAddress();
- }
-
- @Override
- protected void doBind(final SocketAddress localAddress) throws IOException {
- javaChannel().socket().bind(localAddress);
- }
-
- @Override
- protected void doDisconnect() throws IOException {
- doClose();
- }
-
- @Override
- protected void doClose() throws IOException {
- javaChannel().close();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.netty;
-
-import com.google.common.base.Preconditions;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-
-public class MD5NioSocketChannelFactory implements MD5ChannelFactory<MD5NioSocketChannel> {
- private final KeyAccessFactory keyAccessFactory;
-
- public MD5NioSocketChannelFactory(final KeyAccessFactory keyAccessFactory) {
- this.keyAccessFactory = Preconditions.checkNotNull(keyAccessFactory);
- }
-
- @Override
- public MD5NioSocketChannel newChannel() {
- return new MD5NioSocketChannel(keyAccessFactory);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.netty;
-
-import io.netty.bootstrap.ChannelFactory;
-import io.netty.channel.ServerChannel;
-
-public interface MD5ServerChannelFactory<C extends ServerChannel> extends ChannelFactory<C> {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.netty;
-
-import io.netty.buffer.ByteBufAllocator;
-import io.netty.channel.MessageSizeEstimator;
-import io.netty.channel.RecvByteBufAllocator;
-import io.netty.channel.socket.ServerSocketChannelConfig;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-
-/**
- * {@link ServerSocketChannelConfig} augmented with TCP MD5 Signature option support.
- */
-public interface MD5ServerSocketChannelConfig extends ServerSocketChannelConfig {
- KeyMapping getMD5SignatureKeys();
-
- MD5ServerSocketChannelConfig setMD5SignatureKeys(KeyMapping keys);
-
- @Override
- MD5ServerSocketChannelConfig setBacklog(int backlog);
-
- @Override
- MD5ServerSocketChannelConfig setReuseAddress(boolean reuseAddress);
-
- @Override
- MD5ServerSocketChannelConfig setReceiveBufferSize(int receiveBufferSize);
-
- @Override
- MD5ServerSocketChannelConfig setPerformancePreferences(int connectionTime, int latency, int bandwidth);
-
- @Override
- MD5ServerSocketChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis);
-
- @Override
- MD5ServerSocketChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead);
-
- @Override
- MD5ServerSocketChannelConfig setWriteSpinCount(int writeSpinCount);
-
- @Override
- MD5ServerSocketChannelConfig setAllocator(ByteBufAllocator allocator);
-
- @Override
- MD5ServerSocketChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator);
-
- @Override
- MD5ServerSocketChannelConfig setAutoRead(boolean autoRead);
-
- @Override
- MD5ServerSocketChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.netty;
-
-import io.netty.buffer.ByteBufAllocator;
-import io.netty.channel.MessageSizeEstimator;
-import io.netty.channel.RecvByteBufAllocator;
-import io.netty.channel.socket.SocketChannelConfig;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-
-/**
- * {@link SocketChannelConfig} augmented with TCP MD5 Signature option support.
- */
-public interface MD5SocketChannelConfig extends SocketChannelConfig {
- KeyMapping getMD5SignatureKeys();
-
- MD5SocketChannelConfig setMD5SignatureKeys(KeyMapping keys);
-
- @Override
- MD5SocketChannelConfig setTcpNoDelay(boolean tcpNoDelay);
-
- @Override
- MD5SocketChannelConfig setSoLinger(int soLinger);
-
- @Override
- MD5SocketChannelConfig setSendBufferSize(int sendBufferSize);
-
- @Override
- MD5SocketChannelConfig setReceiveBufferSize(int receiveBufferSize);
-
- @Override
- MD5SocketChannelConfig setKeepAlive(boolean keepAlive);
-
- @Override
- MD5SocketChannelConfig setTrafficClass(int trafficClass);
-
- @Override
- MD5SocketChannelConfig setReuseAddress(boolean reuseAddress);
-
- @Override
- MD5SocketChannelConfig setPerformancePreferences(int connectionTime, int latency, int bandwidth);
-
- @Override
- MD5SocketChannelConfig setAllowHalfClosure(boolean allowHalfClosure);
-
- @Override
- MD5SocketChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis);
-
- @Override
- MD5SocketChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead);
-
- @Override
- MD5SocketChannelConfig setWriteSpinCount(int writeSpinCount);
-
- @Override
- MD5SocketChannelConfig setAllocator(ByteBufAllocator allocator);
-
- @Override
- MD5SocketChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator);
-
- @Override
- MD5SocketChannelConfig setAutoRead(boolean autoRead);
-
- @Override
- MD5SocketChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.netty;
-
-import com.google.common.base.Preconditions;
-
-import io.netty.channel.ChannelException;
-
-import java.io.IOException;
-import java.nio.channels.NetworkChannel;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccess;
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-
-/**
- * Utility class for handling MD5 option.
- */
-final class NettyKeyAccess implements KeyAccess {
- private final KeyAccess delegate;
-
- private NettyKeyAccess(final KeyAccess delegate) {
- this.delegate = Preconditions.checkNotNull(delegate);
- }
-
- public static NettyKeyAccess create(final KeyAccessFactory factory, final NetworkChannel channel) {
- final KeyAccess access = factory.getKeyAccess(channel);
- return new NettyKeyAccess(access);
- }
-
- @Override
- public KeyMapping getKeys() {
- try {
- return delegate.getKeys();
- } catch (IOException e) {
- throw new ChannelException("Failed to set channel MD5 signature keys", e);
- }
- }
-
- @Override
- public void setKeys(final KeyMapping keys) {
- try {
- delegate.setKeys(keys);
- } catch (IOException e) {
- throw new ChannelException("Failed to set channel MD5 signature key", e);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.tcpmd5.netty.cfg;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.netty.MD5NioSocketChannelFactory;
-
-/**
- * Service representing a way for accessing key informtion.
- */
-public class MD5ClientChannelFactoryModule extends
- org.opendaylight.controller.config.yang.tcpmd5.netty.cfg.AbstractMD5ClientChannelFactoryModule {
- public MD5ClientChannelFactoryModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public MD5ClientChannelFactoryModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
- final org.opendaylight.controller.config.yang.tcpmd5.netty.cfg.MD5ClientChannelFactoryModule oldModule,
- final java.lang.AutoCloseable oldInstance) {
- super(identifier, dependencyResolver, oldModule, oldInstance);
- }
-
- @Override
- public void customValidation() {
- // add custom validation form module attributes here.
- }
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- final class AutoCloseableMD5NioSocketChannelFactory extends MD5NioSocketChannelFactory implements AutoCloseable {
- public AutoCloseableMD5NioSocketChannelFactory(final KeyAccessFactory keyAccessFactory) {
- super(keyAccessFactory);
- }
-
- @Override
- public void close() {
- // Noop
- }
- }
-
- return new AutoCloseableMD5NioSocketChannelFactory(getKeyAccessFactoryDependency());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.tcpmd5.netty.cfg;
-
-public class MD5ClientChannelFactoryModuleFactory extends
- org.opendaylight.controller.config.yang.tcpmd5.netty.cfg.AbstractMD5ClientChannelFactoryModuleFactory {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.tcpmd5.netty.cfg;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.netty.MD5NioServerSocketChannelFactory;
-
-/**
- * Service representing a way for accessing key informtion.
- */
-public class MD5ServerChannelFactoryModule extends
- org.opendaylight.controller.config.yang.tcpmd5.netty.cfg.AbstractMD5ServerChannelFactoryModule {
- public MD5ServerChannelFactoryModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public MD5ServerChannelFactoryModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
- final org.opendaylight.controller.config.yang.tcpmd5.netty.cfg.MD5ServerChannelFactoryModule oldModule,
- final java.lang.AutoCloseable oldInstance) {
- super(identifier, dependencyResolver, oldModule, oldInstance);
- }
-
- @Override
- public void customValidation() {
- // add custom validation form module attributes here.
- }
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- final class AutoCloseableMD5NioServerSocketChannelFactory extends MD5NioServerSocketChannelFactory implements AutoCloseable {
- public AutoCloseableMD5NioServerSocketChannelFactory(final KeyAccessFactory keyAccessFactory) {
- super(keyAccessFactory);
- }
-
- @Override
- public void close() {
- // Noop
- }
- }
-
- return new AutoCloseableMD5NioServerSocketChannelFactory(getServerKeyAccessFactoryDependency());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.tcpmd5.netty.cfg;
-
-public class MD5ServerChannelFactoryModuleFactory extends
- org.opendaylight.controller.config.yang.tcpmd5.netty.cfg.AbstractMD5ServerChannelFactoryModuleFactory {
-
-}
+++ /dev/null
-// vi: set smarttab et sw=4 tabstop=4:
-module odl-tcpmd5-netty-cfg {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:tcpmd5:netty:cfg";
- prefix "md5-netty";
-
- import config { prefix config; revision-date 2013-04-05; }
- import netty { prefix netty; revision-date 2013-11-19; }
- import odl-tcpmd5-cfg { prefix tcpmd5; revision-date 2014-04-27; }
-
- organization "Cisco Systems, Inc.";
-
- contact "Robert Varga <rovarga@cisco.com>";
-
- description
- "This module contains the base YANG definitions for
- TCP MD5 Signature option.
-
- Copyright (c)2014 Cisco Systems, Inc. All rights reserved.;
-
- This program and the accompanying materials are made available
- under the terms of the Eclipse Public License v1.0 which
- accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html";
-
- revision "2014-04-27" {
- description
- "Initial revision";
- }
-
- identity md5-channel-factory {
- description
- "Service representing a way for instantiating channels.";
-
- //base "netty:channel-factory";
- base "config:service-type";
- config:java-class "org.opendaylight.bgpcep.tcpmd5.netty.MD5ChannelFactory";
- }
-
- identity md5-server-channel-factory {
- description
- "Service representing a way for instantiating channels.";
-
- //base "netty:channel-factory";
- base "config:service-type";
- config:java-class "org.opendaylight.bgpcep.tcpmd5.netty.MD5ServerChannelFactory";
- }
-
- identity md5-server-channel-factory-impl {
- description
- "Service representing a way for accessing key informtion.";
-
- base config:module-type;
- config:provided-service md5-server-channel-factory;
- config:java-name-prefix MD5ServerChannelFactory;
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case md5-server-channel-factory-impl {
- when "/config:modules/config:module/config:type = 'md5-server-channel-factory-impl'";
-
- container server-key-access-factory {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity tcpmd5:key-access-factory;
- }
- }
- }
- }
- }
-
- identity md5-client-channel-factory {
- description
- "Service representing a way for accessing key informtion.";
-
- base config:module-type;
- config:provided-service md5-channel-factory;
- config:java-name-prefix MD5ClientChannelFactory;
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case md5-client-channel-factory {
- when "/config:modules/config:module/config:type = 'md5-client-channel-factory'";
-
- container key-access-factory {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity tcpmd5:key-access-factory;
- }
- }
- }
- }
- }
-}
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2013 Robert Varga. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<projectDescription>
- <name>tcpmd5-nio</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.m2e.core.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.m2e.core.maven2Nature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
- Copyright (c) 2013 Robert Varga. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>tcpmd5-parent</artifactId>
- <version>0.3.1-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>tcpmd5-nio</artifactId>
- <description>RFC2385-enable sockets</description>
- <packaging>bundle</packaging>
- <name>${project.artifactId}</name>
- <prerequisites>
- <maven>3.0.4</maven>
- </prerequisites>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-jni</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
-
- <!-- Testing dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- <Export-Package>
- org.opendaylight.bgpcep.tcpmd5.nio
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.nio;
-
-import org.opendaylight.bgpcep.tcpmd5.DummyKeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.jni.NativeKeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.jni.NativeSupportUnavailableException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Internal utility class for selecting the best available KeyAccessFactory. We prefer NativeKeyAccessFactory, but fall
- * back to DummyKeyAccessFactory if that is not available.
- */
-final class DefaultKeyAccessFactoryFactory {
- private static final Logger LOG = LoggerFactory.getLogger(DefaultKeyAccessFactoryFactory.class);
- private static final KeyAccessFactory FACTORY;
-
- static {
- KeyAccessFactory factory;
-
- try {
- factory = NativeKeyAccessFactory.getInstance();
- } catch (NativeSupportUnavailableException e) {
- LOG.debug("Native key access not available, using no-op fallback", e);
- factory = DummyKeyAccessFactory.getInstance();
- }
-
- FACTORY = factory;
- }
-
- private DefaultKeyAccessFactoryFactory() {
- throw new UnsupportedOperationException("Utility class should never be instantiated");
- }
-
- public static KeyAccessFactory getKeyAccessFactory() {
- return FACTORY;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.nio;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-
-import java.io.IOException;
-import java.net.SocketOption;
-import java.nio.channels.NetworkChannel;
-import java.util.Set;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccess;
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-import org.opendaylight.bgpcep.tcpmd5.MD5SocketOptions;
-
-/**
- * Channel option wrapper which unifies the underlying NetworkChannel with the TCP MD5 Signature option if the channel
- * is supported by the JNI library.
- */
-final class MD5ChannelOptions {
- private static final Set<SocketOption<?>> MD5_OPTIONS = ImmutableSet.<SocketOption<?>> of(MD5SocketOptions.TCP_MD5SIG);
- private final NetworkChannel ch;
- private final KeyAccess access;
-
- private MD5ChannelOptions(final NetworkChannel ch, final KeyAccess access) {
- this.ch = Preconditions.checkNotNull(ch);
- this.access = access;
- }
-
- static MD5ChannelOptions create(final KeyAccessFactory keyAccessFactory, final NetworkChannel ch) {
- final KeyAccess access = keyAccessFactory.getKeyAccess(Preconditions.checkNotNull(ch));
- return new MD5ChannelOptions(ch, access);
- }
-
- @SuppressWarnings("unchecked")
- public <T> T getOption(final SocketOption<T> name) throws IOException {
- if (access != null && name.equals(MD5SocketOptions.TCP_MD5SIG)) {
- return (T) access.getKeys();
- }
-
- return ch.getOption(name);
- }
-
- public <T> void setOption(final SocketOption<T> name, final T value) throws IOException {
- if (access != null && name.equals(MD5SocketOptions.TCP_MD5SIG)) {
- access.setKeys((KeyMapping) value);
- } else {
- ch.setOption(name, value);
- }
- }
-
- public Set<SocketOption<?>> supportedOptions() {
- if (access != null) {
- return Sets.union(MD5_OPTIONS, ch.supportedOptions());
- } else {
- return ch.supportedOptions();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.nio;
-
-import com.google.common.base.Preconditions;
-
-import java.io.IOException;
-import java.net.ProtocolFamily;
-import java.nio.channels.DatagramChannel;
-import java.nio.channels.Pipe;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-import java.nio.channels.spi.AbstractSelector;
-import java.nio.channels.spi.SelectorProvider;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class MD5SelectorProvider extends SelectorProvider {
- private static final Logger LOG = LoggerFactory.getLogger(MD5SelectorProvider.class);
- private static final Map<SelectorProvider, MD5SelectorProvider> INSTANCES = new WeakHashMap<>();
- private final KeyAccessFactory keyAccessFactory;
- private final SelectorProvider delegate;
-
- private MD5SelectorProvider(final KeyAccessFactory keyAccessFactory, final SelectorProvider delegate) {
- this.keyAccessFactory = Preconditions.checkNotNull(keyAccessFactory);
- this.delegate = Preconditions.checkNotNull(delegate);
- }
-
- public static synchronized MD5SelectorProvider getInstance(final KeyAccessFactory keyAccessFactory, final SelectorProvider provider) {
- MD5SelectorProvider ret = INSTANCES.get(provider);
- if (ret == null) {
- ret = new MD5SelectorProvider(keyAccessFactory, provider);
- LOG.debug("Created new provider instance {} for delegate {}", ret, provider);
- INSTANCES.put(provider, ret);
- }
-
- return ret;
- }
-
- public static MD5SelectorProvider getInstance(final KeyAccessFactory keyAccessFactory) {
- return getInstance(keyAccessFactory, provider());
- }
-
- @Override
- public DatagramChannel openDatagramChannel() throws IOException {
- throw new UnsupportedOperationException("Datagram channels are not supported");
- }
-
- @Override
- public DatagramChannel openDatagramChannel(final ProtocolFamily family) throws IOException {
- throw new UnsupportedOperationException("Datagram channels are not supported");
- }
-
- @Override
- public Pipe openPipe() throws IOException {
- throw new UnsupportedOperationException("Pipes are not supported");
- }
-
- @Override
- public AbstractSelector openSelector() throws IOException {
- final AbstractSelector s = delegate.openSelector();
- final AbstractSelector ret = new SelectorFacade(delegate, s);
-
- LOG.debug("Opened facade {} for selector {}", ret, s);
- return ret;
- }
-
- @Override
- public MD5ServerSocketChannel openServerSocketChannel() throws IOException {
- final ServerSocketChannel ch = delegate.openServerSocketChannel();
- final MD5ServerSocketChannel ret = new MD5ServerSocketChannel(ch, keyAccessFactory);
-
- LOG.debug("Created facade {} for server channel {}", ret, ch);
- return ret;
- }
-
- @Override
- public MD5SocketChannel openSocketChannel() throws IOException {
- final SocketChannel ch = delegate.openSocketChannel();
- final MD5SocketChannel ret = new MD5SocketChannel(ch, keyAccessFactory);
-
- LOG.debug("Created facade {} for channel {}", ret, ch);
- return ret;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.nio;
-
-import com.google.common.base.Preconditions;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.SocketAddress;
-import java.net.SocketOption;
-import java.nio.channels.ServerSocketChannel;
-import java.util.Set;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * {@link ServerSocketChannel} augmented with support for TCP MD5 Signature option.
- */
-public final class MD5ServerSocketChannel extends ServerSocketChannel implements ProxyChannel<ServerSocketChannel> {
- private static final Logger LOG = LoggerFactory.getLogger(MD5ServerSocketChannel.class);
- private final KeyAccessFactory keyAccessFactory;
- private final ServerSocketChannel inner;
- private final MD5ChannelOptions options;
-
- public MD5ServerSocketChannel(final ServerSocketChannel inner, final KeyAccessFactory keyAccessFactory) {
- super(MD5SelectorProvider.getInstance(keyAccessFactory, inner.provider()));
- this.inner = inner;
- this.keyAccessFactory = Preconditions.checkNotNull(keyAccessFactory);
- this.options = MD5ChannelOptions.create(keyAccessFactory, inner);
- }
-
- public MD5ServerSocketChannel(final ServerSocketChannel inner) {
- this(inner, DefaultKeyAccessFactoryFactory.getKeyAccessFactory());
- }
-
- public static MD5ServerSocketChannel open() throws IOException {
- return new MD5ServerSocketChannel(ServerSocketChannel.open());
- }
-
- public static MD5ServerSocketChannel open(final KeyAccessFactory keyAccessFactory) throws IOException {
- return new MD5ServerSocketChannel(ServerSocketChannel.open(), keyAccessFactory);
- }
-
- @Override
- public SocketAddress getLocalAddress() throws IOException {
- return inner.getLocalAddress();
- }
-
- @Override
- public <T> T getOption(final SocketOption<T> name) throws IOException {
- return options.getOption(name);
- }
-
- @Override
- public Set<SocketOption<?>> supportedOptions() {
- return options.supportedOptions();
- }
-
- @Override
- public ServerSocketChannel bind(final SocketAddress local, final int backlog) throws IOException {
- inner.bind(local, backlog);
- return this;
- }
-
- @Override
- public <T> ServerSocketChannel setOption(final SocketOption<T> name, final T value) throws IOException {
- options.setOption(name, value);
- return this;
- }
-
- @Override
- public ServerSocket socket() {
- final ServerSocket s = inner.socket();
- LOG.info("Leaking inner socket {} from server {}", s, this);
- return s;
- }
-
- @Override
- public MD5SocketChannel accept() throws IOException {
- return new MD5SocketChannel(inner.accept(), keyAccessFactory);
- }
-
- @Override
- protected void implCloseSelectableChannel() throws IOException {
- inner.close();
- }
-
- @Override
- protected void implConfigureBlocking(final boolean block) throws IOException {
- inner.configureBlocking(block);
- }
-
- @Override
- public ServerSocketChannel getDelegate() {
- return inner;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Robert Varga. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.nio;
-
-import java.io.IOException;
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.net.SocketOption;
-import java.nio.ByteBuffer;
-import java.nio.channels.SocketChannel;
-import java.util.Set;
-
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-
-/**
- * {@link SocketChannel} augmented with support for TCP MD5 Signature option.
- */
-public final class MD5SocketChannel extends SocketChannel implements ProxyChannel<SocketChannel> {
- private final MD5ChannelOptions options;
- private final SocketChannel inner;
-
- public MD5SocketChannel(final SocketChannel inner) {
- this(inner, DefaultKeyAccessFactoryFactory.getKeyAccessFactory());
- }
-
- public MD5SocketChannel(final SocketChannel inner, final KeyAccessFactory keyAccessFactory) {
- super(MD5SelectorProvider.getInstance(keyAccessFactory, inner.provider()));
- this.inner = inner;
- options = MD5ChannelOptions.create(keyAccessFactory, inner);
- }
-
- public static MD5SocketChannel open() throws IOException {
- return new MD5SocketChannel(SocketChannel.open());
- }
-
- public static MD5SocketChannel open(final KeyAccessFactory keyAccessFactory) throws IOException {
- return new MD5SocketChannel(SocketChannel.open(), keyAccessFactory);
- }
-
- @Override
- public SocketAddress getLocalAddress() throws IOException {
- return inner.getLocalAddress();
- }
-
- @Override
- public <T> T getOption(final SocketOption<T> name) throws IOException {
- return options.getOption(name);
- }
-
- @Override
- public Set<SocketOption<?>> supportedOptions() {
- return options.supportedOptions();
- }
-
- @Override
- public SocketChannel bind(final SocketAddress local) throws IOException {
- inner.bind(local);
- return this;
- }
-
- @Override
- public <T> SocketChannel setOption(final SocketOption<T> name, final T value) throws IOException {
- options.setOption(name, value);
- return this;
- }
-
- @Override
- public SocketChannel shutdownInput() throws IOException {
- inner.shutdownInput();
- return this;
- }
-
- @Override
- public SocketChannel shutdownOutput() throws IOException {
- inner.shutdownOutput();
- return this;
- }
-
- @Override
- public Socket socket() {
- // FIXME: provide a wrapper
- return inner.socket();
- }
-
- @Override
- public boolean isConnected() {
- return inner.isConnected();
- }
-
- @Override
- public boolean isConnectionPending() {
- return inner.isConnectionPending();
- }
-
- @Override
- public boolean connect(final SocketAddress remote) throws IOException {
- return inner.connect(remote);
- }
-
- @Override
- public boolean finishConnect() throws IOException {
- return inner.finishConnect();
- }
-
- @Override
- public SocketAddress getRemoteAddress() throws IOException {
- return inner.getRemoteAddress();
- }
-
- @Override
- public int read(final ByteBuffer dst) throws IOException {
- return inner.read(dst);
- }
-
- @Override
- public long read(final ByteBuffer[] dsts, final int offset, final int length) throws IOException {
- return inner.read(dsts, offset, length);
- }
-
- @Override
- public int write(final ByteBuffer src) throws IOException {
- return inner.write(src);
- }
-
- @Override
- public long write(final ByteBuffer[] srcs, final int offset, final int length) throws IOException {
- return inner.write(srcs, offset, length);
- }
-
- @Override
- protected void implCloseSelectableChannel() throws IOException {
- inner.close();
- }
-
- @Override
- protected void implConfigureBlocking(final boolean block) throws IOException {
- inner.configureBlocking(block);
- }
-
- @Override
- public SocketChannel getDelegate() {
- return inner;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.nio;
-
-import java.nio.channels.spi.AbstractSelectableChannel;
-
-interface ProxyChannel<C extends AbstractSelectableChannel> {
- C getDelegate();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.nio;
-
-import com.google.common.base.Preconditions;
-
-import java.io.IOException;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.Selector;
-import java.nio.channels.spi.AbstractSelectableChannel;
-import java.nio.channels.spi.AbstractSelector;
-import java.nio.channels.spi.SelectorProvider;
-import java.util.Set;
-
-final class SelectorFacade extends AbstractSelector {
- private final AbstractSelector delegate;
-
- SelectorFacade(final SelectorProvider provider, final AbstractSelector delegate) {
- super(provider);
- this.delegate = Preconditions.checkNotNull(delegate);
- }
-
- @Override
- protected void implCloseSelector() throws IOException {
- delegate.close();
- }
-
- @Override
- protected SelectionKey register(final AbstractSelectableChannel ch, final int ops, final Object att) {
- Preconditions.checkArgument(ch instanceof ProxyChannel<?>);
-
- final AbstractSelectableChannel ach = ((ProxyChannel<?>) ch).getDelegate();
- try {
- return ach.register(delegate, ops, att);
- } catch (ClosedChannelException e) {
- throw new IllegalArgumentException("Failed to register channel", e);
- }
- }
-
- @Override
- public Set<SelectionKey> keys() {
- return delegate.keys();
- }
-
- @Override
- public Set<SelectionKey> selectedKeys() {
- return delegate.selectedKeys();
- }
-
- @Override
- public int selectNow() throws IOException {
- return delegate.selectNow();
- }
-
- @Override
- public int select(final long timeout) throws IOException {
- return delegate.select(timeout);
- }
-
- @Override
- public int select() throws IOException {
- return delegate.select();
- }
-
- @Override
- public Selector wakeup() {
- return delegate.wakeup();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.nio;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-
-import com.google.common.collect.ImmutableSet;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.SocketOption;
-import java.net.StandardSocketOptions;
-import java.nio.channels.NetworkChannel;
-import java.util.Set;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.bgpcep.tcpmd5.KeyAccess;
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-import org.opendaylight.bgpcep.tcpmd5.MD5SocketOptions;
-
-public class MD5ChannelOptionsTest {
-
- @Mock
- private KeyAccessFactory keyAccessFactory;
- @Mock
- private KeyAccess keyAccess;
- @Mock
- private NetworkChannel channel;
-
- @Before
- public void setup() throws IOException {
- MockitoAnnotations.initMocks(this);
-
- Mockito.doReturn(keyAccess).when(keyAccessFactory).getKeyAccess(channel);
- Mockito.doReturn(null).when(keyAccess).getKeys();
- Mockito.doNothing().when(keyAccess).setKeys(any(KeyMapping.class));
-
- Mockito.doReturn(ImmutableSet.of(StandardSocketOptions.TCP_NODELAY)).when(channel).supportedOptions();
- Mockito.doReturn(false).when(channel).getOption(StandardSocketOptions.TCP_NODELAY);
- Mockito.doReturn(channel).when(channel).setOption(StandardSocketOptions.TCP_NODELAY, true);
- }
-
- @Test
- public void testCreate() {
- final MD5ChannelOptions opts = MD5ChannelOptions.create(keyAccessFactory, channel);
-
- final Set<SocketOption<?>> so = opts.supportedOptions();
- assertTrue(so.contains(MD5SocketOptions.TCP_MD5SIG));
- assertTrue(so.contains(StandardSocketOptions.TCP_NODELAY));
-
- Mockito.verifyZeroInteractions(keyAccess);
- Mockito.verify(keyAccessFactory).getKeyAccess(channel);
- Mockito.verify(channel).supportedOptions();
- }
-
- @Test
- public void testGetOption() throws IOException {
- final MD5ChannelOptions opts = MD5ChannelOptions.create(keyAccessFactory, channel);
-
- assertNull(opts.getOption(MD5SocketOptions.TCP_MD5SIG));
- assertFalse(opts.getOption(StandardSocketOptions.TCP_NODELAY));
-
- Mockito.verify(keyAccess).getKeys();
- Mockito.verify(channel).getOption(StandardSocketOptions.TCP_NODELAY);
- }
-
- @Test
- public void testSetOption() throws IOException {
- final MD5ChannelOptions opts = MD5ChannelOptions.create(keyAccessFactory, channel);
-
- final KeyMapping map = new KeyMapping();
- map.put(InetAddress.getLoopbackAddress(), new byte[] { 1, });
-
- opts.setOption(MD5SocketOptions.TCP_MD5SIG, map);
- opts.setOption(StandardSocketOptions.TCP_NODELAY, true);
-
- Mockito.verify(keyAccess).setKeys(any(KeyMapping.class));
- Mockito.verify(channel).setOption(StandardSocketOptions.TCP_NODELAY, true);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.tcpmd5.nio;
-
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Matchers.any;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.nio.channels.NetworkChannel;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.bgpcep.tcpmd5.KeyAccess;
-import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
-import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
-import org.opendaylight.bgpcep.tcpmd5.MD5SocketOptions;
-
-public class MD5SocketChannelTest {
- @Mock
- private KeyAccessFactory keyAccessFactory;
- @Mock
- private KeyAccess keyAccess;
-
- @Before
- public void setup() throws IOException {
- MockitoAnnotations.initMocks(this);
-
- Mockito.doReturn(keyAccess).when(keyAccessFactory).getKeyAccess(any(NetworkChannel.class));
- Mockito.doReturn(null).when(keyAccess).getKeys();
- Mockito.doNothing().when(keyAccess).setKeys(any(KeyMapping.class));
- }
-
- @Test
- public void testCreate() throws IOException {
- try (final MD5SocketChannel sc = MD5SocketChannel.open(keyAccessFactory)) {
-
- }
-
- Mockito.verify(keyAccessFactory).getKeyAccess(any(NetworkChannel.class));
- }
-
- @Test
- public void testGetKey() throws IOException {
- try (final MD5SocketChannel sc = MD5SocketChannel.open(keyAccessFactory)) {
-
- assertNull(sc.getOption(MD5SocketOptions.TCP_MD5SIG));
- }
-
- Mockito.verify(keyAccessFactory).getKeyAccess(any(NetworkChannel.class));
- Mockito.verify(keyAccess).getKeys();
- }
-
- @Test
- public void testSetKey() throws IOException {
- final KeyMapping map = new KeyMapping();
- map.put(InetAddress.getLoopbackAddress(), new byte[] { 1, 2, 3 });
-
- try (final MD5SocketChannel sc = MD5SocketChannel.open(keyAccessFactory)) {
- assertSame(sc, sc.setOption(MD5SocketOptions.TCP_MD5SIG, map));
- }
-
- Mockito.verify(keyAccessFactory).getKeyAccess(any(NetworkChannel.class));
- Mockito.verify(keyAccess).setKeys(map);
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
- Copyright (c) 2013 Robert Varga. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
- <scm>
- <connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
- <url>https://wiki.opendaylight.org/view/BGP_LS_PCEP:Main</url>
- <tag>HEAD</tag>
- </scm>
- <parent>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>commons.parent</artifactId>
- <version>0.3.1-SNAPSHOT</version>
- <relativePath>../commons/parent</relativePath>
- </parent>
- <prerequisites>
- <maven>3.0.4</maven>
- </prerequisites>
-
- <artifactId>tcpmd5-parent</artifactId>
- <description>RFC2385-enabled sockets components</description>
- <packaging>pom</packaging>
- <name>${project.artifactId}</name>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-api-cfg</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-jni</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-jni-cfg</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-netty</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-nio</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-jni</artifactId>
- <version>${project.version}</version>
- <type>nar</type>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tcpmd5-controller-config</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <profiles>
- <profile>
- <id>jni</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <modules>
- <module>api</module>
- <module>jni</module>
- <module>netty</module>
- <module>nio</module>
- <module>controller-config</module>
- </modules>
- </profile>
- <profile>
- <id>default</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <modules>
- <module>api</module>
- <module>netty</module>
- <module>nio</module>
- <module>controller-config</module>
- </modules>
- </profile>
- </profiles>
-</project>