Add support for exporting flow information in NetFlow v5 format.
[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
21         case NXT_FLOW_END_CONFIG: {
22                 const struct nx_flow_end_config *nfec = msg;
23                 chain->dp->send_flow_end = nfec->enable;
24                 return 0;
25         }
26
27 #ifdef SUPPORT_SNAT
28         case NXT_ACT_SET_CONFIG: {
29                 const struct nx_act_config *nac = msg;
30                 if (ntohs(nh->header.length) < sizeof(*nac)) 
31                         return -EINVAL;
32
33                 if (nac->type == htons(NXAST_SNAT))
34                         return snat_mod_config(chain->dp, nac);
35                 else
36                         return -EINVAL;
37                 break;
38         }
39 #endif
40
41         default:
42                 dp_send_error_msg(chain->dp, sender, OFPET_BAD_REQUEST,
43                                   OFPBRC_BAD_SUBTYPE, msg, ntohs(nh->header.length));
44                 return -EINVAL;
45         }
46
47         return -EINVAL;
48 }