Skip to content

Commit

Permalink
UTNLDiag_sockid_print in util_netlink.c.
Browse files Browse the repository at this point in the history
  • Loading branch information
sflow committed Apr 1, 2019
1 parent d1a66a5 commit 1e9d0d8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/Linux/mod_systemd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ extern "C" {
EVMod *mod = (EVMod *)magic;
HSP_mod_SYSTEMD *mdata = (HSP_mod_SYSTEMD *)mod->data;
char *protocol = NULL;
HSPListenSock search = { 0 };
HSPListenSock search = { };
// use the seqNo as a "queryNo" to imply family and protocol since it does
// not appear in the diag_msg sockid.
switch(seqNo) {
Expand Down
24 changes: 1 addition & 23 deletions src/Linux/mod_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,28 +134,6 @@ extern "C" {
return buf;
}

/*_________________---------------------------__________________
_________________ diag_sockid_print __________________
-----------------___________________________------------------
*/

static char *diag_sockid_print(struct inet_diag_sockid *sockid) {
static char buf[256];
snprintf(buf, 256, "%08x:%08x:%08x:%08x %u - %08x:%08x:%08x:%08x %u if:%u",
sockid->idiag_src[0],
sockid->idiag_src[1],
sockid->idiag_src[2],
sockid->idiag_src[3],
sockid->idiag_sport,
sockid->idiag_dst[0],
sockid->idiag_dst[1],
sockid->idiag_dst[2],
sockid->idiag_dst[3],
sockid->idiag_dport,
sockid->idiag_if);
return buf;
}

/*_________________---------------------------__________________
_________________ parse_diag_msg __________________
-----------------___________________________------------------
Expand Down Expand Up @@ -206,7 +184,7 @@ extern "C" {
memcpy(&tcpi, RTA_DATA(attr), readLen);
myDebug(1, "TCP diag: RTT=%uuS (variance=%uuS) [%s]",
tcpi.tcpi_rtt, tcpi.tcpi_rttvar,
diag_sockid_print(&diag_msg->id));
UTNLDiag_sockid_print(&diag_msg->id));
if(found) {
myDebug(1, "found TCPSample: %s RTT:%uuS", tcpSamplePrint(found), tcpi.tcpi_rtt);
HSPPendingSample *ps;
Expand Down
22 changes: 22 additions & 0 deletions src/Linux/util_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ extern "C" {

#include "util_netlink.h"

/*_________________---------------------------__________________
_________________ UTNLDiag_sockid_print __________________
-----------------___________________________------------------
*/

char *UTNLDiag_sockid_print(struct inet_diag_sockid *sockid) {
static char buf[256];
snprintf(buf, 256, "%08x:%08x:%08x:%08x %u - %08x:%08x:%08x:%08x %u if:%u",
sockid->idiag_src[0],
sockid->idiag_src[1],
sockid->idiag_src[2],
sockid->idiag_src[3],
sockid->idiag_sport,
sockid->idiag_dst[0],
sockid->idiag_dst[1],
sockid->idiag_dst[2],
sockid->idiag_dst[3],
sockid->idiag_dport,
sockid->idiag_if);
return buf;
}

/*_________________---------------------------__________________
_________________ UTNLDiag_send __________________
-----------------___________________________------------------
Expand Down
2 changes: 2 additions & 0 deletions src/Linux/util_netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ extern "C" {
TCP_CLOSING
} EnumKernelTCPState;

char *UTNLDiag_sockid_print(struct inet_diag_sockid *sockid);

int UTNLDiag_open(void);

int UTNLDiag_send(int sockfd, void *req, int req_len, bool dump, uint32_t seqNo);
Expand Down

0 comments on commit 1e9d0d8

Please sign in to comment.