Use getservbyname() on undetermined ports
This commit is contained in:
parent
7954f504a6
commit
30997471e7
21
ponymap.c
21
ponymap.c
|
@ -1385,6 +1385,17 @@ target_dump_json (struct target *self, struct target_dump_data *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
target_dump_terminal_undetermined (uint16_t port_no, struct node ***tail)
|
||||||
|
{
|
||||||
|
struct servent *serv = getservbyport (ntohs (port_no), "tcp");
|
||||||
|
struct node *port = **tail = node_new (serv
|
||||||
|
? xstrdup_printf ("port %" PRIu16 " (%s)",
|
||||||
|
port_no, serv->s_name)
|
||||||
|
: xstrdup_printf ("port %" PRIu16, port_no));
|
||||||
|
*tail = &port->next;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
target_dump_terminal (struct target *self, struct target_dump_data *data)
|
target_dump_terminal (struct target *self, struct target_dump_data *data)
|
||||||
{
|
{
|
||||||
|
@ -1437,14 +1448,8 @@ target_dump_terminal (struct target *self, struct target_dump_data *data)
|
||||||
size_t block = 8 * sizeof *data->undetermined;
|
size_t block = 8 * sizeof *data->undetermined;
|
||||||
for (size_t i = 0; i < 65536 / block; i++)
|
for (size_t i = 0; i < 65536 / block; i++)
|
||||||
for (size_t k = 0; k < block; k++)
|
for (size_t k = 0; k < block; k++)
|
||||||
{
|
if ((data->undetermined[i] & (1 << k)))
|
||||||
if (!(data->undetermined[i] & (1 << k)))
|
target_dump_terminal_undetermined (i * block + k, &p_tail);
|
||||||
continue;
|
|
||||||
|
|
||||||
port = *p_tail = node_new (xstrdup_printf
|
|
||||||
("port %" PRIu16, (uint16_t) (i * block + k)));
|
|
||||||
p_tail = &port->next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node_print_tree (root);
|
node_print_tree (root);
|
||||||
|
|
Loading…
Reference in New Issue