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. */
46 struct nicira_header {
47 struct ofp_header header;
48 uint32_t vendor; /* NX_VENDOR_ID. */
49 uint32_t subtype; /* One of NXT_* above. */
51 OFP_ASSERT(sizeof(struct nicira_header) == sizeof(struct ofp_vendor_header) + 4);
54 enum nx_snat_command {
59 /* Configuration for source-NATing */
60 struct nx_snat_config {
61 uint8_t command; /* One of NXSC_*. */
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. */
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;
72 /* Range of transport ports that should be used as new source port. A
73 * value of zero, let's the switch choose.*/
79 OFP_ASSERT(sizeof(struct nx_snat_config) == 24);
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_* */
87 struct nx_snat_config snat[0];
88 }; /* Array of action configurations. The number
89 is inferred from the length field in the
92 OFP_ASSERT(sizeof(struct nx_act_config) == 20);
95 enum nx_action_subtype {
96 NXAST_SNAT /* Source-NAT */
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
109 OFP_ASSERT(sizeof(struct nx_action_snat) == 16);
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_*. */
119 OFP_ASSERT(sizeof(struct nx_action_header) == 16);
121 /* Status bits for NXT_COMMAND_REPLY. */
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. */
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. */
139 OFP_ASSERT(sizeof(struct nx_command_reply) == 20);
141 #endif /* openflow/nicira-ext.h */