*/
struct l4_xinfo {
struct inet_xinfo inet;
+ unsigned int st;
};
enum l4_side { L4_LOCAL, L4_REMOTE };
struct l4_xinfo l4;
uint16_t local_port;
uint16_t remote_port;
- unsigned int st;
};
enum tcp_state {
struct sock *sock __attribute__((__unused__)))
{
char *str = NULL;
- struct inet_xinfo *inet = ((struct inet_xinfo *)sock_xinfo);
struct tcp_xinfo *tcp = ((struct tcp_xinfo *)sock_xinfo);
+ struct l4_xinfo *l4 = &tcp->l4;
+ struct inet_xinfo *inet = &l4->inet;
+ unsigned int st = l4->st;
char local_s[INET_ADDRSTRLEN], remote_s[INET_ADDRSTRLEN];
if (!inet_ntop(AF_INET, &inet->local_addr, local_s, sizeof(local_s)))
- xasprintf(&str, "state=%s", tcp_decode_state(tcp->st));
- else if (tcp->st == TCP_LISTEN
+ xasprintf(&str, "state=%s", tcp_decode_state(st));
+ else if (st == TCP_LISTEN
|| !inet_ntop(AF_INET, &inet->remote_addr, remote_s, sizeof(remote_s)))
xasprintf(&str, "state=%s laddr=%s:%u",
- tcp_decode_state(tcp->st),
+ tcp_decode_state(st),
local_s, tcp->local_port);
else
xasprintf(&str, "state=%s laddr=%s:%u raddr=%s:%u",
- tcp_decode_state(tcp->st),
+ tcp_decode_state(st),
local_s, tcp->local_port,
remote_s, tcp->remote_port);
return str;
static char *tcp_get_state(struct sock_xinfo *sock_xinfo,
struct sock *sock __attribute__((__unused__)))
{
- struct tcp_xinfo *tcp = (struct tcp_xinfo *)sock_xinfo;
-
- return strdup(tcp_decode_state(tcp->st));
+ return strdup(tcp_decode_state(((struct l4_xinfo *)sock_xinfo)->st));
}
static bool tcp_get_listening(struct sock_xinfo *sock_xinfo,
struct sock *sock __attribute__((__unused__)))
{
- struct tcp_xinfo *tcp = (struct tcp_xinfo *)sock_xinfo;
- return tcp->st == TCP_LISTEN;
+ return ((struct l4_xinfo *)sock_xinfo)->st == TCP_LISTEN;
}
#define define_fill_column_func(l4,L4) \
tcp->local_port = local_port;
inet->remote_addr.s_addr = kernel32_to_cpu(byteorder, remote_addr);
tcp->remote_port = remote_port;
- tcp->st = st;
+ tcp->l4.st = st;
return sock;
}
struct sock *sock __attribute__((__unused__)))
{
char *str = NULL;
- struct inet_xinfo *inet = ((struct inet_xinfo *)sock_xinfo);
struct tcp_xinfo *tcp = ((struct tcp_xinfo *)sock_xinfo);
+ struct l4_xinfo *l4 = &tcp->l4;
+ struct inet_xinfo *inet = &l4->inet;
+ unsigned int st = l4->st;
+
char local_s[INET_ADDRSTRLEN], remote_s[INET_ADDRSTRLEN];
if (!inet_ntop(AF_INET, &inet->local_addr, local_s, sizeof(local_s)))
- xasprintf(&str, "state=%s", tcp_decode_state(tcp->st));
+ xasprintf(&str, "state=%s", tcp_decode_state(st));
else if ((inet->remote_addr.s_addr == 0 && tcp->remote_port == 0)
|| !inet_ntop(AF_INET, &inet->remote_addr, remote_s, sizeof(remote_s)))
xasprintf(&str, "state=%s laddr=%s:%u",
- tcp_decode_state(tcp->st),
+ tcp_decode_state(st),
local_s, tcp->local_port);
else
xasprintf(&str, "state=%s laddr=%s:%u raddr=%s:%u",
- tcp_decode_state(tcp->st),
+ tcp_decode_state(st),
local_s, tcp->local_port,
remote_s, tcp->remote_port);
return str;