34
34
struct ShowNet: public ShowCont
40
39
int showMain(int event, Event * e)
42
41
CHECK_SHOW(begin("Net"));
43
42
CHECK_SHOW(show("<H3>Show <A HREF=\"./connections\">Connections</A></H3>\n"
44
"<H3>Show <A HREF=\"./threads\">Net Threads</A></H3>\n"
43
//"<H3>Show <A HREF=\"./threads\">Net Threads</A></H3>\n"
45
44
"<form method = GET action = \"./ips\">\n"
46
45
"Show Connections to/from IP (e.g. 127.0.0.1):<br>\n"
47
46
"<input type=text name=ip size=64 maxlength=256>\n"
65
64
ink_hrtime now = ink_get_hrtime();
66
65
forl_LL(UnixNetVConnection, vc, nh->open_list) {
67
if (ip && ip != vc->ip)
69
if (port && port != vc->port && port != vc->accept_port)
72
snprintf(ipbuf, sizeof(ipbuf), "%hhu.%hhu.%hhu.%hhu", PRINT_IP(vc->ip));
66
// uint16_t port = ats_ip_port_host_order(&addr.sa);
67
if (ats_is_ip(&addr) && addr != vc->server_addr)
69
// if (port && port != ats_ip_port_host_order(&vc->server_addr.sa) && port != vc->accept_port)
71
char ipbuf[INET6_ADDRSTRLEN];
72
ats_ip_ntop(&vc->server_addr.sa, ipbuf, sizeof(ipbuf));
73
char opt_ipbuf[INET6_ADDRSTRLEN];
74
snprintf(interbuf, sizeof(interbuf), "[%s] %hhu.%hhu.%hhu.%hhu", vc->options.toString(vc->options.addr_binding), PRINT_IP(vc->options.local_addr));
75
snprintf(interbuf, sizeof(interbuf), "[%s] %s:%d",
76
vc->options.toString(vc->options.addr_binding),
77
vc->options.local_ip.toString(opt_ipbuf, sizeof(opt_ipbuf)),
78
vc->options.local_port
75
80
CHECK_SHOW(show("<tr>"
76
// "<td><a href=\"/connection/%d\">%d</a></td>"
81
//"<td><a href=\"/connection/%d\">%d</a></td>"
77
82
"<td>%d</td>" // ID
78
83
"<td>%s</td>" // ipbuf
79
84
"<td>%d</td>" // port
80
85
"<td>%d</td>" // fd
81
86
"<td>%s</td>" // interbuf
82
"<td>%d</td>" // accept port
87
// "<td>%d</td>" // accept port
83
88
"<td>%d secs ago</td>" // start time
84
89
"<td>%d</td>" // thread id
85
90
"<td>%d</td>" // read enabled
86
"<td>%d</td>" // read NBytes
87
"<td>%d</td>" // read NDone
91
"<td>%" PRId64 "</td>" // read NBytes
92
"<td>%" PRId64 "</td>" // read NDone
88
93
"<td>%d</td>" // write enabled
89
"<td>%d</td>" // write nbytes
90
"<td>%d</td>" // write ndone
94
"<td>%" PRId64 "</td>" // write nbytes
95
"<td>%" PRId64 "</td>" // write ndone
91
96
"<td>%d secs</td>" // Inactivity timeout at
92
97
"<td>%d secs</td>" // Activity timeout at
93
98
"<td>%d</td>" // shutdown
202
207
ShowNet(Continuation * c, HTTPHdr * h):
203
ShowCont(c, h), ithread(0), port(0), ip(0) {
208
ShowCont(c, h), ithread(0) {
209
memset(&addr, 0, sizeof(addr));
204
210
SET_HANDLER(&ShowNet::showMain);
222
228
} else if (STREQ_PREFIX(path, path_len, "ips")) {
224
230
const char *query = h->url_get()->query_get(&query_len);
225
s->sarg = xstrndup(query, query_len);
231
s->sarg = ats_strndup(query, query_len);
228
234
gn = (char *)memchr(s->sarg, '=', strlen(s->sarg));
230
s->ip = ink_inet_addr(gn + 1);
236
ats_ip_pton(gn + 1, &s->addr);
231
237
SET_CONTINUATION_HANDLER(s, &ShowNet::showConnections);
232
238
} else if (STREQ_PREFIX(path, path_len, "ports")) {
234
240
const char *query = h->url_get()->query_get(&query_len);
235
s->sarg = xstrndup(query, query_len);
241
s->sarg = ats_strndup(query, query_len);
238
244
gn = (char *)memchr(s->sarg, '=', strlen(s->sarg));
240
s->port = atoi(gn + 1);
246
ats_ip_port_cast(&s->addr.sa) = htons(atoi(gn+1));
241
247
SET_CONTINUATION_HANDLER(s, &ShowNet::showConnections);
243
249
eventProcessor.schedule_imm(s, ET_TASK);