2 * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.genius.mdsalutil.actions;
10 import org.opendaylight.genius.mdsalutil.ActionInfo;
11 import org.opendaylight.genius.mdsalutil.NWUtil;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpShaCaseBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.DstBuilder;
20 import org.opendaylight.yangtools.yang.common.Empty;
21 import org.opendaylight.yangtools.yang.common.Uint16;
22 import org.opendaylight.yangtools.yang.common.Uint64;
25 * Load MAC address to SHA (Sender Hardware Address).
27 * <p>Media address of the sender. In an ARP request this field is used to
28 * indicate the address of the host sending the request. In an ARP reply
29 * this field is used to indicate the address of the host that the request
32 public class ActionLoadMacToSha extends ActionInfo {
34 private final MacAddress address;
36 public ActionLoadMacToSha(MacAddress address) {
40 public ActionLoadMacToSha(int actionKey, MacAddress address) {
42 this.address = address;
46 public Action buildAction() {
47 return buildAction(getActionKey());
51 public Action buildAction(int newActionKey) {
52 return new ActionBuilder()
53 .setAction(new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder()
54 .setNxRegLoad(new NxRegLoadBuilder()
55 .setDst(new DstBuilder()
56 .setDstChoice(new DstNxArpShaCaseBuilder().setNxArpSha(Empty.getInstance()).build())
57 .setStart(Uint16.ZERO)
60 .setValue(Uint64.valueOf(NWUtil.macToLong(address)))
63 .withKey(new ActionKey(newActionKey))
67 public MacAddress getAddress() {
72 public boolean equals(Object other) {
76 if (other == null || getClass() != other.getClass()) {
79 if (!super.equals(other)) {
83 ActionLoadMacToSha that = (ActionLoadMacToSha) other;
85 return address != null ? address.equals(that.address) : that.address == null;
89 public int hashCode() {
90 int result = super.hashCode();
91 result = 31 * result + (address != null ? address.hashCode() : 0);
96 public String toString() {
97 return "ActionLoadMacToSha [address=" + address + ", getActionKey()=" + getActionKey() + "]";