/* * Copyright (c) 2016 Fabien Siron * Copyright (c) 2017 JingPiao Chen * Copyright (c) 2017-2021 The strace developers. * All rights reserved. * * SPDX-License-Identifier: LGPL-2.1-or-later */ #include "defs.h" #include "netlink.h" #include "netlink_sock_diag.h" #include "nlattr.h" #include #include #include "xlat/unix_diag_attrs.h" #include "xlat/unix_diag_show.h" DECL_NETLINK_DIAG_DECODER(decode_unix_diag_req) { struct unix_diag_req req = { .sdiag_family = family }; const size_t offset = sizeof(req.sdiag_family); tprint_struct_begin(); PRINT_FIELD_XVAL(req, sdiag_family, addrfams, "AF_???"); tprint_struct_next(); if (len >= sizeof(req)) { if (!umoven_or_printaddr(tcp, addr + offset, sizeof(req) - offset, (char *) &req + offset)) { PRINT_FIELD_U(req, sdiag_protocol); tprint_struct_next(); PRINT_FIELD_FLAGS(req, udiag_states, tcp_state_flags, "1<= sizeof(msg)) { if (!umoven_or_printaddr(tcp, addr + offset, sizeof(msg) - offset, (char *) &msg + offset)) { PRINT_FIELD_XVAL(msg, udiag_type, socktypes, "SOCK_???"); tprint_struct_next(); PRINT_FIELD_XVAL(msg, udiag_state, tcp_states, "TCP_???"); tprint_struct_next(); PRINT_FIELD_U(msg, udiag_ino); tprint_struct_next(); PRINT_FIELD_COOKIE(msg, udiag_cookie); decode_nla = true; } } else tprint_more_data_follows(); tprint_struct_end(); offset = NLMSG_ALIGN(sizeof(msg)); if (decode_nla && len > offset) { tprint_array_next(); decode_nlattr(tcp, addr + offset, len - offset, unix_diag_attrs, "UNIX_DIAG_???", unix_diag_msg_nla_decoders, ARRAY_SIZE(unix_diag_msg_nla_decoders), NULL); } }