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 java.math.BigInteger;
11 import org.opendaylight.genius.mdsalutil.ActionInfo;
12 import org.opendaylight.genius.mdsalutil.ActionType;
13 import org.opendaylight.genius.mdsalutil.NWUtil;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpShaCaseBuilder;
19 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;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.DstBuilder;
24 * Load MAC address to SHA (Sender Hardware Address).
26 * Media address of the sender. In an ARP request this field is used to
27 * indicate the address of the host sending the request. In an ARP reply
28 * this field is used to indicate the address of the host that the request
31 public class ActionLoadMacToSha extends ActionInfo {
32 private final MacAddress address;
34 public ActionLoadMacToSha(MacAddress address) {
38 public ActionLoadMacToSha(int actionKey, MacAddress address) {
39 super(ActionType.load_mac_to_sha, new String[] {address.getValue()}, actionKey);
40 this.address = address;
44 public ActionLoadMacToSha(ActionInfo actionInfo) {
45 this(actionInfo.getActionKey(), new MacAddress(actionInfo.getActionValues()[0]));
49 public Action buildAction() {
50 return buildAction(getActionKey());
53 public Action buildAction(int newActionKey) {
54 return new ActionBuilder()
55 .setAction(new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder()
56 .setNxRegLoad(new NxRegLoadBuilder()
57 .setDst(new DstBuilder()
58 .setDstChoice(new DstNxArpShaCaseBuilder().setNxArpSha(true).build())
62 .setValue(BigInteger.valueOf(NWUtil.macToLong(address)))
65 .setKey(new ActionKey(newActionKey))
69 public MacAddress getAddress() {
74 public boolean equals(Object o) {
75 if (this == o) return true;
76 if (o == null || getClass() != o.getClass()) return false;
77 if (!super.equals(o)) return false;
79 ActionLoadMacToSha that = (ActionLoadMacToSha) o;
81 return address != null ? address.equals(that.address) : that.address == null;
85 public int hashCode() {
86 int result = super.hashCode();
87 result = 31 * result + (address != null ? address.hashCode() : 0);