From 3c58c44881df41f633ba6a7d7a9165d773055ce5 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Wed, 1 Mar 2017 16:38:29 +0100 Subject: [PATCH] Add multipart request message serializers - Add serializers for multipart request and it's subtypes - Add YANG models for multipart request and it's subtypes See also: bug 6915 Change-Id: I465c23a6fc3bea0cf944bbe8e6f75e17833d4449 Signed-off-by: Tomas Slusny --- .../openflowplugin-experimenter-types.yang | 6 +- .../main/yang/opendaylight-flow-types.yang | 80 ++++---- .../yang/opendaylight-multipart-types.yang | 13 +- .../main/yang/opendaylight-port-types.yang | 7 + .../main/yang/opendaylight-table-types.yang | 121 ++++++------ .../src/main/yang/flow-node-inventory.yang | 6 + .../src/main/yang/sal-table.yang | 16 +- .../opendaylight-flow-table-statistics.yang | 6 + .../yang/opendaylight-group-statistics.yang | 14 ++ .../yang/opendaylight-meter-statistics.yang | 16 ++ .../yang/opendaylight-port-statistics.yang | 8 + .../yang/opendaylight-queue-statistics.yang | 12 ++ .../common/MultipartReplyTranslatorUtil.java | 4 +- .../ActionDeserializerInjector.java | 2 +- .../InstructionDeserializerInjector.java | 2 +- .../MatchDeserializerInjector.java | 7 +- .../MessageDeserializerInjector.java | 2 +- .../MultipartDeserializerInjector.java | 2 +- ...ltipartReplyTableFeaturesDeserializer.java | 2 +- .../MatchSerializerInjector.java | 4 +- .../MessageSerializerInjector.java | 5 +- ...MultipartMatchFieldSerializerInjector.java | 181 ++++++++++++++++++ .../MultipartSerializerInjector.java | 100 ++++++++++ ...tipartTableFeaturesSerializerInjector.java | 95 +++++++++ .../serialization/SerializerInjector.java | 1 + .../messages/FlowMessageSerializer.java | 8 +- .../MultipartRequestDescSerializer.java | 22 +++ ...ultipartRequestExperimenterSerializer.java | 73 +++++++ ...rtRequestFlowAggregateStatsSerializer.java | 53 +++++ .../MultipartRequestFlowStatsSerializer.java | 53 +++++ ...tipartRequestFlowTableStatsSerializer.java | 22 +++ .../MultipartRequestGroupDescSerializer.java | 22 +++ ...ltipartRequestGroupFeaturesSerializer.java | 22 +++ .../MultipartRequestGroupStatsSerializer.java | 36 ++++ .../MultipartRequestMessageSerializer.java | 101 ++++++++++ ...MultipartRequestMeterConfigSerializer.java | 34 ++++ ...ltipartRequestMeterFeaturesSerializer.java | 22 +++ .../MultipartRequestMeterStatsSerializer.java | 34 ++++ .../MultipartRequestPortDescSerializer.java | 22 +++ .../MultipartRequestPortStatsSerializer.java | 42 ++++ .../MultipartRequestQueueStatsSerializer.java | 43 +++++ ...ltipartRequestTableFeaturesSerializer.java | 81 ++++++++ .../AbstractTablePropertySerializer.java | 45 +++++ ...plyActionsMissTablePropertySerializer.java | 54 ++++++ .../ApplyActionsTablePropertySerializer.java | 54 ++++++ ...lySetfieldMissTablePropertySerializer.java | 54 ++++++ .../ApplySetfieldTablePropertySerializer.java | 54 ++++++ ...structionsMissTablePropertySerializer.java | 54 ++++++ .../InstructionsTablePropertySerializer.java | 54 ++++++ .../MatchTablePropertySerializer.java | 54 ++++++ .../NextTableMissTablePropertySerializer.java | 35 ++++ .../NextTableTablePropertySerializer.java | 35 ++++ .../WildcardsTablePropertySerializer.java | 54 ++++++ ...iteActionsMissTablePropertySerializer.java | 54 ++++++ .../WriteActionsTablePropertySerializer.java | 54 ++++++ ...teSetfieldMissTablePropertySerializer.java | 54 ++++++ .../WriteSetfieldTablePropertySerializer.java | 54 ++++++ .../AbstractMatchFieldSerializer.java | 37 ++++ .../matchfield/ArpOpMatchFieldSerializer.java | 29 +++ .../ArpShaMatchFieldSerializer.java | 29 +++ .../ArpSpaMatchFieldSerializer.java | 29 +++ .../ArpThaMatchFieldSerializer.java | 29 +++ .../ArpTpaMatchFieldSerializer.java | 29 +++ .../EthDstMatchFieldSerializer.java | 29 +++ .../EthSrcMatchFieldSerializer.java | 29 +++ .../EthTypeMatchFieldSerializer.java | 29 +++ .../Icmpv4CodeMatchFieldSerializer.java | 29 +++ .../Icmpv4TypeMatchFieldSerializer.java | 29 +++ .../Icmpv6CodeMatchFieldSerializer.java | 29 +++ .../Icmpv6TypeMatchFieldSerializer.java | 29 +++ .../InPhyPortMatchFieldSerializer.java | 29 +++ .../InPortMatchFieldSerializer.java | 29 +++ .../IpDscpMatchFieldSerializer.java | 29 +++ .../matchfield/IpEcnMatchFieldSerializer.java | 29 +++ .../IpProtoMatchFieldSerializer.java | 29 +++ .../Ipv4DstMatchFieldSerializer.java | 29 +++ .../Ipv4SrcMatchFieldSerializer.java | 29 +++ .../Ipv6DstMatchFieldSerializer.java | 29 +++ .../Ipv6ExtHdrMatchFieldSerializer.java | 29 +++ .../Ipv6FlabelMatchFieldSerializer.java | 29 +++ .../Ipv6NdSllMatchFieldSerializer.java | 29 +++ .../Ipv6NdTargetMatchFieldSerializer.java | 29 +++ .../Ipv6NdTllMatchFieldSerializer.java | 29 +++ .../Ipv6SrcMatchFieldSerializer.java | 29 +++ .../MetadataMatchFieldSerializer.java | 29 +++ .../MplsBosMatchFieldSerializer.java | 29 +++ .../MplsLabelMatchFieldSerializer.java | 29 +++ .../MplsTcMatchFieldSerializer.java | 29 +++ .../PbbIsidMatchFieldSerializer.java | 29 +++ .../SctpDstMatchFieldSerializer.java | 29 +++ .../SctpSrcMatchFieldSerializer.java | 29 +++ .../TcpDstMatchFieldSerializer.java | 29 +++ .../TcpFlagsMatchFieldSerializer.java | 30 +++ .../TcpSrcMatchFieldSerializer.java | 29 +++ .../TunnelIdMatchFieldSerializer.java | 29 +++ .../UdpDstMatchFieldSerializer.java | 29 +++ .../UdpSrcMatchFieldSerializer.java | 29 +++ .../VlanPcpMatchFieldSerializer.java | 29 +++ .../VlanVidMatchFieldSerializer.java | 29 +++ .../serialization/util/ActionUtil.java | 40 ++++ .../serialization/util/InstructionUtil.java | 66 +++++++ .../impl/rpc/RpcContextImpl.java | 2 +- .../SingleLayerTableMultipartService.java | 2 +- ...artReplyTableFeaturesDeserializerTest.java | 2 +- ...MultipartRequestMessageSerializerTest.java | 71 +++++++ 105 files changed, 3448 insertions(+), 127 deletions(-) create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MultipartMatchFieldSerializerInjector.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MultipartSerializerInjector.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MultipartTableFeaturesSerializerInjector.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestDescSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestExperimenterSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowAggregateStatsSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowStatsSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowTableStatsSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupDescSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupFeaturesSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupStatsSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMessageSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterConfigSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterFeaturesSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterStatsSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestPortDescSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestPortStatsSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestQueueStatsSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/AbstractTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsMissTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldMissTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsMissTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/MatchTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableMissTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WildcardsTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsMissTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldMissTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldTablePropertySerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/AbstractMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpOpMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpShaMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpSpaMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpThaMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpTpaMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/EthDstMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/EthSrcMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/EthTypeMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv4CodeMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv4TypeMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv6CodeMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv6TypeMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/InPhyPortMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/InPortMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/IpDscpMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/IpEcnMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/IpProtoMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv4DstMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv4SrcMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6DstMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6ExtHdrMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6FlabelMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6NdSllMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6NdTargetMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6NdTllMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6SrcMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MetadataMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MplsBosMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MplsLabelMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MplsTcMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/PbbIsidMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/SctpDstMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/SctpSrcMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TcpDstMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TcpFlagsMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TcpSrcMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TunnelIdMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/UdpDstMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/UdpSrcMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/VlanPcpMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/VlanVidMatchFieldSerializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/util/InstructionUtil.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMessageSerializerTest.java diff --git a/extension/openflowplugin-extension-api/src/main/yang/openflowplugin-experimenter-types.yang b/extension/openflowplugin-extension-api/src/main/yang/openflowplugin-experimenter-types.yang index 6c9b77acc3..f8c0d80a9d 100644 --- a/extension/openflowplugin-extension-api/src/main/yang/openflowplugin-experimenter-types.yang +++ b/extension/openflowplugin-extension-api/src/main/yang/openflowplugin-experimenter-types.yang @@ -8,7 +8,6 @@ module openflowplugin-experimenter-types { description "Initial revision of experimenter basic types"; } - grouping experimenter-core-message { choice experimenter-message-of-choice { // to be augmented by vendors @@ -21,4 +20,9 @@ module openflowplugin-experimenter-types { } } + augment "/multipart:multipart-request/multipart:multipart-request-body" { + case multipart-request-experimenter { + uses experimenter-core-message; + } + } } diff --git a/model/model-flow-base/src/main/yang/opendaylight-flow-types.yang b/model/model-flow-base/src/main/yang/opendaylight-flow-types.yang index c6f7204690..ce4baf6738 100644 --- a/model/model-flow-base/src/main/yang/opendaylight-flow-types.yang +++ b/model/model-flow-base/src/main/yang/opendaylight-flow-types.yang @@ -8,20 +8,21 @@ module opendaylight-flow-types { import opendaylight-meter-types {prefix meter; revision-date "2013-09-18";} import openflow-protocol { prefix ofproto; revision-date "2013-07-31"; } import openflow-types { prefix oft; revision-date "2013-07-31"; } + import opendaylight-multipart-types { prefix multipart; revision-date "2017-01-12"; } revision "2013-10-26" { description "Initial revision of flow service"; } - + typedef flow-ref { type instance-identifier; } - + typedef flow-cookie { description "openflow specific type - flow cookie / flow cookie mask"; type uint64; } - + typedef output-port-values { type enumeration { enum MAX { @@ -74,47 +75,47 @@ module opendaylight-flow-types { } } } - + case write-metadata-case { container write-metadata { leaf metadata { type uint64; } - + leaf metadata-mask { type uint64; } } } - + case write-actions-case { container write-actions { uses action:action-list; } } - + case apply-actions-case { container apply-actions { uses action:action-list; } } - + case clear-actions-case { container clear-actions { uses action:action-list; } } - + case meter-case { container meter { leaf meter-id { type meter:meter-id; - } + } } } } } - + typedef flow-mod-flags { type bits { bit CHECK_OVERLAP; @@ -145,68 +146,68 @@ module opendaylight-flow-types { } } - + grouping generic_flow_attributes { leaf priority { type uint16; } - + leaf idle-timeout { type uint16; } - + leaf hard-timeout { type uint16; } - + leaf cookie { type flow-cookie; } - + leaf table_id { type uint8; } } - + grouping flow { container match { uses match:match; } - + container instructions { uses instruction-list; - } - + } + uses generic_flow_attributes; - + leaf container-name { - type string; + type string; } - + leaf cookie_mask { type flow-cookie; } - + leaf buffer_id { type uint32; } - + leaf out_port { type uint64; } - + leaf out_group { type uint32; } - + leaf flags { type flow-mod-flags; } - + leaf flow-name { type string; } - + leaf installHw { type boolean; } @@ -244,20 +245,20 @@ module opendaylight-flow-types { grouping flow-table-statistics { leaf active { type yang:counter64; - } + } leaf lookup { type yang:counter64; } leaf matched { - type yang:counter64; + type yang:counter64; } } - + grouping flow-mod-removed { uses generic_flow_attributes; - + leaf removed_reason { type removed-flow-reason; } @@ -265,7 +266,7 @@ module opendaylight-flow-types { leaf duration_nsec { type uint32; } - + leaf duration_sec { type uint32; } @@ -277,7 +278,7 @@ module opendaylight-flow-types { leaf byte_count { type uint64; } - + container match { uses match:match; } @@ -291,4 +292,13 @@ module opendaylight-flow-types { type oft:flow-mod-command; } } + + augment "/multipart:multipart-request/multipart:multipart-request-body" { + case multipart-request-flow-stats { + uses flow; + } + case multipart-request-flow-aggregate-stats { + uses flow; + } + } } diff --git a/model/model-flow-base/src/main/yang/opendaylight-multipart-types.yang b/model/model-flow-base/src/main/yang/opendaylight-multipart-types.yang index 0280fe502e..5696ae5b5e 100644 --- a/model/model-flow-base/src/main/yang/opendaylight-multipart-types.yang +++ b/model/model-flow-base/src/main/yang/opendaylight-multipart-types.yang @@ -8,15 +8,26 @@ module opendaylight-multipart-types { description "Initial revision"; } - container multipart-reply { + grouping multipart-header { uses ofproto:ofHeader; leaf request-more { type boolean; default false; } + } + + container multipart-reply { + uses multipart-header; choice multipart-reply-body { } } + + container multipart-request { + uses multipart-header; + + choice multipart-request-body { + } + } } diff --git a/model/model-flow-base/src/main/yang/opendaylight-port-types.yang b/model/model-flow-base/src/main/yang/opendaylight-port-types.yang index a2f6ed0356..9c6d3a34bd 100644 --- a/model/model-flow-base/src/main/yang/opendaylight-port-types.yang +++ b/model/model-flow-base/src/main/yang/opendaylight-port-types.yang @@ -193,4 +193,11 @@ module opendaylight-port-types { } } } + + + augment "/multipart:multipart-request/multipart:multipart-request-body" { + case multipart-request-port-desc { + // Empty case + } + } } diff --git a/model/model-flow-base/src/main/yang/opendaylight-table-types.yang b/model/model-flow-base/src/main/yang/opendaylight-table-types.yang index e236287807..f67159bfb5 100644 --- a/model/model-flow-base/src/main/yang/opendaylight-table-types.yang +++ b/model/model-flow-base/src/main/yang/opendaylight-table-types.yang @@ -4,6 +4,7 @@ module opendaylight-table-types { import opendaylight-flow-types {prefix flow;revision-date "2013-10-26";} import opendaylight-action-types {prefix action;} + import opendaylight-multipart-types { prefix multipart; revision-date "2017-01-12"; } revision "2013-10-26" { description "Initial revision of table service"; @@ -16,7 +17,7 @@ module opendaylight-table-types { typedef table-ref { type instance-identifier; } - + typedef table-config { type bits { bit DEPRECATED-MASK; @@ -211,135 +212,135 @@ module opendaylight-table-types { } leaf has-mask { type boolean; - } + } } } - + grouping table-feature-prop-type { choice table-feature-prop-type { - case instructions { + case instructions { container instructions { uses flow:instruction-list; - } + } } - - case instructions-miss { + + case instructions-miss { container instructions-miss { uses flow:instruction-list; - } + } } - case next-table { + case next-table { container tables { leaf-list table-ids { type uint8; } - } + } } - - case next-table-miss { + + case next-table-miss { container tables-miss { leaf-list table-ids { type uint8; } - } + } } - - case write-actions { + + case write-actions { container write-actions { uses action:action-list; - } + } } - - case write-actions-miss { + + case write-actions-miss { container write-actions-miss { uses action:action-list; - } + } } - - case apply-actions { + + case apply-actions { container apply-actions { uses action:action-list; - } + } } - - case apply-actions-miss { + + case apply-actions-miss { container apply-actions-miss { uses action:action-list; - } + } } - + case match { container match-setfield { - uses set-field-match; + uses set-field-match; } } - - case wildcards { + + case wildcards { container wildcard-setfield { uses set-field-match; } } - - case write-setfield { + + case write-setfield { container write-setfield { uses set-field-match; } } - - case write-setfield-miss { + + case write-setfield-miss { container write-setfield-miss { uses set-field-match; } } - - case apply-setfield { + + case apply-setfield { container apply-setfield { - uses set-field-match; + uses set-field-match; } } - - case apply-setfield-miss { + + case apply-setfield-miss { container apply-setfield-miss { - uses set-field-match; + uses set-field-match; } } } - } - + } + grouping table-features { list table-features { key "table-id"; - + leaf table-id { type uint8; - } - + } + leaf name { description "Name of the table"; - type string; + type string; } - + leaf metadata-match { description "Bits of metadata table can match"; - type uint64; + type uint64; } - + leaf metadata-write { description "Bits of metadata table can write"; - type uint64; + type uint64; } - + leaf max-entries { description "Max number of entries supported"; - type uint32; + type uint32; } - + leaf config { description "Bitmap of OFPTC_ values"; type table-config; } - + container table-properties { list table-feature-properties { key "order"; @@ -348,5 +349,17 @@ module opendaylight-table-types { } } } - } + } + + augment "/multipart:multipart-reply/multipart:multipart-reply-body" { + case multipart-reply-table-features { + uses table-features; + } + } + + augment "/multipart:multipart-request/multipart:multipart-request-body" { + case multipart-request-table-features { + uses table-features; + } + } } diff --git a/model/model-flow-service/src/main/yang/flow-node-inventory.yang b/model/model-flow-service/src/main/yang/flow-node-inventory.yang index 4901f08f24..813a8b225a 100644 --- a/model/model-flow-service/src/main/yang/flow-node-inventory.yang +++ b/model/model-flow-service/src/main/yang/flow-node-inventory.yang @@ -324,4 +324,10 @@ module flow-node-inventory { uses desc; } } + + augment "/multipart:multipart-request/multipart:multipart-request-body" { + case multipart-request-desc { + // Empty request case + } + } } diff --git a/model/model-flow-service/src/main/yang/sal-table.yang b/model/model-flow-service/src/main/yang/sal-table.yang index ddaabebeb3..cfbd6f0304 100644 --- a/model/model-flow-service/src/main/yang/sal-table.yang +++ b/model/model-flow-service/src/main/yang/sal-table.yang @@ -5,14 +5,13 @@ module sal-table { import opendaylight-inventory {prefix inv;revision-date "2013-08-19";} import opendaylight-table-types {prefix table-type;revision-date "2013-10-26";} import flow-capable-transaction {prefix tr; revision-date "2015-03-04";} - import opendaylight-multipart-types { prefix multipart; revision-date "2017-01-12"; } description "Openflow table management."; revision "2013-10-26" { description "Initial revision of table service"; } - + grouping table-update { description "Openflow table configuration structure suitable for rpc (contains node-context-ref)"; @@ -24,10 +23,10 @@ module sal-table { uses table-type:table-features; } } - + rpc update-table { description "Configuring openflow table."; - + input { uses tr:transaction-metadata; leaf table-ref { @@ -40,7 +39,7 @@ module sal-table { uses tr:transaction-aware; } } - + notification table-updated { status deprecated; @@ -48,11 +47,4 @@ module sal-table { uses tr:multipart-transaction-aware; uses table-type:table-features; } - - - augment "/multipart:multipart-reply/multipart:multipart-reply-body" { - case multipart-reply-table-features { - uses table-type:table-features; - } - } } diff --git a/model/model-flow-statistics/src/main/yang/opendaylight-flow-table-statistics.yang b/model/model-flow-statistics/src/main/yang/opendaylight-flow-table-statistics.yang index 96e4e8d55a..4c069c891f 100644 --- a/model/model-flow-statistics/src/main/yang/opendaylight-flow-table-statistics.yang +++ b/model/model-flow-statistics/src/main/yang/opendaylight-flow-table-statistics.yang @@ -74,4 +74,10 @@ module opendaylight-flow-table-statistics { uses flow-table-and-statistics-map; } } + + augment "/multipart:multipart-request/multipart:multipart-request-body" { + case multipart-request-flow-table-stats { + // Empty request case + } + } } diff --git a/model/model-flow-statistics/src/main/yang/opendaylight-group-statistics.yang b/model/model-flow-statistics/src/main/yang/opendaylight-group-statistics.yang index 318cf17430..ee3bc86fd6 100644 --- a/model/model-flow-statistics/src/main/yang/opendaylight-group-statistics.yang +++ b/model/model-flow-statistics/src/main/yang/opendaylight-group-statistics.yang @@ -146,4 +146,18 @@ module opendaylight-group-statistics { uses group-types:group-features-reply; } } + + augment "/multipart:multipart-request/multipart:multipart-request-body" { + case multipart-request-group-desc { + // Empty request case + } + case multipart-request-group-features { + // Empty request case + } + case multipart-request-group-stats { + leaf group-id { + type group-types:group-id; + } + } + } } diff --git a/model/model-flow-statistics/src/main/yang/opendaylight-meter-statistics.yang b/model/model-flow-statistics/src/main/yang/opendaylight-meter-statistics.yang index 0d91e4c49e..a41176e7d5 100644 --- a/model/model-flow-statistics/src/main/yang/opendaylight-meter-statistics.yang +++ b/model/model-flow-statistics/src/main/yang/opendaylight-meter-statistics.yang @@ -137,4 +137,20 @@ module opendaylight-meter-statistics { uses meter-types:meter-features-reply; } } + + augment "/multipart:multipart-request/multipart:multipart-request-body" { + case multipart-request-meter-config { + leaf meter-id { + type meter-types:meter-id; + } + } + case multipart-request-meter-features { + // Empty request case + } + case multipart-request-meter-stats { + leaf meter-id { + type meter-types:meter-id; + } + } + } } diff --git a/model/model-flow-statistics/src/main/yang/opendaylight-port-statistics.yang b/model/model-flow-statistics/src/main/yang/opendaylight-port-statistics.yang index e63f1bd7af..16cf660c2d 100644 --- a/model/model-flow-statistics/src/main/yang/opendaylight-port-statistics.yang +++ b/model/model-flow-statistics/src/main/yang/opendaylight-port-statistics.yang @@ -87,4 +87,12 @@ module opendaylight-port-statistics { uses node-connector-statistics-and-port-number-map; } } + + augment "/multipart:multipart-request/multipart:multipart-request-body" { + case multipart-request-port-stats { + leaf node-connector-id { + type inv:node-connector-id; + } + } + } } diff --git a/model/model-flow-statistics/src/main/yang/opendaylight-queue-statistics.yang b/model/model-flow-statistics/src/main/yang/opendaylight-queue-statistics.yang index 0768119a88..aaf3bd9fa8 100644 --- a/model/model-flow-statistics/src/main/yang/opendaylight-queue-statistics.yang +++ b/model/model-flow-statistics/src/main/yang/opendaylight-queue-statistics.yang @@ -112,4 +112,16 @@ module opendaylight-queue-statistics { uses queue-id-and-statistics-map; } } + + augment "/multipart:multipart-request/multipart:multipart-request-body" { + case multipart-request-queue-stats { + leaf queue-id { + type queue-types:queue-id; + } + + leaf node-connector-id { + type inv:node-connector-id; + } + } + } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtil.java index 1a07a4340c..43eeceb38d 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtil.java @@ -118,8 +118,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216. import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.reply.multipart.reply.body.MultipartReplyQueueStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -206,7 +206,7 @@ public class MultipartReplyTranslatorUtil { .build(); } - private static org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.multipart.reply.multipart.reply.body + private static org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body .MultipartReplyTableFeatures translateTableFeatures(final MultipartReply msg, final short version, final ConvertorExecutor convertorExecutor) { diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/ActionDeserializerInjector.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/ActionDeserializerInjector.java index c87190852c..ad1c41dd36 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/ActionDeserializerInjector.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/ActionDeserializerInjector.java @@ -36,7 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import com.google.common.annotations.VisibleForTesting; -public class ActionDeserializerInjector { +class ActionDeserializerInjector { /** * Injects action deserializers into provided {@link org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/InstructionDeserializerInjector.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/InstructionDeserializerInjector.java index cae6b641ce..de508a0f92 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/InstructionDeserializerInjector.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/InstructionDeserializerInjector.java @@ -29,7 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru import com.google.common.annotations.VisibleForTesting; -public class InstructionDeserializerInjector { +class InstructionDeserializerInjector { /** * Injects instruction deserializers into provided {@link org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MatchDeserializerInjector.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MatchDeserializerInjector.java index 082e299737..19ebb8a094 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MatchDeserializerInjector.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MatchDeserializerInjector.java @@ -13,15 +13,12 @@ import java.util.function.Consumer; import java.util.function.Function; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowplugin.impl.protocol.deserialization.key.MessageCodeMatchKey; -import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MatchDeserializer; -import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MatchDeserializer; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MatchEntryDeserializer; import org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MatchEntryDeserializerRegistry; import org.opendaylight.openflowplugin.extension.api.path.MatchPath; +import org.opendaylight.openflowplugin.impl.protocol.deserialization.key.MessageCodeMatchKey; import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.ArpOpEntryDeserializer; import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.ArpSourceHardwareAddressEntryDeserializer; import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.ArpSourceTransportAddressEntryDeserializer; @@ -75,7 +72,7 @@ public class MatchDeserializerInjector { * Injects deserializers into provided {@link org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider} * @param provider OpenflowJava deserializer extension provider */ - public static void injectDeserializers(final DeserializerExtensionProvider provider) { + static void injectDeserializers(final DeserializerExtensionProvider provider) { for (MatchPath path : MatchPath.values()) { final MatchDeserializer deserializer = new MatchDeserializer(path); provider.registerDeserializer( diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MessageDeserializerInjector.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MessageDeserializerInjector.java index 6c670b0d66..367b9f19eb 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MessageDeserializerInjector.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MessageDeserializerInjector.java @@ -33,7 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; -public class MessageDeserializerInjector { +class MessageDeserializerInjector { /** * Injects message deserializers into provided {@link org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MultipartDeserializerInjector.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MultipartDeserializerInjector.java index dd47f0fa43..cf83b2861b 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MultipartDeserializerInjector.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MultipartDeserializerInjector.java @@ -33,7 +33,7 @@ import org.opendaylight.openflowplugin.impl.protocol.deserialization.multipart.M import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -public class MultipartDeserializerInjector { +class MultipartDeserializerInjector { /** * Injects message deserializers into provided {@link org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializer.java index 0e535da16f..3a0e4685be 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializer.java @@ -28,8 +28,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MatchSerializerInjector.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MatchSerializerInjector.java index 8ec19b84b2..8812f3fad5 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MatchSerializerInjector.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MatchSerializerInjector.java @@ -67,13 +67,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 /** * Util class for injecting new match serializers into OpenflowJava */ -public class MatchSerializerInjector { +class MatchSerializerInjector { /** * Injects match serializers into provided {@link org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider} * @param provider OpenflowJava serializer extension provider */ - public static void injectSerializers(final SerializerExtensionProvider provider) { + static void injectSerializers(final SerializerExtensionProvider provider) { final MatchSerializer serializer = new MatchSerializer(); provider.registerSerializer( new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class), diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MessageSerializerInjector.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MessageSerializerInjector.java index e8997a43e7..cf34d19d44 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MessageSerializerInjector.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MessageSerializerInjector.java @@ -19,10 +19,12 @@ import org.opendaylight.openflowplugin.impl.protocol.serialization.messages.Flow import org.opendaylight.openflowplugin.impl.protocol.serialization.messages.GroupMessageSerializer; import org.opendaylight.openflowplugin.impl.protocol.serialization.messages.MeterMessageSerializer; import org.opendaylight.openflowplugin.impl.protocol.serialization.messages.PortMessageSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestMessageSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; /** @@ -38,11 +40,12 @@ class MessageSerializerInjector { // Inject new message serializers here using injector created by createInjector method final Function, Consumer>> injector = createInjector(provider, EncodeConstants.OF13_VERSION_ID); - + injector.apply(FlowMessage.class).accept(new FlowMessageSerializer()); injector.apply(MeterMessage.class).accept(new MeterMessageSerializer()); injector.apply(PortMessage.class).accept(new PortMessageSerializer()); injector.apply(GroupMessage.class).accept(new GroupMessageSerializer()); + injector.apply(MultipartRequest.class).accept(new MultipartRequestMessageSerializer()); } /** diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MultipartMatchFieldSerializerInjector.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MultipartMatchFieldSerializerInjector.java new file mode 100644 index 0000000000..389e628e66 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MultipartMatchFieldSerializerInjector.java @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization; + +import com.google.common.annotations.VisibleForTesting; +import java.util.function.Consumer; +import java.util.function.Function; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.ArpOpMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.ArpShaMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.ArpSpaMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.ArpThaMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.ArpTpaMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.EthDstMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.EthSrcMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.EthTypeMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.Icmpv4CodeMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.Icmpv4TypeMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.Icmpv6CodeMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.Icmpv6TypeMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.InPhyPortMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.InPortMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.IpDscpMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.IpEcnMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.IpProtoMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.Ipv4DstMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.Ipv4SrcMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.Ipv6DstMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.Ipv6ExtHdrMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.Ipv6FlabelMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.Ipv6NdSllMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.Ipv6NdTargetMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.Ipv6NdTllMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.Ipv6SrcMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.MetadataMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.MplsBosMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.MplsLabelMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.MplsTcMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.PbbIsidMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.SctpDstMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.SctpSrcMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.TcpDstMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.TcpFlagsMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.TcpSrcMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.TunnelIdMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.UdpDstMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.UdpSrcMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.VlanPcpMatchFieldSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield.VlanVidMatchFieldSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch; + +/** + * Util class for injecting new multipart match field serializers into OpenflowJava + */ +class MultipartMatchFieldSerializerInjector { + + /** + * Injects multipart match field serializers into provided {@link org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider} + * @param provider OpenflowJava serializer extension provider + */ + static void injectSerializers(final SerializerExtensionProvider provider) { + // Inject new message serializers here using injector created by createInjector method + final Function, Consumer>> injector = + createInjector(provider, EncodeConstants.OF13_VERSION_ID); + + injector.apply(ArpOp.class).accept(new ArpOpMatchFieldSerializer()); + injector.apply(ArpSha.class).accept(new ArpShaMatchFieldSerializer()); + injector.apply(ArpSpa.class).accept(new ArpSpaMatchFieldSerializer()); + injector.apply(ArpTha.class).accept(new ArpThaMatchFieldSerializer()); + injector.apply(ArpTpa.class).accept(new ArpTpaMatchFieldSerializer()); + injector.apply(EthDst.class).accept(new EthDstMatchFieldSerializer()); + injector.apply(EthSrc.class).accept(new EthSrcMatchFieldSerializer()); + injector.apply(EthType.class).accept(new EthTypeMatchFieldSerializer()); + injector.apply(Icmpv4Code.class).accept(new Icmpv4CodeMatchFieldSerializer()); + injector.apply(Icmpv4Type.class).accept(new Icmpv4TypeMatchFieldSerializer()); + injector.apply(Icmpv6Code.class).accept(new Icmpv6CodeMatchFieldSerializer()); + injector.apply(Icmpv6Type.class).accept(new Icmpv6TypeMatchFieldSerializer()); + injector.apply(InPhyPort.class).accept(new InPhyPortMatchFieldSerializer()); + injector.apply(InPort.class).accept(new InPortMatchFieldSerializer()); + injector.apply(IpDscp.class).accept(new IpDscpMatchFieldSerializer()); + injector.apply(IpEcn.class).accept(new IpEcnMatchFieldSerializer()); + injector.apply(IpProto.class).accept(new IpProtoMatchFieldSerializer()); + injector.apply(Ipv4Dst.class).accept(new Ipv4DstMatchFieldSerializer()); + injector.apply(Ipv4Src.class).accept(new Ipv4SrcMatchFieldSerializer()); + injector.apply(Ipv6Dst.class).accept(new Ipv6DstMatchFieldSerializer()); + injector.apply(Ipv6Exthdr.class).accept(new Ipv6ExtHdrMatchFieldSerializer()); + injector.apply(Ipv6Flabel.class).accept(new Ipv6FlabelMatchFieldSerializer()); + injector.apply(Ipv6NdSll.class).accept(new Ipv6NdSllMatchFieldSerializer()); + injector.apply(Ipv6NdTarget.class).accept(new Ipv6NdTargetMatchFieldSerializer()); + injector.apply(Ipv6NdTll.class).accept(new Ipv6NdTllMatchFieldSerializer()); + injector.apply(Ipv6Src.class).accept(new Ipv6SrcMatchFieldSerializer()); + injector.apply(Metadata.class).accept(new MetadataMatchFieldSerializer()); + injector.apply(MplsBos.class).accept(new MplsBosMatchFieldSerializer()); + injector.apply(MplsLabel.class).accept(new MplsLabelMatchFieldSerializer()); + injector.apply(MplsTc.class).accept(new MplsTcMatchFieldSerializer()); + injector.apply(PbbIsid.class).accept(new PbbIsidMatchFieldSerializer()); + injector.apply(SctpDst.class).accept(new SctpDstMatchFieldSerializer()); + injector.apply(SctpSrc.class).accept(new SctpSrcMatchFieldSerializer()); + injector.apply(TcpDst.class).accept(new TcpDstMatchFieldSerializer()); + injector.apply(TcpFlags.class).accept(new TcpFlagsMatchFieldSerializer()); + injector.apply(TcpSrc.class).accept(new TcpSrcMatchFieldSerializer()); + injector.apply(TunnelId.class).accept(new TunnelIdMatchFieldSerializer()); + // TODO: Finish implementation of Tunnel Ipv4 src and dst + injector.apply(TunnelIpv4Dst.class).accept(new Ipv4DstMatchFieldSerializer()); + injector.apply(TunnelIpv4Src.class).accept(new Ipv4SrcMatchFieldSerializer()); + injector.apply(UdpDst.class).accept(new UdpDstMatchFieldSerializer()); + injector.apply(UdpSrc.class).accept(new UdpSrcMatchFieldSerializer()); + injector.apply(VlanPcp.class).accept(new VlanPcpMatchFieldSerializer()); + injector.apply(VlanVid.class).accept(new VlanVidMatchFieldSerializer()); + } + + /** + * Create injector that will inject new multipart match field features serializers into #{@link org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider} + * @param provider OpenflowJava serializer extension provider + * @param version Openflow version + * @return injector + */ + @VisibleForTesting + static Function, Consumer>> createInjector( + final SerializerExtensionProvider provider, + final byte version) { + return type -> serializer -> + provider.registerSerializer( + new MessageTypeKey<>(version, type), + serializer); + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MultipartSerializerInjector.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MultipartSerializerInjector.java new file mode 100644 index 0000000000..4dda5730c4 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MultipartSerializerInjector.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization; + +import com.google.common.annotations.VisibleForTesting; +import java.util.function.Consumer; +import java.util.function.Function; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestDescSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestExperimenterSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestFlowAggregateStatsSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestFlowStatsSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestFlowTableStatsSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestGroupDescSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestGroupFeaturesSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestGroupStatsSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestMeterConfigSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestMeterFeaturesSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestMeterStatsSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestPortDescSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestPortStatsSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestQueueStatsSerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestTableFeaturesSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.request.multipart.request.body.MultipartRequestDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.request.multipart.request.body.MultipartRequestFlowTableStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.request.multipart.request.body.MultipartRequestPortDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowAggregateStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.multipart.request.multipart.request.body.MultipartRequestExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.request.multipart.request.body.MultipartRequestPortStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.request.multipart.request.body.MultipartRequestQueueStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.request.multipart.request.body.MultipartRequestTableFeatures; + +/** + * Util class for injecting new multipart serializers into OpenflowJava + */ +class MultipartSerializerInjector { + + /** + * Injects multipart serializers into provided {@link org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider} + * @param provider OpenflowJava serializer extension provider + */ + static void injectSerializers(final SerializerExtensionProvider provider) { + // Inject new message serializers here using injector created by createInjector method + final Function, Consumer>> injector = + createInjector(provider, EncodeConstants.OF13_VERSION_ID); + + MultipartMatchFieldSerializerInjector.injectSerializers(provider); + MultipartTableFeaturesSerializerInjector.injectSerializers(provider); + + injector.apply(MultipartRequestDesc.class).accept(new MultipartRequestDescSerializer()); + injector.apply(MultipartRequestFlowTableStats.class).accept(new MultipartRequestFlowTableStatsSerializer()); + injector.apply(MultipartRequestGroupDesc.class).accept(new MultipartRequestGroupDescSerializer()); + injector.apply(MultipartRequestGroupFeatures.class).accept(new MultipartRequestGroupFeaturesSerializer()); + injector.apply(MultipartRequestGroupStats.class).accept(new MultipartRequestGroupStatsSerializer()); + injector.apply(MultipartRequestMeterFeatures.class).accept(new MultipartRequestMeterFeaturesSerializer()); + injector.apply(MultipartRequestMeterStats.class).accept(new MultipartRequestMeterStatsSerializer()); + injector.apply(MultipartRequestMeterConfig.class).accept(new MultipartRequestMeterConfigSerializer()); + injector.apply(MultipartRequestPortDesc.class).accept(new MultipartRequestPortDescSerializer()); + injector.apply(MultipartRequestPortStats.class).accept(new MultipartRequestPortStatsSerializer()); + injector.apply(MultipartRequestQueueStats.class).accept(new MultipartRequestQueueStatsSerializer()); + injector.apply(MultipartRequestFlowStats.class).accept(new MultipartRequestFlowStatsSerializer()); + injector.apply(MultipartRequestFlowAggregateStats.class).accept(new MultipartRequestFlowAggregateStatsSerializer()); + injector.apply(MultipartRequestExperimenter.class).accept(new MultipartRequestExperimenterSerializer()); + injector.apply(MultipartRequestTableFeatures.class).accept(new MultipartRequestTableFeaturesSerializer()); + } + + /** + * Create injector that will inject new multipart serializers into #{@link org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider} + * @param provider OpenflowJava serializer extension provider + * @param version Openflow version + * @return injector + */ + @VisibleForTesting + static Function, Consumer>> createInjector( + final SerializerExtensionProvider provider, + final byte version) { + return type -> serializer -> + provider.registerSerializer( + new MessageTypeKey<>(version, type), + serializer); + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MultipartTableFeaturesSerializerInjector.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MultipartTableFeaturesSerializerInjector.java new file mode 100644 index 0000000000..90972b73cf --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/MultipartTableFeaturesSerializerInjector.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization; + +import com.google.common.annotations.VisibleForTesting; +import java.util.function.Consumer; +import java.util.function.Function; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.ApplyActionsMissTablePropertySerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.ApplyActionsTablePropertySerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.ApplySetfieldMissTablePropertySerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.ApplySetfieldTablePropertySerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.InstructionsMissTablePropertySerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.InstructionsTablePropertySerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.MatchTablePropertySerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.NextTableMissTablePropertySerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.NextTableTablePropertySerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.WildcardsTablePropertySerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.WriteActionsMissTablePropertySerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.WriteActionsTablePropertySerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.WriteSetfieldMissTablePropertySerializer; +import org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.WriteSetfieldTablePropertySerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Instructions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss; + +/** + * Util class for injecting new multipart table features serializers into OpenflowJava + */ +class MultipartTableFeaturesSerializerInjector { + + /** + * Injects multipart table features serializers into provided {@link org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider} + * @param provider OpenflowJava serializer extension provider + */ + static void injectSerializers(final SerializerExtensionProvider provider) { + // Inject new message serializers here using injector created by createInjector method + final Function, Consumer>> injector = + createInjector(provider, EncodeConstants.OF13_VERSION_ID); + + injector.apply(Instructions.class).accept(new InstructionsTablePropertySerializer()); + injector.apply(InstructionsMiss.class).accept(new InstructionsMissTablePropertySerializer()); + injector.apply(NextTable.class).accept(new NextTableTablePropertySerializer()); + injector.apply(NextTableMiss.class).accept(new NextTableMissTablePropertySerializer()); + injector.apply(ApplyActions.class).accept(new ApplyActionsTablePropertySerializer()); + injector.apply(ApplyActionsMiss.class).accept(new ApplyActionsMissTablePropertySerializer()); + injector.apply(WriteActions.class).accept(new WriteActionsTablePropertySerializer()); + injector.apply(WriteActionsMiss.class).accept(new WriteActionsMissTablePropertySerializer()); + injector.apply(Match.class).accept(new MatchTablePropertySerializer()); + injector.apply(Wildcards.class).accept(new WildcardsTablePropertySerializer()); + injector.apply(WriteSetfield.class).accept(new WriteSetfieldTablePropertySerializer()); + injector.apply(WriteSetfieldMiss.class).accept(new WriteSetfieldMissTablePropertySerializer()); + injector.apply(ApplySetfield.class).accept(new ApplySetfieldTablePropertySerializer()); + injector.apply(ApplySetfieldMiss.class).accept(new ApplySetfieldMissTablePropertySerializer()); + // TODO: Add support for experimenters + } + + /** + * Create injector that will inject new multipart table features serializers into #{@link org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider} + * @param provider OpenflowJava serializer extension provider + * @param version Openflow version + * @return injector + */ + @VisibleForTesting + static Function, Consumer>> createInjector( + final SerializerExtensionProvider provider, + final byte version) { + return type -> serializer -> + provider.registerSerializer( + new MessageTypeKey<>(version, type), + serializer); + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/SerializerInjector.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/SerializerInjector.java index 4af3d12211..b8654060c5 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/SerializerInjector.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/SerializerInjector.java @@ -24,6 +24,7 @@ public class SerializerInjector { MatchSerializerInjector.injectSerializers(provider); ActionSerializerInjector.injectSerializers(provider); InstructionSerializerInjector.injectSerializers(provider); + MultipartSerializerInjector.injectSerializers(provider); MessageSerializerInjector.injectSerializers(provider); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializer.java index 2d7cf3708d..d99feb7565 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializer.java @@ -26,6 +26,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.impl.protocol.serialization.util.ActionUtil; +import org.opendaylight.openflowplugin.impl.protocol.serialization.util.InstructionUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.ActionList; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder; @@ -193,12 +194,7 @@ public class FlowMessageSerializer extends AbstractMessageSerializer protocol.flatMap(p -> updateInstruction(i, p)).orElse(i)) - .forEach(i -> registry.>getSerializer( - new MessageTypeKey<>( - EncodeConstants.OF13_VERSION_ID, - (Class) i.getImplementedInterface())) - .serialize(i, outBuffer) - )); + .forEach(i -> InstructionUtil.writeInstruction(i, EncodeConstants.OF13_VERSION_ID, registry, outBuffer))); } /** diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestDescSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestDescSerializer.java new file mode 100644 index 0000000000..5733f5fc9a --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestDescSerializer.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; + +public class MultipartRequestDescSerializer implements OFSerializer { + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + // NOOP + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestExperimenterSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestExperimenterSerializer.java new file mode 100644 index 0000000000..9f623307ea --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestExperimenterSerializer.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import io.netty.buffer.ByteBuf; +import java.util.Optional; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; +import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowplugin.extension.api.TypeVersionKey; +import org.opendaylight.openflowplugin.extension.api.exception.ConversionException; +import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.multipart.request.multipart.request.body.MultipartRequestExperimenter; + +public class MultipartRequestExperimenterSerializer implements OFSerializer, SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + @SuppressWarnings("unchecked") + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + final MultipartRequestExperimenter multipartRequestExperimenter = MultipartRequestExperimenter + .class + .cast(multipartRequestBody); + + try { + final OFSerializer serializer = registry + .getSerializer(new MessageTypeKey<>( + EncodeConstants.OF13_VERSION_ID, + multipartRequestExperimenter.getExperimenterMessageOfChoice().getImplementedInterface())); + + serializer.serialize(multipartRequestExperimenter.getExperimenterMessageOfChoice(), byteBuf); + } catch (ClassCastException | IllegalStateException ex) { + Optional + .ofNullable(OFSessionUtil.getExtensionConvertorProvider().getMessageConverter(new TypeVersionKey<>( + (Class)multipartRequestExperimenter.getExperimenterMessageOfChoice().getImplementedInterface(), + OFConstants.OFP_VERSION_1_3))) + .ifPresent(converter -> { + final OFSerializer serializer = registry + .getSerializer(ExperimenterSerializerKeyFactory + .createMultipartRequestSerializerKey( + EncodeConstants.OF13_VERSION_ID, + converter.getExperimenterId().getValue(), + converter.getType())); + + try { + serializer.serialize(converter.convert(multipartRequestExperimenter.getExperimenterMessageOfChoice()), byteBuf); + } catch (ConversionException e) { + throw new IllegalStateException(e); + } + }); + } + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowAggregateStatsSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowAggregateStatsSerializer.java new file mode 100644 index 0000000000..53c6762d7a --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowAggregateStatsSerializer.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import com.google.common.base.MoreObjects; +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowAggregateStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; + +public class MultipartRequestFlowAggregateStatsSerializer implements OFSerializer, SerializerRegistryInjector { + + private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01 = 3; + private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02 = 4; + private SerializerRegistry registry; + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + final MultipartRequestFlowAggregateStats multipartRequestFlowAggregateStats = MultipartRequestFlowAggregateStats + .class + .cast(multipartRequestBody); + + byteBuf.writeByte(MoreObjects.firstNonNull(multipartRequestFlowAggregateStats.getTableId(), OFConstants.OFPTT_ALL).byteValue()); + byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01); + byteBuf.writeInt(MoreObjects.firstNonNull(multipartRequestFlowAggregateStats.getOutPort(), OFConstants.OFPP_ANY).intValue()); + byteBuf.writeInt(MoreObjects.firstNonNull(multipartRequestFlowAggregateStats.getOutGroup(), OFConstants.OFPG_ANY).intValue()); + byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02); + byteBuf.writeLong(MoreObjects.firstNonNull(multipartRequestFlowAggregateStats.getCookie(), new FlowCookie(OFConstants.DEFAULT_COOKIE)).getValue().longValue()); + byteBuf.writeLong(MoreObjects.firstNonNull(multipartRequestFlowAggregateStats.getCookieMask(), new FlowCookie(OFConstants.DEFAULT_COOKIE_MASK)).getValue().longValue()); + + registry.>getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class)) + .serialize(multipartRequestFlowAggregateStats.getMatch(), byteBuf); + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowStatsSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowStatsSerializer.java new file mode 100644 index 0000000000..bf150be9c8 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowStatsSerializer.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import com.google.common.base.MoreObjects; +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; + +public class MultipartRequestFlowStatsSerializer implements OFSerializer, SerializerRegistryInjector { + + private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01 = 3; + private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02 = 4; + private SerializerRegistry registry; + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + final MultipartRequestFlowStats multipartRequestFlowStats = MultipartRequestFlowStats + .class + .cast(multipartRequestBody); + + byteBuf.writeByte(MoreObjects.firstNonNull(multipartRequestFlowStats.getTableId(), OFConstants.OFPTT_ALL).byteValue()); + byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01); + byteBuf.writeInt(MoreObjects.firstNonNull(multipartRequestFlowStats.getOutPort(), OFConstants.OFPP_ANY).intValue()); + byteBuf.writeInt(MoreObjects.firstNonNull(multipartRequestFlowStats.getOutGroup(), OFConstants.OFPG_ANY).intValue()); + byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02); + byteBuf.writeLong(MoreObjects.firstNonNull(multipartRequestFlowStats.getCookie(), new FlowCookie(OFConstants.DEFAULT_COOKIE)).getValue().longValue()); + byteBuf.writeLong(MoreObjects.firstNonNull(multipartRequestFlowStats.getCookieMask(), new FlowCookie(OFConstants.DEFAULT_COOKIE_MASK)).getValue().longValue()); + + registry.>getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class)) + .serialize(multipartRequestFlowStats.getMatch(), byteBuf); + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowTableStatsSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowTableStatsSerializer.java new file mode 100644 index 0000000000..c1bc804785 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowTableStatsSerializer.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; + +public class MultipartRequestFlowTableStatsSerializer implements OFSerializer { + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + // NOOP + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupDescSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupDescSerializer.java new file mode 100644 index 0000000000..7bf868e2e9 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupDescSerializer.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; + +public class MultipartRequestGroupDescSerializer implements OFSerializer { + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + // NOOP + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupFeaturesSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupFeaturesSerializer.java new file mode 100644 index 0000000000..3c7f7fa8bf --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupFeaturesSerializer.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; + +public class MultipartRequestGroupFeaturesSerializer implements OFSerializer { + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + // NOOP + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupStatsSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupStatsSerializer.java new file mode 100644 index 0000000000..b6999961bd --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupStatsSerializer.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import com.google.common.base.MoreObjects; +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; + +public class MultipartRequestGroupStatsSerializer implements OFSerializer { + + private static final byte PADDING_IN_MULTIPART_REQUEST_GROUP_BODY = 4; + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + final MultipartRequestGroupStats multipartRequestGroupStats = MultipartRequestGroupStats + .class + .cast(multipartRequestBody); + + byteBuf.writeInt(MoreObjects + .firstNonNull(multipartRequestGroupStats.getGroupId(), new GroupId(OFConstants.OFPG_ALL)) + .getValue().intValue()); + + byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_GROUP_BODY); + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMessageSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMessageSerializer.java new file mode 100644 index 0000000000..61081b2b12 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMessageSerializer.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import io.netty.buffer.ByteBuf; +import java.util.Objects; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowplugin.impl.protocol.serialization.messages.AbstractMessageSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.request.multipart.request.body.MultipartRequestDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.request.multipart.request.body.MultipartRequestFlowTableStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.request.multipart.request.body.MultipartRequestPortDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowAggregateStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.multipart.request.multipart.request.body.MultipartRequestExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.request.multipart.request.body.MultipartRequestPortStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.request.multipart.request.body.MultipartRequestQueueStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.request.multipart.request.body.MultipartRequestTableFeatures; +import org.opendaylight.yangtools.yang.binding.DataContainer; + +public class MultipartRequestMessageSerializer extends AbstractMessageSerializer implements SerializerRegistryInjector { + private static final byte PADDING_IN_MULTIPART_REQUEST_MESSAGE = 4; + private SerializerRegistry registry; + + @Override + public void serialize(final MultipartRequest message, final ByteBuf outBuffer) { + final MultipartRequestBody multipartRequestBody = message.getMultipartRequestBody(); + final MultipartType multipartType = getMultipartType(multipartRequestBody); + + int index = outBuffer.writerIndex(); + super.serialize(message, outBuffer); + outBuffer.writeShort(multipartType.getIntValue()); + outBuffer.writeShort(ByteBufUtils.fillBitMask(0, message.isRequestMore())); + outBuffer.writeZero(PADDING_IN_MULTIPART_REQUEST_MESSAGE); + + final OFSerializer serializer = registry + .getSerializer(new MessageTypeKey<>( + EncodeConstants.OF13_VERSION_ID, + multipartRequestBody.getImplementedInterface())); + + serializer.serialize(multipartRequestBody, outBuffer); + outBuffer.setShort(index + 2, outBuffer.writerIndex() - index); + } + + @Override + protected byte getMessageType() { + return 18; + } + + private static MultipartType getMultipartType(final MultipartRequestBody multipartRequestBody) { + final Class clazz = multipartRequestBody.getImplementedInterface(); + + final MultipartType multipartType = MultipartRequestDesc.class.equals(clazz) ? MultipartType.OFPMPDESC + : MultipartRequestFlowTableStats.class.equals(clazz) ? MultipartType.OFPMPTABLE + : MultipartRequestGroupDesc.class.equals(clazz) ? MultipartType.OFPMPGROUPDESC + : MultipartRequestGroupFeatures.class.equals(clazz) ? MultipartType.OFPMPGROUPFEATURES + : MultipartRequestGroupStats.class.equals(clazz) ? MultipartType.OFPMPGROUP + : MultipartRequestMeterFeatures.class.equals(clazz) ? MultipartType.OFPMPMETERFEATURES + : MultipartRequestMeterStats.class.equals(clazz) ? MultipartType.OFPMPMETER + : MultipartRequestMeterConfig.class.equals(clazz) ? MultipartType.OFPMPMETERCONFIG + : MultipartRequestPortDesc.class.equals(clazz) ? MultipartType.OFPMPPORTDESC + : MultipartRequestPortStats.class.equals(clazz) ? MultipartType.OFPMPPORTSTATS + : MultipartRequestFlowStats.class.equals(clazz) ? MultipartType.OFPMPFLOW + : MultipartRequestFlowAggregateStats.class.equals(clazz) ? MultipartType.OFPMPAGGREGATE + : MultipartRequestTableFeatures.class.equals(clazz) ? MultipartType.OFPMPTABLEFEATURES + : MultipartRequestQueueStats.class.equals(clazz) ? MultipartType.OFPMPQUEUE + : MultipartRequestExperimenter.class.equals(clazz) ? MultipartType.OFPMPEXPERIMENTER + : null; + + if (Objects.isNull(multipartType)) { + throw new IllegalArgumentException(clazz.toString() + " is not valid multipart type"); + } + + return multipartType; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterConfigSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterConfigSerializer.java new file mode 100644 index 0000000000..01c27c0d2d --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterConfigSerializer.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import com.google.common.base.MoreObjects; +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; + +public class MultipartRequestMeterConfigSerializer implements OFSerializer { + + private static final byte PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY = 4; + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + final MultipartRequestMeterConfig multipartRequestMeterConfig = MultipartRequestMeterConfig + .class + .cast(multipartRequestBody); + + byteBuf.writeInt(MoreObjects.firstNonNull(multipartRequestMeterConfig.getMeterId(), new MeterId(OFConstants.OFPM_ALL)) + .getValue().intValue()); + byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY); + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterFeaturesSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterFeaturesSerializer.java new file mode 100644 index 0000000000..045f294596 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterFeaturesSerializer.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; + +public class MultipartRequestMeterFeaturesSerializer implements OFSerializer { + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + // NOOP + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterStatsSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterStatsSerializer.java new file mode 100644 index 0000000000..a962e7d341 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterStatsSerializer.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import com.google.common.base.MoreObjects; +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; + +public class MultipartRequestMeterStatsSerializer implements OFSerializer { + + private static final byte PADDING_IN_MULTIPART_REQUEST_METER_BODY = 4; + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + final MultipartRequestMeterStats multipartRequestMeterStats = MultipartRequestMeterStats + .class + .cast(multipartRequestBody); + + byteBuf.writeInt(MoreObjects + .firstNonNull(multipartRequestMeterStats.getMeterId(), new MeterId(OFConstants.OFPM_ALL)).getValue().intValue()); + byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_METER_BODY); + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestPortDescSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestPortDescSerializer.java new file mode 100644 index 0000000000..00dc4fe232 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestPortDescSerializer.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; + +public class MultipartRequestPortDescSerializer implements OFSerializer { + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + // NOOP + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestPortStatsSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestPortStatsSerializer.java new file mode 100644 index 0000000000..a4a0a37047 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestPortStatsSerializer.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import io.netty.buffer.ByteBuf; +import java.util.Objects; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; +import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.request.multipart.request.body.MultipartRequestPortStats; + +public class MultipartRequestPortStatsSerializer implements OFSerializer { + + private static final byte PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY = 4; + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + final MultipartRequestPortStats multipartRequestPortStats = MultipartRequestPortStats + .class + .cast(multipartRequestBody); + + if (Objects.isNull(multipartRequestPortStats.getNodeConnectorId())) { + byteBuf.writeInt(OFConstants.OFPP_ANY.intValue()); + } else { + byteBuf.writeInt(InventoryDataServiceUtil + .portNumberfromNodeConnectorId( + OpenflowVersion.OF13, + multipartRequestPortStats.getNodeConnectorId()).intValue()); + } + + byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY); + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestQueueStatsSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestQueueStatsSerializer.java new file mode 100644 index 0000000000..120f6b082e --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestQueueStatsSerializer.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import com.google.common.base.MoreObjects; +import io.netty.buffer.ByteBuf; +import java.util.Objects; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; +import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.request.multipart.request.body.MultipartRequestQueueStats; + +public class MultipartRequestQueueStatsSerializer implements OFSerializer { + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + final MultipartRequestQueueStats multipartRequestQueueStats = MultipartRequestQueueStats + .class + .cast(multipartRequestBody); + + if (Objects.isNull(multipartRequestQueueStats.getNodeConnectorId())) { + byteBuf.writeInt(OFConstants.OFPP_ANY.intValue()); + } else { + byteBuf.writeInt(InventoryDataServiceUtil + .portNumberfromNodeConnectorId( + OpenflowVersion.OF13, + multipartRequestQueueStats.getNodeConnectorId()).intValue()); + } + + byteBuf.writeInt(MoreObjects + .firstNonNull(multipartRequestQueueStats.getQueueId(), new QueueId(OFConstants.OFPQ_ALL)).getValue().intValue()); + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializer.java new file mode 100644 index 0000000000..5fb6f5b73d --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializer.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import io.netty.buffer.ByteBuf; +import java.util.Objects; +import java.util.Optional; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.request.MultipartRequestBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.request.multipart.request.body.MultipartRequestTableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties; + +public class MultipartRequestTableFeaturesSerializer implements OFSerializer, SerializerRegistryInjector { + + private static final byte PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY = 5; + private SerializerRegistry registry; + + @Override + public void serialize(final MultipartRequestBody multipartRequestBody, final ByteBuf byteBuf) { + final MultipartRequestTableFeatures multipartRequestTableFeatures = MultipartRequestTableFeatures + .class + .cast(multipartRequestBody); + + Optional + .ofNullable(multipartRequestTableFeatures.getTableFeatures()) + .ifPresent(tableFeatures -> tableFeatures + .stream() + .filter(Objects::nonNull) + .forEach(tableFeature -> { + final int featureIndex = byteBuf.writerIndex(); + byteBuf.writeShort(EncodeConstants.EMPTY_LENGTH); + byteBuf.writeByte(tableFeature.getTableId().byteValue()); + byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY); + byteBuf.writeBytes(tableFeature.getName().getBytes()); + byteBuf.writeZero(32 - tableFeature.getName().getBytes().length); + byteBuf.writeLong(tableFeature.getMetadataMatch().longValue()); + byteBuf.writeLong(tableFeature.getMetadataWrite().longValue()); + byteBuf.writeInt(ByteBufUtils.fillBitMask(0, tableFeature.getConfig().isDEPRECATEDMASK())); + byteBuf.writeInt(tableFeature.getMaxEntries().intValue()); + serializeProperties(tableFeature.getTableProperties(), byteBuf); + byteBuf.setShort(featureIndex, byteBuf.writerIndex() - featureIndex); + })); + } + + @SuppressWarnings("unchecked") + private void serializeProperties(final TableProperties tableProperties, final ByteBuf byteBuf) { + Optional + .ofNullable(tableProperties) + .flatMap(properties -> Optional.ofNullable(properties.getTableFeatureProperties())) + .ifPresent(properties -> properties + .stream() + .filter(Objects::nonNull) + .forEach(property -> { + final Class clazz = (Class) property + .getTableFeaturePropType() + .getImplementedInterface(); + + registry. + >getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, clazz)) + .serialize(property.getTableFeaturePropType(), byteBuf); + })); + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/AbstractTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/AbstractTablePropertySerializer.java new file mode 100644 index 0000000000..349ae34985 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/AbstractTablePropertySerializer.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType; + +public abstract class AbstractTablePropertySerializer implements OFSerializer { + + @Override + public void serialize(final TableFeaturePropType tableFeaturePropType, final ByteBuf byteBuf) { + final int startIndex = byteBuf.writerIndex(); + byteBuf.writeShort(getType().getIntValue()); + final int lengthIndex = byteBuf.writerIndex(); + byteBuf.writeShort(EncodeConstants.EMPTY_LENGTH); + + serializeProperty(getClazz().cast(tableFeaturePropType), byteBuf); + + final int length = byteBuf.writerIndex() - startIndex; + byteBuf.setShort(lengthIndex, length); + + int paddingRemainder = length % EncodeConstants.PADDING; + int padding = 0; + + if (paddingRemainder != 0) { + padding = EncodeConstants.PADDING - paddingRemainder; + } + + byteBuf.writeZero(padding); + } + + protected abstract void serializeProperty(final T property, final ByteBuf byteBuf); + protected abstract TableFeaturesPropType getType(); + protected abstract Class getClazz(); + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsMissTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsMissTablePropertySerializer.java new file mode 100644 index 0000000000..bbe617f8ad --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsMissTablePropertySerializer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowplugin.impl.protocol.serialization.util.ActionUtil; +import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss; + +public class ApplyActionsMissTablePropertySerializer extends AbstractTablePropertySerializer implements SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + protected void serializeProperty(final ApplyActionsMiss property, final ByteBuf byteBuf) { + property + .getApplyActionsMiss() + .getAction() + .stream() + .map(Action::getAction) + .forEach(action -> ActionUtil + .writeActionHeader( + action, + EncodeConstants.OF13_VERSION_ID, + registry, + byteBuf)); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS; + } + + @Override + protected Class getClazz() { + return ApplyActionsMiss.class; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsTablePropertySerializer.java new file mode 100644 index 0000000000..22754799d9 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsTablePropertySerializer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowplugin.impl.protocol.serialization.util.ActionUtil; +import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions; + +public class ApplyActionsTablePropertySerializer extends AbstractTablePropertySerializer implements SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + protected void serializeProperty(final ApplyActions property, final ByteBuf byteBuf) { + property + .getApplyActions() + .getAction() + .stream() + .map(Action::getAction) + .forEach(action -> ActionUtil + .writeActionHeader( + action, + EncodeConstants.OF13_VERSION_ID, + registry, + byteBuf)); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTAPPLYACTIONS; + } + + @Override + protected Class getClazz() { + return ApplyActions.class; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldMissTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldMissTablePropertySerializer.java new file mode 100644 index 0000000000..ba7967445f --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldMissTablePropertySerializer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss; + +public class ApplySetfieldMissTablePropertySerializer extends AbstractTablePropertySerializer implements SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + protected void serializeProperty(final ApplySetfieldMiss property, final ByteBuf byteBuf) { + property + .getApplySetfieldMiss() + .getSetFieldMatch() + .forEach(setFieldMatch -> registry + .>getSerializer( + new MessageTypeKey<>( + EncodeConstants.OF13_VERSION_ID, + setFieldMatch.getMatchType())) + .serialize(setFieldMatch, byteBuf)); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS; + } + + @Override + protected Class getClazz() { + return ApplySetfieldMiss.class; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldTablePropertySerializer.java new file mode 100644 index 0000000000..4767f79a3a --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldTablePropertySerializer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield; + +public class ApplySetfieldTablePropertySerializer extends AbstractTablePropertySerializer implements SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + protected void serializeProperty(final ApplySetfield property, final ByteBuf byteBuf) { + property + .getApplySetfield() + .getSetFieldMatch() + .forEach(setFieldMatch -> registry + .>getSerializer( + new MessageTypeKey<>( + EncodeConstants.OF13_VERSION_ID, + setFieldMatch.getMatchType())) + .serialize(setFieldMatch, byteBuf)); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTAPPLYSETFIELD; + } + + @Override + protected Class getClazz() { + return ApplySetfield.class; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsMissTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsMissTablePropertySerializer.java new file mode 100644 index 0000000000..d5b1e97068 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsMissTablePropertySerializer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowplugin.impl.protocol.serialization.util.InstructionUtil; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss; + +public class InstructionsMissTablePropertySerializer extends AbstractTablePropertySerializer implements SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + protected void serializeProperty(final InstructionsMiss property, final ByteBuf byteBuf) { + property + .getInstructionsMiss() + .getInstruction() + .stream() + .map(Instruction::getInstruction) + .forEach(instruction -> InstructionUtil + .writeInstructionHeader( + instruction, + EncodeConstants.OF13_VERSION_ID, + registry, + byteBuf)); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS; + } + + @Override + protected Class getClazz() { + return InstructionsMiss.class; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsTablePropertySerializer.java new file mode 100644 index 0000000000..f5dcf71c86 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsTablePropertySerializer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowplugin.impl.protocol.serialization.util.InstructionUtil; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Instructions; + +public class InstructionsTablePropertySerializer extends AbstractTablePropertySerializer implements SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + protected void serializeProperty(final Instructions property, final ByteBuf byteBuf) { + property + .getInstructions() + .getInstruction() + .stream() + .map(Instruction::getInstruction) + .forEach(instruction -> InstructionUtil + .writeInstructionHeader( + instruction, + EncodeConstants.OF13_VERSION_ID, + registry, + byteBuf)); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTINSTRUCTIONS; + } + + @Override + protected Class getClazz() { + return Instructions.class; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/MatchTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/MatchTablePropertySerializer.java new file mode 100644 index 0000000000..06d5e5d3fa --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/MatchTablePropertySerializer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match; + +public class MatchTablePropertySerializer extends AbstractTablePropertySerializer implements SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + protected void serializeProperty(final Match property, final ByteBuf byteBuf) { + property + .getMatchSetfield() + .getSetFieldMatch() + .forEach(setFieldMatch -> registry + .>getSerializer( + new MessageTypeKey<>( + EncodeConstants.OF13_VERSION_ID, + setFieldMatch.getMatchType())) + .serialize(setFieldMatch, byteBuf)); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTMATCH; + } + + @Override + protected Class getClazz() { + return Match.class; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableMissTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableMissTablePropertySerializer.java new file mode 100644 index 0000000000..64621deff9 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableMissTablePropertySerializer.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss; + +public class NextTableMissTablePropertySerializer extends AbstractTablePropertySerializer { + + @Override + protected void serializeProperty(final NextTableMiss property, final ByteBuf byteBuf) { + property + .getTablesMiss() + .getTableIds() + .forEach(byteBuf::writeByte); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTNEXTTABLESMISS; + } + + @Override + protected Class getClazz() { + return NextTableMiss.class; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableTablePropertySerializer.java new file mode 100644 index 0000000000..de1e41c9b3 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableTablePropertySerializer.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTable; + +public class NextTableTablePropertySerializer extends AbstractTablePropertySerializer { + + @Override + protected void serializeProperty(final NextTable property, final ByteBuf byteBuf) { + property + .getTables() + .getTableIds() + .forEach(byteBuf::writeByte); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTNEXTTABLES; + } + + @Override + protected Class getClazz() { + return NextTable.class; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WildcardsTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WildcardsTablePropertySerializer.java new file mode 100644 index 0000000000..9bc59530d9 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WildcardsTablePropertySerializer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards; + +public class WildcardsTablePropertySerializer extends AbstractTablePropertySerializer implements SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + protected void serializeProperty(final Wildcards property, final ByteBuf byteBuf) { + property + .getWildcardSetfield() + .getSetFieldMatch() + .forEach(setFieldMatch -> registry + .>getSerializer( + new MessageTypeKey<>( + EncodeConstants.OF13_VERSION_ID, + setFieldMatch.getMatchType())) + .serialize(setFieldMatch, byteBuf)); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTWILDCARDS; + } + + @Override + protected Class getClazz() { + return Wildcards.class; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsMissTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsMissTablePropertySerializer.java new file mode 100644 index 0000000000..7869880e76 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsMissTablePropertySerializer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowplugin.impl.protocol.serialization.util.ActionUtil; +import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss; + +public class WriteActionsMissTablePropertySerializer extends AbstractTablePropertySerializer implements SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + protected void serializeProperty(final WriteActionsMiss property, final ByteBuf byteBuf) { + property + .getWriteActionsMiss() + .getAction() + .stream() + .map(Action::getAction) + .forEach(action -> ActionUtil + .writeActionHeader( + action, + EncodeConstants.OF13_VERSION_ID, + registry, + byteBuf)); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS; + } + + @Override + protected Class getClazz() { + return WriteActionsMiss.class; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsTablePropertySerializer.java new file mode 100644 index 0000000000..0556941d0d --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsTablePropertySerializer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowplugin.impl.protocol.serialization.util.ActionUtil; +import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions; + +public class WriteActionsTablePropertySerializer extends AbstractTablePropertySerializer implements SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + protected void serializeProperty(final WriteActions property, final ByteBuf byteBuf) { + property + .getWriteActions() + .getAction() + .stream() + .map(Action::getAction) + .forEach(action -> ActionUtil + .writeActionHeader( + action, + EncodeConstants.OF13_VERSION_ID, + registry, + byteBuf)); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTWRITEACTIONS; + } + + @Override + protected Class getClazz() { + return WriteActions.class; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldMissTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldMissTablePropertySerializer.java new file mode 100644 index 0000000000..bd64f146d3 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldMissTablePropertySerializer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss; + +public class WriteSetfieldMissTablePropertySerializer extends AbstractTablePropertySerializer implements SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + protected void serializeProperty(final WriteSetfieldMiss property, final ByteBuf byteBuf) { + property + .getWriteSetfieldMiss() + .getSetFieldMatch() + .forEach(setFieldMatch -> registry + .>getSerializer( + new MessageTypeKey<>( + EncodeConstants.OF13_VERSION_ID, + setFieldMatch.getMatchType())) + .serialize(setFieldMatch, byteBuf)); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS; + } + + @Override + protected Class getClazz() { + return WriteSetfieldMiss.class; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldTablePropertySerializer.java new file mode 100644 index 0000000000..043fe7e438 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldTablePropertySerializer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield; + +public class WriteSetfieldTablePropertySerializer extends AbstractTablePropertySerializer implements SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + protected void serializeProperty(final WriteSetfield property, final ByteBuf byteBuf) { + property + .getWriteSetfield() + .getSetFieldMatch() + .forEach(setFieldMatch -> registry + .>getSerializer( + new MessageTypeKey<>( + EncodeConstants.OF13_VERSION_ID, + setFieldMatch.getMatchType())) + .serialize(setFieldMatch, byteBuf)); + } + + @Override + protected TableFeaturesPropType getType() { + return TableFeaturesPropType.OFPTFPTWRITESETFIELD; + } + + @Override + protected Class getClazz() { + return WriteSetfield.class; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/AbstractMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/AbstractMatchFieldSerializer.java new file mode 100644 index 0000000000..5e71323d15 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/AbstractMatchFieldSerializer.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch; + +public abstract class AbstractMatchFieldSerializer implements OFSerializer { + + @Override + public void serialize(final SetFieldMatch setFieldMatch, final ByteBuf byteBuf) { + byteBuf.writeShort(getOxmClassCode()); + + int fieldAndMask = getOxmFieldCode() << 1; + int length = getValueLength(); + + if (setFieldMatch.isHasMask()) { + fieldAndMask |= 1; + length *= 2; + } + + byteBuf.writeByte(fieldAndMask); + byteBuf.writeByte(length); + } + + protected abstract int getOxmClassCode(); + protected abstract int getOxmFieldCode(); + protected abstract int getValueLength(); + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpOpMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpOpMatchFieldSerializer.java new file mode 100644 index 0000000000..31004bb0df --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpOpMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class ArpOpMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_OP; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpShaMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpShaMatchFieldSerializer.java new file mode 100644 index 0000000000..ae74abe6fb --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpShaMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class ArpShaMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_SHA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpSpaMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpSpaMatchFieldSerializer.java new file mode 100644 index 0000000000..305f4b813c --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpSpaMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class ArpSpaMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_SPA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpThaMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpThaMatchFieldSerializer.java new file mode 100644 index 0000000000..2a93130a5f --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpThaMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class ArpThaMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_THA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpTpaMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpTpaMatchFieldSerializer.java new file mode 100644 index 0000000000..d3ac917bd2 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/ArpTpaMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class ArpTpaMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_TPA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/EthDstMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/EthDstMatchFieldSerializer.java new file mode 100644 index 0000000000..fb8574075f --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/EthDstMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class EthDstMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ETH_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/EthSrcMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/EthSrcMatchFieldSerializer.java new file mode 100644 index 0000000000..aa1927b6d6 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/EthSrcMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class EthSrcMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ETH_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/EthTypeMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/EthTypeMatchFieldSerializer.java new file mode 100644 index 0000000000..8c18274355 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/EthTypeMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class EthTypeMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ETH_TYPE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv4CodeMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv4CodeMatchFieldSerializer.java new file mode 100644 index 0000000000..6d7b19dc1d --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv4CodeMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class Icmpv4CodeMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ICMPV4_CODE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv4TypeMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv4TypeMatchFieldSerializer.java new file mode 100644 index 0000000000..7947f44101 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv4TypeMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class Icmpv4TypeMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ICMPV4_TYPE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv6CodeMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv6CodeMatchFieldSerializer.java new file mode 100644 index 0000000000..d6b8a4bf46 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv6CodeMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class Icmpv6CodeMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ICMPV6_CODE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv6TypeMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv6TypeMatchFieldSerializer.java new file mode 100644 index 0000000000..53e092f70e --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Icmpv6TypeMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class Icmpv6TypeMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ICMPV6_TYPE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/InPhyPortMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/InPhyPortMatchFieldSerializer.java new file mode 100644 index 0000000000..65355cf523 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/InPhyPortMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class InPhyPortMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IN_PHY_PORT; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/InPortMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/InPortMatchFieldSerializer.java new file mode 100644 index 0000000000..059be6d5b0 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/InPortMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class InPortMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IN_PORT; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/IpDscpMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/IpDscpMatchFieldSerializer.java new file mode 100644 index 0000000000..203d027d1d --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/IpDscpMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class IpDscpMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IP_DSCP; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/IpEcnMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/IpEcnMatchFieldSerializer.java new file mode 100644 index 0000000000..211a9fd666 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/IpEcnMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class IpEcnMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IP_ECN; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/IpProtoMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/IpProtoMatchFieldSerializer.java new file mode 100644 index 0000000000..b525109e2e --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/IpProtoMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class IpProtoMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IP_PROTO; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv4DstMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv4DstMatchFieldSerializer.java new file mode 100644 index 0000000000..65bf2e897b --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv4DstMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class Ipv4DstMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV4_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv4SrcMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv4SrcMatchFieldSerializer.java new file mode 100644 index 0000000000..25dc1cefda --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv4SrcMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class Ipv4SrcMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV4_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6DstMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6DstMatchFieldSerializer.java new file mode 100644 index 0000000000..5e6a5cd06e --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6DstMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class Ipv6DstMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6ExtHdrMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6ExtHdrMatchFieldSerializer.java new file mode 100644 index 0000000000..aa1b50dc6a --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6ExtHdrMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class Ipv6ExtHdrMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_EXTHDR; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6FlabelMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6FlabelMatchFieldSerializer.java new file mode 100644 index 0000000000..20d813c4c0 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6FlabelMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class Ipv6FlabelMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_FLABEL; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6NdSllMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6NdSllMatchFieldSerializer.java new file mode 100644 index 0000000000..b6403bb342 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6NdSllMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class Ipv6NdSllMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_ND_SLL; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6NdTargetMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6NdTargetMatchFieldSerializer.java new file mode 100644 index 0000000000..723a9373d5 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6NdTargetMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class Ipv6NdTargetMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_ND_TARGET; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6NdTllMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6NdTllMatchFieldSerializer.java new file mode 100644 index 0000000000..449612cb73 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6NdTllMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class Ipv6NdTllMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_ND_TLL; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6SrcMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6SrcMatchFieldSerializer.java new file mode 100644 index 0000000000..a7ea2725d9 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/Ipv6SrcMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class Ipv6SrcMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MetadataMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MetadataMatchFieldSerializer.java new file mode 100644 index 0000000000..9cfacf9320 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MetadataMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class MetadataMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.METADATA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_LONG_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MplsBosMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MplsBosMatchFieldSerializer.java new file mode 100644 index 0000000000..8d043f8350 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MplsBosMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class MplsBosMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.MPLS_BOS; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MplsLabelMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MplsLabelMatchFieldSerializer.java new file mode 100644 index 0000000000..0127250882 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MplsLabelMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class MplsLabelMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.MPLS_LABEL; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MplsTcMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MplsTcMatchFieldSerializer.java new file mode 100644 index 0000000000..2b4b024380 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/MplsTcMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class MplsTcMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.MPLS_TC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/PbbIsidMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/PbbIsidMatchFieldSerializer.java new file mode 100644 index 0000000000..6378291ea7 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/PbbIsidMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class PbbIsidMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.PBB_ISID; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_3_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/SctpDstMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/SctpDstMatchFieldSerializer.java new file mode 100644 index 0000000000..3b9f3aa5b8 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/SctpDstMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class SctpDstMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.SCTP_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/SctpSrcMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/SctpSrcMatchFieldSerializer.java new file mode 100644 index 0000000000..b929f40013 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/SctpSrcMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class SctpSrcMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.SCTP_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TcpDstMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TcpDstMatchFieldSerializer.java new file mode 100644 index 0000000000..585ef9d3f3 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TcpDstMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class TcpDstMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.TCP_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TcpFlagsMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TcpFlagsMatchFieldSerializer.java new file mode 100644 index 0000000000..b492eb36b2 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TcpFlagsMatchFieldSerializer.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class TcpFlagsMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.EXPERIMENTER_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return EncodeConstants.ONFOXM_ET_TCP_FLAGS; + } + + @Override + protected int getValueLength() { + // Increase length by experimenter ID length + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES + EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TcpSrcMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TcpSrcMatchFieldSerializer.java new file mode 100644 index 0000000000..f04a031d4e --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TcpSrcMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class TcpSrcMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.TCP_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TunnelIdMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TunnelIdMatchFieldSerializer.java new file mode 100644 index 0000000000..96edb9fad1 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/TunnelIdMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class TunnelIdMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.TUNNEL_ID; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_LONG_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/UdpDstMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/UdpDstMatchFieldSerializer.java new file mode 100644 index 0000000000..43e7fb32f1 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/UdpDstMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class UdpDstMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.UDP_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/UdpSrcMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/UdpSrcMatchFieldSerializer.java new file mode 100644 index 0000000000..265cc567cb --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/UdpSrcMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class UdpSrcMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.UDP_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/VlanPcpMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/VlanPcpMatchFieldSerializer.java new file mode 100644 index 0000000000..0aa22effc4 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/VlanPcpMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class VlanPcpMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.VLAN_PCP; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/VlanVidMatchFieldSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/VlanVidMatchFieldSerializer.java new file mode 100644 index 0000000000..2f7f50e1cd --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/matchfield/VlanVidMatchFieldSerializer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +public class VlanVidMatchFieldSerializer extends AbstractMatchFieldSerializer { + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.VLAN_VID; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/util/ActionUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/util/ActionUtil.java index f2bc24bf8f..6478b0e1fb 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/util/ActionUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/util/ActionUtil.java @@ -12,6 +12,7 @@ import com.google.common.collect.Ordering; import io.netty.buffer.ByteBuf; import java.util.List; import java.util.Optional; +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; @@ -86,6 +87,45 @@ public class ActionUtil { } } + /** + * Serialize OpenFlow action header, using extension converter if available + * TODO: Remove also extension converters + * + * @param action OpenFlowPlugin action + * @param version OpenFlow version + * @param registry serializer registry + * @param outBuffer output buffer + */ + @SuppressWarnings("unchecked") + public static void writeActionHeader(Action action, short version, SerializerRegistry registry, ByteBuf outBuffer) { + try { + Optional.ofNullable(OFSessionUtil.getExtensionConvertorProvider()) + .flatMap(provider -> + (GeneralExtensionGrouping.class.isInstance(action) + ? convertExtensionGrouping(provider, action, version) + : convertGenericAction(provider, action, version)) + .map(ofjAction -> { + final HeaderSerializer serializer = registry + .getSerializer(TypeKeyMakerFactory.createActionKeyMaker(version) + .make(ofjAction)); + + serializer.serializeHeader(ofjAction, outBuffer); + return action; + }) + ).orElseGet(() -> { + final HeaderSerializer serializer = registry.getSerializer( + new MessageTypeKey<>( + version, (Class) action.getImplementedInterface())); + + serializer.serializeHeader(action, outBuffer); + return action; + }); + } catch (final IllegalStateException | ClassCastException e) { + LOG.warn("Header Serializer for action {} for version {} not found.", action.getImplementedInterface(), version); + } + } + /** * Try to convert action that implements #{@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionGrouping} * to OpenFlowJava action diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/util/InstructionUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/util/InstructionUtil.java new file mode 100644 index 0000000000..bd5de027f4 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/util/InstructionUtil.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.util; + + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction; + +/** + * Utility class for instruction serialization + */ +public class InstructionUtil { + + /** + * Serialize instruction + * @param instruction OpenFlow instruction + * @param version OpenFlow version + * @param registry OpenFlowJava serializer registry + * @param outBuffer output buffer + */ + @SuppressWarnings("unchecked") + public static void writeInstruction(final Instruction instruction, + final short version, + final SerializerRegistry registry, + final ByteBuf outBuffer) { + + registry.>getSerializer( + new MessageTypeKey<>( + EncodeConstants.OF13_VERSION_ID, + (Class) instruction.getImplementedInterface())) + .serialize(instruction, outBuffer); + } + + + /** + * Serialize instruction header + * @param instruction OpenFlow instruction + * @param version OpenFlow version + * @param registry OpenFlowJava serializer registry + * @param outBuffer output buffer + */ + @SuppressWarnings("unchecked") + public static void writeInstructionHeader(final Instruction instruction, + final short version, + final SerializerRegistry registry, + final ByteBuf outBuffer) { + + registry.>getSerializer( + new MessageTypeKey<>( + EncodeConstants.OF13_VERSION_ID, + (Class) instruction.getImplementedInterface())) + .serializeHeader(instruction, outBuffer); + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java index 2c3db2a498..2bb0cbee8d 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java @@ -203,7 +203,7 @@ class RpcContextImpl implements RpcContext { MdSalRegistrationUtils.registerServices(this, deviceContext, extensionConverterProvider, convertorExecutor); - if (isStatisticsRpcEnabled) { + if (isStatisticsRpcEnabled && !deviceContext.canUseSingleLayerSerialization()) { MdSalRegistrationUtils.registerStatCompatibilityServices( this, deviceContext, diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java index a1a93a3755..2378352515 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java @@ -25,7 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.M import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures; import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializerTest.java index 5bb18eb70d..ab386259ec 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializerTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMessageSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMessageSerializerTest.java new file mode 100644 index 0000000000..2a60b26f74 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMessageSerializerTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.multipart; + +import static org.junit.Assert.assertEquals; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowplugin.impl.protocol.serialization.AbstractSerializerTest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.request.multipart.request.body.MultipartRequestDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequestBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; + +public class MultipartRequestMessageSerializerTest extends AbstractSerializerTest { + // Multipart request message constants + private static final byte PADDING_IN_MULTIPART_REQUEST_MESSAGE = 4; + private static final short LENGTH = 16; + private static final Long XID = 42L; + private static final short VERSION = EncodeConstants.OF13_VERSION_ID; + private static final boolean IS_REQUEST_MORE = false; + private static final MultipartType MULTIPART_TYPE = MultipartType.OFPMPDESC; + private static final int MESSAGE_TYPE = 18; + + // Message + private static final MultipartRequest MESSAGE = new MultipartRequestBuilder() + .setRequestMore(IS_REQUEST_MORE) + .setXid(XID) + .setVersion(VERSION) + .setMultipartRequestBody(new MultipartRequestDescBuilder() + .build()) + .build(); + + private MultipartRequestMessageSerializer serializer; + + + @Override + protected void init() { + serializer = getRegistry().getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequest.class)) ; + } + + @Test + public void testSerialize() throws Exception { + final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(MESSAGE, out); + + // Header + assertEquals(out.readByte(), VERSION); + assertEquals(out.readByte(), MESSAGE_TYPE); + assertEquals(out.readUnsignedShort(), LENGTH); + assertEquals(out.readInt(), XID.intValue()); + + // Body + assertEquals(out.readShort(), MULTIPART_TYPE.getIntValue()); + assertEquals(out.readUnsignedShort(), ByteBufUtils.fillBitMask(0, IS_REQUEST_MORE)); + out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); + + assertEquals(out.readableBytes(), 0); + } + +} \ No newline at end of file -- 2.36.6