~ubuntu-branches/ubuntu/wily/trafficserver/wily

« back to all changes in this revision

Viewing changes to iocore/net/UnixNetPages.cc

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2012-12-17 22:28:16 UTC
  • mfrom: (5.1.8 raring-proposed)
  • Revision ID: package-import@ubuntu.com-20121217222816-7xwjsx5k76zkb63d
Tags: 3.2.0-1ubuntu1
* Revert FreeBSD strerror_r() fixes that give errors with glibc 2.16.
* Apply patch from Konstantinos Margaritis to define barriers on ARM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
struct ShowNet: public ShowCont
35
35
{
36
36
  int ithread;
37
 
  int port;
38
 
  unsigned int ip;
 
37
  IpEndpoint addr;
39
38
 
40
39
  int showMain(int event, Event * e)
41
40
  {
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"
64
63
 
65
64
    ink_hrtime now = ink_get_hrtime();
66
65
    forl_LL(UnixNetVConnection, vc, nh->open_list) {
67
 
      if (ip && ip != vc->ip)
68
 
        continue;
69
 
      if (port && port != vc->port && port != vc->accept_port)
70
 
        continue;
71
 
      char ipbuf[80];
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)
 
68
        continue;
 
69
//      if (port && port != ats_ip_port_host_order(&vc->server_addr.sa) && port != vc->accept_port)
 
70
//        continue;
 
71
      char ipbuf[INET6_ADDRSTRLEN];
 
72
      ats_ip_ntop(&vc->server_addr.sa, ipbuf, sizeof(ipbuf));
 
73
      char opt_ipbuf[INET6_ADDRSTRLEN];
73
74
      char interbuf[80];
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
 
79
      );
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
95
100
                      "</tr>\n",
96
101
                      vc->id,
97
102
                      ipbuf,
98
 
                      vc->port,
 
103
                      ats_ip_port_host_order(&vc->server_addr),
99
104
                      vc->con.fd,
100
105
                      interbuf,
101
 
                      vc->accept_port,
 
106
//                      vc->accept_port,
102
107
                      (int) ((now - vc->submit_time) / HRTIME_SECOND),
103
108
                      ethread->id,
104
109
                      vc->read.enabled,
200
205
  }
201
206
 
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);
205
211
  }
206
212
};
222
228
  } else if (STREQ_PREFIX(path, path_len, "ips")) {
223
229
    int query_len;
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);
226
232
    char *gn = NULL;
227
233
    if (s->sarg)
228
234
      gn = (char *)memchr(s->sarg, '=', strlen(s->sarg));
229
235
    if (gn)
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")) {
233
239
    int query_len;
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);
236
242
    char *gn = NULL;
237
243
    if (s->sarg)
238
244
      gn = (char *)memchr(s->sarg, '=', strlen(s->sarg));
239
245
    if (gn)
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);
242
248
  }
243
249
  eventProcessor.schedule_imm(s, ET_TASK);