1use std::convert::Into;
2use std::net::IpAddr;
3use std::net::Ipv4Addr;
4use std::net::Ipv6Addr;
5
6pub mod client;
7mod http_helper;
8pub mod service;
9
10#[cfg(test)]
11mod http_helper_test;
12mod socket_helper;
13
14#[derive(PartialEq)]
15pub enum MulticastAddr {
19 V4,
23
24 V6LinkLocal,
28
29 V6SiteLocal,
33
34 Loopback,
38}
39
40impl MulticastAddr {
41 pub fn get_ip(&self) -> IpAddr {
43 match self {
44 MulticastAddr::V4 => self.get_v4().unwrap().into(),
45 MulticastAddr::V6LinkLocal => self.get_v6().unwrap().into(),
46 MulticastAddr::V6SiteLocal => self.get_v6().unwrap().into(),
47 MulticastAddr::Loopback => self.get_v4().unwrap().into(),
48 }
49 }
50
51 pub fn is_v4(&self) -> bool {
53 match self {
54 MulticastAddr::V4 => true,
55 MulticastAddr::V6LinkLocal => false,
56 MulticastAddr::V6SiteLocal => false,
57 MulticastAddr::Loopback => true,
58 }
59 }
60
61 pub fn get_v4(&self) -> Option<Ipv4Addr> {
63 match self {
64 MulticastAddr::V4 => Some(Ipv4Addr::new(239, 255, 255, 250)),
65 MulticastAddr::V6LinkLocal => None,
66 MulticastAddr::V6SiteLocal => None,
67 MulticastAddr::Loopback => Some(Ipv4Addr::new(127, 0, 0, 1)),
68 }
69 }
70
71 pub fn get_v6(&self) -> Option<Ipv6Addr> {
73 match self {
74 MulticastAddr::V4 => None,
75 MulticastAddr::V6LinkLocal => Some(Ipv6Addr::new(0xFF02, 0, 0, 0, 0, 0, 0, 0xC)),
76 MulticastAddr::V6SiteLocal => Some(Ipv6Addr::new(0xFF05, 0, 0, 0, 0, 0, 0, 0xC)),
77 MulticastAddr::Loopback => None,
78 }
79 }
80}
81
82pub(crate) static SSDP_PORT: u16 = 1900;