Add support for printing the path state for SCTP association.
This commit is contained in:
parent
7c1b51d6dc
commit
e389705ed3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=323507
@ -153,8 +153,12 @@ The address the foreign end of the socket is bound to (see
|
|||||||
The remote UDP encapsulation port number if
|
The remote UDP encapsulation port number if
|
||||||
.Fl U
|
.Fl U
|
||||||
is specified (only for SCTP).
|
is specified (only for SCTP).
|
||||||
.It Li STATE
|
.It Li PATH STATE
|
||||||
The protocol state if
|
The path state if
|
||||||
|
.Fl s
|
||||||
|
is specified (only for SCTP).
|
||||||
|
.It Li CONN STATE
|
||||||
|
The connection state if
|
||||||
.Fl s
|
.Fl s
|
||||||
is specified (only for SCTP or TCP).
|
is specified (only for SCTP or TCP).
|
||||||
.It Li STACK
|
.It Li STACK
|
||||||
|
@ -97,6 +97,7 @@ static int *ports;
|
|||||||
struct addr {
|
struct addr {
|
||||||
struct sockaddr_storage address;
|
struct sockaddr_storage address;
|
||||||
unsigned int encaps_port;
|
unsigned int encaps_port;
|
||||||
|
int state;
|
||||||
struct addr *next;
|
struct addr *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -534,6 +535,7 @@ gather_sctp(void)
|
|||||||
xraddr->address.sa.sa_family);
|
xraddr->address.sa.sa_family);
|
||||||
}
|
}
|
||||||
faddr->encaps_port = xraddr->encaps_port;
|
faddr->encaps_port = xraddr->encaps_port;
|
||||||
|
faddr->state = xraddr->state;
|
||||||
faddr->next = NULL;
|
faddr->next = NULL;
|
||||||
if (prev_faddr == NULL)
|
if (prev_faddr == NULL)
|
||||||
sock->faddr = faddr;
|
sock->faddr = faddr;
|
||||||
@ -939,7 +941,7 @@ check_ports(struct sock *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
sctp_state(int state)
|
sctp_conn_state(int state)
|
||||||
{
|
{
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case SCTP_CLOSED:
|
case SCTP_CLOSED:
|
||||||
@ -978,6 +980,25 @@ sctp_state(int state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
sctp_path_state(int state)
|
||||||
|
{
|
||||||
|
switch (state) {
|
||||||
|
case SCTP_UNCONFIRMED:
|
||||||
|
return "UNCONFIRMED";
|
||||||
|
break;
|
||||||
|
case SCTP_ACTIVE:
|
||||||
|
return "ACTIVE";
|
||||||
|
break;
|
||||||
|
case SCTP_INACTIVE:
|
||||||
|
return "INACTIVE";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
displaysock(struct sock *s, int pos)
|
displaysock(struct sock *s, int pos)
|
||||||
{
|
{
|
||||||
@ -1062,6 +1083,19 @@ displaysock(struct sock *s, int pos)
|
|||||||
}
|
}
|
||||||
offset += 7;
|
offset += 7;
|
||||||
}
|
}
|
||||||
|
if (opt_s) {
|
||||||
|
if (faddr != NULL &&
|
||||||
|
s->proto == IPPROTO_SCTP &&
|
||||||
|
s->state != SCTP_CLOSED &&
|
||||||
|
s->state != SCTP_BOUND &&
|
||||||
|
s->state != SCTP_LISTEN) {
|
||||||
|
while (pos < offset)
|
||||||
|
pos += xprintf(" ");
|
||||||
|
pos += xprintf("%s",
|
||||||
|
sctp_path_state(faddr->state));
|
||||||
|
}
|
||||||
|
offset += 13;
|
||||||
|
}
|
||||||
if (first) {
|
if (first) {
|
||||||
if (opt_s) {
|
if (opt_s) {
|
||||||
if (s->proto == IPPROTO_SCTP ||
|
if (s->proto == IPPROTO_SCTP ||
|
||||||
@ -1071,7 +1105,7 @@ displaysock(struct sock *s, int pos)
|
|||||||
switch (s->proto) {
|
switch (s->proto) {
|
||||||
case IPPROTO_SCTP:
|
case IPPROTO_SCTP:
|
||||||
pos += xprintf("%s",
|
pos += xprintf("%s",
|
||||||
sctp_state(s->state));
|
sctp_conn_state(s->state));
|
||||||
break;
|
break;
|
||||||
case IPPROTO_TCP:
|
case IPPROTO_TCP:
|
||||||
if (s->state >= 0 &&
|
if (s->state >= 0 &&
|
||||||
@ -1118,8 +1152,10 @@ display(void)
|
|||||||
"LOCAL ADDRESS", "FOREIGN ADDRESS");
|
"LOCAL ADDRESS", "FOREIGN ADDRESS");
|
||||||
if (opt_U)
|
if (opt_U)
|
||||||
printf(" %-6s", "ENCAPS");
|
printf(" %-6s", "ENCAPS");
|
||||||
if (opt_s)
|
if (opt_s) {
|
||||||
printf(" %-12s", "STATE");
|
printf(" %-12s", "PATH STATE");
|
||||||
|
printf(" %-12s", "CONN STATE");
|
||||||
|
}
|
||||||
if (opt_S)
|
if (opt_S)
|
||||||
printf(" %.*s", TCP_FUNCTION_NAME_LEN_MAX, "STACK");
|
printf(" %.*s", TCP_FUNCTION_NAME_LEN_MAX, "STACK");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user