#!/bin/sh

# Shell script to collect network data.
# Copyright (C) 2001-2004 Open Challenge B.V.
# Copyright (C) 2004-2005 OpenEyeT Professional Services.
# Copyright (C) 2005-2009 QNH.
#
# This program 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, or (at your option)
# any later version.
#
# 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 the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Contact information: http://scc.qnh-infrastructure.nl/index.html 

# This is a system module of scc, to call it separately in the
# proper environment, use: scc-collect -i -e <module_name>

# SCC-release:	1.9.28
# file-version:	$Revision: 1.103 $
 
set -u

. ${SCC_BIN}/scc_modules/scc_utils

if [ -d /etc/avahi ]
then
	scc_check_file /etc/avahi/hosts "fix:network:avahi:/etc/avahi/hosts::" "#"
	scc_check_file /etc/avahi/avahi-daemon.conf "fix:network:avahi:/etc/avahi/avahi-daemon.conf::" "#"
	for s in /etc/avahi/services/*
	do
		scc_check_file "${s}" "fix:network:avahi:${s}::" "#"
	done
fi

if [ -x /usr/bin/what -a -f /usr/conf/lib/liblan.a ]
then
	what /usr/conf/lib/liblan.a					|
	sed -e 's@^@fix:network:Core-lan /usr/conf/lib/liblan.a::@'
fi

lines=$(grep -c [g]ated ${PROC_FILE})
if [ ${lines} -ge 1 ]
then
	echo "fix:network:gated::status:	active"
else
	echo "fix:network:gated::status:	inactive"
fi
scc_check_file /etc/gated.conf "fix:network:gated::/etc/gated.conf:	" "#"

for file in		\
		/etc/bgpd.conf			\
		/etc/binld.cnf			\
		/etc/bootptab			\
		/etc/conman.conf		\
		/etc/defaultdomain		\
		/etc/defaultrouter		\
		/etc/dhclient.conf		\
		/etc/dhcpd.conf			\
		/etc/dhcptab			\
		/etc/dhcpd.interfaces		\
		/etc/dhcpcd.ini			\
		/etc/dhcprd.cnf			\
		/etc/dhcpsd.cnf			\
		/etc/dhcp/inittab		\
		/etc/dhcp/dhcpd.conf		\
		/etc/dlpi.conf			\
		/etc/dvmrpd.conf		\
		/etc/ethers			\
		/etc/eth0mode			\
		/etc/firewall.conf		\
		/etc/gateways			\
		/etc/gai.conf			\
		/etc/host.conf			\
		/etc/hostapd.conf		\
		/etc/hosts			\
		/etc/hosts.lpd			\
		/etc/hostmibd.conf		\
		/etc/hosts.equiv		\
		/etc/ifaccess.conf		\
		/etc/ifaliases			\
		/etc/ifp.conf			\
		/etc/ifp6.conf			\
		/etc/ifstated.conf		\
		/etc/ipnat.conf			\
		/etc/ipsec.conf			\
		/etc/isp.conf			\
		/etc/libnet.cfg			\
		/etc/mactab			\
		/etc/mib.defs			\
		/etc/mrouted.conf		\
		/etc/myname			\
		/etc/mygate			\
		/etc/netconfig			\
		/etc/netgroup			\
		/etc/netmasks			\
		/etc/netsvc.conf		\
		/etc/nettlgen.conf		\
		/etc/network/interfaces		\
		/etc/network/options		\
		/etc/network.conf		\
		/etc/networks			\
		/etc/nsswitch.conf		\
		/etc/nscd.conf			\
		/etc/ospfd.conf			\
		/etc/policyd.conf		\
		/etc/ppp/chap-secrets		\
		/etc/ppp/ioptions		\
		/etc/ppp/options		\
		/etc/ppp/pap-secrets		\
		/etc/ppp/peers/pppoe		\
		/etc/ppp/resolv.conf		\
		/etc/pppoed.conf		\
		/etc/protocols			\
		/etc/pxed.cnf			\
		/etc/rcdialout.conf		\
		/etc/rbootd.conf		\
		/etc/ripd.conf			\
		/etc/route.conf			\
		/etc/routes			\
		/etc/rpc			\
		/etc/rpld.conf			\
		/etc/rsh.allow			\
		/etc/rsvpd.conf			\
		/etc/rsyncd.conf		\
		/etc/slip.hosts			\
		/etc/smpppd.conf		\
		/etc/snmpd.peers		\
		/etc/sysctl.cfg			\
		/etc/svc.conf			\
		/etc/telnet.conf		\
		/etc/xtiso.conf			\
		/etc/wgetrc			\
		/etc/wvdial.conf		\
		/var/adm/inetd.sec
do
	scc_check_file "${file}" "fix:network:file:${file}::" "#"

	if [ ${IS_NIS_MASTER} -eq 1 -a "${NIS_DATA_DIR}" != "/etc" ]
	then
		nis_file="${NIS_DATA_DIR}/$(basename ${file})"
		scc_check_file "${nis_file}" "fix:network:file:${nis_file}::" "#"
	fi
done

for file in /etc/dhcpc/dhcpcd-*.info
do
	scc_check_file "${file}" "fix:network:file:${file}::" "#"		|
	sed -e 's/fix:\(.*IPADDR=\)/var:\1/'
done

if [ -f /etc/dhcpd.conf ]
then
	# Indicated by Harry van Wiggen. Example of incude statement:
	#include "/etc/dhcpd.master";
	sed -n -e 's/^[ 	]*include//p' /etc/dhcpd.conf		|
	sed	-e 's/"[ 	]*;[ 	]*$//'	\
		-e 's/^[ 	]*"//'					|
	while read file
	do
		scc_check_file "${file}" "fix:network:file:${file}::" "#"
	done
fi

# Border Gateway Protocol Daemon
bgpd_conf=$(sed -n -e 's/.*bgpd .*-f *//p' ${PROC_FILE})
bgpd_conf=${bgpd_conf%% *}
bgpd_conf=${bgpd_conf:-/etc/bgpd.conf}		# Default config file.
scc_check_file "${bgpd_conf}" "fix:network:file:${bgpd_conf}::" "#"

if [ -f /etc/notrouter ]
then
	echo "fix:network:file:/etc/notrouter::1"
fi

if [ ! -h /etc/hosts ]
then
	scc_check_file /etc/inet/hosts "fix:network:file:/etc/inet/hosts::" "#"
fi

sun_snmp_file=""
if [ "${OS_NAME}" = "SunOS" ]
then
	dir=$(sed -n -e 's/.*snmpdx .*-c *//p' ${PROC_FILE})
	dir=${dir%% *}
	dir=${dir:-/etc/snmp/conf}
	sun_snmp_file=${dir}/snmpd.conf

	for f in mibiisa.reg mibiisa.rsrc snmpdx.reg snmpdx.rsrc snmpdx.acl
	do
		scc_check_file "${dir}/${f}" "fix:network:file:${dir}/${f}::" "#"
	done
fi

# Avoid the clear-text community-names to appear in the snapshots.
rm -f ${TMP1_FILE}
for file in     /etc/snmpd.conf ${sun_snmp_file}	\
		/etc/snmp/snmpd.conf			\
                /etc/SnmpAgent.d/snmpd.conf
do
        if [ ! -f ${file} -o -h ${file} ]
        then
                continue
        fi

	prefix="fix:network:file:${file}::"
	# Communitynames are sensitive information, therefore we crypt them.
	sed	-e '/^#/d'			\
		-e 's/[ 	]*#.*//'	\
		-e '/^[ 	]*$/d' ${file}			|
	while read key data
	do
		case "${key}" in
		trap-community)	echo "${prefix}${key}	${data}";;
		*community*)	if [ -n "${data}" ]
				then
					echo "${prefix}${key}	$(echo "${key} ${data}" | scc_crypt )"
				else
					echo "${prefix}${key}	# No access"
				fi;;
		*)		echo "${prefix}${key}	${data}";;
		esac
	done
done

scc_check_file /etc/services "fix:network:file:/etc/services::" "#"		|
sort -k 2n
if [ ${IS_NIS_MASTER} -eq 1 -a "${NIS_DATA_DIR}" != "/etc" ]
then
	scc_check_file "${NIS_DATA_DIR}/services" "fix:network:file:${NIS_DATA_DIR}/services::" "#"
fi

for file in	/etc/ftp-banner			\
		/etc/ftpaccess			\
		/etc/ftpchroot			\
		/etc/ftpconversions		\
		/etc/ftpgroups			\
		/etc/ftphosts			\
		/etc/ftpusers			\
		/etc/ftpwelcome			\
		/etc/ftpd/ftpusers		\
		/etc/proftpd.conf		\
		/etc/ftpd.conf			\
		/etc/lftp.conf			\
		/etc/vsftpd.conf		\
		/etc/vsftpd/vsftpd.conf		\
		/etc/vsftpd.ftpusers		\
		/etc/vsftpd.user_list		\
		/etc/iptos			\
		/usr/local/etc/proftpd.conf
do
	scc_check_file "${file}" "fix:network:ftp:${file}::" "#"
done

# In case the default config file for vsftpd is not used:
{
	sed -n -e '/.*server_args.*-f[ 	]*//p' /etc/xinetd.d/vsftp* 2>/dev/null
	sed -n -e '/.*vsftpd.*vsftpd[ 	]*.*-f[ 	]*//p' /etc/inetd.conf 2>/dev/null
}					|
while read file remainder
do
	scc_check_file "${file}" "fix:network:ftp:${file}::" "#"
done

if [ -x /usr/sbin/ipaddrsel ]
then
	/usr/sbin/ipaddrsel				|
	sort -k 2n					|
	sed -e 's/^/fix:network:IPV6:ipaddrsel::/'
fi

# Record ports that are listened on. Select only the ports that are
# present in the file /etc/services.
sed	-e '/^[ 	]*$/d'	\
	-e '/^#/d'		\
	-e 's@/.*@@'		\
		/etc/services 2>/dev/null	|
awk '{ if ( NF == 2 ) print }' >${TMP1_FILE}

netstat -an 2>/dev/null				|
awk '/^tcp.*LISTEN *$/	{ i=4; work=1 }
	/^ .*LISTEN *$/	{ i=1; work=1 }
	{
		if ( ! work )
		{
			next;
		}
		cnt=split( $i, parts, ":" );
		if ( cnt > 1 )
		{
			# Example data:
			# tcp        0      0 0.0.0.0:901                 0.0.0.0:*                   LISTEN      
			# tcp        0      0 :::80                       :::*                        LISTEN      
			print parts[ cnt ];
		}
		else
		{
			cnt=split( $i, parts, "." );
			print parts[ 2 ];
		}
		work=0;
	}'				|
sort -u					|
awk '{
	if ( NF == 2 )
	{
		service[ $2 ] = $1;
	}
	else
	{
		if ( length( service[ $1 ] ) > 0 )
		{
			print "fix", service[ $1 ], $1;
		}
		else
		{
			print "var", $1, $1
		}
	}
}' ${TMP1_FILE} -			|
sort -k 3n				|
sed	-e 's/^fix /fix:network:ports::/'	\
	-e 's/^var /var:network:ports::/'

rm -f ${TMP1_FILE}

if [ -x /sbin/mii-tool ]
then
	/sbin/mii-tool -v 2>/dev/null		|
	sed -e 's/^/fix:network:media independant interface status::/'
fi

if [ -x /usr/bin/ipcs ]
then
	# The output of ipcs changes frequently. Treat it as variable.

	extra_options=""
	if [ "${OS_NAME}" = "HP-UX" -o "${OS_NAME}" = "SunOS" ]
	then
		extra_options="-a"
	fi

	ipcs -m ${extra_options}			|
	sed	-e '/^ *$/d'		\
		-e 's/^/var:network:ipcs::shared-memory:	/'

	ipcs -q ${extra_options}			|
	sed	-e '/^ *$/d'		\
		-e 's/^/var:network:ipcs::message-queue:	/'

	ipcs -s ${extra_options}			|
	sed	-e '/^ *$/d'		\
		-e 's/^/var:network:ipcs::semaphores:		/'
fi

# Tag the output of nslookup as variable. The nameserver is fixed data in the resolv.conf
# and the ip-address of the host is recorded elsewhere. This avoids changes for a host using dhcp.
nslookup $(hostname) 2>/dev/null			|
sed	-e '/^[ 	]*$/d'			\
	-e '/authoritative answer/d'		\
	-e 's/^/var:network:DNS::nslookup:	/'

# Maarten de Boer and Nico van Royen provided some NIS-background.
is_slave_server=0
is_client=0
if [ ${IS_NIS_MASTER} -eq 0 ]
then
	is_slave_server="$(grep -l ypserv ${PROC_FILE} >/dev/null 2>/dev/null; echo $(( 1 - $? )) )"
	if [ "${is_slave_server}" -eq 0 ]
	then
		is_client="$(grep -l ypbind ${PROC_FILE} >/dev/null 2>/dev/null; echo $(( 1 - $? )) )"
	fi
else
	echo "fix:network:NIS:general::data-directory:		${NIS_DATA_DIR}"
fi

NIS_DOMAIN="$(domainname 2>/dev/null)"
NIS_MASTER=""
if [ ${is_client} -eq 1 -o ${is_slave_server} -eq 1 ]
then
	NIS_MASTER="$(ypwhich 2>/dev/null)"
fi
echo "fix:network:NIS:general::domain:		${NIS_DOMAIN}"
echo "fix:network:NIS:general::binding:		${NIS_MASTER}"

echo "fix:network:NIS:general::is-master-server:	${IS_NIS_MASTER}"
echo "fix:network:NIS:general::is-slave-server:		${is_slave_server}"
echo "fix:network:NIS:general::is-client:		${is_client}"

scc_check_file "/var/yp/binding/${NIS_DOMAIN}/ypservers" "fix:network:NIS:binding ${NIS_DOMAIN} ypservers::" "#"
scc_check_file /etc/yp.conf "fix:network:NIS:binding /etc/yp.conf::" "#"
scc_check_file /var/yp/securenets "fix:network:NIS:/var/yp/securenets::" "#"

if [ -f /etc/publickey ]
then
	# Ignore comment and blank lines. Also erase the private key.
	sed	-e '/^#/d'		\
		-e '/^[ 	]*$/d'	\
		-e 's/:.*//'		\
		-e 's@^@fix:network:NIS:/etc/publickey::@' /etc/publickey
fi

if [ -x /usr/bin/ypwhich ]
then
	ypwhich -x 2>/dev/null		|
	sed -e 's/^/var:network:NIS:nicknames::/'

	if [ ${is_client} -gt 0 -o ${is_slave_server} -gt 0 ]
	then
		ypwhich -m 2>/dev/null		|
		sed -e 's/^/var:network:NIS:maps::/'
	fi
fi

config=""
key=""
if [ -f /etc/rc.config.d/netdaemons ]
then
	. /etc/rc.config.d/netdaemons
	if [ "${XNTPD_ARGS}" != "" ]
	then
		config=$(echo "${XNTPD_ARGS}" | sed -e 's/.*-c[ ]*//' -e 's/ .*//')
		key=$(echo "${XNTPD_ARGS}" | sed -e 's/.*-k[ ]*//' -e 's/ .*//')
	fi
else
	config="$(sed -n -e 's/.*xntpd.* -c[ ]*//p' ${PROC_FILE})"
	config="${config% *}"
fi
if [ ! -f "${config}" ]
then
	if [ -f /etc/ntp.conf ]
	then
		config=/etc/ntp.conf
	elif [ -f /etc/inet/ntp.conf ]
	then
		config=/etc/inet/ntp.conf
	else
		config=""
	fi
fi
if [ "${config}" != "" ]
then
	scc_check_file "${config}" "fix:network:ntp:${config}::" "#"

	if [ ! -f "${key}" ]
	then
		key=$(awk '/^keys/ { print $2 }' ${config})
	fi

	if [ "${key}" ]
	then
		scc_check_file "${key}" "fix:network:ntp:${key}::" "#"
	fi
fi
scc_check_file /etc/ntp/ntpservers	"fix:network:ntp:/etc/ntp/ntpservers::"	"#"
scc_check_file /etc/ntp/keys		"fix:network:ntp:/etc/ntp/keys::"	"#"
if [ -x /usr/sbin/ntpq ]
then
	ntpq -p 2>/dev/null			|
	sed -e 's/^/var:network:ntp:ntpq::/'
fi

# When you change these labels, also change them in the named user-module!
named_class="fix:network:named"
scc_keep_named_config="network:named:config"
scc_keep_named_count="network:named:count"

# Check the list of processes for a specific config file of named.
# When the process is found without a file spec, the default file is used.
named_conf="$(awk '/s*bin\/[n]amed/	{
				dir="";
				file="";
				# Look for the options specifying the directory and file.
				for ( i = 1; i <= NF; i++ )
				{
					if ( $i ~ "^-t$" )
					{
						i++;
						dir = $i;
					}
					if ( $i ~ "^-[bc]$" )
					{
						i++;
						file = $i;
					}
				}
				if ( file ~ "^/" )	# absolute path?
				{
					path = file;
				}
				else
				{
					path = sprintf( "%s/%s", dir, file );
				}

				if ( length( path ) > 1 )
				{
					print path;
				}
			}' ${PROC_FILE})"

if [ "${named_conf}" ]
then
	echo "${named_class}:general::status:	active"

	cnt=1		# We obtained fresh data from a running named.
else
	echo "${named_class}:general::status:	inactive"

	cnt=$(sed -n -e "s/^${scc_keep_named_count}://p" ${SCC_KEEP_CONFIG})
	cnt=$(( ${cnt:-0} + 1 ))		# Add 1 to the "age"
	if [ ${cnt} -lt 5 -a ${cnt} -gt 1 ]	# Not too old and present?
	then
		named_conf="$(sed -n -e "s/^${scc_keep_named_config}://p" ${SCC_KEEP_CONFIG})"
	fi
fi

if [ -d "${named_conf}" ]		# Only -t option with named?
then
	for file in /var/named/named.conf /etc/named.conf /var/named/etc/named.conf
	do
		if [ -f "${named_conf}/${file}" ]
		then
			named_conf="$( echo "${named_conf}/${file}" | sed -e 's@//@/@g')"
			break
		fi
	done
elif [ ! -f "${named_conf}" ]		# Nothing soo far?
then
	# Determine the default config file for named.
	for file in /var/named/named.conf /etc/named.conf /var/named/etc/named.conf
	do
		if [ -f "$file}" ]
		then
			named_conf=${file}
			break
		fi
	done
fi

named_exe=$(which named 2>/dev/null)
if [ -x "${named_exe}" ]
then
	what "${named_exe}"		|
	grep "named"			|
	sed -e "s/^/${named_class}:general::version:	/"
fi

if [ "${named_conf}" -a ${cnt} -lt 5 ]
then
	# Keep for the next run and for the named user-module.
	echo "${scc_keep_named_config}:${named_conf}"	>>${SCC_KEEP_NEW}
	echo "${scc_keep_named_count}:${cnt}"		>>${SCC_KEEP_NEW}
fi

scc_check_file "${named_conf}" "${named_class}:config ${named_conf}::" "#"
# To collect the detailled DNS-data, activate the named user-module by using the -e option of scc.

if [ -f /etc/resolv.conf ]
then
	awk '/^#/	{
				next;
			 }
		/^[ 	]*$/	{
				next;
			 }
			{
				printf( "fix:network:file:/etc/resolv.conf::%04d:	%s\n",\
					( 1 + i++ ), $0 );
			}' /etc/resolv.conf
fi

if [ -x /usr/sbin/inetadm ]
then
	# Output of inetadm:
	#enabled   online         svc:/network/fs/tcp6:default
	/usr/sbin/inetadm 2>/dev/null			|
	awk '/svc:/ { print $3 }'			|
	sort						|
	while read entry
	do
		label=${entry#svc:/}
		/usr/sbin/inetadm -l "${entry}" 2>/dev/null	|
		sed	-e "s@^@${label}:	@"	\
			-e "s@:@::@"			\
			-e "s@/@:@"				|
		sed -e "s/^/fix:network:inetadm:/"
	done
fi

if [ -f /etc/inetd.conf ]
then
	# During removal and (re)installation of software, services are
	# removed from this file and added at the end. To avoid reporting,
	# we sort the file. Special consideration with continuation lines.
	sed	-e '/^#/d'		\
		-e '/^[ 	]*$/d' /etc/inetd.conf		|
	awk '{
			if ( length( prev_service ) > 0 )
			{
				printf( "%s_%08d ", prev_service, counter );
				counter++;
			}
			print;
		}
	/\\$/	{
			if ( length( prev_service ) == 0 )
			{
				prev_service = $1;
			}
			next;
		}
		{
			prev_service = "";
			counter = 0;
		}'						|
	sort 							|
	sed	-e 's/^[a-zA-Z][a-zA-Z]*_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] //'	\
		-e 's@^@fix:network:file:/etc/inetd.conf::@'
fi

if [ -f /etc/xinetd.conf ]
then
	scc_check_file /etc/xinetd.conf "fix:network:file:/etc/xinetd.conf::" "#"

	dir=$(sed -n -e 's/^includedir  *//p' /etc/xinetd.conf)
	if [ -z "${dir}" ]
	then
		dir=/etc/xinetd.d
	fi
	for f in ${dir}/*
	do
		scc_check_file "${f}" "fix:network:file:xinetd:${f}::" "#"
	done
fi

if [ -x /sbin/gabconfig ]
then
	class="fix:network:GAB"

	gabconfig -v 2>/dev/null	|
	sed -e "s/^/${class}::version   : /"

	gabconfig -e 2>/dev/null	|
	sed -e "s/^/${class}::kernel tunables   : /"

	gabconfig -l 2>/dev/null	|
	sed -e "s/^/${class}::driver config     : /"

	gabconfig -a 2>/dev/null	|
	sed -e "s/^/${class}::port membership   : /"
fi

if [ -x /usr/sbin/pmadm ]
then
	/usr/sbin/pmadm -l 2>/dev/null		|
	sed -e 's/^/fix:network:pmadm::/'
fi

# Add the interface specific output of mii-tool to the properties of the interface: fix:network:lan:<ifc>::mii-tool
if [ -x /sbin/mii-tool ]
then
	/sbin/mii-tool 2>/dev/null		|
	sed -n -e 's/:/::mii-tool:	/p'	|
	sed -e 's/^/fix:network:lan:/'
fi

if [ -x /usr/sbin/lanscan ]
then
	/usr/sbin/lanscan -v					|
	sed -e 's/^/fix:network:lan:lanscan::/'

	# Catch the differences between 10.20 and 11.x
	/usr/sbin/lanscan								|
	awk '/NameUnit/			{ i=7; next }
		/NamePPA/		{ i=6; next }
		/^[0-9].* ETHER /	{ sub( "^[^0-9]*", "", $i ); print $5, $i }'	|
	sort										|
	while read lan nmid remainder
	do
		ifconfig ${lan} 2>&1						|
		sed	-e "s/ifconfig: no such interface/not configured/"	\
			-e "s/^/fix:network:lan:${lan}::ifconfig:	/"

		# Show all the IP-addresses of the interface.
		# Remove the statistics.
		netstat -in -I ${lan} 2>/dev/null					|
		sed	-e 's/Ipkts.*//'				\
			-e 's/  *[- 0-9]*$//'				\
			-e "s/^/fix:network:lan:${lan}::netstat:	/"

		lanadmin -g ${nmid} 2>/dev/null >${TMP1_FILE}
		if [ $? -ne 0 ]
		then
			lanadmin -ams ${nmid}				|
			sed -e "s/^/fix:network:lan:${lan}::lanadmin:	/"
		else
			label="network:lan:${lan}::lanadmin:	"
			awk	'/^PPA/		{ print f $0; }
				/^Description/	{ print f $0; }
				/^Type/		{ print f $0; }
				/^MTU/		{ print f $0; }
				/^Speed/	{ print f $0; }
				/^Station/	{ print f $0; }
				/Status/	{ print v $0; }'	\
					f="fix:${label}"		\
					v="var:${label}"		\
					${TMP1_FILE}
		fi
		rm -f ${TMP1_FILE}
	done
elif [ "${SCC_LINUX_DISTRO}" = "redhat" ]
then
	# Kor Gros indicated the following method to determine the networking interfaces.
	ifconfig 2>/dev/null			|
	awk '/^[^ 	]/ { print $1 }'	|
	while read ifc remainder
	do
		# Avoid class conflicts messages for: bond0 and bond0:0
		# Indicated by Michael Figiel.
		if [ "${ifc}" != "${ifc%:*}" ]
		then
			label="${ifc%:*}_${ifc#*:}"
		else
			label="${ifc}"
		fi
		ifc_file=/etc/sysconfig/network-scripts/ifcfg-${ifc}
		scc_check_file "${ifc_file}" "fix:network:lan:${label}::network-script:	" "#"

		# Determine whether this interface obtains its address and mask via dhcp:
		prefix="fix"
		if [ -f "${ifc_file}" ]
		then
			grep "^BOOTPROTO=dhcp" ${ifc_file} >/dev/null 2>/dev/null
			if [ $? -eq 0 ]
			then
				prefix="var"
			fi
		fi

		# Ignore the statistics; for dhcp interfaces, all data is variable.
		ifconfig ${ifc} 2>/dev/null		|
		sed -e '/^ *RX packets:/,$ d'		|
		sed -e "s/^/${prefix}:network:lan:${label}::ifconfig:	/"

		if [ "${label}" != "${ifc}" ]
		then
			continue
		fi

		if [ -x /sbin/sysctl ]
		then
			/sbin/sysctl -a 2>/dev/null	|
			grep "^net\..*\.${ifc}\."	|
			sort				|
			sed -e "s/^/fix:network:lan:${ifc}::sysctl:	/"
		fi
	done
elif [ "${OS_NAME}" = "SunOS" -o "${OS_NAME}" = "OpenBSD" ]
then
	{
		# When zones are used on Solaris10, additional "interfaces" appear.
		# Tag these interfaces variable to avoid changes in the logbook.
		if [ -x /usr/sbin/zoneadm ]
		then
			ifconfig -a		|
			awk	'/^[^ 	]/		{ ifc=$1; next }
				/^[ 	]*zone /	{ print "zone " ifc }'
		fi

		if [ "${OS_NAME}" = "OpenBSD" ]
		then
			# Check for dhcp interfaces on OpenBSD: data is variable.
			for f in /etc/hostname.*
			do
				if [ -f "${f}" ]
				then
					ifc="${f##*hostname.}"
					grep -i dhcp "${f}" >/dev/null
					if [ $? -eq 0 ]
					then
						echo "dhcp ${ifc}:"
					fi
				fi
			done
		fi

		if [ "${OS_NAME}" = "SunOS" ]
		then
			for ifc in $(ifconfig -a | sed -n -e 's/:.*//' -e '/^[^ 	]/p' | sort -u)
			do
				ifconfig ${ifc} 2>/dev/null | grep DHCP >/dev/null
				if [ $? -eq 0 ]
				then
					echo "dhcp ${ifc}:"
				fi
			done
		fi

		# Adjust the output, add the interface name to the classification.
		# Data of PPP-connections is tagged variable.
		ifconfig -a
	}				|
	awk	'/^zone/	{ var[ $2 ] = 1; next }
		/^dhcp/		{ var[ $2 ] = 1; next }
		/^[^ 	]/	{
					prefix="fix";
					for ( x in var )
					{
						if ( x == $1 )
						{
							prefix="var";
						}
					}
					ifc = $1;		# qfe1: or qfe1:1: for vitual interfaces
					sub( ":$", "", ifc );
					gsub( ":", "_", ifc );	# qfe1: or qfe1_1:
					if ( ifc ~ "ppp" )
					{
						prefix="var";
					}
				}
				{ print prefix ":network:lan:" ifc "::" $0; }'

	all_types=""
	ifconfig -a				|
	sed	-e '/^[ 	]/d'    \
		-e 's/:[ 	].*//'		|
	sort					|
	while read ifc
	do
		# Avoid class conflicts for qfe1 and qfe1:1 (virtual interface).
		label="${ifc}"
		if [ "${ifc}" != "${ifc%:*}" ]
		then
			label="${ifc%:*}_${ifc#*:}"
		fi
		scc_check_file "/etc/hostname.${ifc}" "fix:network:lan:${label}::/etc/hostname.${ifc}:	" "#"
		
		if [ "${label}" != "${ifc}" ]
		then
			continue	# Do not collect additional parameters for virtual interfaces
		fi

		# Extract additional parameters from the interface.
		if_type=${ifc%%[0-9]*}
		if_instance=${ifc##*[a-z]}
		ndd /dev/${if_type} "?" 2>/dev/null	|
		sed	-e '/^?/d'	\
			-e '/write only/d'		|
		sort >${TMP1_FILE}

		# Check the amount of data in this file, some drivers, like "le", do
		# not support requesting settings with ndd.
		# Ignore dman type of interfaces as their instance cannot be set (indicated by Nico van Royen).
		if [ $(wc -l <${TMP1_FILE}) -gt 1 -a "${if_type}" != "dman" ]
		then
			# Select the proper instance.
			ndd -set /dev/${if_type} instance ${if_instance}

			case "${if_type}" in
			*ppp*)	prefix="var";;
			*)	prefix="fix";;
			esac
			while read parm remainder
			do
				ndd -get /dev/${if_type} ${parm} 2>/dev/null	|
				sed -e "s/^/${prefix}:network:lan:${ifc}::${parm}:	/"
			done <${TMP1_FILE}

		fi
		rm -f ${TMP1_FILE}

		# Collect all interface types that are in use.
		all_types="${all_types} ${if_type}"
	done

	# Check the system-wide default settings for each type of interface.
	echo "${all_types}"			|
	tr " " "\012"				|
	sort -u					|
	while read if_type
	do
		if [ "${if_type}" ]
		then
			config_file="/kernel/drv/${if_type}.conf"
			scc_check_file "${config_file}" "fix:network:lan:${config_file}::" "#"
		fi
	done

elif [ "${OS_NAME}" = "AIX" ]
then
	# Contributed by Doug Probst.
	ifconfig -l		|
	tr " " "\012"		|
	while read ifc remainder
	do
		ifconfig ${ifc}			|
		sed -e "s/^/fix:network:lan:${ifc}::/"
	done
else
	# Adjust the output, add the interface name to the classification.
	# Data of PPP-connections is tagged variable.
	# Ignore for Debian the RX/TX counters and the collisions.
		#eth0      Link encap:Ethernet  HWaddr 00:00:F8:10:49:CA
		#          inet addr:192.233.54.140  Bcast:192.233.54.255  Mask:255.255.255.128
		#          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
		#          RX packets:3106025 errors:0 dropped:0 overruns:0 frame:0
		#          TX packets:3849963 errors:0 dropped:0 overruns:0 carrier:0
		#          collisions:25937 txqueuelen:100
		#          RX bytes:3437928343 (3.2 GiB)  TX bytes:3413435887 (3.1 GiB)
		#          Interrupt:15 Base address:0x4000
	{
		if [ "${OS_NAME}" = "DragonFly" -o "${OS_NAME}" = "FreeBSD" ]
		then
			# Check for dhcp interfaces on DragonFly. Mark their data as variable.
			for ifc in $(ifconfig -a | sed -n -e 's/:.*//' -e '/^[^ 	]/p')
			do
				grep -i "^ifconfig_${ifc}=.*dhcp" /etc/rc.conf >/dev/null 2>/dev/null
				if [ $? -eq 0 ]
				then
					echo "var	${ifc}"
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "archlinux" ]
		then
			# Check for dhcp interfaces on Arch Linux. Mark their data as variable.
			for ifc in $(ifconfig -a | sed -n -e 's/:.*//' -e '/^[^ 	]/p')
			do
				# eth0="dhcp"
				grep -i "^${ifc}=.*dhcp" /etc/rc.conf >/dev/null 2>/dev/null
				if [ $? -eq 0 ]
				then
					echo "var	${ifc}"
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "AltLinux" ]
		then
			for ifc in $(ifconfig -a | sed -n -e 's/:.*//' -e '/^[^ 	]/p')
			do
				grep '^BOOTPROTO=dhcp' /etc/net/ifaces/${ifc}/options >/dev/null 2>/dev/null
				if [ $? -eq 0 ]
				then
					echo "var	${ifc}"
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "DreamLinux" ]
		then
			for ifc in $(ifconfig -a | sed -n -e 's/:.*//' -e '/^[^ 	]/p')
			do
				grep "/sbin/[d]hclient ${ifc}" ${PROC_FILE} >/dev/null 2>/dev/null
				if [ $? -eq 0 ]
				then
					echo "var	${ifc}"
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "DSL" ]
		then
			for ifc in $(ifconfig -a | sed -e '/^[  ]/d' -e 's/[    ].*//')
			do
				grep "IFACE=${ifc}" /etc/dhcpc/config >/dev/null 2>/dev/null
				if [ $? -eq 0 ]
				then
					echo "var	${ifc}"
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "debian" -o "${SCC_LINUX_DISTRO}" = "feather" -o "${SCC_LINUX_DISTRO}" = "Ubuntu" ]
		then
			for ifc in $(ifconfig -a | sed -e '/^[  ]/d' -e 's/[    ].*//')
			do
				grep "^iface.*${ifc}.*dhcp" /etc/network/interfaces >/dev/null 2>/dev/null
				if [ $? -eq 0 ]
				then
					echo "var	${ifc}"
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "gentoo" ]
		then
			for ifc in $(ifconfig -a | sed -e '/^[  ]/d' -e 's/[    ].*//')
			do
				# DHCP is used when the interface is missing in this file or when dhcp is explicit activated.
				grep "config_${ifc}" /etc/conf.d/net >/dev/null 2>/dev/null
				if [ $? -eq 1 ]
				then
					echo "var	${ifc}"
				else
					grep "config_${ifc}.*dhcp" /etc/conf.d/net >/dev/null 2>/dev/null
					if [ $? -eq 0 ]
					then
						echo "var	${ifc}"
					fi
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "GoboLinux" ]
		then
			for ifc in $(ifconfig -a | sed -e '/^[  ]/d' -e 's/[    ].*//')
			do
				grep "^${ifc}_BootProto=DHCP" /System/Settings/NetworkOptions >/dev/null 2>/dev/null
				if [ $? -eq 0 ]
				then
					echo "var	${ifc}"
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "Mint" -o "${SCC_LINUX_DISTRO}" = "sabayon" ]
		then
			for ifc in $(ifconfig -a | sed -e '/^[  ]/d' -e 's/[    ].*//')
			do
				if [ -f /var/run/nm-dhclient-${ifc}.conf -a -f /var/run/dhclient-${ifc}.pid ]
				then
					echo "var	${ifc}"
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "pardus" ]
		then
			for ifc in $(ifconfig -a | sed -e '/^[  ]/d' -e 's/[    ].*//')
			do
				# Each dhcp interface is listed in the variable, or all are dhcp when none is listed in the variable.
				grep "^DHCPD_IFACE=\"\"" /etc/conf.d/dhcpd >/dev/null 2>/dev/null
				if [ $? -eq 0 ]
				then
					echo "var	${ifc}"
				else
					grep "^DHCPD_IFACE=.*${ifc}" /etc/conf.d/dhcpd >/dev/null 2>/dev/null
					if [ $? -eq 0 ]
					then
						echo "var	${ifc}"
					fi
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "PuppyLinux" ]
		then
			for ifc in $(ifconfig -a | sed -e '/^[  ]/d' -e 's/[    ].*//')
			do
				if [ -f /var/lib/dhcpcd/dhcpcd-${ifc}.info -a -f /var/run/dhcpcd-${ifc}.pid ]
				then
					echo "var	${ifc}"
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "ttylinux" ]
		then
			# Check for dhcp interfaces on ttylinux. Mark their data as variable.
			for ifc in $(ifconfig -a | sed -e '/^[ 	]/d' -e 's/[ 	].*//')
			do
				if [ -f /etc/network.d/interface.${ifc} ]
				then
					grep -i "dhcp=.*yes" /etc/network.d/interface.${ifc} >/dev/null 2>/dev/null
				else
					grep "^DHCP=yes" /etc/sysconfig/network-scripts/ifcfg-${ifc}
				fi
				if [ $? -eq 0 ]
				then
					echo "var	${ifc}"
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "zenwalk" ]
		then
			for ifc in $(ifconfig -a | sed -e '/^[  ]/d' -e 's/[    ].*//')
			do
				grep "/sbin/[d]hcpcd .*${ifc}" ${PROC_FILE}  >/dev/null 2>/dev/null
				if [ $? -eq 0 ]
				then
					echo "var	${ifc}"
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "vector" -o "${SCC_LINUX_DISTRO}" = "slax" ]
		then
			for ifc in $(ifconfig -a | sed -e '/^[  ]/d' -e 's/[    ].*//')
			do
				if [ -f /etc/dhcpc/dhcpcd-${ifc}.info ]
				then
					echo "var	${ifc}"
				fi
			done
		elif [ "${SCC_LINUX_DISTRO}" = "SuSE" ]
		then
			for ifc in $(ifconfig -a | sed -e '/^[  ]/d' -e 's/[    ].*//')
			do
				grep "^BOOTPROTO=.*dhcp" /etc/sysconfig/network/ifcfg-${ifc} >/dev/null 2>/dev/null
				if [ $? -eq 0 ]
				then
					echo "var	${ifc}"
				fi
			done
		fi

		ifconfig -a 2>/dev/null			|
		sed	-e '/ [RT]X [bp]/d'	\
			-e '/collisions/d'
	}								|
	awk	'/^var	/	{	dhcp[ $2 ] = 1; next }
		/^[^ 	]/	{
					ifc = $1;		# eth0 or eth0:1 for virtual interfaces
					sub( ":$", "", ifc );
					gsub( ":", "_", ifc );
					prefix="fix";
					if ( ( ifc ~ "ppp" ) || ( dhcp[ ifc ] > 0 ) )
					{
						prefix="var";
					}
				}
				{ print prefix ":network:lan:" ifc "::" $0; }'

	# Search lines starting with eth0: or eth0
	ifconfig -a 2>/dev/null			|
	sed	-e '/^[ 	]/d'	\
		-e 's/:.*//'		\
		-e 's/[ 	].*//'	\
		-e '/^[ 	]*$/d'		|
	sort -u					|
	while read ifc
	do
		for file in	/etc/ifconfig.${ifc}		\
				/etc/network.d/interface.${ifc}	\
				/etc/net/ifaces/${ifc}/options
		do
			scc_check_file "${file}" "fix:network:lan:${ifc}::${file}	" "#"
		done

		case "${ifc}" in
		eth*)	if [ -x /sbin/ifstatus-dhcp ]
			then
				/sbin/ifstatus-dhcp "${ifc}" 2>/dev/null	|
				awk	'		{ prefix="fix"; }
					/IPADDR/	{ prefix="var"; }
							{
								printf( "%s:network:lan:%s::DHCP:	%s\n",\
									prefix, i, $0 );
							}' i="${ifc}"
			fi
			;;
		esac
	done

	if [ -d /etc/sysconfig/network ]
	then
		scc_check_file /etc/sysconfig/network/config "fix:network:file:/etc/sysconfig/network/config::" "#"

		for f in /etc/sysconfig/network/ifcfg-*
		do
			# Some interfaces are denoted by their MAC-address, with ":" separtors.
			# scc_check_file changes this to "_" in the classification.
			# Remove "ifcfg-" to group this data with the proper interface.
			ifc=${f##*/}
			scc_check_file "${f}" "fix:network:lan:${ifc}::ifcfg-${ifc}:	" "#"		|
			sed	-e 's/ifcfg-//'						\
				-e 's/"password"\.*\=\.*/### ERASED PASSWORD ###/'	\
				-e 's/"WIRELESS_KEY"\.*\=\.*/### ERASED PASSWORD ###/'
		done
	fi
fi

if [ -d /etc/net ]
then
	for d in ticlts ticots ticotsord
	do
		for f in hosts services
		do
			scc_check_file "/etc/net/${d}/${f}" "fix:network:loopback:/etc/net/${d}/${f}::" "#"
		done
	done
fi

if [ -x /usr/sbin/nfso ]
then
	/usr/sbin/nfso -a			|
	sed -e 's/^/fix:network:NFS:nfso::/'
fi

rpcinfo -p 2>/dev/null		|
awk '/^ *[0-9][0-9]*/ {
		# Ignore the ports without name
		if ( NF <= 4 )
		{
			next
		}
	}
	{
		print $1, $2, $3, $5;
	}'			|
sort -n				|
sed -e 's/^/fix:network:rpcinfo::/'

if [ -x /sbin/sysctl ]
then
	# Record the sed-commands in ${TMP1_FILE} that are used to delete/modify variable data from sysctl.
	echo "/^net\\.ip.*\\.ip_\\./d"			>${TMP1_FILE}
	echo "/^net\\.ip.*\\.ip_\\./d"			>>${TMP1_FILE}
	echo "/^net\\.inet\\.tcp\\.pcbcount/d"		>>${TMP1_FILE}
	echo "/^net\\.isr\\./d"				>>${TMP1_FILE}
	echo "/ip_always_defrag/d"			>>${TMP1_FILE}
	echo "/hostcache.count/d"			>>${TMP1_FILE}
	echo "/net\\.link\\.ether\\.restore_hdr/d"	>>${TMP1_FILE}
	echo "/_conntrack_count/d"			>>${TMP1_FILE}	# Indicated by Anthony Caetano

	if [ -f /proc/net/dev ]
	then
		# Determine the interfaces and extend the sed-script to remove all the
		# interface specific output of sysctl. These settings are recorded by ndd.
		awk -F: '{
				if ( NF > 1 )
				{
					sub( "  *", "", $1 )
					printf( "/^net\\..*\\.%s\\./d\n", $1 )
				}
			}' /proc/net/dev >>${TMP1_FILE}
	fi

	/sbin/sysctl -a 2>/dev/null			|
	sed -f ${TMP1_FILE}				|
	sed -n -e "s/^net\./fix:network:sysctl::net./p"	|
	sort
fi
rm -f ${TMP1_FILE}

if [ -x /usr/contrib/bin/nettune ]
then
	/usr/contrib/bin/nettune -l 2>/dev/null		|
	sed -e 's/^/fix:network:nettune::/'
fi

if [ -x /usr/bin/ndd -o -x /usr/sbin/ndd ]
then
	for d in arp icmp icmp6 ip ip6 tcp tcp6 udp udp6
	do
		if [ ! -r /dev/${d} ]
		then
			continue
		fi

		ndd -get /dev/${d} "?" 2>/dev/null		|
		sed	-e "/write only/d"		\
			-e "/arp_cache_report/d"	\
			-e "s/[ (].*//"			\
			-e "/status/d"			\
			-e "/stats$/d"			\
			-e "/hash/d"			\
			-e "/ip_always_defrag/d"	\
			-e "/pullups$/d"		\
			-e "/^?/d"				|
		while read parm remainder
		do
			case "${parm}" in
			*ppp*)	prefix="var";;
			*)	prefix="fix";;
			esac
			ndd -get /dev/${d} ${parm} 2>&1	|
			sed -e "s/^/${prefix}:network:ndd:${d}::${parm}:	/"
		done

	done
fi

if [ -d /proc/sys/net/ipv4 ]
then
	(
	cd /proc/sys/net/ipv4

	for p in icmp ip tcp
	do
		for f in ${p}*
		do
			name="${f##*/}"		# basename
			# Avoid the overhead of the function scc_check_file.
			sed -e "s/^/fix:network:${p}::${name}:	/" "${f}" 2>/dev/null	|
			sed -e '/ip_always_defrag/d'
		done
	done

	# We prefer sysctl to obtain the following data.
	if [ -d conf -a ! -x /sbin/sysctl ]
	then
		cd conf
		for if in */*
		do
			interface="${if%/*}"	# dirname
			name="${if##*/}"	# basename
			# Avoid the overhead of the function scc_check_file.
			sed -e "s/^/fix:network:/proc/sys/net/ipv4:${interface}::${name}:	/" "${if}" 2>/dev/null
		done
	fi
	)
fi

# Alexander Fuchs indicated that logbooks of systems connected to networks with many ICMP redirects
# suffer from many "changes". By default it is usefull to treat the routing data as fixed data (except
# dynamic routes). Optionally we will treat all route data as variable. 
# Edit scc-localize to change the default setting of this variable.
prefix="fix"
if [ "${SCC_VAR_ROUTE_DATA:-}" = "yes" ]
then
	prefix="var"
fi
if [ "${OS_NAME}" = "SunOS" ]
then
	netstat -rv 2>/dev/null				|
	awk '/^---/	{ next }
		{
			# Dynamic routes are treated as variable, not fixed config items
			p="fix";
			if ( NF == 10 )
			{
				if ( ( $8 ~ "D" ) || ( $4 ~ "ppp" ) )
				{
					p="var";
				}
				printf( "%s:network:netstat-route::%s:%s:%s:%s:%s:%s\n",\
					p, $1, $2, $3, $4, $5, $8 );
			}
			else if ( NF == 9 )
			{
				if ( $7 ~ "D" )
				{
					p="var";
				}
				printf( "%s:network:netstat-route::%s:%s:%s:%s:%s\n",\
					p, $1, $2, $3, $4, $7 );
			}
			else if ( NF > 0 )
			{
				print "fix:network:netstat-route::" $0;
			}
		}'
elif [ "${OS_NAME}" = "HP-UX" ]
then
	netstat -rv 2>/dev/null				|
	awk '/^Routing tables/	{
					print;
					next;
				}
		/^[ 	]/	{
					if ( NF == 1 )
					{
						# Netmask does not fit: continuation 
						# line with only netmask.
						printf( "%s ", $0 );
						offset++;
						next;
					}

					if ( offset == 1 )
					{
						# Destination was on previous line
						print $1, $2, $(NF-1), $NF;
					}
					else
					{
						# Destination and netmask were on
						# previous line(s)
						print $1, $(NF-1), $NF;
					}
					next;
				}
				{
					if ( NF < 3 )
					{
						# Destination and/or netmask do not
						# fit into the column. Remainder follows
						# on next line.
						printf( "%s ", $0 );
						offset=NF;
					}
					else
					{
						print $1, $2, $3, $(NF-1), $NF;
					}
				}'		|
	awk '{
		p="fix";
		if ( $3 ~ "D" )
		{
			p="var";
		}
		printf( "%s:network:netstat-route::%s:%s:%s:%s\n", p, $1, $2, $3, $4 );
	}'
elif [ "${OS_NAME}" = "FreeBSD" -o "${OS_NAME}" = "NetBSD" -o "${OS_NAME}" = "OpenBSD" -o "${OS_NAME}" = "DragonFly" ]
then
	netstat -rl 2>/dev/null			|
	awk	'{
			if ( NF < 6 )
			{
				print "fix:network:netstat-route::" $0;
			}
			else
			{
				p="fix";
				if ( $3 ~ "D" || $3 ~ "M" || $3 ~ "c" || $3 ~ "W" )	# Dynamic, Modified, cloned, Was cloned
				{
					p="var"
				}
				printf( "%s:network:netstat-route::%s:%s:%s:%s:%s\n", p, $1, $2, $3, $6, $7 );
			}
		}'
elif [ "${OS_NAME}" = "OSF1" ]
then
	netstat -rv 2>&1		|
	awk '{
		p="fix";
		if ( NF < 8 )
		{
			print "fix:network:netstat-route::" $0;
		}
		else
		{
			if ( $3 ~ "D" )
			{
				p="var";
			}
			printf( "%s:network:netstat-route::%s:%s:%s:%s:%s\n",\
				p, $1, $2, $3, $6, $7 );
		}
	}'
elif [ "${OS_NAME}" = "AIX" ]
then
	# Contributed by Doug Probst.
	netstat -nr 2> /dev/null | 
	awk	'{
			if ( NF < 8 )
			{
				print "fix:network:netstat-route::" $0;
			}
			else
			{ 
				p="fix";
				if ( $3 ~ "D" )
				{
					p="var";
				}
				printf( "%s:network:netstat-route::%s:%s:%s:%s:%s:%s:%s:%s\n",\
					p, $1, $2, $3, $6, $7, $8, $9, $10 );
			} 
		}'
else
	busybox_check netstat
	if [ $? -ne 0 ]
	then
		netstat -r 2>/dev/null				# No -v options available.
	else
		netstat -rv 2>/dev/null
	fi						|
	awk '{
		p="fix";
		if ( NF < 6 )
		{
			print "fix:network:netstat-route::" $0;
		}
		else
		{
			if ( $4 ~ "D" )
			{
				p="var";
			}
			printf( "%s:network:netstat-route::%s:%s:%s:%s:%s:%s\n",\
				p, $1, $2, $3, $4, $(NF-1), $NF );
		}
	}'
fi				|
tr "A-Z" "a-z"			|
sed -e "s/^fix:/${prefix}:/"

for file in /etc/iproute2/*
do
	scc_check_file "${file}" "fix:network:iproute2:${file}::" "#"
done

# Service Location Protocol
for file in slp.conf slp.reg slp.spi
do
	sed	-e 's/[#;].*//'		\
		-e '/^[ 	]*$/d'	\
		-e "s@^@fix:network:slp:/etc/${file}::@" /etc/${file} 2>/dev/null
done
for file in /etc/slp.reg.d/*
do
	scc_check_file "${file}" "fix:network:slp:/etc/slp.reg.d:${file##*/}::" "#"
done

ls /dev/x25* 2>/dev/null | grep x25 >/dev/null 2>&1
if [ -d /etc/x25 -a $? -eq 0 ]
then
	if [ -f /etc/rc.config.d/acc ]
	then
		. /etc/rc.config.d/acc

		if [ "${START_ZCOM}" = 1 ]
		then
			echo "fix:network:x25-mux:config::status:	active"

			# The variabele ${X25INIT_FILE} contains the name of the file that
			# contains the names of the configuration-files with the names of the
			# device files. Obvious.
			init_file=$(echo ${X25INIT_FILE})
			file=$(awk '/-c/ { print $3 }' ${init_file})
			dev=$(awk '/^device/ { print $2 }' ${file})
			rm -f ${TMP1_FILE}
			for d in ${dev}
			do
				if [ -n "${d}" ]
				then
					if [ ! -f ${TMP1_FILE} ]
					then
						/usr/sbin/x25stat -d ${dev} -c 2>&1		|
						sed	-e '/Programatic Access Name/d'			\
							-e '/^ *$/d'					\
							-e '/Packet type.*TX.*RX/,/-* X.25 CONFIG -*/d'	\
							-e 's/^/fix:network:x25-mux:config::/'
						touch ${TMP1_FILE}
					fi

					/usr/sbin/x25stat -d ${dev} -c 2>&1		|
					sed -n	-e '/Programatic Access Name/p'		|
					sed	-e 's/.*: //'			\
						-e "s/^/fix:network:x25-mux:${d}::access:	/"
				fi
			done
		else
			echo "fix:network:x25-mux:config::status:	inactive"
		fi
	else
		/usr/sbin/x25stat -c 2>&1	|
		sed -e 's/^/fix:network:x25:data::/'

		/usr/sbin/x25stat -a 2>&1	|
		sed -e 's/^/fix:network:x25:ipmap::/'
	fi
fi

if [ -f /etc/snet_info ]
then
	scc_check_file /etc/snet_info "fix:network:x25:/etc/snet_info::" "#"

	(
		cfg="$(grep "^X25CONFIGFILES=" /etc/snet_info | tail -n 1)"
		eval "${cfg}"			# set X25CONFIGFILES
		X25CONFIGFILES=${X25CONFIGFILES:=/etc/opt/SUNWconn/x25}

		for f in	${X25CONFIGFILES}/ipconf	\
				${X25CONFIGFILES}/netconf	\
				${X25CONFIGFILES}/config/link_config_0*.cfg
		do
			scc_check_file "${f}" "fix:network:x25:${f##*/}::" "#"
		done
	)
fi

exit 0
