Pull configuration information from DMI.
[sliver-openvswitch.git] / include / openflow / nicira-ext.h
1 /*
2  * Distributed under the terms of the GNU GPL version 2.
3  * Copyright (c) 2008 Nicira Networks
4  */
5
6 #ifndef OPENFLOW_NICIRA_EXT_H
7 #define OPENFLOW_NICIRA_EXT_H 1
8
9 #include "openflow/openflow.h"
10
11 #define NICIRA_OUI_STR "002320"
12
13 /* The following vendor extensions, proposed by Nicira Networks, are not yet
14  * ready for standardization (and may never be), so they are not included in
15  * openflow.h. */
16
17 #define NX_VENDOR_ID 0x00002320
18
19 enum nicira_type {
20     /* Switch status request.  The request body is an ASCII string that
21      * specifies a prefix of the key names to include in the output; if it is
22      * the null string, then all key-value pairs are included. */
23     NXT_STATUS_REQUEST,
24
25     /* Switch status reply.  The reply body is an ASCII string of key-value
26      * pairs in the form "key=value\n". */
27     NXT_STATUS_REPLY,
28
29     /* Configure an action.  Most actions do not require configuration
30      * beyond that supplied in the actual action call. */
31     NXT_ACT_SET_CONFIG,
32
33     /* Get configuration of action. */
34     NXT_ACT_GET_CONFIG,
35
36     /* Remote command execution.  The request body is a sequence of strings
37      * delimited by null bytes.  The first string is a command name.
38      * Subsequent strings are command arguments. */
39     NXT_COMMAND_REQUEST,
40
41     /* Remote command execution reply, sent when the command's execution
42      * completes.  The reply body is struct nx_command_reply. */
43     NXT_COMMAND_REPLY
44 };
45
46 struct nicira_header {
47     struct ofp_header header;
48     uint32_t vendor;            /* NX_VENDOR_ID. */
49     uint32_t subtype;           /* One of NXT_* above. */
50 };
51 OFP_ASSERT(sizeof(struct nicira_header) == sizeof(struct ofp_vendor_header) + 4);
52
53
54 enum nx_snat_command {
55     NXSC_ADD,
56     NXSC_DELETE
57 };
58
59 /* Configuration for source-NATing */
60 struct nx_snat_config {
61     uint8_t command;        /* One of NXSC_*. */
62     uint8_t pad[3];
63     uint16_t port;          /* Physical switch port. */
64     uint16_t mac_timeout;   /* Time to cache MAC addresses of SNAT'd hosts
65                                in seconds.  0 uses the default value. */
66
67     /* Range of IP addresses to impersonate.  Set both values to the
68      * same to support a single address.  */
69     uint32_t ip_addr_start; 
70     uint32_t ip_addr_end;
71
72     /* Range of transport ports that should be used as new source port.  A
73      * value of zero, let's the switch choose.*/
74     uint16_t tcp_start;
75     uint16_t tcp_end;
76     uint16_t udp_start;
77     uint16_t udp_end;
78 };
79 OFP_ASSERT(sizeof(struct nx_snat_config) == 24);
80
81 /* Action configuration.  Not all actions require separate configuration. */
82 struct nx_act_config {
83     struct nicira_header header;
84     uint16_t type;          /* One of OFPAT_* */
85     uint8_t pad[2];
86     union {
87         struct nx_snat_config snat[0];
88     };                      /* Array of action configurations.  The number 
89                                is inferred from the length field in the 
90                                header. */
91 };
92 OFP_ASSERT(sizeof(struct nx_act_config) == 20);
93
94
95 enum nx_action_subtype {
96     NXAST_SNAT                      /* Source-NAT */
97 };
98
99 /* Action structure for NXAST_SNAT. */
100 struct nx_action_snat {
101     uint16_t type;                  /* OFPAT_VENDOR. */
102     uint16_t len;                   /* Length is 8. */
103     uint32_t vendor;                /* NX_VENDOR_ID. */
104     uint16_t subtype;               /* NXAST_SNAT. */
105     uint16_t port;                  /* Output port--it must be previously 
106                                        configured. */
107     uint8_t pad[4];
108 };
109 OFP_ASSERT(sizeof(struct nx_action_snat) == 16);
110
111 /* Header for Nicira-defined actions. */
112 struct nx_action_header {
113     uint16_t type;                  /* OFPAT_VENDOR. */
114     uint16_t len;                   /* Length is 8. */
115     uint32_t vendor;                /* NX_VENDOR_ID. */
116     uint16_t subtype;               /* NXAST_*. */
117     uint8_t pad[6];
118 };
119 OFP_ASSERT(sizeof(struct nx_action_header) == 16);
120
121 /* Status bits for NXT_COMMAND_REPLY. */
122 enum {
123     NXT_STATUS_EXITED = 1 << 31,   /* Exited normally. */
124     NXT_STATUS_SIGNALED = 1 << 30, /* Exited due to signal. */
125     NXT_STATUS_UNKNOWN = 1 << 29,  /* Exited for unknown reason. */
126     NXT_STATUS_COREDUMP = 1 << 28, /* Exited with core dump. */
127     NXT_STATUS_ERROR = 1 << 27,    /* Command could not be executed. */
128     NXT_STATUS_STARTED = 1 << 26,  /* Command was started. */
129     NXT_STATUS_EXITSTATUS = 0xff,  /* Exit code mask if NXT_STATUS_EXITED. */
130     NXT_STATUS_TERMSIG = 0xff,     /* Signal number if NXT_STATUS_SIGNALED. */
131 };
132
133 /* NXT_COMMAND_REPLY. */
134 struct nx_command_reply {
135     struct nicira_header nxh;
136     uint32_t status;            /* Status bits defined above. */
137     /* Followed by any number of bytes of process output. */
138 };
139 OFP_ASSERT(sizeof(struct nx_command_reply) == 20);
140
141 #endif /* openflow/nicira-ext.h */