Make snat_skb() skb argument const.
[sliver-openvswitch.git] / datapath / nx_act.c
1 /*
2  * Distributed under the terms of the GNU GPL version 2.
3  * Copyright (c) 2008 Nicira Networks
4  */
5
6 /* Functions for Nicira-extended actions. */
7 #include "openflow/nicira-ext.h"
8 #include "dp_act.h"
9 #include "nx_act.h"
10 #include "nx_act_snat.h"
11
12 uint16_t
13 nx_validate_act(struct datapath *dp, const struct sw_flow_key *key,
14                 const struct nx_action_header *nah, uint16_t len)
15 {
16         if (len < sizeof *nah) 
17                 return OFPBAC_BAD_LEN;
18
19 #ifdef SUPPORT_SNAT
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;
26
27                 return ACT_VALIDATION_OK;
28         }
29 #endif
30         return OFPBAC_BAD_VENDOR_TYPE;
31 }
32
33 struct sk_buff *
34 nx_execute_act(struct sk_buff *skb, const struct sw_flow_key *key,
35                 const struct nx_action_header *nah)
36 {
37 #ifdef SUPPORT_SNAT
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));
41         }
42 #endif
43
44         return skb;
45 }
46