Code Review
/
openflowplugin.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Added JSON and XML payloads tabs with RFC 8040 URL"
[openflowplugin.git]
/
openflowplugin-impl
/
src
/
main
/
java
/
org
/
opendaylight
/
openflowplugin
/
impl
/
protocol
/
serialization
/
messages
/
PortMessageSerializer.java
diff --git
a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/PortMessageSerializer.java
b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/PortMessageSerializer.java
index c098ab51271d66f488089eb930dca1e8287554dd..ffcf596f0d4420abac00156167704e6211fd0ab2 100644
(file)
--- a/
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/PortMessageSerializer.java
+++ b/
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/PortMessageSerializer.java
@@
-5,9
+5,9
@@
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.openflowplugin.impl.protocol.serialization.messages;
package org.opendaylight.openflowplugin.impl.protocol.serialization.messages;
+import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableMap;
import io.netty.buffer.ByteBuf;
import org.opendaylight.openflowjava.util.ByteBufUtils;
import com.google.common.collect.ImmutableMap;
import io.netty.buffer.ByteBuf;
import org.opendaylight.openflowjava.util.ByteBufUtils;
@@
-23,23
+23,28
@@
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.P
* OF protocol versions: 1.3.
*/
public class PortMessageSerializer extends AbstractMessageSerializer<PortMessage> {
* OF protocol versions: 1.3.
*/
public class PortMessageSerializer extends AbstractMessageSerializer<PortMessage> {
+
private static final byte PADDING_IN_PORT_MOD_MESSAGE_01 = 4;
private static final byte PADDING_IN_PORT_MOD_MESSAGE_02 = 2;
private static final byte PADDING_IN_PORT_MOD_MESSAGE_03 = 4;
private static final byte PADDING_IN_PORT_MOD_MESSAGE_01 = 4;
private static final byte PADDING_IN_PORT_MOD_MESSAGE_02 = 2;
private static final byte PADDING_IN_PORT_MOD_MESSAGE_03 = 4;
+ private static final Integer DEFAULT_PORT_CONFIG_MASK = createPortConfigBitMask(
+ new PortConfig(true, true, true, true));
@Override
public void serialize(final PortMessage message, final ByteBuf outBuffer) {
@Override
public void serialize(final PortMessage message, final ByteBuf outBuffer) {
+ final int index = outBuffer.writerIndex();
super.serialize(message, outBuffer);
super.serialize(message, outBuffer);
- outBuffer.writeInt(OpenflowPortsUtil.getProtocolPortNumber(OpenflowVersion.OF13, message.getPortNumber()).intValue());
+ outBuffer.writeInt(OpenflowPortsUtil
+ .getProtocolPortNumber(OpenflowVersion.OF13, message.getPortNumber()).intValue());
outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_01);
outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_01);
- outBuffer.writeBytes(IetfYangUtil.INSTANCE.
bytesFor
(message.getHardwareAddress()));
+ outBuffer.writeBytes(IetfYangUtil.INSTANCE.
macAddressBytes
(message.getHardwareAddress()));
outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_02);
outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_02);
-
final int portConfigBitMask = createPortConfigBitMask(message.getConfiguration(
));
- outBuffer.writeInt(
portConfigBitMask); // Configuration
- outBuffer.writeInt(portConfigBitMask); // Configuration mask
+
outBuffer.writeInt(createPortConfigBitMask(message.getConfiguration()
));
+ outBuffer.writeInt(
MoreObjects
+ .firstNonNull(createPortConfigBitMask(message.getMask()), DEFAULT_PORT_CONFIG_MASK));
outBuffer.writeInt(createPortFeaturesBitMask(message.getAdvertisedFeatures()));
outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_03);
outBuffer.writeInt(createPortFeaturesBitMask(message.getAdvertisedFeatures()));
outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_03);
-
ByteBufUtils.updateOFHeaderLength(outBuffer
);
+
outBuffer.setShort(index + 2, outBuffer.writerIndex() - index
);
}
@Override
}
@Override
@@
-47,8
+52,8
@@
public class PortMessageSerializer extends AbstractMessageSerializer<PortMessage
return 16;
}
return 16;
}
- private static
int
createPortConfigBitMask(final PortConfig config) {
- return ByteBufUtils.fillBitMaskFromMap(ImmutableMap
+ private static
Integer
createPortConfigBitMask(final PortConfig config) {
+ return
config == null ? null :
ByteBufUtils.fillBitMaskFromMap(ImmutableMap
.<Integer, Boolean>builder()
.put(0, config.isPORTDOWN())
.put(2, config.isNORECV())
.<Integer, Boolean>builder()
.put(0, config.isPORTDOWN())
.put(2, config.isNORECV())