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 /* The following vendor extensions, proposed by Nicira Networks, are not yet
12 * ready for standardization (and may never be), so they are not included in
15 #define NX_VENDOR_ID 0x00002320
18 /* Switch status request. The request body is an ASCII string that
19 * specifies a prefix of the key names to include in the output; if it is
20 * the null string, then all key-value pairs are included. */
23 /* Switch status reply. The reply body is an ASCII string of key-value
24 * pairs in the form "key=value\n". */
27 /* Configure an action. Most actions do not require configuration
28 * beyond that supplied in the actual action call. */
31 /* Get configuration of action. */
34 /* Remote command execution. The request body is a sequence of strings
35 * delimited by null bytes. The first string is a command name.
36 * Subsequent strings are command arguments. */
39 /* Remote command execution reply, sent when the command's execution
40 * completes. The reply body is struct nx_command_reply. */
44 struct nicira_header {
45 struct ofp_header header;
46 uint32_t vendor; /* NX_VENDOR_ID. */
47 uint32_t subtype; /* One of NXT_* above. */
49 OFP_ASSERT(sizeof(struct nicira_header) == sizeof(struct ofp_vendor_header) + 4);
52 enum nx_snat_command {
57 /* Configuration for source-NATing */
58 struct nx_snat_config {
59 uint8_t command; /* One of NXSC_*. */
61 uint16_t port; /* Physical switch port. */
62 uint16_t mac_timeout; /* Time to cache MAC addresses of SNAT'd hosts
63 in seconds. 0 uses the default value. */
65 /* Range of IP addresses to impersonate. Set both values to the
66 * same to support a single address. */
67 uint32_t ip_addr_start;
70 /* Range of transport ports that should be used as new source port. A
71 * value of zero, let's the switch choose.*/
77 OFP_ASSERT(sizeof(struct nx_snat_config) == 24);
79 /* Action configuration. Not all actions require separate configuration. */
80 struct nx_act_config {
81 struct nicira_header header;
82 uint16_t type; /* One of OFPAT_* */
85 struct nx_snat_config snat[0];
86 }; /* Array of action configurations. The number
87 is inferred from the length field in the
90 OFP_ASSERT(sizeof(struct nx_act_config) == 20);
93 enum nx_action_subtype {
94 NXAST_SNAT /* Source-NAT */
97 /* Action structure for NXAST_SNAT. */
98 struct nx_action_snat {
99 uint16_t type; /* OFPAT_VENDOR. */
100 uint16_t len; /* Length is 8. */
101 uint32_t vendor; /* NX_VENDOR_ID. */
102 uint16_t subtype; /* NXAST_SNAT. */
103 uint16_t port; /* Output port--it must be previously
107 OFP_ASSERT(sizeof(struct nx_action_snat) == 16);
109 /* Header for Nicira-defined actions. */
110 struct nx_action_header {
111 uint16_t type; /* OFPAT_VENDOR. */
112 uint16_t len; /* Length is 8. */
113 uint32_t vendor; /* NX_VENDOR_ID. */
114 uint16_t subtype; /* NXAST_*. */
117 OFP_ASSERT(sizeof(struct nx_action_header) == 16);
119 /* Status bits for NXT_COMMAND_REPLY. */
121 NXT_STATUS_EXITED = 1 << 31, /* Exited normally. */
122 NXT_STATUS_SIGNALED = 1 << 30, /* Exited due to signal. */
123 NXT_STATUS_UNKNOWN = 1 << 29, /* Exited for unknown reason. */
124 NXT_STATUS_COREDUMP = 1 << 28, /* Exited with core dump. */
125 NXT_STATUS_ERROR = 1 << 27, /* Command could not be executed. */
126 NXT_STATUS_STARTED = 1 << 26, /* Command was started. */
127 NXT_STATUS_EXITSTATUS = 0xff, /* Exit code mask if NXT_STATUS_EXITED. */
128 NXT_STATUS_TERMSIG = 0xff, /* Signal number if NXT_STATUS_SIGNALED. */
131 /* NXT_COMMAND_REPLY. */
132 struct nx_command_reply {
133 struct nicira_header nxh;
134 uint32_t status; /* Status bits defined above. */
135 /* Followed by any number of bytes of process output. */
137 OFP_ASSERT(sizeof(struct nx_command_reply) == 20);
139 #endif /* openflow/nicira-ext.h */