stun_rs/attributes/discovery/
response_origin.rs1use crate::attributes::address_port::{address_port_attribute, address_port_tests};
2use crate::{Decode, Encode};
3
4const RESPONSE_ORIGIN: u16 = 0x802b;
5
6address_port_attribute!(
7 ResponseOrigin,
23 RESPONSE_ORIGIN
24);
25
26address_port_tests!(ResponseOrigin, super);
27
28#[cfg(test)]
29mod tests {
30 use super::*;
31 use crate::StunAttribute;
32 use std::net::{IpAddr, Ipv4Addr, SocketAddr};
33
34 #[test]
35 fn response_origin_server_stunt_attribute() {
36 let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
37 let attr = StunAttribute::ResponseOrigin(ResponseOrigin::from(socket));
38 assert!(attr.is_response_origin());
39 assert!(attr.as_response_origin().is_ok());
40 assert!(attr.as_error_code().is_err());
41
42 assert!(!attr.attribute_type().is_comprehension_required());
43 assert!(attr.attribute_type().is_comprehension_optional());
44
45 let dbg_fmt = format!("{:?}", attr);
46 assert_eq!("ResponseOrigin(ResponseOrigin(127.0.0.1:8080))", dbg_fmt);
47 }
48}