2 * Distributed under the terms of the GNU GPL version 2.
3 * Copyright (c) 2008 Nicira Networks
6 #ifndef OPENFLOW_NICIRA_EXT_H
7 #define OPENFLOW_NICIRA_EXT_H 1
9 #include "openflow/openflow.h"
11 #define NICIRA_OUI_STR "002320"
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
17 #define NX_VENDOR_ID 0x00002320
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. */
25 /* Switch status reply. The reply body is an ASCII string of key-value
26 * pairs in the form "key=value\n". */
29 /* Configure an action. Most actions do not require configuration
30 * beyond that supplied in the actual action call. */
33 /* Get configuration of action. */
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. */
41 /* Remote command execution reply, sent when the command's execution
42 * completes. The reply body is struct nx_command_reply. */
45 /* Configure whether Flow End messages should be sent. */
48 /* Sent by switch when a flow ends. These messages are turned into
49 * ofp_flow_expired and NetFlow messages in user-space. */
53 struct nicira_header {
54 struct ofp_header header;
55 uint32_t vendor; /* NX_VENDOR_ID. */
56 uint32_t subtype; /* One of NXT_* above. */
58 OFP_ASSERT(sizeof(struct nicira_header) == sizeof(struct ofp_vendor_header) + 4);
61 enum nx_snat_command {
66 /* Configuration for source-NATing */
67 struct nx_snat_config {
68 uint8_t command; /* One of NXSC_*. */
70 uint16_t port; /* Physical switch port. */
71 uint16_t mac_timeout; /* Time to cache MAC addresses of SNAT'd hosts
72 in seconds. 0 uses the default value. */
74 /* Range of IP addresses to impersonate. Set both values to the
75 * same to support a single address. */
76 uint32_t ip_addr_start;
79 /* Range of transport ports that should be used as new source port. A
80 * value of zero, let's the switch choose.*/
86 /* MAC address to use for ARP requests for a SNAT IP address that
87 * comes in on a different interface than 'port'. A value of all
88 * zeros silently drops those ARP requests. Requests that arrive
89 * on 'port' get a response with the mac address of the datapath
91 uint8_t mac_addr[OFP_ETH_ALEN];
94 OFP_ASSERT(sizeof(struct nx_snat_config) == 32);
96 /* Action configuration. Not all actions require separate configuration. */
97 struct nx_act_config {
98 struct nicira_header header;
99 uint16_t type; /* One of OFPAT_* */
102 struct nx_snat_config snat[0];
103 }; /* Array of action configurations. The number
104 is inferred from the length field in the
107 OFP_ASSERT(sizeof(struct nx_act_config) == 20);
110 enum nx_action_subtype {
111 NXAST_SNAT /* Source-NAT */
114 /* Action structure for NXAST_SNAT. */
115 struct nx_action_snat {
116 uint16_t type; /* OFPAT_VENDOR. */
117 uint16_t len; /* Length is 8. */
118 uint32_t vendor; /* NX_VENDOR_ID. */
119 uint16_t subtype; /* NXAST_SNAT. */
120 uint16_t port; /* Output port--it must be previously
124 OFP_ASSERT(sizeof(struct nx_action_snat) == 16);
126 /* Header for Nicira-defined actions. */
127 struct nx_action_header {
128 uint16_t type; /* OFPAT_VENDOR. */
129 uint16_t len; /* Length is 8. */
130 uint32_t vendor; /* NX_VENDOR_ID. */
131 uint16_t subtype; /* NXAST_*. */
134 OFP_ASSERT(sizeof(struct nx_action_header) == 16);
136 /* Status bits for NXT_COMMAND_REPLY. */
138 NXT_STATUS_EXITED = 1 << 31, /* Exited normally. */
139 NXT_STATUS_SIGNALED = 1 << 30, /* Exited due to signal. */
140 NXT_STATUS_UNKNOWN = 1 << 29, /* Exited for unknown reason. */
141 NXT_STATUS_COREDUMP = 1 << 28, /* Exited with core dump. */
142 NXT_STATUS_ERROR = 1 << 27, /* Command could not be executed. */
143 NXT_STATUS_STARTED = 1 << 26, /* Command was started. */
144 NXT_STATUS_EXITSTATUS = 0xff, /* Exit code mask if NXT_STATUS_EXITED. */
145 NXT_STATUS_TERMSIG = 0xff, /* Signal number if NXT_STATUS_SIGNALED. */
148 /* NXT_COMMAND_REPLY. */
149 struct nx_command_reply {
150 struct nicira_header nxh;
151 uint32_t status; /* Status bits defined above. */
152 /* Followed by any number of bytes of process output. */
154 OFP_ASSERT(sizeof(struct nx_command_reply) == 20);
156 enum nx_flow_end_reason {
157 NXFER_IDLE_TIMEOUT, /* Flow idle time exceeded idle_timeout. */
158 NXFER_HARD_TIMEOUT, /* Time exceeded hard_timeout. */
159 NXFER_DELETE, /* Flow was removed by delete command. */
160 NXFER_EJECT /* Flow was ejected. */
163 struct nx_flow_end_config {
164 struct nicira_header header;
165 uint8_t enable; /* Set to 1 to enable Flow End message
166 generation. 0 to disable. */
169 OFP_ASSERT(sizeof(struct nx_flow_end_config) == 20);
172 struct nicira_header header;
173 struct ofp_match match; /* Description of fields. */
175 uint16_t priority; /* Priority level of flow entry. */
176 uint8_t reason; /* One of NXFER_*. */
178 uint8_t tcp_flags; /* Union of seen TCP flags. */
179 uint8_t ip_tos; /* IP TOS value. */
181 uint8_t pad[7]; /* Align to 64-bits. */
183 uint64_t init_time; /* Time flow started in milliseconds. */
184 uint64_t used_time; /* Time entry was last used in milliseconds. */
185 uint64_t end_time; /* Time flow ended in milliseconds. */
187 uint64_t packet_count;
190 OFP_ASSERT(sizeof(struct nx_flow_end) == 104);
192 #endif /* openflow/nicira-ext.h */