2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.translate.v3po.interfaces.acl.common;
19 import io.fd.honeycomb.translate.vpp.util.MacTranslator;
20 import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSession;
21 import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTable;
22 import java.util.List;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
25 interface L2AclTranslator extends MacTranslator {
27 default boolean destinationMacAddressMask(final MacAddress dstMask, final MacAddress dstAddress,
28 final ClassifyAddDelTable request) {
29 // destination-mac-address or destination-mac-address-mask is present =>
30 // ff:ff:ff:ff:ff:ff:00:00:00:00:00:00:00:00:00:00
31 if (dstMask != null) {
32 final List<String> parts = COLON_SPLITTER.splitToList(dstMask.getValue());
34 for (String part : parts) {
35 request.mask[i++] = parseHexByte(part);
38 } else if (dstAddress != null) {
39 for (int i = 0; i < 6; ++i) {
40 request.mask[i] = (byte) 0xff;
47 default boolean sourceMacAddressMask(final MacAddress srcMask, final MacAddress srcAddress,
48 final ClassifyAddDelTable request) {
49 // source-mac-address or source-mac-address-mask =>
50 // 00:00:00:00:00:00:ff:ff:ff:ff:ff:ff:00:00:00:00
51 if (srcMask != null) {
52 final List<String> parts = COLON_SPLITTER.splitToList(srcMask.getValue());
54 for (String part : parts) {
55 request.mask[i++] = parseHexByte(part);
58 } else if (srcAddress != null) {
59 for (int i = 6; i < 12; ++i) {
60 request.mask[i] = (byte) 0xff;
67 default boolean destinationMacAddressMatch(final MacAddress dstAddress, final ClassifyAddDelSession request) {
68 if (dstAddress != null) {
69 final List<String> parts = COLON_SPLITTER.splitToList(dstAddress.getValue());
71 for (String part : parts) {
72 request.match[i++] = parseHexByte(part);
79 default boolean sourceMacAddressMatch(final MacAddress srcAddress, final ClassifyAddDelSession request) {
80 if (srcAddress != null) {
81 final List<String> parts = COLON_SPLITTER.splitToList(srcAddress.getValue());
83 for (String part : parts) {
84 request.match[i++] = parseHexByte(part);