Skip to content

Commit

Permalink
chore: Made it possible to override the default for "resolve-mac-addr…
Browse files Browse the repository at this point in the history
…ess" and updated the raw-socket transport to use the new transport configs.
  • Loading branch information
chrisdutz committed Dec 3, 2023
1 parent 8144ed9 commit 7a219c4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,13 @@

package org.apache.plc4x.java.profinet.config;

import org.apache.plc4x.java.spi.configuration.annotations.ConfigurationParameter;
import org.apache.plc4x.java.spi.configuration.annotations.defaults.BooleanDefaultValue;
import org.apache.plc4x.java.transport.rawsocket.DefaultRawSocketTransportConfiguration;
import org.apache.plc4x.java.utils.pcap.netty.handlers.PacketHandler;

public class ProfinetRawSocketTransportConfiguration extends DefaultRawSocketTransportConfiguration {

@ConfigurationParameter("resolve-mac-address")
@BooleanDefaultValue(true)
private boolean resolveMacAddress;

@Override
public boolean isResolveMacAccess() {
return resolveMacAddress;
}

public void setResolveMacAddress(boolean resolveMacAddress) {
this.resolveMacAddress = resolveMacAddress;
public ProfinetRawSocketTransportConfiguration() {
setResolveMacAddress(true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
public abstract class DefaultRawSocketTransportConfiguration extends DefaultPcapTransportConfiguration implements RawSocketTransportConfiguration {

@ConfigurationParameter("resolve-mac-address")
@BooleanDefaultValue(false)
private boolean resolveMacAddress;

public DefaultRawSocketTransportConfiguration() {
resolveMacAddress = false;
}

@Override
public boolean isResolveMacAccess() {
return resolveMacAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ public ChannelFactory createChannelFactory(String transportConfig) {
// Create the fully qualified remote socket address which we should connect to.
SocketAddress address = new InetSocketAddress((ip == null) ? hostname : ip, port);

return new RawSocketChannelFactory(address);
RawSocketChannelFactory rawSocketChannelFactory = new RawSocketChannelFactory(address);
if(configuration != null) {
rawSocketChannelFactory.setConfiguration(configuration);
}
return rawSocketChannelFactory;
}

@Override
Expand Down

0 comments on commit 7a219c4

Please sign in to comment.