2 * Distributed under the terms of the GNU GPL version 2.
3 * Copyright (c) 2008 Nicira Networks
6 /* Functions for Nicira-extended actions. */
7 #include "openflow/nicira-ext.h"
10 #include "nx_act_snat.h"
13 nx_validate_act(struct datapath *dp, const struct sw_flow_key *key,
14 const struct nx_action_header *nah, uint16_t len)
16 if (len < sizeof *nah)
17 return OFPBAC_BAD_LEN;
20 if (nah->subtype == ntohs(NXAST_SNAT)) {
21 struct nx_action_snat *nas = (struct nx_action_snat *)nah;
22 if (len != sizeof(*nas))
23 return OFPBAC_BAD_LEN;
24 else if (ntohs(nas->port) >= OFPP_MAX)
25 return OFPBAC_BAD_ARGUMENT;
27 return ACT_VALIDATION_OK;
30 return OFPBAC_BAD_VENDOR_TYPE;
34 nx_execute_act(struct sk_buff *skb, const struct sw_flow_key *key,
35 const struct nx_action_header *nah)
38 if (nah->subtype == ntohs(NXAST_SNAT)) {
39 struct nx_action_snat *nas = (struct nx_action_snat *)nah;
40 snat_skb(skb->dev->br_port->dp, skb, ntohs(nas->port));