async_coap/consts.rs
1// Copyright 2019 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15
16//! Module defining various CoAP-related constants.
17
18/// The standard default IP port number used for CoAP-over-UDP.
19pub const DEFAULT_PORT_COAP_UDP: u16 = 5683;
20
21/// The standard default IP port number used for CoAP-over-DTLS.
22pub const DEFAULT_PORT_COAP_DTLS: u16 = 5684;
23
24/// The standard default IP port number used for CoAP-over-TCP.
25pub const DEFAULT_PORT_COAP_TCP: u16 = 5683;
26
27/// The standard default IP port number used for CoAP-over-TLS.
28pub const DEFAULT_PORT_COAP_TLS: u16 = 5684;
29
30/// The standard URI scheme for vanilla CoAP-over-UDP on IP networks.
31pub const URI_SCHEME_COAP: &'static str = "coap";
32
33/// The standard URI scheme for CoAP-over-DTLS on IP networks.
34pub const URI_SCHEME_COAPS: &'static str = "coaps";
35
36/// The standard URI scheme for CoAP-over-TCP on IP networks.
37pub const URI_SCHEME_COAP_TCP: &'static str = "coap+tcp";
38
39/// The standard URI scheme for CoAP-over-TLS on IP networks.
40pub const URI_SCHEME_COAPS_TCP: &'static str = "coaps+tcp";
41
42/// Non-standard URI scheme for a [loopback interface](https://en.wikipedia.org/wiki/Loopback).
43pub const URI_SCHEME_LOOPBACK: &'static str = "loop";
44
45/// Non-standard URI scheme for a [null interface](https://en.wikipedia.org/wiki/Black_hole_(networking)).
46pub const URI_SCHEME_NULL: &'static str = "null";
47
48/// A fake hostname representing the "all CoAP devices" multicast addresses, or
49/// the equivalent for a given network layer.
50///
51/// Note that the value of this string has been chosen somewhat arbitrarily and
52/// is unlikely to be supported outside of this library. The trailing "dot" is to
53/// ensure that it can never be interpreted as a partial domain name.
54pub const ALL_COAP_DEVICES_HOSTNAME: &'static str = "all-coap-devices.";
55
56/// Value for `OptionNumber::OBSERVE` when registering an observer.
57///
58/// Note that this is only for requests, replies have entirely different semantics.
59///
60/// Defined by [IETF-RFC7641](https://tools.ietf.org/html/rfc7641).
61pub const OBSERVE_REGISTER: u32 = 0;
62
63/// Value for `OptionNumber::OBSERVE` when deregistering an observer.
64///
65/// Note that this is only for requests, replies have entirely different semantics.
66///
67/// Defined by [IETF-RFC7641](https://tools.ietf.org/html/rfc7641).
68pub const OBSERVE_DEREGISTER: u32 = 1;
69
70/// Value for `OptionNumber::NO_RESPONSE` when "Not interested in 2.xx responses".
71/// From [RFC7967](https://tools.ietf.org/html/rfc7967).
72pub const NO_RESPONSE_SUCCESS: u8 = 0b00000010;
73
74/// Value for `OptionNumber::NO_RESPONSE` when "Not interested in 4.xx responses".
75/// From [RFC7967](https://tools.ietf.org/html/rfc7967).
76pub const NO_RESPONSE_CLIENT_ERROR: u8 = 0b00001000;
77
78/// Value for `OptionNumber::NO_RESPONSE` when "Not interested in 5.xx responses".
79/// From [RFC7967](https://tools.ietf.org/html/rfc7967).
80pub const NO_RESPONSE_SERVER_ERROR: u8 = 0b00010000;
81
82/// Value for `OptionNumber::NO_RESPONSE` when not interested in any response.
83/// From [RFC7967](https://tools.ietf.org/html/rfc7967).
84pub const NO_RESPONSE_ANY: u8 = 0;
85
86/// Value for `OptionNumber::NO_RESPONSE` when not interested in any error response.
87/// From [RFC7967](https://tools.ietf.org/html/rfc7967).
88pub const NO_RESPONSE_ERROR: u8 = NO_RESPONSE_CLIENT_ERROR | NO_RESPONSE_SERVER_ERROR;