Improve secchan.8 manpage.
[sliver-openvswitch.git] / datapath / nx_msg.c
1 /*
2  * Distributed under the terms of the GNU GPL version 2.
3  * Copyright (c) 2008 Nicira Networks
4  */
5
6 #include "chain.h"
7 #include "datapath.h"
8 #include "openflow/nicira-ext.h"
9 #include "nx_act_snat.h"
10 #include "nx_msg.h"
11
12
13 int
14 nx_recv_msg(struct sw_chain *chain, const struct sender *sender,
15                 const void *msg)
16 {
17         const struct nicira_header *nh = msg;
18
19         switch (ntohl(nh->subtype)) {
20 #ifdef SUPPORT_SNAT
21         case NXT_ACT_SET_CONFIG: {
22                 const struct nx_act_config *nac = msg;
23                 if (ntohs(nh->header.length) < sizeof(*nac)) 
24                         return -EINVAL;
25
26                 if (nac->type == htons(NXAST_SNAT))
27                         return snat_mod_config(chain->dp, nac);
28                 else
29                         return -EINVAL;
30                 break;
31         }
32 #endif
33
34         default:
35                 dp_send_error_msg(chain->dp, sender, OFPET_BAD_REQUEST,
36                                   OFPBRC_BAD_SUBTYPE, msg, ntohs(nh->header.length));
37                 return -EINVAL;
38         }
39
40         return -EINVAL;
41 }