Functions

lib/kcore/statistics.c File Reference

Statistics support. More...

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "../../ut.h"
#include "../../dprint.h"
#include "../../socket_info.h"
#include "statistics.h"
Include dependency graph for lib/kcore/statistics.c:

Go to the source code of this file.

Functions


Detailed Description

Definition in file lib/kcore/statistics.c.


Function Documentation

int get_socket_list_from_proto ( int **  ipList,
int  protocol 
)

The first parameter, ipList, is a pointer to a pointer. It will be assigned a new block of memory holding the IP Addresses and ports being listened to with respect to 'protocol'. The array maps a 2D array into a 1 dimensional space, and is layed out as follows:

The first NUM_IP_OCTETS indices will be the IP address, and the next index the port. So if NUM_IP_OCTETS is equal to 4 and there are two IP addresses found, then:

  • ipList[0] will be the first octet of the first ip address
  • ipList[3] will be the last octet of the first ip address.
  • iplist[4] will be the port of the first ip address
  • iplist[5] will be the first octet of the first ip address,
  • and so on.

The function will return the number of sockets which were found. This can be used to index into ipList.

Note:
This function assigns a block of memory equal to:

returnedValue * (NUM_IP_OCTETS + 1) * sizeof(int);

Therefore it is CRUCIAL that you free ipList when you are done with its contents, to avoid a nasty memory leak.

Definition at line 115 of file lib/kcore/statistics.c.

Referenced by get_total_bytes_waiting().

Here is the caller graph for this function:

int get_total_bytes_waiting ( void   ) 

Note: This currently only works on systems supporting the /proc/net/[tcp|udp] interface. On other systems, zero will always be returned. To change this in the future, add an equivalent for get_used_waiting_queue().

Definition at line 395 of file lib/kcore/statistics.c.

References get_socket_list_from_proto(), and get_used_waiting_queue().

Referenced by check_msg_queue_alarm().

Here is the call graph for this function:

Here is the caller graph for this function:

static int get_used_waiting_queue ( int  forTCP,
int *  interfaceList,
int  listSize 
) [static]

The check will be limited to the TCP or UDP transport exclusively. Specifically:

  • If forTCP is non-zero, the check involves only the TCP transport.
  • if forTCP is zero, the check involves only the UDP transport.

Note: This only works on linux systems supporting the /proc/net/[tcp|udp] interface. On other systems, zero will always be returned.

Definition at line 336 of file lib/kcore/statistics.c.

References match_ip_and_port(), and parse_proc_net_line().

Referenced by get_total_bytes_waiting().

Here is the call graph for this function:

Here is the caller graph for this function:

static int match_ip_and_port ( int *  ipOne,
int *  ipArray,
int  sizeOf_ipArray 
) [static]

The format of ipOne and ipArray are described in the comments of get_socket_list_from_proto() in this file.

Definition at line 289 of file lib/kcore/statistics.c.

Referenced by get_used_waiting_queue().

Here is the caller graph for this function:

static int parse_proc_net_line ( char *  line,
int *  ipAddress,
int *  rx_queue 
) [static]

Returns 1 on success, and 0 on a failed parse.

Note: The format of ipAddress is as defined in the comments of get_socket_list_from_proto() in this file.

Definition at line 206 of file lib/kcore/statistics.c.

Referenced by get_used_waiting_queue().

Here is the caller graph for this function: