line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
#include |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
using namespace xs; |
6
|
|
|
|
|
|
|
using namespace xs::exp; |
7
|
|
|
|
|
|
|
using namespace panda::net; |
8
|
|
|
|
|
|
|
using panda::string; |
9
|
|
|
|
|
|
|
using panda::string_view; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
template |
12
|
70
|
|
|
|
|
|
static inline string_view addr2sv (const T& addr) { return string_view((const char*)&addr, sizeof(T)); } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
MODULE = Net::SockAddr PACKAGE = Net::SockAddr |
15
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
BOOT { |
18
|
10
|
50
|
|
|
|
|
Stash me(__PACKAGE__); |
19
|
5
|
50
|
|
|
|
|
Stash("Net::SockAddr::Inet4", GV_ADD).inherit(me); |
|
|
50
|
|
|
|
|
|
20
|
5
|
50
|
|
|
|
|
Stash("Net::SockAddr::Inet6", GV_ADD).inherit(me); |
|
|
50
|
|
|
|
|
|
21
|
5
|
50
|
|
|
|
|
Stash("Net::SockAddr::Unix", GV_ADD).inherit(me); |
|
|
50
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
135
|
50
|
|
|
|
|
create_constants(me, { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
24
|
|
|
|
|
|
|
{"AF_UNSPEC", AF_UNSPEC}, |
25
|
|
|
|
|
|
|
{"AF_INET", AF_INET }, |
26
|
|
|
|
|
|
|
{"AF_INET6", AF_INET6 }, |
27
|
|
|
|
|
|
|
#ifndef _WIN32 |
28
|
|
|
|
|
|
|
{"AF_UNIX", AF_UNIX }, |
29
|
5
|
|
|
|
|
|
#endif |
30
|
5
|
|
|
|
|
|
|
31
|
5
|
|
|
|
|
|
{"INADDR_ANY", Simple(addr2sv(SockAddr::Inet4::addr_any)) }, |
32
|
5
|
|
|
|
|
|
{"INADDR_LOOPBACK", Simple(addr2sv(SockAddr::Inet4::addr_loopback)) }, |
33
|
5
|
|
|
|
|
|
{"INADDR_BROADCAST", Simple(addr2sv(SockAddr::Inet4::addr_broadcast)) }, |
34
|
5
|
|
|
|
|
|
{"INADDR_NONE", Simple(addr2sv(SockAddr::Inet4::addr_none)) }, |
35
|
10
|
50
|
|
|
|
|
{"IN6ADDR_ANY", Simple(addr2sv(SockAddr::Inet6::addr_any)) }, |
36
|
10
|
50
|
|
|
|
|
{"IN6ADDR_LOOPBACK", Simple(addr2sv(SockAddr::Inet6::addr_loopback)) }, |
37
|
10
|
50
|
|
|
|
|
{"SOCKADDR_ANY", xs::out(SockAddr::Inet4::sockaddr_any) }, |
38
|
10
|
50
|
|
|
|
|
{"SOCKADDR_LOOPBACK", xs::out(SockAddr::Inet4::sockaddr_loopback) }, |
39
|
75
|
50
|
|
|
|
|
{"SOCKADDR6_ANY", xs::out(SockAddr::Inet6::sockaddr_any) }, |
40
|
5
|
50
|
|
|
|
|
{"SOCKADDR6_LOOPBACK", xs::out(SockAddr::Inet6::sockaddr_loopback) } |
|
|
50
|
|
|
|
|
|
41
|
|
|
|
|
|
|
}); |
42
|
|
|
|
|
|
|
autoexport(me); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
SockAddr SockAddr::new (SockAddr oth) { |
46
|
10
|
|
|
|
|
|
RETVAL = oth; |
47
|
5
|
50
|
|
|
|
|
} |
48
|
5
|
50
|
|
|
|
|
|
49
|
6
|
|
|
|
|
|
sa_family_t SockAddr::family () |
50
|
3
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
|
bool SockAddr::is_inet4 () |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
|
bool SockAddr::is_inet6 () |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#ifndef _WIN32 |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
|
bool SockAddr::is_unix () |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#endif |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
string_view SockAddr::get () { |
62
|
8
|
50
|
|
|
|
|
if (THIS->family() == AF_UNSPEC) XSRETURN_UNDEF; |
63
|
4
|
50
|
|
|
|
|
RETVAL = string_view((const char*)THIS->get(), THIS->length()); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
std::string SockAddr::_to_string (...) { |
67
|
6
|
50
|
|
|
|
|
std::ostringstream os; |
68
|
3
|
50
|
|
|
|
|
os << *THIS; |
69
|
3
|
50
|
|
|
|
|
RETVAL = os.str(); |
|
|
50
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
7
|
50
|
|
|
|
|
bool SockAddr::_eq (SockAddr oth, ...) { RETVAL = *THIS == oth; } |
73
|
|
|
|
|
|
|
|
74
|
3
|
50
|
|
|
|
|
bool SockAddr::_ne (SockAddr oth, ...) { RETVAL = *THIS != oth; } |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
MODULE = Net::SockAddr PACKAGE = Net::SockAddr::Inet4 |
77
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
SockAddr from_addr (string_view addr, uint16_t port) { |
80
|
6
|
|
|
|
|
|
if (addr.length() != sizeof(in_addr)) throw "invalid ip4 addr"; |
81
|
3
|
50
|
|
|
|
|
RETVAL = SockAddr::Inet4(*(const in_addr*)addr.data(), port); |
82
|
3
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
SockAddr new (SV*, string_view ip, uint16_t port) { |
85
|
20
|
|
|
|
|
|
RETVAL = SockAddr::Inet4(ip, port); |
86
|
10
|
100
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
string SockAddr::ip () { |
89
|
4
|
50
|
|
|
|
|
RETVAL = THIS->as_inet4().ip(); |
|
|
50
|
|
|
|
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
uint16_t SockAddr::port () { |
93
|
4
|
|
|
|
|
|
RETVAL = THIS->as_inet4().port(); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
string_view SockAddr::addr () { |
97
|
3
|
|
|
|
|
|
RETVAL = addr2sv(THIS->as_inet4().addr()); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
MODULE = Net::SockAddr PACKAGE = Net::SockAddr::Inet6 |
102
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
SockAddr from_addr (string_view addr, uint16_t port, uint32_t scope_id = 0, uint32_t flow_info = 0) { |
105
|
6
|
|
|
|
|
|
if (addr.length() != sizeof(in6_addr)) throw "invalid ip6 addr"; |
106
|
3
|
50
|
|
|
|
|
RETVAL = SockAddr::Inet6(*(const in6_addr*)addr.data(), port, scope_id, flow_info); |
107
|
3
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
SockAddr new (SV*, string_view ip, uint16_t port, uint32_t scope_id = 0, uint32_t flow_info = 0) { |
110
|
10
|
|
|
|
|
|
RETVAL = SockAddr::Inet6(ip, port, scope_id, flow_info); |
111
|
5
|
100
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
string SockAddr::ip () { |
114
|
3
|
50
|
|
|
|
|
RETVAL = THIS->as_inet6().ip(); |
|
|
50
|
|
|
|
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
uint16_t SockAddr::port () { |
118
|
3
|
|
|
|
|
|
RETVAL = THIS->as_inet6().port(); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
uint32_t SockAddr::scope_id () { |
122
|
3
|
|
|
|
|
|
RETVAL = THIS->as_inet6().scope_id(); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
uint32_t SockAddr::flowinfo () { |
126
|
3
|
|
|
|
|
|
RETVAL = THIS->as_inet6().flowinfo(); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
string_view SockAddr::addr () { |
130
|
2
|
|
|
|
|
|
RETVAL = addr2sv(THIS->as_inet6().addr()); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
MODULE = Net::SockAddr PACKAGE = Net::SockAddr::Unix |
135
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
#ifndef _WIN32 |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
SockAddr new (SV*, string_view path) { |
140
|
6
|
|
|
|
|
|
RETVAL = SockAddr::Unix(path); |
141
|
3
|
100
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
string_view SockAddr::path () { |
144
|
3
|
|
|
|
|
|
RETVAL = THIS->as_unix().path(); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
#endif |