Contiki 3.x
rest-constants.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  */
31 
32 /**
33  * \file
34  * Constants for the REST Engine (Erbium).
35  * \author
36  * Matthias Kovatsch <kovatsch@inf.ethz.ch>
37  */
38 
39 #ifndef REST_CONSTANTS_H_
40 #define REST_CONSTANTS_H_
41 
42 /**
43  * Generic status codes that are mapped to either HTTP or CoAP codes.
44  */
46  const unsigned int OK; /* CONTENT_2_05, OK_200 */
47  const unsigned int CREATED; /* CREATED_2_01, CREATED_201 */
48  const unsigned int CHANGED; /* CHANGED_2_04, NO_CONTENT_204 */
49  const unsigned int DELETED; /* DELETED_2_02, NO_CONTENT_204 */
50  const unsigned int NOT_MODIFIED; /* VALID_2_03, NOT_MODIFIED_304 */
51 
52  const unsigned int BAD_REQUEST; /* BAD_REQUEST_4_00, BAD_REQUEST_400 */
53  const unsigned int UNAUTHORIZED; /* UNAUTHORIZED_4_01, UNAUTHORIZED_401 */
54  const unsigned int BAD_OPTION; /* BAD_OPTION_4_02, BAD_REQUEST_400 */
55  const unsigned int FORBIDDEN; /* FORBIDDEN_4_03, FORBIDDEN_403 */
56  const unsigned int NOT_FOUND; /* NOT_FOUND_4_04, NOT_FOUND_404 */
57  const unsigned int METHOD_NOT_ALLOWED; /* METHOD_NOT_ALLOWED_4_05, METHOD_NOT_ALLOWED_405 */
58  const unsigned int NOT_ACCEPTABLE; /* NOT_ACCEPTABLE_4_06, NOT_ACCEPTABLE_406 */
59  const unsigned int REQUEST_ENTITY_TOO_LARGE; /* REQUEST_ENTITY_TOO_LARGE_4_13, REQUEST_ENTITY_TOO_LARGE_413 */
60  const unsigned int UNSUPPORTED_MEDIA_TYPE; /* UNSUPPORTED_MEDIA_TYPE_4_15, UNSUPPORTED_MEDIA_TYPE_415 */
61 
62  const unsigned int INTERNAL_SERVER_ERROR; /* INTERNAL_SERVER_ERROR_5_00, INTERNAL_SERVER_ERROR_500 */
63  const unsigned int NOT_IMPLEMENTED; /* NOT_IMPLEMENTED_5_01, NOT_IMPLEMENTED_501 */
64  const unsigned int BAD_GATEWAY; /* BAD_GATEWAY_5_02, BAD_GATEWAY_502 */
65  const unsigned int SERVICE_UNAVAILABLE; /* SERVICE_UNAVAILABLE_5_03, SERVICE_UNAVAILABLE_503 */
66  const unsigned int GATEWAY_TIMEOUT; /* GATEWAY_TIMEOUT_5_04, GATEWAY_TIMEOUT_504 */
67  const unsigned int PROXYING_NOT_SUPPORTED; /* PROXYING_NOT_SUPPORTED_5_05, INTERNAL_SERVER_ERROR_500 */
68 };
69 
70 /**
71  * List of Content-Formats which are Internet Media Types plus encoding.
72  * TODO This should be a constant enum taken from CoAP for both CoAP and HTTP.
73  */
75  unsigned int TEXT_PLAIN;
76  unsigned int TEXT_XML;
77  unsigned int TEXT_CSV;
78  unsigned int TEXT_HTML;
79  unsigned int IMAGE_GIF;
80  unsigned int IMAGE_JPEG;
81  unsigned int IMAGE_PNG;
82  unsigned int IMAGE_TIFF;
83  unsigned int AUDIO_RAW;
84  unsigned int VIDEO_RAW;
85  unsigned int APPLICATION_LINK_FORMAT;
86  unsigned int APPLICATION_XML;
87  unsigned int APPLICATION_OCTET_STREAM;
88  unsigned int APPLICATION_RDF_XML;
89  unsigned int APPLICATION_SOAP_XML;
90  unsigned int APPLICATION_ATOM_XML;
91  unsigned int APPLICATION_XMPP_XML;
92  unsigned int APPLICATION_EXI;
93  unsigned int APPLICATION_FASTINFOSET;
94  unsigned int APPLICATION_SOAP_FASTINFOSET;
95  unsigned int APPLICATION_JSON;
96  unsigned int APPLICATION_X_OBIX_BINARY;
97 };
98 
99 /**
100  * Resource flags for allowed methods and special functionalities.
101  */
102 typedef enum {
103  NO_FLAGS = 0,
104 
105  /* methods to handle */
106  METHOD_GET = (1 << 0),
107  METHOD_POST = (1 << 1),
108  METHOD_PUT = (1 << 2),
109  METHOD_DELETE = (1 << 3),
110 
111  /* special flags */
112  HAS_SUB_RESOURCES = (1 << 4),
113  IS_SEPARATE = (1 << 5),
114  IS_OBSERVABLE = (1 << 6),
115  IS_PERIODIC = (1 << 7)
117 
118 #endif /* REST_CONSTANTS_H_ */
rest_resource_flags_t
Resource flags for allowed methods and special functionalities.
List of Content-Formats which are Internet Media Types plus encoding.
Generic status codes that are mapped to either HTTP or CoAP codes.