/* * $Id: network_stats.h 1425 2006-12-18 22:22:51Z jmagder $ * * SNMPStats Module * Copyright (C) 2006 SOMA Networks, INC. * Written by: Jeffrey Magder (jmagder@somanetworks.com) * * This file is part of openser, a free SIP server. * * openser is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * * openser is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * * History: * -------- * 2006-11-23 initial version (jmagder) * * This file groups together function prototypes for retrieving tcp and udp * queue usage information from the proc file system. * * get_total_bytes_waiting() is the only external function that needs to be * declared here. It has dependencies on other hidden functions defined in * network_stats.c. Currently this function returns non-zero values only on * systems supporting the proc file system. * * For further information, please consult network_stats.c */ #ifndef _SNMPSTATS_NETWORK_STATS_ #define _SNMPSTATS_NETWORK_STATS_ /* * This function will retrieve a list of all ip addresses and ports that OpenSER * is listening on, with respect to the transport protocol specified with * '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. */ int get_socket_list_from_proto(int **ipList, int protocol); /* * Returns the sum of the number of bytes waiting to be consumed on all network * interfaces and transports that OpenSER is listening on. * * Note: This currently only works on systems supporting the /proc/net/[tcp|udp] * interface. On other systems, zero will always be returned. Details of * why this is so can be found in network_stats.c */ int get_total_bytes_waiting(); #endif