… | |
… | |
33 | u32 host; |
33 | u32 host; |
34 | u16 port; |
34 | u16 port; |
35 | u8 prot; |
35 | u8 prot; |
36 | u8 pad1; |
36 | u8 pad1; |
37 | |
37 | |
38 | void set (const sockaddr_in *sa, u8 prot_ = PROT_UDPv4); |
38 | void set (const sockaddr_in *sa, u8 prot_); |
39 | void set (const conf_node *conf, u8 prot_ = PROT_UDPv4); |
39 | void set (const conf_node *conf, u8 prot_); |
40 | |
40 | |
41 | operator const char *() const; |
41 | operator const char *() const; |
42 | |
42 | |
43 | const sockaddr *sav4 () const; |
43 | const sockaddr *sav4 () const; |
44 | const socklen_t salenv4 () const |
44 | const socklen_t salenv4 () const |
45 | { return sizeof (sockaddr_in); } |
45 | { return sizeof (sockaddr_in); } |
46 | |
46 | |
47 | const char *ntoa () const; |
47 | const char *ntoa () const; |
48 | |
48 | |
|
|
49 | bool valid () const |
|
|
50 | { return prot != 0 && host != 0; } |
|
|
51 | |
49 | sockinfo() { prot = 0; } |
52 | sockinfo() { prot = 0; } |
50 | |
53 | |
51 | sockinfo(const sockaddr_in &sa, u8 prot_ = PROT_UDPv4) |
54 | sockinfo(const sockaddr_in &sa, u8 prot) |
52 | { set (&sa, prot_); } |
55 | { set (&sa, prot); } |
53 | |
56 | |
54 | sockinfo(const conf_node *conf, u8 prot_ = PROT_UDPv4) |
57 | sockinfo(const conf_node *conf, u8 prot) |
55 | { set (conf, prot_); } |
58 | { set (conf, prot); } |
56 | }; |
59 | }; |
57 | |
60 | |
58 | inline bool |
|
|
59 | operator == (const sockinfo &a, const sockinfo &b) |
61 | bool operator == (const sockinfo &a, const sockinfo &b); |
60 | { |
62 | bool operator < (const sockinfo &a, const sockinfo &b); |
61 | return a.host == b.host && a.port == b.port && a.prot == b.prot; |
|
|
62 | } |
|
|
63 | |
63 | |
64 | #endif |
64 | #endif |
65 | |
65 | |