#!/bin/sh
#
# when trying to set properties of a net interface with help of "proc/sysconfig/net/intf_type", for example, use command
# "echo br-lan 0xc0000000 > /proc/sysconfig/net/intf_type" to set properties of interface  br-lan. It actually set the
# element intf_type of the net_device object relate to "br-lan". intf_type is a bit map, you can find complete
# definition in following kernel source code.
# 	include/uapi/linux/netdevice.h
#	include/linux/netdevice.h
#

[ "$ACTION" == "add"] && exit 0


if [ "$INTERFACE" == "br-lan" ]; then
            # bridge(1<<19) lan(1<<18)
            echo br-lan 0x000c0000 > /proc/sysconfig/net/intf_type
fi


if [ "$INTERFACE" == "br-wan" ]; then
	# bridge(1<<19) internet(1<<14) wan(1<<17)
            echo br-wan 0x000a4000 > /proc/sysconfig/net/intf_type
fi


if [ "$INTERFACE" == "br-iptv" ]; then
            # bridge(1<<19) iptv(1<<16)
            echo br-iptv 0x00090000 > /proc/sysconfig/net/intf_type
fi


if [ "$INTERFACE" == "eth1" ]; then
            # eth(1<<31)
            echo eth1 0x80000000 > /proc/sysconfig/net/intf_type
fi

if [ "$INTERFACE" == "eth1.2" ]; then
            # eth(1<<31)
            echo eth1.2 0x80000000 > /proc/sysconfig/net/intf_type
fi

if [ "$INTERFACE" == "eth1.3" ]; then
            # eth(1<<31)
            echo eth1.3 0x80000000 > /proc/sysconfig/net/intf_type
fi

if [ "$INTERFACE" == "eth1.4" ]; then
            # eth(1<<31)
            echo eth1.4 0x80000000 > /proc/sysconfig/net/intf_type
fi


if [ "$INTERFACE" == "dslt-wan"]; then
	#wan(1<<17) internet(1<<14)  ds-lite(intf_type[9:4] = 8)
            echo dslt-wan 0x00024080 > /proc/sysconfig/net/intf_type
fi

if [ "$INTERFACE" == "v6plus-wan"]; then
	#wan(1<<17) internet(1<<14)  v6plus(intf_type[9:4] = 9)
            echo v6plus-wan 0x00024090 > /proc/sysconfig/net/intf_type
fi


if [ "$INTERFACE" == "6to4-wanv6"]; then
	#wan(1<<17) internet(1<<14) 6to4(intf_type[9:4] = 10)
            echo 6to4-wanv6 0x000240a0 > /proc/sysconfig/net/intf_type
fi
