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