Update primary code license to Apache 2.0.
[cascardo/ovs.git] / include / openflow / nicira-ext.h
1 /*
2  * Copyright (c) 2008, 2009 Nicira Networks
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef OPENFLOW_NICIRA_EXT_H
18 #define OPENFLOW_NICIRA_EXT_H 1
19
20 #include "openflow/openflow.h"
21
22 #define NICIRA_OUI_STR "002320"
23
24 /* The following vendor extensions, proposed by Nicira Networks, are not yet
25  * ready for standardization (and may never be), so they are not included in
26  * openflow.h. */
27
28 #define NX_VENDOR_ID 0x00002320
29
30 enum nicira_type {
31     /* Switch status request.  The request body is an ASCII string that
32      * specifies a prefix of the key names to include in the output; if it is
33      * the null string, then all key-value pairs are included. */
34     NXT_STATUS_REQUEST,
35
36     /* Switch status reply.  The reply body is an ASCII string of key-value
37      * pairs in the form "key=value\n". */
38     NXT_STATUS_REPLY,
39
40     /* Configure an action.  Most actions do not require configuration
41      * beyond that supplied in the actual action call. */
42     NXT_ACT_SET_CONFIG,
43
44     /* Get configuration of action. */
45     NXT_ACT_GET_CONFIG,
46
47     /* Remote command execution.  The request body is a sequence of strings
48      * delimited by null bytes.  The first string is a command name.
49      * Subsequent strings are command arguments. */
50     NXT_COMMAND_REQUEST,
51
52     /* Remote command execution reply, sent when the command's execution
53      * completes.  The reply body is struct nx_command_reply. */
54     NXT_COMMAND_REPLY,
55
56     /* No longer used. */
57     NXT_FLOW_END_CONFIG__OBSOLETE,
58
59     /* No longer used. */
60     NXT_FLOW_END__OBSOLETE,
61
62     /* Management protocol.  See "openflow-mgmt.h". */
63     NXT_MGMT,
64 };
65
66 struct nicira_header {
67     struct ofp_header header;
68     uint32_t vendor;            /* NX_VENDOR_ID. */
69     uint32_t subtype;           /* One of NXT_* above. */
70 };
71 OFP_ASSERT(sizeof(struct nicira_header) == sizeof(struct ofp_vendor_header) + 4);
72
73
74 enum nx_action_subtype {
75     NXAST_SNAT__OBSOLETE,           /* No longer used. */
76     NXAST_RESUBMIT                  /* Throw against flow table again. */
77 };
78
79 /* Action structure for NXAST_RESUBMIT. */
80 struct nx_action_resubmit {
81     uint16_t type;                  /* OFPAT_VENDOR. */
82     uint16_t len;                   /* Length is 8. */
83     uint32_t vendor;                /* NX_VENDOR_ID. */
84     uint16_t subtype;               /* NXAST_RESUBMIT. */
85     uint16_t in_port;               /* New in_port for checking flow table. */
86     uint8_t pad[4];
87 };
88 OFP_ASSERT(sizeof(struct nx_action_resubmit) == 16);
89
90 /* Header for Nicira-defined actions. */
91 struct nx_action_header {
92     uint16_t type;                  /* OFPAT_VENDOR. */
93     uint16_t len;                   /* Length is 8. */
94     uint32_t vendor;                /* NX_VENDOR_ID. */
95     uint16_t subtype;               /* NXAST_*. */
96     uint8_t pad[6];
97 };
98 OFP_ASSERT(sizeof(struct nx_action_header) == 16);
99
100 /* Status bits for NXT_COMMAND_REPLY. */
101 enum {
102     NXT_STATUS_EXITED = 1 << 31,   /* Exited normally. */
103     NXT_STATUS_SIGNALED = 1 << 30, /* Exited due to signal. */
104     NXT_STATUS_UNKNOWN = 1 << 29,  /* Exited for unknown reason. */
105     NXT_STATUS_COREDUMP = 1 << 28, /* Exited with core dump. */
106     NXT_STATUS_ERROR = 1 << 27,    /* Command could not be executed. */
107     NXT_STATUS_STARTED = 1 << 26,  /* Command was started. */
108     NXT_STATUS_EXITSTATUS = 0xff,  /* Exit code mask if NXT_STATUS_EXITED. */
109     NXT_STATUS_TERMSIG = 0xff,     /* Signal number if NXT_STATUS_SIGNALED. */
110 };
111
112 /* NXT_COMMAND_REPLY. */
113 struct nx_command_reply {
114     struct nicira_header nxh;
115     uint32_t status;            /* Status bits defined above. */
116     /* Followed by any number of bytes of process output. */
117 };
118 OFP_ASSERT(sizeof(struct nx_command_reply) == 20);
119
120 #endif /* openflow/nicira-ext.h */