Net-Interface

 view release on metacpan or  search on metacpan

ni_linuxproc.c  view on Meta::CPAN


/* ********************************************************************	*
 * ni_linuxproc.c	version 0.04 3-9-09				*
 *									*
 *     COPYRIGHT 2008-2009 Michael Robinton <michael@bizsystems.com>	*
 *									*
 * This program is free software; you can redistribute it and/or modify	*
 * it under the terms of either:					*
 *									*
 *  a) the GNU General Public License as published by the Free		*
 *  Software Foundation; either version 2, or (at your option) any	*
 *  later version, or							*
 *									*
 *  b) the "Artistic License" which comes with this distribution.	*
 *									*
 * This program 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 either	*
 * the GNU General Public License or the Artistic License for more 	*
 * details.								*
 *									*
 * You should have received a copy of the Artistic License with this	*
 * distribution, in the file named "Artistic".  If not, I'll be glad 	*
 * to provide one.							*
 *									*
 * You should also have received a copy of the GNU General Public 	*
 * License along with this program in the file named "Copying". If not, *
 * write to the 							*
 *									*
 *	Free Software Foundation, Inc.					*
 *	59 Temple Place, Suite 330					*
 *	Boston, MA  02111-1307, USA					*
 *									*
 * or visit their web page on the internet at:				*
 *									*
 *	http://www.gnu.org/copyleft/gpl.html.				*
 * ********************************************************************	*/

#include "localconf.h"

#ifdef __ni_Linux

#define _PATH_PROCNET_DEV	       "/proc/net/dev"
#define _PATH_PROCNET_IFINET6	   "/proc/net/if_inet6"

/*	should be  include from /linux/include/linux/rtnetlink.h	*/

/* ifa_flags */
#ifndef IFA_F_SECONDARY
#define IFA_F_SECONDARY		0x01
#endif
#ifndef IFA_F_TEMPORARY
#define IFA_F_TEMPORARY		IFA_F_SECONDARY
#endif
#ifndef IFA_F_NODAD
#define IFA_F_NODAD		0x02
#endif
#ifndef IFA_F_OPTIMISTIC
#define IFA_F_OPTIMISTIC	0x04
#endif
#ifndef IFA_F_HOMEADDRESS
#define IFA_F_HOMEADDRESS	0x10
#endif
#ifndef IFA_F_DEPRECATED
#define IFA_F_DEPRECATED	0x20
#endif
#ifndef IFA_F_TENTATIVE
#define IFA_F_TENTATIVE		0x40
#endif
#ifndef IFA_F_PERMANENT
#define IFA_F_PERMANENT		0x80
#endif

static void
lx_ifa_f_flags(int flags)
{
    if (flags & IFA_F_SECONDARY)
	printf("Secondory ");
    if (flags & IFA_F_NODAD)
	printf("NoDAD ");
    if (flags & IFA_F_OPTIMISTIC)
	printf("Optimistic ");
    if (flags & IFA_F_HOMEADDRESS)
	printf("Home ");
    if (flags & IFA_F_DEPRECATED)
	printf("Deprecated ");
    if (flags & IFA_F_TENTATIVE)
	printf("Tentative ");
    if (flags & IFA_F_PERMANENT)
	printf("Permanent ");
}

struct ni_linux_iface {
    char	devname[20];
    char	chp[8][5];
#if LOCAL_SIZEOF_POINTER == 8
    char	_pad[4];
#endif			/* align 64 bit host	*/
    int		plen;
    int		scope;
    int		dad;
    int		idx;
};



( run in 1.095 second using v1.01-cache-2.11-cpan-39bf76dae61 )