diff --git a/libcoap/src/message/mod.rs b/libcoap/src/message/mod.rs index 048d030..fbcc45e 100644 --- a/libcoap/src/message/mod.rs +++ b/libcoap/src/message/mod.rs @@ -29,7 +29,6 @@ use libcoap_sys::{ pub use request::CoapRequest; pub use response::CoapResponse; -use crate::types::{decode_var_len_u16, decode_var_len_u32, decode_var_len_u8, encode_var_len_u16, encode_var_len_u32, encode_var_len_u8}; use crate::{ error::{MessageConversionError, OptionValueError}, protocol::{ @@ -39,7 +38,11 @@ use crate::{ session::CoapSessionCommon, types::CoapMessageId, }; -use crate::protocol::{Echo, OsCore, RequestTag}; +use crate::protocol::{Echo, Oscore, RequestTag}; +use crate::types::{ + decode_var_len_u16, decode_var_len_u32, decode_var_len_u8, encode_var_len_u16, encode_var_len_u32, + encode_var_len_u8, +}; pub mod request; pub mod response; @@ -72,7 +75,7 @@ pub enum CoapOption { MaxAge(MaxAge), Observe(Observe), Other(CoapOptionNum, Box<[u8]>), - OsCore(OsCore), + Oscore(Oscore), Echo(Echo), RTag(RequestTag), QBlock1(Block), @@ -126,13 +129,15 @@ impl CoapOption { CoapOptionType::Block1 => Ok(CoapOption::Block1(decode_var_len_u32(value.as_slice()))), CoapOptionType::Block2 => Ok(CoapOption::Block2(decode_var_len_u32(value.as_slice()))), CoapOptionType::HopLimit => Ok(CoapOption::HopLimit(decode_var_len_u16(value.as_slice()))), - CoapOptionType::NoResponse => Ok(CoapOption::NoResponse(decode_var_len_u8(value.as_slice()) as NoResponse)), + CoapOptionType::NoResponse => { + Ok(CoapOption::NoResponse(decode_var_len_u8(value.as_slice()) as NoResponse)) + }, CoapOptionType::Observe => Ok(CoapOption::Observe(decode_var_len_u32(value.as_slice()))), - CoapOptionType::OsCore => Ok(CoapOption::OsCore(value.into_boxed_slice())), - CoapOptionType::Echo => Ok(CoapOption::Echo(value.into_boxed_slice())), + CoapOptionType::Oscore => Ok(CoapOption::Oscore(value.into_boxed_slice())), + CoapOptionType::Echo => Ok(CoapOption::Echo(value.into_boxed_slice())), CoapOptionType::RTag => Ok(CoapOption::RTag(value.into_boxed_slice())), CoapOptionType::QBlock1 => Ok(CoapOption::QBlock1(decode_var_len_u32(value.as_slice()))), - CoapOptionType::QBlock2 => Ok(CoapOption::QBlock2(decode_var_len_u32(value.as_slice()))) + CoapOptionType::QBlock2 => Ok(CoapOption::QBlock2(decode_var_len_u32(value.as_slice()))), } }, _ => Ok(CoapOption::Other(number, value.into_boxed_slice())), @@ -163,7 +168,7 @@ impl CoapOption { CoapOption::ETag(_) => CoapOptionType::ETag as u16, CoapOption::MaxAge(_) => CoapOptionType::MaxAge as u16, CoapOption::Observe(_) => CoapOptionType::Observe as u16, - CoapOption::OsCore(_) => CoapOptionType::OsCore as u16, + CoapOption::Oscore(_) => CoapOptionType::Oscore as u16, CoapOption::Echo(_) => CoapOptionType::Echo as u16, CoapOption::RTag(_) => CoapOptionType::RTag as u16, CoapOption::QBlock1(_) => CoapOptionType::QBlock1 as u16, @@ -201,7 +206,7 @@ impl CoapOption { CoapOption::MaxAge(value) => encode_var_len_u32(value), CoapOption::Observe(value) => encode_var_len_u32(value), CoapOption::Other(_num, data) => data, - CoapOption::OsCore(value) => value, + CoapOption::Oscore(value) => value, CoapOption::Echo(value) => value, CoapOption::RTag(value) => value, CoapOption::QBlock1(value) => encode_var_len_u32(value), diff --git a/libcoap/src/message/request.rs b/libcoap/src/message/request.rs index 41e3ca9..f3acdda 100644 --- a/libcoap/src/message/request.rs +++ b/libcoap/src/message/request.rs @@ -470,8 +470,8 @@ impl CoapRequest { )); }, // libcoap handles blockwise transfer for us (for now). - CoapOption::QBlock1(_) => {} - CoapOption::QBlock2(_) => {} + CoapOption::QBlock1(_) => {}, + CoapOption::QBlock2(_) => {}, CoapOption::HopLimit(value) => { if hop_limit.is_some() { return Err(MessageConversionError::NonRepeatableOptionRepeated( @@ -508,14 +508,13 @@ impl CoapRequest { observe = Some(*value); }, // Handling of echo options is automatically done by libcoap (see man coap_send) - CoapOption::Echo(_) => { - }, + CoapOption::Echo(_) => {}, // Handling of request tag options is automatically done by libcoap (see man // coap_send) CoapOption::RTag(_) => {}, // OSCORE is currently not supported, and even if it should probably be handled by // libcoap, so I'm unsure whether we have to expose this. - CoapOption::OsCore(v) => {}, + CoapOption::Oscore(v) => {}, // TODO maybe we can save some copies here if we use into_iter for the options instead. CoapOption::Other(n, v) => { additional_opts.push(CoapOption::Other(*n, v.clone())); diff --git a/libcoap/src/message/response.rs b/libcoap/src/message/response.rs index 7f1ae51..2f75f7b 100644 --- a/libcoap/src/message/response.rs +++ b/libcoap/src/message/response.rs @@ -7,12 +7,15 @@ * See the README as well as the LICENSE file for more information. */ +use std::fmt::Display; +use std::fmt::Formatter; + use crate::error::{MessageConversionError, MessageTypeError, OptionValueError}; use crate::message::{CoapMessage, CoapMessageCommon, CoapOption}; -use crate::protocol::{CoapMessageCode, CoapMessageType, CoapOptionType, CoapResponseCode, ContentFormat, Echo, ETag, MaxAge, Observe}; +use crate::protocol::{ + CoapMessageCode, CoapMessageType, CoapOptionType, CoapResponseCode, ContentFormat, Echo, ETag, MaxAge, Observe, +}; use crate::types::CoapUri; -use std::fmt::Display; -use std::fmt::Formatter; /// Internal representation of a CoAP URI that can be used as a response location. #[derive(Clone, Debug, Eq, PartialEq, Hash)] @@ -350,11 +353,9 @@ impl CoapResponse { CoapOptionType::NoResponse, )); }, - CoapOption::Other(n, v) => additional_opts.push(CoapOption::Other(*n, v.clone())), // Handling of echo options is automatically done by libcoap (see man coap_send) CoapOption::Echo(v) => { - if echo.is_some() { return Err(MessageConversionError::NonRepeatableOptionRepeated( CoapOptionType::Echo, @@ -367,7 +368,8 @@ impl CoapResponse { CoapOption::RTag(_) => {}, // OSCORE is currently not supported, and even if it should probably be handled by // libcoap, so I'm unsure whether we have to expose this. - CoapOption::OsCore(_) => {}, + CoapOption::Oscore(_) => {}, + CoapOption::Other(n, v) => additional_opts.push(CoapOption::Other(*n, v.clone())), } } let location = if location_path.is_some() || location_query.is_some() { diff --git a/libcoap/src/protocol.rs b/libcoap/src/protocol.rs index fb3e8b8..1811d4e 100644 --- a/libcoap/src/protocol.rs +++ b/libcoap/src/protocol.rs @@ -17,7 +17,28 @@ use std::{ use num_derive::FromPrimitive; use num_traits::FromPrimitive; -use libcoap_sys::{coap_option_num_t, coap_pdu_code_t, coap_pdu_type_t, coap_pdu_type_t::{COAP_MESSAGE_ACK, COAP_MESSAGE_CON, COAP_MESSAGE_NON, COAP_MESSAGE_RST}, coap_request_t, coap_response_phrase, COAP_MEDIATYPE_APPLICATION_CBOR, COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT, COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0, COAP_MEDIATYPE_APPLICATION_COSE_KEY, COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET, COAP_MEDIATYPE_APPLICATION_COSE_MAC, COAP_MEDIATYPE_APPLICATION_COSE_MAC0, COAP_MEDIATYPE_APPLICATION_COSE_SIGN, COAP_MEDIATYPE_APPLICATION_COSE_SIGN1, COAP_MEDIATYPE_APPLICATION_CWT, COAP_MEDIATYPE_APPLICATION_DOTS_CBOR, COAP_MEDIATYPE_APPLICATION_EXI, COAP_MEDIATYPE_APPLICATION_JSON, COAP_MEDIATYPE_APPLICATION_LINK_FORMAT, COAP_MEDIATYPE_APPLICATION_OCTET_STREAM, COAP_MEDIATYPE_APPLICATION_RDF_XML, COAP_MEDIATYPE_APPLICATION_SENML_CBOR, COAP_MEDIATYPE_APPLICATION_SENML_EXI, COAP_MEDIATYPE_APPLICATION_SENML_JSON, COAP_MEDIATYPE_APPLICATION_SENML_XML, COAP_MEDIATYPE_APPLICATION_SENSML_CBOR, COAP_MEDIATYPE_APPLICATION_SENSML_EXI, COAP_MEDIATYPE_APPLICATION_SENSML_JSON, COAP_MEDIATYPE_APPLICATION_SENSML_XML, COAP_MEDIATYPE_APPLICATION_XML, COAP_MEDIATYPE_TEXT_PLAIN, COAP_OPTION_ACCEPT, COAP_OPTION_BLOCK1, COAP_OPTION_BLOCK2, COAP_OPTION_CONTENT_FORMAT, COAP_OPTION_ETAG, COAP_OPTION_HOP_LIMIT, COAP_OPTION_IF_MATCH, COAP_OPTION_IF_NONE_MATCH, COAP_OPTION_LOCATION_PATH, COAP_OPTION_LOCATION_QUERY, COAP_OPTION_MAXAGE, COAP_OPTION_NORESPONSE, COAP_OPTION_OBSERVE, COAP_OPTION_PROXY_SCHEME, COAP_OPTION_PROXY_URI, COAP_OPTION_SIZE1, COAP_OPTION_SIZE2, COAP_OPTION_URI_HOST, COAP_OPTION_URI_PATH, COAP_OPTION_URI_PORT, COAP_OPTION_URI_QUERY, COAP_OPTION_OSCORE, COAP_OPTION_Q_BLOCK1, COAP_OPTION_Q_BLOCK2, COAP_OPTION_RTAG, COAP_OPTION_ECHO, COAP_MEDIATYPE_APPLICATION_ACE_CBOR, COAP_MEDIATYPE_APPLICATION_COAP_GROUP_JSON, COAP_MEDIATYPE_APPLICATION_MB_CBOR_SEQ, COAP_MEDIATYPE_APPLICATION_OSCORE}; +use libcoap_sys::{ + COAP_MEDIATYPE_APPLICATION_ACE_CBOR, COAP_MEDIATYPE_APPLICATION_CBOR, COAP_MEDIATYPE_APPLICATION_COAP_GROUP_JSON, + COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT, + COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0, COAP_MEDIATYPE_APPLICATION_COSE_KEY, COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET, COAP_MEDIATYPE_APPLICATION_COSE_MAC, + COAP_MEDIATYPE_APPLICATION_COSE_MAC0, COAP_MEDIATYPE_APPLICATION_COSE_SIGN, + COAP_MEDIATYPE_APPLICATION_COSE_SIGN1, COAP_MEDIATYPE_APPLICATION_CWT, + COAP_MEDIATYPE_APPLICATION_DOTS_CBOR, COAP_MEDIATYPE_APPLICATION_EXI, COAP_MEDIATYPE_APPLICATION_JSON, + COAP_MEDIATYPE_APPLICATION_LINK_FORMAT, COAP_MEDIATYPE_APPLICATION_MB_CBOR_SEQ, COAP_MEDIATYPE_APPLICATION_OCTET_STREAM, + COAP_MEDIATYPE_APPLICATION_OSCORE, COAP_MEDIATYPE_APPLICATION_RDF_XML, COAP_MEDIATYPE_APPLICATION_SENML_CBOR, + COAP_MEDIATYPE_APPLICATION_SENML_EXI, COAP_MEDIATYPE_APPLICATION_SENML_JSON, + COAP_MEDIATYPE_APPLICATION_SENML_XML, COAP_MEDIATYPE_APPLICATION_SENSML_CBOR, COAP_MEDIATYPE_APPLICATION_SENSML_EXI, + COAP_MEDIATYPE_APPLICATION_SENSML_JSON, COAP_MEDIATYPE_APPLICATION_SENSML_XML, COAP_MEDIATYPE_APPLICATION_XML, + COAP_MEDIATYPE_TEXT_PLAIN, COAP_OPTION_ACCEPT, + COAP_OPTION_BLOCK1, COAP_OPTION_BLOCK2, + COAP_OPTION_CONTENT_FORMAT, COAP_OPTION_ECHO, COAP_OPTION_ETAG, + COAP_OPTION_HOP_LIMIT, COAP_OPTION_IF_MATCH, COAP_OPTION_IF_NONE_MATCH, COAP_OPTION_LOCATION_PATH, COAP_OPTION_LOCATION_QUERY, + COAP_OPTION_MAXAGE, COAP_OPTION_NORESPONSE, coap_option_num_t, COAP_OPTION_OBSERVE, + COAP_OPTION_OSCORE, COAP_OPTION_PROXY_SCHEME, COAP_OPTION_PROXY_URI, COAP_OPTION_Q_BLOCK1, + COAP_OPTION_Q_BLOCK2, COAP_OPTION_RTAG, COAP_OPTION_SIZE1, COAP_OPTION_SIZE2, COAP_OPTION_URI_HOST, + COAP_OPTION_URI_PATH, COAP_OPTION_URI_PORT, COAP_OPTION_URI_QUERY, coap_pdu_code_t, coap_pdu_type_t, + coap_pdu_type_t::{COAP_MESSAGE_ACK, COAP_MESSAGE_CON, COAP_MESSAGE_NON, COAP_MESSAGE_RST}, coap_request_t, coap_response_phrase, +}; use crate::error::{MessageCodeError, UnknownOptionError}; @@ -38,7 +59,7 @@ pub type HopLimit = u16; pub type NoResponse = u8; pub type Observe = u32; // TODO actually parse this option (for OSCORE support) -pub type OsCore = Box<[u8]>; +pub type Oscore = Box<[u8]>; pub type Echo = Box<[u8]>; pub type RequestTag = Box<[u8]>; @@ -73,10 +94,14 @@ pub enum CoapOptionType { ETag = COAP_OPTION_ETAG as u16, /// If-None-Match option ([RFC 7252, Section 5.10.8.2](https://datatracker.ietf.org/doc/html/rfc7252#section-5.10.8.2)). IfNoneMatch = COAP_OPTION_IF_NONE_MATCH as u16, + /// Observe option ([RFC 7641, Section 2](https://datatracker.ietf.org/doc/html/rfc7641#section-2)). + Observe = COAP_OPTION_OBSERVE as u16, /// Uri-Port option ([RFC 7252, Section 5.10.1](https://datatracker.ietf.org/doc/html/rfc7252#section-5.10.1)). UriPort = COAP_OPTION_URI_PORT as u16, /// Location-Path option ([RFC 7252, Section 5.10.7](https://datatracker.ietf.org/doc/html/rfc7252#section-5.10.7)). LocationPath = COAP_OPTION_LOCATION_PATH as u16, + /// OSCORE option ([RFC 8613, Section 2](https://datatracker.ietf.org/doc/html/rfc8613#section-2). + Oscore = COAP_OPTION_OSCORE as u16, /// Uri-Path option ([RFC 7252, Section 5.10.1](https://datatracker.ietf.org/doc/html/rfc7252#section-5.10.1)). UriPath = COAP_OPTION_URI_PATH as u16, /// Content-Format option ([RFC 7252, Section 5.10.3](https://datatracker.ietf.org/doc/html/rfc7252#section-5.10.3)). @@ -85,38 +110,34 @@ pub enum CoapOptionType { MaxAge = COAP_OPTION_MAXAGE as u16, /// Uri-Query option ([RFC 7252, Section 5.10.1](https://datatracker.ietf.org/doc/html/rfc7252#section-5.10.1)). UriQuery = COAP_OPTION_URI_QUERY as u16, + /// Hop-Limit option ([RFC 8768, Section 3](https://datatracker.ietf.org/doc/html/rfc8768#section-3)). + HopLimit = COAP_OPTION_HOP_LIMIT as u16, /// Accept option ([RFC 7252, Section 5.10.4](https://datatracker.ietf.org/doc/html/rfc7252#section-5.10.4)). Accept = COAP_OPTION_ACCEPT as u16, + /// Q-Block1 option ([RFC 9177, Section 4](https://datatracker.ietf.org/doc/html/rfc9177#section-4)). + QBlock1 = COAP_OPTION_Q_BLOCK1 as u16, /// Location-Query option ([RFC 7252, Section 5.10.7](https://datatracker.ietf.org/doc/html/rfc7252#section-5.10.7)). LocationQuery = COAP_OPTION_LOCATION_QUERY as u16, + /// Block2 option ([RFC 7959, Section 2.1](https://datatracker.ietf.org/doc/html/rfc7959#section-2.1)). + Block2 = COAP_OPTION_BLOCK2 as u16, + /// Block1 option ([RFC 7959, Section 2.1](https://datatracker.ietf.org/doc/html/rfc7959#section-2.1)). + Block1 = COAP_OPTION_BLOCK1 as u16, + /// Size2 option ([RFC 7959, Section 4](https://datatracker.ietf.org/doc/html/rfc7959#section-4)). + Size2 = COAP_OPTION_SIZE2 as u16, + /// Q-Block2 option ([RFC 9177, Section 4](https://datatracker.ietf.org/doc/html/rfc9177#section-4)). + QBlock2 = COAP_OPTION_Q_BLOCK2 as u16, /// Proxy-Uri option ([RFC 7252, Section 5.10.2](https://datatracker.ietf.org/doc/html/rfc7252#section-5.10.2)). ProxyUri = COAP_OPTION_PROXY_URI as u16, /// Proxy-Scheme option ([RFC 7252, Section 5.10.2](https://datatracker.ietf.org/doc/html/rfc7252#section-5.10.2)). ProxyScheme = COAP_OPTION_PROXY_SCHEME as u16, - /// Observe option ([RFC 7641, Section 2](https://datatracker.ietf.org/doc/html/rfc7641#section-2)). - Observe = COAP_OPTION_OBSERVE as u16, /// Size1 option ([RFC 7959, Section 4](https://datatracker.ietf.org/doc/html/rfc7959#section-4)). Size1 = COAP_OPTION_SIZE1 as u16, - /// Size2 option ([RFC 7959, Section 4](https://datatracker.ietf.org/doc/html/rfc7959#section-4)). - Size2 = COAP_OPTION_SIZE2 as u16, - /// Block1 option ([RFC 7959, Section 2.1](https://datatracker.ietf.org/doc/html/rfc7959#section-2.1)). - Block1 = COAP_OPTION_BLOCK1 as u16, - /// Block2 option ([RFC 7959, Section 2.1](https://datatracker.ietf.org/doc/html/rfc7959#section-2.1)). - Block2 = COAP_OPTION_BLOCK2 as u16, - /// No-Response option ([RFC 7967, Section 2](https://datatracker.ietf.org/doc/html/rfc7967#section-2)). - NoResponse = COAP_OPTION_NORESPONSE as u16, - /// OSCORE option ([RFC 8613, Section 2](https://datatracker.ietf.org/doc/html/rfc8613#section-2). - OsCore = COAP_OPTION_OSCORE as u16, - /// Hop-Limit option ([RFC 8768, Section 3](https://datatracker.ietf.org/doc/html/rfc8768#section-3)). - HopLimit = COAP_OPTION_HOP_LIMIT as u16, /// Echo option ([RFC 9175, Section 2.2](https://datatracker.ietf.org/doc/html/rfc9175#section-2.2)). Echo = COAP_OPTION_ECHO as u16, + /// No-Response option ([RFC 7967, Section 2](https://datatracker.ietf.org/doc/html/rfc7967#section-2)). + NoResponse = COAP_OPTION_NORESPONSE as u16, /// Request-Tag option ([RFC 9175, Section 3.2](https://datatracker.ietf.org/doc/html/rfc9175#section-3.2)). RTag = COAP_OPTION_RTAG as u16, - /// Q-Block1 option ([RFC 9177, Section 4](https://datatracker.ietf.org/doc/html/rfc9177#section-4)). - QBlock1 = COAP_OPTION_Q_BLOCK1 as u16, - /// Q-Block2 option ([RFC 9177, Section 4](https://datatracker.ietf.org/doc/html/rfc9177#section-4)). - QBlock2 = COAP_OPTION_Q_BLOCK2 as u16, } impl CoapOptionType { @@ -149,7 +170,7 @@ impl CoapOptionType { CoapOptionType::HopLimit => 1, CoapOptionType::NoResponse => 1, CoapOptionType::Observe => 3, - CoapOptionType::OsCore => 255, + CoapOptionType::Oscore => 255, CoapOptionType::Echo => 40, CoapOptionType::RTag => 8, CoapOptionType::QBlock1 => 3, @@ -181,7 +202,7 @@ impl CoapOptionType { CoapOptionType::HopLimit => 1, CoapOptionType::NoResponse => 0, CoapOptionType::Observe => 0, - CoapOptionType::OsCore => 0, + CoapOptionType::Oscore => 0, CoapOptionType::Echo => 1, CoapOptionType::RTag => 0, CoapOptionType::QBlock1 => 0, diff --git a/libcoap/src/types.rs b/libcoap/src/types.rs index 305d296..6b0a2b7 100644 --- a/libcoap/src/types.rs +++ b/libcoap/src/types.rs @@ -9,7 +9,6 @@ //! Types required for conversion between libcoap C library abstractions and Rust types. -use std::fmt::{Display, Formatter}; use std::{ convert::Infallible, fmt::Debug, @@ -20,8 +19,9 @@ use std::{ str::FromStr, vec::Drain, }; +use std::fmt::{Display, Formatter}; -use libc::{c_ushort, in6_addr, in_addr, sa_family_t, sockaddr_in, sockaddr_in6, socklen_t, AF_INET, AF_INET6}; +use libc::{AF_INET, AF_INET6, c_ushort, in6_addr, in_addr, sa_family_t, sockaddr_in, sockaddr_in6, socklen_t}; use num_derive::FromPrimitive; use num_traits::FromPrimitive; use url::{Host, Url}; @@ -29,12 +29,12 @@ use url::{Host, Url}; use libcoap_sys::{ coap_address_t, coap_mid_t, coap_proto_t, coap_proto_t::{COAP_PROTO_DTLS, COAP_PROTO_NONE, COAP_PROTO_TCP, COAP_PROTO_TLS, COAP_PROTO_UDP}, + COAP_URI_SCHEME_SECURE_MASK, coap_uri_scheme_t, coap_uri_scheme_t::{ - COAP_URI_SCHEME_COAP, COAP_URI_SCHEME_COAPS, COAP_URI_SCHEME_COAPS_TCP, COAP_URI_SCHEME_COAP_TCP, + COAP_URI_SCHEME_COAP, COAP_URI_SCHEME_COAP_TCP, COAP_URI_SCHEME_COAPS, COAP_URI_SCHEME_COAPS_TCP, COAP_URI_SCHEME_HTTP, COAP_URI_SCHEME_HTTPS, }, - COAP_URI_SCHEME_SECURE_MASK, }; use crate::error::UriParsingError; @@ -136,7 +136,7 @@ impl From for CoapAddress { target_os = "haiku", target_os = "hurd", target_os = "espidf", - ))] + ))] sin_len: (std::mem::size_of::() as u8), sin_family: AF_INET as sa_family_t, sin_port: addr.port().to_be(), @@ -144,7 +144,7 @@ impl From for CoapAddress { s_addr: u32::from_ne_bytes(addr.ip().octets()), }, sin_zero: Default::default(), - }; + }; CoapAddress(coap_addr) } }, @@ -157,7 +157,7 @@ impl From for CoapAddress { size: std::mem::size_of::() as socklen_t, addr: std::mem::zeroed(), }; - + *coap_addr.addr.sin6.as_mut() = sockaddr_in6 { #[cfg(any( bsd, @@ -165,7 +165,7 @@ impl From for CoapAddress { target_os = "haiku", target_os = "hurd", target_os = "espidf", - ))] + ))] sin6_len: (std::mem::size_of::() as u8), sin6_family: AF_INET6 as sa_family_t, sin6_port: addr.port().to_be(), @@ -175,7 +175,7 @@ impl From for CoapAddress { sin6_flowinfo: addr.flowinfo(), sin6_scope_id: addr.scope_id(), }; - + CoapAddress(coap_addr) } }, @@ -503,7 +503,6 @@ pub(crate) fn encode_var_len_u16(val: u16) -> Box<[u8]> { ret_val.into_boxed_slice() } -// Kept for consistency pub(crate) fn decode_var_len_u8(val: &[u8]) -> u16 { u16::from_be_bytes( convert_to_fixed_size_slice(1, val)[..1]