Move exported headers to include/openflow, private headers to lib/.
[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 /* 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
13  * openflow.h. */
14
15 #define NX_VENDOR_ID 0x00002320
16
17 enum nicira_type {
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. */
21     NXT_STATUS_REQUEST,
22
23     /* Switch status reply.  The reply body is an ASCII string of key-value
24      * pairs in the form "key=value\n". */
25     NXT_STATUS_REPLY,
26
27     /* Configure an action.  Most actions do not require configuration
28      * beyond that supplied in the actual action call. */
29     NXT_ACT_SET_CONFIG,
30
31     /* Get configuration of action. */
32     NXT_ACT_GET_CONFIG,
33
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. */
37     NXT_COMMAND_REQUEST,
38
39     /* Remote command execution reply, sent when the command's execution
40      * completes.  The reply body is struct nx_command_reply. */
41     NXT_COMMAND_REPLY
42 };
43
44 struct nicira_header {
45     struct ofp_header header;
46     uint32_t vendor;            /* NX_VENDOR_ID. */
47     uint32_t subtype;           /* One of NXT_* above. */
48 };
49 OFP_ASSERT(sizeof(struct nicira_header) == sizeof(struct ofp_vendor_header) + 4);
50
51
52 enum nx_snat_command {
53     NXSC_ADD,
54     NXSC_DELETE
55 };
56
57 /* Configuration for source-NATing */
58 struct nx_snat_config {
59     uint8_t command;        /* One of NXSC_*. */
60     uint8_t pad[3];
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. */
64
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; 
68     uint32_t ip_addr_end;
69
70     /* Range of transport ports that should be used as new source port.  A
71      * value of zero, let's the switch choose.*/
72     uint16_t tcp_start;
73     uint16_t tcp_end;
74     uint16_t udp_start;
75     uint16_t udp_end;
76 };
77 OFP_ASSERT(sizeof(struct nx_snat_config) == 24);
78
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_* */
83     uint8_t pad[2];
84     union {
85         struct nx_snat_config snat[0];
86     };                      /* Array of action configurations.  The number 
87                                is inferred from the length field in the 
88                                header. */
89 };
90 OFP_ASSERT(sizeof(struct nx_act_config) == 20);
91
92
93 enum nx_action_subtype {
94     NXAST_SNAT                      /* Source-NAT */
95 };
96
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 
104                                        configured. */
105     uint8_t pad[4];
106 };
107 OFP_ASSERT(sizeof(struct nx_action_snat) == 16);
108
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_*. */
115     uint8_t pad[6];
116 };
117 OFP_ASSERT(sizeof(struct nx_action_header) == 16);
118
119 /* Status bits for NXT_COMMAND_REPLY. */
120 enum {
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. */
129 };
130
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. */
136 };
137 OFP_ASSERT(sizeof(struct nx_command_reply) == 20);
138
139 #endif /* openflow/nicira-ext.h */